File: gmetad.aix.init

package info (click to toggle)
ganglia 3.6.0-7
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 6,484 kB
  • ctags: 3,880
  • sloc: ansic: 27,874; sh: 11,052; python: 6,695; makefile: 565; perl: 366; php: 126; xml: 28
file content (99 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/ksh
#
# description: gmetad startup script
#
# Oct 27, 2010, Michael Perzl (michael@perzl.org)
#

GMETAD_BIN=/opt/freeware/sbin/gmetad

PIDFILE=/var/run/gmetad.pid

RUN_AS_USER="nobody"


# define some generic commands
AWK=/usr/bin/awk
CAT=/usr/bin/cat
ECHO=/usr/bin/echo
GREP=/usr/bin/grep
KILL=/usr/bin/kill
MKDIR=/usr/bin/mkdir
PRINTF=/usr/bin/printf
PS=/usr/bin/ps
RM=/usr/bin/rm


# check for missing binaries (stale symlinks should not happen)
test -x ${GMETAD_BIN} ||
    {
      $ECHO "${GMETAD_BIN} not installed"
      if [ "$1" = "stop" ] ; then
          exit 0
      else
          exit 5
      fi
    }

# check for existence of necessary config file
GMETAD_CONFIG=/etc/ganglia/gmetad.conf
test -r ${GMETAD_CONFIG} ||
    {
      $ECHO "${GMETAD_CONFIG} does not exist"
      if [ "$1" = "stop" ] ; then
          exit 0
      else
          exit 6
      fi
    }


case "$1" in
    start)
	if [ -r ${PIDFILE} ]; then
            pid=`$CAT ${PIDFILE}`
            if [ "`$PS -ef | $GREP -v grep | $GREP ${pid} | $AWK '{ print $2 }'`" = "${pid}" ] ; then
	        $ECHO "GANGLIA gmetad daemon is already running with PID ${pid}."
	        exit 1
	    else
	        $RM -f ${PIDFILE}
	    fi
	fi
	$PRINTF "Starting GANGLIA gmetad... "

	## start daemon and write PID to file ${PIDFILE}
	$MKDIR -p /var/run
	${GMETAD_BIN} -p ${PIDFILE} -c ${GMETAD_CONFIG}
        $ECHO "done."
	;;
    stop)
	$PRINTF "Shutting down GANGLIA gmetad daemon... "
	## stop daemon
	if [ -r ${PIDFILE} ]; then
	    $KILL -HUP `$CAT ${PIDFILE}`
	    $RM -f ${PIDFILE}
	fi
        $ECHO "done."
	;;
    status)
	if [ -r ${PIDFILE} ]; then
            pid=`$CAT ${PIDFILE}`
            if [ `$PS -ef | $GREP -v grep | $GREP ${pid} | $AWK '{ print $2 }'` = ${pid} ] ; then
	        $ECHO "GANGLIA gmetad daemon is running with PID ${pid}."
	    fi
	else
	    $ECHO "GANGLIA gmetad daemon is not running."
	fi
	;;
    restart)
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	$0 stop
	$0 start
	;;
    *)
	$ECHO "Usage: $0 {start|stop|status|restart}"
	exit 1
	;;
esac