spong-client - report system information to spong server.
SYNOPSIS
spong-client [--debug] [--kill|--restart|--nosleep|--refresh] [config_file]
DESCRIPTION
This program is run on each Unix (and NT) machine in which you want to monitor local system attributes, and report that information to the spong server. It runs one or more configured checks. It then sleeps for a time period you have defined in your configuration file and does it all again (it actually adds or subtracts a random amount of time - no more then 10% of the total you have specified, to keep clients from syncing up and overloading the spong-server).
The checks are modular in nature. You can configure the number of checks to run and the order in which to run to them. The list of checks that are included are disk space, cpu load, running processes and log files.
It sends a message for each check to the spong server and reports the following:
The one line summary provides information that might be useful at a glance when looking at the overall system status (such as a brief report on the load, number of users, and uptime).
The more detailed message contains information such as the complete df output, or a listing of the top 10 processes sorted by CPU.
You should start this program in your system startup file, and it should be running constantly. If you provide the --debug flag, then debugging information will be printed to stdout, otherwise output will only be produced if there is a problem.
If you provide the --restart flag, a signal will be sent to the spong-client process that is currently running that will cause it to reload it's configuration files. If you provide the --kill flag, a signal will be sent to the running spong-client process causing it to exit. The --nosleep or --refresh flags causs the program to cycle through all of the checks one and hen exit. These flags can be used to run spong-client as a cron job (depreciated, this reduced the effectivemess of the check_logs module, see: Client Modules).
CONFIGURATION
By default this reads the /usr/local/etc/spong/spong.conf file on startup. You can specify an alternate config file via a command line option and it will read that file instead. If you change values in the configuration file you will need to restart this program for those changes to be re-read.
After reading the configuration file that you specify (or the default), it then reads the /usr/local/etc/spong/spong.conf.[host] file where [host] is the hostname of the machine that you are running on. Since these configuration files are just standard perl code that gets imported, the variables that you define in the host specific config file will take precedence over the standard configuration settings.
Here is a listing of the configuration variables applicable to the spong-client program.
$SPONGSLEEP, $SPONGSERVER, $SPONGPORTCLIENT CHECKS
Some basic spong configuration options that define how long to sleep (in seconds) before checking the status of a service again, the hostname of the spong server, and the port number that the spong server listens on.$CHECKS
A string that has the list of client check modules to run. If $CHECK is missed or blank, spong-client defaults to "disk cpu processes logs". If the &check_local() function is present then 'local' is appened.
$CPUWARN, $CPUCRIT
A number indicating the CPU load that triggers a problem ($CPUWARN triggers warnings - yellow, and $CPUCRIT triggers alerts - red).@PROCSWARN, @PROCSCRIT
A list of processes that should be running, if they are not running, then trigger a problem (processes in @PROCSWARN trigger a warning - yellow, and processes in @PROCSCRIT trigger an alert - red).$LOGCHECKS
A list of hashes which defined checks to apply to log files. Each hash contains the fields logfile which is the full path to the log file to check and checks whch is a list of check to apply to the log file. Each check is a hash that contains the fields: pattern - a Perl regular expression to be scanned for, status - the status color to reported lines matching pattern, duration - the duration that each event is to be reported to the server, text - the text to reported back in the detailed message field of the status report (which can include match position variables from pattern) and id - an optional key field to associated with each event generated.$DF, $UPTIME, $PS, $GREP
These variables are OS specific variables, which are hopefully set correctly for your machine, if they are not - please send me email letting me know what OS you are running on, and what the correct value should be.
The checks are actually a set of modules that are called in series by spong-client. The list of modules to run are defined in the $CHECKS configuration variable. Upon initialization, spong-client will load the modules defined in $CHECKS from the "LIBDIR/Spong/Client/plugins/" directory. As each modules is initialized, it registers itself with the the plugins registery (see the Developer Guide). Spong comes with a standard set of clients check_disk, check_cpu, check_processes and check_logs (see Client Modules for details.)
EXTENDING FUNCTIONALITY
Depreciated, please refer to the Client Modules section of the developer guide.
If you want to check some service which is not being checked by spong-client, then you can define a &check_local() function in your config file (either in your standard config file or your host specific file - but not both!). That function can do anything you want, but at the end needs to call the &status() function to report what you have found to the spong server.
&status( SERVERADDR, HOST, SERVICE, COLOR, SUMMARY, MESSAGE )The arguments to the &status() function are:
* SERVERADDR - Should be $SPONGSERVER * HOST - The full hostname of the machine you are on * SERVICE - Should be the string local. * COLOR - Either "red", "yellow", or "green" * SUMMARY - A short one line summary of the status * MESSAGE - More detailed information (can be multi-lined)Here is an example &check_local() function that we run on some of our machines to check to make sure that our sendmail mail queue is not getting too large.
sub check_local { my $color = "green"; my $summary = ""; my $rt = `mailq | head -1`; chomp $rt; if( $rt =~ /\((\d+) request/ ) { $items = $1 if( $items > 1000 ) { $color = "red"; } elsif( $items > 500 ) { $color = "yellow"; } $summary = "$items messages in the mail queue"; } else { $color = "yellow"; $summary = "Can't parse mailq output: $rt"; } &status( $SPONGDISPLAY, $HOST, "local", $color, $summary, "" ); }FILES
Perl v5.003 or greater is required.
BUGS
None know bugs.
SEE ALSO
the spong-server manpage , spong.conf, client-modules, develper-guild
AUTHOR
Ed Hill (ed-hill@uiowa.edu),
Unix System Administrator, The University of Iowa
Stephen L Johnson (stephen.johnson@mail.state.ar.us)
or (sjohnson@monsters.org),
Unix System Administator, DIS - State of Arkansas
Based on code/ideas from Sean MacGuire (BB), and Helen Harrison (Pong).