/[nagraffiti]/backend/nagraffiti.init
ViewVC logotype

Contents of /backend/nagraffiti.init

Parent Directory Parent Directory | Revision Log Revision Log


Revision 45 - (show annotations) (download)
Wed Apr 24 10:30:07 2013 UTC (7 years, 7 months ago) by racvision
File size: 1774 byte(s)
s/nagraffiti-fifo-daemon.pl/nagraffiti-daemon.pl/
1 #!/bin/sh
2 #
3 # nagraffiti This shell script takes care of starting and stopping
4 # the nagraffitid.pl grapher daemon.
5 #
6 # chkconfig: 2345 98 13
7 # description: Nagraffiti - Use Nagios performance data make rrd graphs.
8 # processname: nagraffitid.pl
9 # config:
10 # pidfile:
11
12 # Source function library.
13 . /etc/rc.d/init.d/functions
14
15 # Source networking configuration.
16 . /etc/sysconfig/network
17
18 prog="nagraffiti"
19 progbin="/usr/sbin/nagraffiti-daemon.pl"
20 proguser=$prog
21 pidfile="/var/run/nagraffiti/nagraffiti.pid"
22
23 livestatus_sock="/var/lib/nagios/livestatus.sock"
24 nagios_perfdata_pipe=/var/lib/nagraffiti/nagios-service-perfdata.pipe
25
26 MYSQL_PASSWORD_PATH=/etc/racvision/mysql/passwords
27
28 start_mode="livestatus"
29
30 test -p $nagios_perfdata_pipe || mkfifo $nagios_perfdata_pipe
31 chown nagios $nagios_perfdata_pipe
32 chmod 755 $nagios_perfdata_pipe
33
34
35
36 # Run some action. Log its output.
37 r_action() {
38 if [ $2 -eq 0 ]; then
39 action "$1" /bin/true
40 return 1
41 else
42 action "$1" /bin/false
43 return 0
44 fi
45 }
46
47
48 start() {
49
50 if [ ! -S $livestatus_sock ]; then
51 echo "Livestatus socket not found !"
52 exit 1
53 fi
54
55 $progbin -D -d -d
56 ret=$?
57 if [ $ret -eq 0 ]; then
58 action $"Starting $prog (mode $start_mode): " /bin/true
59 else
60 action $"Starting $prog (mode $start_mode): " /bin/false
61 fi
62 return $ret
63 }
64
65 stop(){
66 ret=1
67 if [ -f $pidfile ]; then
68 /bin/kill $(cat $pidfile 2> /dev/null ) > /dev/null 2>&1
69 ret=$?
70 fi
71 if [ $ret -eq 0 ]; then
72 action $"Stopping $prog: " /bin/true
73 else
74 action $"Stopping $prog: " /bin/false
75 fi
76 return $ret
77 }
78
79 restart() {
80 stop
81 start
82 }
83
84
85
86
87 # See how we were called.
88 case "$1" in
89 start)
90 start
91 ;;
92 stop)
93 stop
94 ;;
95 status)
96 status $prog
97 ;;
98 restart)
99 restart
100 ;;
101 *)
102 echo $"Usage: $0 {start|stop|status|restart}"
103 exit 1
104 esac
105
106 exit $?

  ViewVC Help
Powered by ViewVC 1.1.8