Recently, while configuring two new RHEL5 webserver nodes at VSU, I decided to install the Linux server for the iStat program. The iStat program is an iPhone app that will allow you to receive vital stats on your remote servers. It also gives you a nice interface for both the ping and traceroute network tools.
The installation of the istatd daemon, an open source server for Linux, Solaris and FreeBSD, was quite easy. The configuration file is easily understood and edited for your particular installation needs, allowing you to change the defaults when necessary, for example I did not want to add an additional user, so I configured istatd to use the monitor account I created for use with Nagios.
One thing that was missing from istatd was an init script to allow for easily controlling the startup and shutdown of the daemon as well as determining what runlevels the daemon should be active in.
To solve this I wrote an init.d script. These scripts are fairly self-explanatory. I used the script that starts the xinetd service as my base, since I knew that this one checks to ensure that the networking service is active before it starts the service.
The location of both the binary and the configuration file may vary depending on the installation itself. When I built istatd I used the following configure command:
./configure --sysconfdir=/etc
Here’s how to install the script
- Copy the file into /etc/init.d/
cp istatd /etc/init.d/
- make a symbolic link to this file in the rc.d directories for each runlevel specified in the script (note: this may differ based on the runlevels you use in the script.)
ln -s /etc/init.d/istatd /etc/rc3.d/S99istatd ln -s /etc/init.d/istatd /etc/rc4.d/S99istatd ln -s /etc/init.d/istatd /etc/rc3.d/S99istatd
Here is the script in it’s entirety, and you can download it as well.
#!/bin/bash # # istatd This starts and stops istatd. # # chkconfig: 345 99 01 # description: istatd is a daemon serving statistics to your \ # iStat iPhone application from Linux, Solaris & FreeBSD. \ # istatd collects data such as CPU, memory, network and \ # disk usage and keeps the history. Once connecting from \ # the iPhone and entering the lock code this data will be \ # sent to the iPhone and shown in fancy graphs. # # processname: /usr/local/bin/istatd # config: /etc/istat.conf # pidfile: /var/run/istat/istatd.pid # Source function library. . /etc/init.d/functions # Get config. test -f /etc/sysconfig/network && . /etc/sysconfig/network test -f /etc/istat.conf # Check that we are root ... so non-root users stop here [ `id -u` = 0 ] || exit 1 # Check that networking is up. [ "${NETWORKING}" = "yes" ] || exit 0 [ -f /usr/local/bin/istatd ] || exit 1 [ -f /etc/istat.conf ] || exit 1 RETVAL=0 prog="/usr/local/bin/istatd" start(){ echo -n $"Starting istatd: " $prog -d --pid=/var/run/istat/istatd.pid RETVAL=$? echo touch /var/lock/subsys/istatd return $RETVAL } stop(){ echo -n $"Stopping istatd: " killproc $prog RETVAL=$? echo rm -f /var/lock/subsys/istatd return $RETVAL } reload(){ stop start } restart(){ stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $prog ;; restart) restart ;; reload) reload ;; *) echo $"Usage: $0 {start|stop|status|restart|reload}" RETVAL=1 esac exit $RETVAL
If you need any assistance creating your own scripts, you might find this link from Novell’s Cool Solutions site: Creating Custom init Scripts.

