From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 29 06:40:08 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 159BA16A418 for ; Thu, 29 Nov 2007 06:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0809C13C458 for ; Thu, 29 Nov 2007 06:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id lAT6e2Jx059367 for ; Thu, 29 Nov 2007 06:40:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id lAT6e2T6059366; Thu, 29 Nov 2007 06:40:02 GMT (envelope-from gnats) Resent-Date: Thu, 29 Nov 2007 06:40:02 GMT Resent-Message-Id: <200711290640.lAT6e2T6059366@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Matthew Seaman Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 648CA16A41A for ; Thu, 29 Nov 2007 06:35:22 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id EC4F713C467 for ; Thu, 29 Nov 2007 06:35:21 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1]) by smtp.infracaninophile.co.uk (8.14.1/8.14.1) with ESMTP id lAT6Z6AO066289 for ; Thu, 29 Nov 2007 06:35:06 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.14.1/8.14.1/Submit) id lAT6Z6IO066288; Thu, 29 Nov 2007 06:35:06 GMT (envelope-from matthew) Message-Id: <200711290635.lAT6Z6IO066288@happy-idiot-talk.infracaninophile.co.uk> Date: Thu, 29 Nov 2007 06:35:06 GMT From: Matthew Seaman To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/118325: periodic script to test statuses of daemons started via rc system X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthew Seaman List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2007 06:40:08 -0000 >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: