=head1 NAME B - spong-network module to check MySQL servers =head1 DESCRIPTION This is a plugin module for the Spong L program. The B module checks the status of MySQL servers by querying them using the mysqladmin command. It not only alerts you to a problem if it can't connect, but it also returns some potentially interesting numbers. These numbers can be graphed using L. =cut # Register the routine with the plugin registry $PLUGINS{'mysql'} = \&check_mysql; sub check_mysql { my( $host ) = @_; my( $dbuser ) = $HOSTS{$host}{'mysql'}{'dbuser'} || $HOSTS_DEFAULTS{'mysql'}{'dbuser'}; my( $dbpass ) = $HOSTS{$host}{'mysql'}{'dbpass'} || $HOSTS_DEFAULTS{'mysql'}{'dbpass'}; my( $color, $summary, $message ) = ( "green", "MySQL Ok", "" ); open (MYSQL,"$MYSQLADMIN $host status -u$dbuser -p$dbpass 2>&1 |") || warn "Could not exec $MYSQLADMIN for status info."; while () { $message .= $_; if (/Can\'t connect/) { $color = "red"; $summary = "Server is unreachable."; } if (/Access denied/) { $color = "yellow"; $summary = "Server is up, but access is denied."; } } &debug( "mysql - $host - $color, $summary" ); return( $color, $summary, $message ); } 1; __END__ =head2 Output Returned =over 4 =item Status If there is nothing degraded or failed on the MySQL server then 'green' status is returned. Otherwise 'yellow' is returned if we don't have access or 'red' is returned if the connection fails. This could be extended in the future to check and see if a minimum number of tables are present. =item Summary Field If there are no problems, 'MySQL Ok' is returned. Otherwise the summary field will have a short description of what the problem or anamoly is. =item Detail Message Field If the MySQL process is contactable, then the detail message will have some interesting numbers from the MySQL server. =back =head2 Configuration It is necessary to add the following to L: $MYSQLADMIN = "/usr/bin/mysqladmin -h"; Where C is replaced with the path that leads to C. It is possible to set configuration details both for as a a default and then for specific hosts. An example is given in L. =back =head1 EXAMPLES %HOSTS_DEFAULTS = ( 'mysql' => { 'dbuser' => 'spong', 'dbpass' => 'default-password' } ) %HOSTS = ( 'mysql.server.com' => { 'services' => 'mysql', 'mysql' => { 'dbpass' => 'host-specific-password' } } =head1 SEE ALSO L, L, L, L =head1 RESTRICTIONS B uses mysqladmin, hence it is necessary to have some basic client utilities installed from MySQL. =head1 AUTHOR Miles Lott Support for %HOSTS and %HOSTS_DEFAULTS and POD documentation added by Andrew Ruthven - 2002/06/13.