Sysmon init scriptSysmon init script

Posted October 5th, 2008 in Linux/Unix/BSD

Last week I added monitoring to a customer's SMTP mail server using sysmon and posted about a couple of errors I had when installing sysmon (undefined reference to yywrap error and Errors compiling sysmon 0.92.2 on CentOS 64 bit). This post contains my init script for automatically starting sysmon at system startup. I'm posting it here for future reference in case I need to install sysmon on another machine in the future.

So here's the script:

#!/bin/bash
#
# sysmond
#
# chkconfig: 3 56 50
# description:  Sysmond
# processname: sysmond
# config: /usr/local/etc/sysmond
# pidfile: /var/run/sysmond.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

PATH=$PATH:/usr/local/bin

start(){
    sysmond
}

stop(){
    sysmond stop
}

restart(){
    sysmond stop
    sysmond
}

reload(){
    sysmond reload
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  reload)
    reload
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|reload}"
    exit 1
esac

exit $?

Then it's just a matter of changing the permissions of the file so it can be executed and installing it with the distro's appropriate command (e.g. chkconfig on Red Hat, Fedora or CentOS) so it auto starts on system startup.

Related posts:

Comments

blog comments powered by Disqus