Revision: 7913
http://syscheck.svn.sourceforge.net/syscheck/?rev=7913&view=rev
Author: kinneh
Date: 2010-10-14 07:37:31 +0000 (Thu, 14 Oct 2010)
Log Message:
-----------
First version for #6 change the help function so it prints the log standard format instead and
#3 move level to a define per message instead of each printlogmess chooses the level
Also closes #37 add better support for changing the location of syscheck install for sc_300_check_running_procs.sh
Added Paths:
-----------
trunk/syscheck/config/300.conf
trunk/syscheck/lang/300.english
trunk/syscheck/scripts-available/sc_300_check_running_procs.sh
Removed Paths:
-------------
trunk/syscheck/config/30.conf
trunk/syscheck/lang/30.english
trunk/syscheck/scripts-available/sc_30_check_running_procs.sh
Deleted: trunk/syscheck/config/30.conf
===================================================================
--- trunk/syscheck/config/30.conf 2010-10-14 06:56:06 UTC (rev 7912)
+++ trunk/syscheck/config/30.conf 2010-10-14 07:37:31 UTC (rev 7913)
@@ -1,31 +0,0 @@
-# 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
-
-
-
-
Copied: trunk/syscheck/config/300.conf (from rev 7902, trunk/syscheck/config/30.conf)
===================================================================
--- trunk/syscheck/config/300.conf (rev 0)
+++ trunk/syscheck/config/300.conf 2010-10-14 07:37:31 UTC (rev 7913)
@@ -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
+
+
+
+
Property changes on: trunk/syscheck/config/300.conf
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/syscheck/lang/30.english
===================================================================
--- trunk/syscheck/lang/30.english 2010-10-14 06:56:06 UTC (rev 7912)
+++ trunk/syscheck/lang/30.english 2010-10-14 07:37:31 UTC (rev 7913)
@@ -1,9 +0,0 @@
-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"
Copied: trunk/syscheck/lang/300.english (from rev 7902, trunk/syscheck/lang/30.english)
===================================================================
--- trunk/syscheck/lang/300.english (rev 0)
+++ trunk/syscheck/lang/300.english 2010-10-14 07:37:31 UTC (rev 7913)
@@ -0,0 +1,20 @@
+ABOUT="Generic script to check a proc is running and try to restart those that's not"
+DESCR[0]="Process %s is running"
+HELP[0]="No action is needed"
+LEVEL[0]=$INFO
+ERRNO[0]=${SCRIPTID}0
+
+DESCR[1]="Process %s was not running, restart succeded"
+HELP[1]="If this happens regulary this need to be looked into"
+LEVEL[1]=$WARN
+ERRNO[1]=${SCRIPTID}1
+
+DESCR[2]="Process %s was not running, restart failed"
+HELP[2]="If this needs to be this handled manually"
+LEVEL[2]=$ERROR
+ERRNO[2]=${SCRIPTID}2
+
+DESCR[3]="Process %s was not running, no restart command defined"
+HELP[3]="No restart command defined, restart manually"
+LEVEL[3]=$ERROR
+ERRNO[3]=${SCRIPTID}3
Property changes on: trunk/syscheck/lang/300.english
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/syscheck/scripts-available/sc_300_check_running_procs.sh (from rev 7902, trunk/syscheck/scripts-available/sc_30_check_running_procs.sh)
===================================================================
--- trunk/syscheck/scripts-available/sc_300_check_running_procs.sh (rev 0)
+++ trunk/syscheck/scripts-available/sc_300_check_running_procs.sh 2010-10-14 07:37:31 UTC (rev 7913)
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# Set SYSCHECK_HOME if not already set.
+
+# 1. First check if SYSCHECK_HOME is set then use that
+if [ "x${SYSCHECK_HOME}" = "x" ] ; then
+# 2. Check if /etc/syscheck.conf exists then source that (put SYSCHECK_HOME=/path/to/syscheck in ther)
+ if [ -e /etc/syscheck.conf ] ; then
+ source /etc/syscheck.conf
+ else
+# 3. last resort use default path
+ SYSCHECK_HOME="/usr/local/syscheck"
+ fi
+fi
+
+if [ ! -f ${SYSCHECK_HOME}/syscheck.sh ] ; then echo "$0: Can't find syscheck.sh in SYSCHECK_HOME ($SYSCHECK_HOME)" ;exit ; fi
+
+
+
+
+# uniq ID of script (please use in the name of this file also for convinice for finding next availavle number)
+SCRIPTID=300
+
+## Import common definitions ##
+. $SYSCHECK_HOME/config/syscheck-scripts.conf
+
+getlangfiles $SCRIPTID
+getconfig $SCRIPTID
+
+
+# help
+if [ "x$1" = "x--help" ] ; then
+ displayhelp
+ 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
+ # no restart cmd defined
+ printlogmess ${LEVEL[3]} ${ERRNO[3]} "${DESCR[3]}" ${PROCNAME[$i]}
+ continue
+ fi
+
+ eval ${RESTARTCMD[$i]}
+
+ if [ $? -eq 0 ] ; then
+ # log restart success
+ printlogmess ${LEVEL[1]} ${ERRNO[1]} "${DESCR[1]}" ${PROCNAME[$i]}
+ else
+ # log restart fail
+ printlogmess ${LEVEL[2]} ${ERRNO[2]} "${DESCR[2]}" ${PROCNAME[$i]}
+ fi
+ else
+ printlogmess ${LEVEL[0]} ${ERRNO[0]} "${DESCR[0]}" ${PROCNAME[$i]}
+ printtoscreen "proc $i: ${PROCNAME[$i]} is running"
+ fi
+
+
+done
+
Property changes on: trunk/syscheck/scripts-available/sc_300_check_running_procs.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+
Deleted: trunk/syscheck/scripts-available/sc_30_check_running_procs.sh
===================================================================
--- trunk/syscheck/scripts-available/sc_30_check_running_procs.sh 2010-10-14 06:56:06 UTC (rev 7912)
+++ trunk/syscheck/scripts-available/sc_30_check_running_procs.sh 2010-10-14 07:37:31 UTC (rev 7913)
@@ -1,60 +0,0 @@
-#!/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
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|