Sophie

Sophie

distrib > Mandriva > cooker > x86_64 > by-pkgid > 1fc93a2ad9036e17d8a80d0bb1b76aaf > files > 2

monitorix-1.2.0-4mdv2011.0.src.rpm

#!/bin/bash
#
# @(#) Fibranet NSP, SL
# Copyright (C) 2005-2008 by Jordi Sanfeliu <admin@fibranet.cat>
#
#	/etc/rc.d/init.d/monitorix
#
# Starts Monitorix on RedHat/Fedora/CentOS Linux systems
#
# chkconfig: 2345 99 10
# description: lightweight system monitoring tool

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

RETVAL=0
LOCK="/var/lock/monitorix"
PROGRAM="Monitorix"

start() {
	# Check if monitorix is already running
	gprintf "Starting %s:" "$PROGRAM"
	if [ ! -f "$LOCK" ]; then
                touch $LOCK
	else
		echo_failure
		echo
		return $RETVAL
	fi

	# Creates RRDs files (if needed)
	/usr/sbin/monitorix.pl create
	if [ $? -gt 0 ]; then
		echo_failure
		echo
		return $RETVAL
	fi
	/usr/sbin/monitorix.pl init
	if [ $? -eq 0 ]; then
		echo_success
	else
		echo_failure
		return $RETVAL
	fi
	echo
}

stop() {
	gprintf "Stopping %s:" "$PROGRAM"
	if [ -e $LOCK ] ; then
		rm -f $LOCK
		/usr/sbin/monitorix.pl stop
		if [ $? -gt 0 ]; then
			echo_failure
			echo
			return $RETVAL
		else
			echo_success
		fi
	else
		echo_failure
	fi
	echo
}

status() {
        if [ -e $LOCK ] ; then
                echo $"$PROGRAM is running."
        else
                echo $"$PROGRAM is stopped."
        fi
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status
		;;
	restart)
		stop
		sleep 1
		start
		;;
	*)
		echo $"Usage: $0 {start|stop|status|restart}"
		exit 1
esac

exit $RETVAL