[check_postgres] cannot get options right check_hot_standby_delay

Bill MacArthur webmaster at dhs-club.com
Tue Oct 4 19:05:05 UTC 2011


On 10/4/2011 10:51 AM, Bill MacArthur wrote:
> Greetings,
>
> I have tried and tried to get check_hot_standby_delay working from the command line, but no go. I am missing something simple, but cannot figure out exactly what even after glancing at the source. Please make the necessary correction for me. (I am using .pgpass)
>
> I am good on connecting.......
> sh-3.2$ ./check_postgres_connection --db=network -H=db3 -dbuser1=nagios
> POSTGRES_CONNECTION OK: DB "network" (host:db3) version 9.0.4 | time=0.36s
> sh-3.2$ ./check_postgres_connection --db=network -H=db2 -dbuser1=nagios
> POSTGRES_CONNECTION OK: DB "network" (host:db2) version 9.0.4 | time=0.23s
>
> Just can't seem to get this right, though....
> sh-3.2$ ./check_hot_standby_delay --dbname1=network --dbhost1=db3 --dbhost2=db2 --dbuser=nagios --warning=100000 --critical=10000000 --dbuser2=nagios -db2 network
> Invalid arguments:
>     network
>     -db2
>
> Usage: ..............
>
> sh-3.2$ ./check_hot_standby_delay --dbname1=network --dbhost1=db3 --dbhost2=db2 --dbuser=nagios --warning=100000 --critical=10000000 --dbuser2=nagios -dbname2=network
>
> Usage:...............
>
> sh-3.2$ ./check_hot_standby_delay -db network -H db3,db2 -u nagios --dbport2=5432 --warning=100000 --critical=1000000
>
> Usage:...............
>
> sh-3.2$ ./check_hot_standby_delay -db network -H db3,db2 -u nagios --dbport2=5432
>
> Usage:...............
>
> sh-3.2$ ./check_hot_standby_delay --dbname=network --dbhost=db3 --dbuser=nagios --dbname2=network --dbhost2=db2 --dbuser2=nagios --warning=100000 --critical=10000000
>
> Usage:...............
>
> Thank you for your assistance.
> Bill MacArthur
> _______________________________________________
> Check_postgres mailing list
> Check_postgres at bucardo.org
> https://mail.endcrypt.com/mailman/listinfo/check_postgres

After digging in further, I finally discovered that the problem centered around the name of the symlink. check_postgres.pl will use the name of the running script to decide what action it is to take if there is no "action" argument. However, it does it's matching like this:
## See if we need to invoke something based on our name
our $action = $opt{action} || '';
if ($ME =~ /check_postgres_(\w+)/ and ! defined $opt{action}) {
     $action = $1;
}

This particular symlink, "check_hot_standby_delay", does not begin with "check_postgres" and so without an action argument on the commandline, there ends up being no action the usage instructions are presented.

By adding the --action=hot_standby_delay argument, joy was found.
I also found that besides the check_hot_standby_delay symlink, there was a check_postgres_hot_standby_delay. The latter provided the desired functionality. Perhaps the former is a leftover from a previous check_postgres.pl version. The docs should probably indicate the latter symlink name to avoid confusion for new users of this fine module.

At any rate, the plugin works very nicely.
Thank you.


More information about the Check_postgres mailing list