Don't show service= unless there is something there
authorGreg Sabino Mullane <[email protected]>
Sun, 25 Jan 2009 15:20:42 +0000 (10:20 -0500)
committerGreg Sabino Mullane <[email protected]>
Sun, 25 Jan 2009 15:20:42 +0000 (10:20 -0500)
check_postgres.pl

index 6a8f2fc3081f832ee2c727f0ec20b3e435e9fb8e..a20a6ee9ebc122fe28df5b2c0f86e4205f437e32 100755 (executable)
@@ -356,9 +356,10 @@ sub add_response {
        my ($type,$msg) = @_;
 
        my $header = sprintf q{%s%s%s},
-               $action_info->{$action}[0] ? '' : defined $db->{dbservice} ? qq{service=$db->{dbservice} } : qq{DB "$db->{dbname}" },
-                       $db->{host} eq '<none>' ? '' : qq{(host:$db->{host}) },
-                               defined $db->{port} ? ($db->{port} eq $opt{defaultport} ? '' : qq{(port=$db->{port}) }) : '';
+               $action_info->{$action}[0] ? '' : (defined $db->{dbservice} and length $db->{dbservice}) ? 
+                       qq{service=$db->{dbservice} } : qq{DB "$db->{dbname}" },
+                               $db->{host} eq '<none>' ? '' : qq{(host:$db->{host}) },
+                                       defined $db->{port} ? ($db->{port} eq $opt{defaultport} ? '' : qq{(port=$db->{port}) }) : '';
        $header =~ s/\s+$//;
        my $perf = ($opt{showtime} and $db->{totaltime}) ? "time=$db->{totaltime}" : '';
        if ($db->{perf}) {