Permalink
Browse files

Add --quiet argument.

  • Loading branch information...
Greg Sabino Mullane
Greg Sabino Mullane committed Nov 8, 2010
1 parent 5c210e8 commit c54c4d041bb164c201f5da2de217496c9f4e261c
Showing with 13 additions and 3 deletions.
  1. +13 −3 check_postgres.pl
View
@@ -675,6 +675,7 @@ package check_postgres;
'version|V',
'verbose|v+',
'help|h',
+ 'quiet|q',
'man',
'output=s',
'simple',
@@ -1164,7 +1165,12 @@ sub finishup {
$action =~ s/^\s*(\S+)\s*$/$1/;
my $service = sprintf "%s$action", $FANCYNAME ? 'postgres_' : '';
if (keys %critical or keys %warning or keys %ok or keys %unknown) {
- printf '%s ', $YELLNAME ? uc $service : $service;
+ ## If in quiet mode, print nothing if all is ok
+ if ($opt{quiet} and ! keys %critical and ! keys %warning and ! keys %unknown) {
+ }
+ else {
+ printf '%s ', $YELLNAME ? uc $service : $service;
+ }
}
sub dumpresult {
@@ -1208,8 +1214,11 @@ sub finishup {
exit 1;
}
if (keys %ok) {
- print 'OK: ';
- dumpresult(o => \%ok);
+ ## We print nothing if in quiet mode
+ if (! $opt{quiet}) {
+ print 'OK: ';
+ dumpresult(o => \%ok);
+ }
exit 0;
}
if (keys %unknown) {
@@ -8740,6 +8749,7 @@ =head1 HISTORY
=item B<Version 2.15.0>
+ Add --quiet argument to surpress output on OK Nagios results
Add index comparison for same_schema (Norman Yamada and Greg Sabino Mullane)
Use $ENV{PGSERVICE} instead of "service=" to prevent problems (Guillaume Lelarge)
Add --man option to show the entire manual. (Andy Lester)

0 comments on commit c54c4d0

Please sign in to comment.