Revision: 7902
http://syscheck.svn.sourceforge.net/syscheck/?rev=7902&view=rev
Author: kinneh
Date: 2010-10-06 18:42:34 +0000 (Wed, 06 Oct 2010)
Log Message:
-----------
Closes #31 add generic process check
Added Paths:
-----------
trunk/syscheck/config/30.conf
trunk/syscheck/lang/30.english
trunk/syscheck/scripts-available/sc_30_check_running_procs.sh
Added: trunk/syscheck/config/30.conf
===================================================================
--- trunk/syscheck/config/30.conf (rev 0)
+++ trunk/syscheck/config/30.conf 2010-10-06 18:42:34 UTC (rev 7902)
@@ -0,0 +1,31 @@
+# config for sc_30_check_running_procs.sh
+
+# set RESTARTCMD to empty if no automatic action is wanted
+
+PROCNAME[0]=apache2
+RESTARTCMD[0]="/etc/init.d/apache2 restart"
+PIDFILE[0]=/var/run/apache2.pid
+
+#
+PROCNAME[1]=ntpd
+RESTARTCMD[1]="/etc/init.d/ntp restart"
+PIDFILE[1]=/var/run/ntpd.pid
+
+#
+PROCNAME[2]=cupsd
+RESTARTCMD[2]="/etc/init.d/cups stop ; sleep 3 ; /etc/init.d/cups start"
+PIDFILE[2]=/var/run/cups/cupsd.pid
+
+
+#PROCNAME[3]=apache2
+#RESTARTCMD[3]="/etc/init.d/apache2 stop ; sleep 3 ; /etc/init.d/apache2 start"
+#PIDFILE[3]=/var/run/apache2.pid
+
+
+#PROCNAME[4]=apache2
+#RESTARTCMD[4]="/etc/init.d/apache2 stop ; sleep 3 ; /etc/init.d/apache2 start"
+#PIDFILE[4]=/var/run/apache2.pid
+
+
+
+
Added: trunk/syscheck/lang/30.english
===================================================================
--- trunk/syscheck/lang/30.english (rev 0)
+++ trunk/syscheck/lang/30.english 2010-10-06 18:42:34 UTC (rev 7902)
@@ -0,0 +1,9 @@
+HELP="Generic script to check a proc is running and try to restart those that's not"
+DESCR_1="Process %s is running"
+HELP_1="No action is needed"
+DESCR_2="Process %s was not running, restart succeded"
+HELP_2="If this happens regulary this need to be looked into"
+DESCR_3="Process %s was not running, restart succeded"
+HELP_3="If this happens regulary this need to be looked into"
+DESCR_4="Process %s was not running, no restart command defined"
+HELP_4="No restart command defined, restart manually"
Added: trunk/syscheck/scripts-available/sc_30_check_running_procs.sh
===================================================================
--- trunk/syscheck/scripts-available/sc_30_check_running_procs.sh (rev 0)
+++ trunk/syscheck/scripts-available/sc_30_check_running_procs.sh 2010-10-06 18:42:34 UTC (rev 7902)
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# Set default home if not already set.
+SYSCHECK_HOME=${SYSCHECK_HOME:-"/usr/local/syscheck"}
+
+# uniq ID of script (please use in the name of this file also for convinice for finding next availavle number)
+SCRIPTID=30
+
+## Import common definitions ##
+. $SYSCHECK_HOME/config/syscheck-scripts.conf
+
+getlangfiles $SCRIPTID
+getconfig $SCRIPTID
+
+ERRNO_1=${SCRIPTID}01
+ERRNO_2=${SCRIPTID}02
+ERRNO_3=${SCRIPTID}03
+ERRNO_4=${SCRIPTID}04
+
+
+# help
+if [ "x$1" = "x--help" ] ; then
+ echo "$0 $HELP"
+ echo "$ERRNO_1/$DESCR_1 - $HELP_1"
+ echo "$ERRNO_2/$DESCR_2 - $HELP_2"
+ echo "$ERRNO_3/$DESCR_3 - $HELP_3"
+ echo "$ERRNO_4/$DESCR_4 - $HELP_4"
+ exit
+elif [ "x$1" = "x-s" -o "x$1" = "x--screen" ] ; then
+ PRINTTOSCREEN=1
+fi
+
+
+for (( i = 0 ; i < ${#PROCNAME[@]} ; i++ )) ; do
+
+ pidinfo=`${SYSCHECK_HOME}/lib/proc_checker.sh ${PIDFILE[$i]} ${PROCNAME[$i]}`
+ if [ "x$pidinfo" = "x" ] ; then
+
+ # try restart
+ if [ "x${RESTARTCMD[$i]}" = "x" ] ; then
+ printlogmess $ERROR $ERRNO_4 "$DESCR_4" ${PROCNAME[$i]}
+ continue
+ fi
+
+ eval ${RESTARTCMD[$i]}
+
+ if [ $? -ne 0 ] ; then
+ # log restart success
+ printlogmess $INFO $ERRNO_1 "$DESCR_1" ${PROCNAME[$i]}
+ else
+ # log restart fail
+ printlogmess $ERROR $ERRNO_3 "$DESCR_2" ${PROCNAME[$i]}
+ fi
+ else
+ printtoscreen "proc $i: ${PROCNAME[$i]} is running, no action needed"
+ fi
+
+
+done
+
Property changes on: trunk/syscheck/scripts-available/sc_30_check_running_procs.sh
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|