summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Sabino Mullane2013-06-25 02:28:31 +0000
committerGreg Sabino Mullane2013-06-25 02:28:31 +0000
commit3dd88c6c37f2aa18aac0f4087508be1555129d0a (patch)
treea40d93927920e9a6745867cb4a55d7ba9282b398
parent2a3d9456ac59d8c260fe0e0f903b2f94942ed584 (diff)
Better "simple" output
-rwxr-xr-xcheck_postgres.pl42
1 files changed, 26 insertions, 16 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index aa4378704..bed2bd3dd 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -1495,23 +1495,28 @@ sub do_mrtg {
my $one = $arg->{one} || 0;
my $two = $arg->{two} || 0;
if ($SIMPLE) {
- $one = $two if (length $two and $two > $one);
- if ($opt{transform} eq 'KB' and $one =~ /^\d+$/) {
- $one = int $one/(1024);
+ if (! exists $arg->{one}) {
+ print "$arg->{msg}\n";
}
- if ($opt{transform} eq 'MB' and $one =~ /^\d+$/) {
- $one = int $one/(1024*1024);
- }
- elsif ($opt{transform} eq 'GB' and $one =~ /^\d+$/) {
- $one = int $one/(1024*1024*1024);
- }
- elsif ($opt{transform} eq 'TB' and $one =~ /^\d+$/) {
- $one = int $one/(1024*1024*1024*1024);
- }
- elsif ($opt{transform} eq 'EB' and $one =~ /^\d+$/) {
- $one = int $one/(1024*1024*1024*1024*1024);
+ else {
+ $one = $two if (length $two and $two > $one);
+ if ($opt{transform} eq 'KB' and $one =~ /^\d+$/) {
+ $one = int $one/(1024);
+ }
+ if ($opt{transform} eq 'MB' and $one =~ /^\d+$/) {
+ $one = int $one/(1024*1024);
+ }
+ elsif ($opt{transform} eq 'GB' and $one =~ /^\d+$/) {
+ $one = int $one/(1024*1024*1024);
+ }
+ elsif ($opt{transform} eq 'TB' and $one =~ /^\d+$/) {
+ $one = int $one/(1024*1024*1024*1024);
+ }
+ elsif ($opt{transform} eq 'EB' and $one =~ /^\d+$/) {
+ $one = int $one/(1024*1024*1024*1024*1024);
+ }
+ print "$one\n";
}
- print "$one\n";
}
else {
my $uptime = $arg->{uptime} || '';
@@ -1537,7 +1542,12 @@ sub do_mrtg_stats {
my $msg = shift;
defined $msg or ndie('unknown-error');
- keys %stats or bad_mrtg($msg);
+ if (! keys %stats) {
+ if ($SIMPLE) {
+ do_mrtg({msg => $msg});
+ }
+ bad_mrtg($msg);
+ }
my ($one,$two) = ('','');
for (sort { $stats{$b} <=> $stats{$a} } keys %stats) {
if ($one eq '') {