check_logfiles: 3.7.5.1
[omd.git] / packages / rrdtool / skel / etc / init.d / rrdcached
blobd72816beb01d15aff0af7c34b8a575aab0e116ba
1 #!/bin/bash
3 # chkconfig: 345 98 02
4 # description: RRD Tool cache daemon
6 ### BEGIN INIT INFO
7 # Provides: rrdcached
8 # Required-Start:
9 # Required-Stop:
10 # Default-Start: 2 3 5
11 # Default-Stop:
12 # Description: Start RRD cache daemon
13 ### END INIT INFO
15 # Start only if PNP is enabled
16 . ###ROOT###/etc/omd/site.conf
17 if [ "$CONFIG_PNP4NAGIOS" == off ] ; then
18 exit 5
21 # Set default values
22 TIMEOUT=3600
23 RANDOM_DELAY=1800
24 FLUSH_TIMEOUT=7200
27 # Read in tuning configuration of admin
28 CONFFILE=$OMD_ROOT/etc/rrdcached.conf
29 if [ -e "$CONFFILE" ] ; then
30 . $CONFFILE
33 TIMING=""
37 # Please do not touch the code below
38 CACHE_DIR="###ROOT###/tmp/rrdcached"
39 JOURNAL_DIR="###ROOT###/var/rrdcached"
40 SOCKET="###ROOT###/tmp/run/rrdcached.sock"
41 PIDFILE="###ROOT###/tmp/rrdcached.pid"
42 USER="###SITE###"
43 GROUP="###SITE###"
44 OPTS="-w $TIMEOUT -z $RANDOM_DELAY -f $FLUSH_TIMEOUT -s $GROUP -m 660 -l unix:$SOCKET -p $PIDFILE -j $JOURNAL_DIR"
45 DAEMON="###ROOT###/bin/rrdcached"
47 case "$1" in
48 start)
49 echo -n 'Starting rrdcached...'
50 if [ -e "$PIDFILE" ] ; then
51 PID=$(cat $PIDFILE)
52 if [ -n "$PID" ] && ps $PID > /dev/null 2>&1 ; then
53 echo "Already running."
54 exit 0
56 echo "removing stale pid file..."
57 rm -f $PIDFILE
60 # make sure, directories are there (ramdisk!)
61 mkdir -p $CACHE_DIR $RRD_DIR &&
62 $DAEMON $OPTS &&
63 echo OK || echo Error
65 stop)
66 echo -n 'Stopping rrdcached...'
67 PID=$(cat $PIDFILE 2>/dev/null)
68 if [ -z "$PID" ] ; then
69 echo "not running."
70 elif kill "$PID" ; then
71 echo -n 'waiting for termination..'
72 N=0
73 while [ -d /proc/$PID ] ; do
74 echo -n .
75 if [ $N -ge 20 ] ; then
76 echo "still running after 20 secs!"
77 exit 1
79 N=$((N+1))
80 sleep 1
81 done
82 echo "OK"
83 else
84 echo "Failed"
87 restart|reload)
88 $0 stop
89 $0 start
91 status)
92 echo -n 'Checking status of rrdcached...'
93 if [ -e "$PIDFILE" ] ; then
94 PID=$(cat $PIDFILE)
95 if [ -n "$PID" ] && ps $PID > /dev/null 2>&1 ; then
96 echo "running"
97 exit 0
100 echo "stopped"
101 exit 1
103 flush)
104 echo -n 'Triggering global flush of rrdcached...'
105 result=$(echo 'FLUSHALL' | unixcat ~/tmp/run/rrdcached.sock)
106 if [ "$result" = "0 Started flush." ] ; then
107 echo "OK"
108 exit 0
109 else
110 echo Failed: $result
111 exit 1
115 echo "Usage: $0 {start|stop|restart|reload|status}"
117 esac