Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Nov 2007 06:35:06 GMT
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/118325: periodic script to test statuses of daemons started via rc system
Message-ID:  <200711290635.lAT6Z6IO066288@happy-idiot-talk.infracaninophile.co.uk>
Resent-Message-ID: <200711290640.lAT6e2T6059366@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         118325
>Category:       bin
>Synopsis:       periodic script to test statuses of daemons started via rc system
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 29 06:40:02 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Seaman
>Release:        FreeBSD 7.0-BETA1 i386
>Organization:
Infracaninophile
>Environment:
System: FreeBSD happy-idiot-talk.infracaninophile.co.uk 7.0-BETA1 FreeBSD 7.0-BETA1 #14: Thu Nov 1 23:25:45 GMT 2007 root@happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK i386


	
>Description:

I submit for your consideration a periodic script which I've been
running for a month or so.  It checks on the status of all the daemons
started up by the rc system by using rcorder to get the list of all
enabled startup scripts exactly as the system initialisation does (as
in: I copied that chunk of code pretty much verbatim.)

I find this a useful double check after eg. a portupgrade session
where it's all too easy to forget to restart a particular daemon that
has been turned off for updating.

>How-To-Repeat:
	
>Fix:

	

--- 490.status-rc.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	490.status-rc
#
echo x - 490.status-rc
sed 's/^X//' >490.status-rc << 'END-of-490.status-rc'
X#!/bin/sh
X#
X# $Id: 490.status-rc,v 1.3 2007/10/21 11:25:25 matthew Exp $
X# $FreeBSD$
X#
X
X# Define these variables in either /etc/periodic.conf or
X# /etc/periodic.conf.local to override the default values.
X#
X# daily_status_rc_enable="YES" # run tests
X# daily_status_rc_exceptions="newsyslog bsdstats.sh othermta"
X#     # Startup scripts that don't give meaningful status output
X
Xdaily_status_rc_enable="YES"
Xdaily_status_rc_exceptions="newsyslog bsdstats.sh othermta"
X
X# If there is a global system configuration file, suck it in.
X#
Xif [ -r /etc/defaults/periodic.conf ]
Xthen
X    . /etc/defaults/periodic.conf
X    source_periodic_confs
Xfi
X
Xall_startup() {
X    # Cribbed shamelessly from /etc/rc
X
X    if [ -r /etc/rc.subr ]
X    then
X	. /etc/rc.subr
X	load_rc_config 'XXX'
X    fi
X
X    skip="-s nostart"
X    if [ $( /sbin/sysctl -n security.jail.jailed ) -eq 1 ]; then
X        skip="$skip -s nojail"
X    fi
X
X    case ${local_startup} in
X	[Nn][Oo] | '') ;;
X	*)             find_local_scripts_new ;;
X    esac
X
X    files=$( /sbin/rcorder ${skip} /etc/rc.d/* ${local_rc} 2>/dev/null )
X
X    # Now loop over all of the rc files and query their status
X    for _rc_elem in ${files}; do
X	output=$( run_rc_script $_rc_elem status 2>&1 )
X	result=$?
X
X	if [ $result -ne 0 ] ; then
X
X	    # Many of the system rc-scripts do not support 'status' as
X	    # a command line flag. Most, if not all, of the ports
X	    # rc-cripts do.
X
X	    if echo $output | \
X		grep -F "unknown directive 'status'" >/dev/null 2>&1 ; then
X		continue
X	    fi
X
X	    # Some rc-scripts do not start long-running processes but
X	    # still provide the default 'status' action.  This doesn't
X	    # make a great deal of sense given the default action is
X	    # to test that some process is alive.
X
X	    if echo $daily_status_rc_exceptions | \
X		grep -F $( basename ${_rc_elem} ) >/dev/null 2>&1 ; then
X		continue
X	    fi
X
X	    echo "==>> $_rc_elem"
X	    echo $output
X	    rc=1
X	fi
X    done
X}
X
X
X
Xrc=0
X
Xcase "$daily_status_rc_enable" in
X    [Yy][Ee][Ss])
X        echo ""
X        echo "RC Script Status Problems:"
X
X	all_startup
X	;;
X    *)
X        ;;
Xesac
X
Xexit $rc
END-of-490.status-rc
exit
--- 490.status-rc.shar ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711290635.lAT6Z6IO066288>