I just started using the msql-mysql.monitor that came with mon-0.99.2.
The patch below gives it (1) "standard" summary/detail output and (2)
suppresses unneeded error messages printed by the DBI module that
interfere with that output.
--- Ed
-------------------cut here----------------------------
--- ./msql-mysql.monitor 2001/10/10 00:49:27 1.1
+++ ./msql-mysql.monitor 2001/10/10 00:52:25
@@ -54,6 +54,9 @@
use DBI;
use Getopt::Long;
+my @details=();
+my @failures=();
+
GetOptions( \%options, "mode=s", "port=i", "username=s", "password=s", "database=s" );
# uncomment these two lines and provide suitable information if you don't
@@ -73,22 +76,27 @@
}
for $host( @ARGV ) {
- my( $dbh ) = DBI->connect(
"DBI:$mode:$options{database}:$host:$options{port}", $options{username},
$options{password} );
+ my( $dbh ) = DBI->connect(
+"DBI:$mode:$options{database}:$host:$options{port}", $options{username},
+$options{password}, { PrintError => 0 } );
if( ! $dbh ) {
- push( @failures, "Could not connect to $mode server $host: " .
$DBI::errstr );
+ push( @failures, $host);
+ push( @details, "$host: Could not connect to $mode server on
+$options{port}: " . $DBI::errstr . "\n");
next;
}
@tables = $dbh->func( '_ListTables' );
if( $#tables < 0 ) {
- push( @failures, "No tables found for database $options{database} on
server $host" );
+ push( @failures, $host);
+ push( @details, "$host: No tables found for database
+$options{database}\n");
}
$dbh->disconnect();
}
-if (@failures) {
- print join (", ", sort @failures), "\n";
- exit 1;
-};
+if (@failures == 0) {
+ exit 0;
+ }
+
+print join (" ", sort @failures), "\n";
+print sort @details if (scalar @details > 0);
+
+exit 1;
-exit 0;