Hi ,
Im using postgres.pl script to monitor database backends and having issue with generating nagios alert message and performance graphs.
When there are 0 connections , nagios message is showing as No connections instead of 0 connections and event performance is not showing saying 0 backend connections and in performance graphs its showing only time.
[nagios@nagioshost~]$ /usr/local/nagios/libexec/check_postgres.pl -H hostname --port=5432 --dbuser=user --dbname=sosproddb01 --action=backends --include=soslabdb01 --warning=70 --critical=80
POSTGRES_BACKENDS OK: DB "sosproddb01" (host:dkr1.2750.lowes.com) No Connections | time=0.10s
[nagios@nagioshost~]$
Can some one help me to get this modified so that alert message will be something like 0 connections and in performance graphs we should see both time and total connections.
Issue with Postgres.pl script
Re: Issue with Postgres.pl script
This works properly on mine:
What version are you running?
Additionally, please post the output with a -v -v -v added:
Code: Select all
[root@xip libexec]# ./check_postgres.pl -H 127.0.0.1 --port=5432 --dbuser=nagiosxi --dbname=nagiosxi --include=template1 --action=backends --warning=70 --critical=80
POSTGRES_BACKENDS OK: DB "nagiosxi" (host:127.0.0.1) No connections | time=0.01s template1=0;70;80;0;100Code: Select all
[root@xip libexec]# /usr/local/nagios/libexec/check_postgres.pl -V
check_postgres.pl version 2.21.0Code: Select all
/usr/local/nagios/libexec/check_postgres.pl -H hostname --port=5432 --dbuser=user --dbname=sosproddb01 --action=backends --include=soslabdb01 --warning=70 --critical=80 -v -v -vRe: Issue with Postgres.pl script
Below is the output of plugin version.
[nagios@lxappnagprd021 dkr1.2750.lowes.com]$ /usr/local/nagios/libexec/check_postgres.pl -V
check_postgres.pl version 2.21.0
Below is the verbose output
[nagios@lxappnagprd021 dkr1.2750.lowes.com]$ /usr/local/nagios/libexec/check_postgres.pl -H dkr1.2750.lowes.com --port=5432 --dbuser=sosnagread --dbname=sosproddb01 --action=backends --include=soslabdb01 --warning=70 --critical=80 -v -v -v
$POSTGRES1 = {
"verbose" => 3,
"test" => 0,
"include" => [
"soslabdb01"
],
"defaultport" => 5432,
"dbname" => [
"sosproddb01"
],
"critical" => 80,
"dbuser" => [
"sosnagread"
],
"showtime" => 1,
"timeout" => 30,
"showperf" => 1,
"transform" => "",
"port" => [
5432
],
"defaultuser" => "postgres",
"host" => [
"dkr1.2750.lowes.com"
],
"action" => "backends",
"warning" => 70
};
psql=/bin/psql version=9.2
Starting run_command with:
SELECT COUNT(datid) AS current,
(SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,
d.datname
FROM pg_database d
LEFT JOIN pg_stat_activity s ON (s.datid = d.oid)
GROUP BY 2,3
ORDER BY datname
$POSTGRES1 = [
"-q",
"-t",
"-d",
"sosproddb01",
"-U",
"sosnagread",
"-p",
5432,
"-h",
"dkr1.2750.lowes.com",
"-o",
"/tmp/cAQaLP2wKh/check_postgres_psql.ABL5xf4.tmp",
"-x",
"-c",
"SELECT version()"
];
$POSTGRES1 = [
"-q",
"-t",
"-d",
"sosproddb01",
"-U",
"sosnagread",
"-p",
5432,
"-h",
"dkr1.2750.lowes.com",
"-o",
"/tmp/cAQaLP2wKh/check_postgres_psql.ABL5xf4.tmp",
"-x",
"-c",
"SELECT COUNT(datid) AS current,\n (SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,\n d.datname\nFROM pg_database d\nLEFT JOIN pg_stat_activity s ON (s.datid = d.oid) \nGROUP BY 2,3\nORDER BY datname\n"
];
$POSTGRES1 = {
"hosts" => 1,
"db" => [
{
"dbpass" => "",
"version" => "9.5",
"dbservice" => "",
"port" => 5432,
"dbname" => "sosproddb01",
"host" => "dkr1.2750.lowes.com",
"ok" => 1,
"dbuser" => "sosnagread",
"totaltime" => "0.11",
"slurp" => [
{
"datname" => "postgres",
"mc" => 100,
"current" => 0
},
{
"datname" => "sosproddb01",
"mc" => 100,
"current" => 11
},
{
"datname" => "template0",
"mc" => 100,
"current" => 0
},
{
"datname" => "template1",
"mc" => 100,
"current" => 0
}
],
"pname" => "port=5432 host=dkr1.2750.lowes.com db=sosproddb01 user=sosnagread"
}
],
"command" => "SELECT COUNT(datid) AS current,\n (SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,\n d.datname\nFROM pg_database d\nLEFT JOIN pg_stat_activity s ON (s.datid = d.oid) \nGROUP BY 2,3\nORDER BY datname\n"
};
POSTGRES_BACKENDS OK: DB "sosproddb01" (host:dkr1.2750.lowes.com) No Connections | time=0.11s
[nagios@lxappnagprd021 dkr1.2750.lowes.com]$
Let me know hoew to fix this issue
[nagios@lxappnagprd021 dkr1.2750.lowes.com]$ /usr/local/nagios/libexec/check_postgres.pl -V
check_postgres.pl version 2.21.0
Below is the verbose output
[nagios@lxappnagprd021 dkr1.2750.lowes.com]$ /usr/local/nagios/libexec/check_postgres.pl -H dkr1.2750.lowes.com --port=5432 --dbuser=sosnagread --dbname=sosproddb01 --action=backends --include=soslabdb01 --warning=70 --critical=80 -v -v -v
$POSTGRES1 = {
"verbose" => 3,
"test" => 0,
"include" => [
"soslabdb01"
],
"defaultport" => 5432,
"dbname" => [
"sosproddb01"
],
"critical" => 80,
"dbuser" => [
"sosnagread"
],
"showtime" => 1,
"timeout" => 30,
"showperf" => 1,
"transform" => "",
"port" => [
5432
],
"defaultuser" => "postgres",
"host" => [
"dkr1.2750.lowes.com"
],
"action" => "backends",
"warning" => 70
};
psql=/bin/psql version=9.2
Starting run_command with:
SELECT COUNT(datid) AS current,
(SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,
d.datname
FROM pg_database d
LEFT JOIN pg_stat_activity s ON (s.datid = d.oid)
GROUP BY 2,3
ORDER BY datname
$POSTGRES1 = [
"-q",
"-t",
"-d",
"sosproddb01",
"-U",
"sosnagread",
"-p",
5432,
"-h",
"dkr1.2750.lowes.com",
"-o",
"/tmp/cAQaLP2wKh/check_postgres_psql.ABL5xf4.tmp",
"-x",
"-c",
"SELECT version()"
];
$POSTGRES1 = [
"-q",
"-t",
"-d",
"sosproddb01",
"-U",
"sosnagread",
"-p",
5432,
"-h",
"dkr1.2750.lowes.com",
"-o",
"/tmp/cAQaLP2wKh/check_postgres_psql.ABL5xf4.tmp",
"-x",
"-c",
"SELECT COUNT(datid) AS current,\n (SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,\n d.datname\nFROM pg_database d\nLEFT JOIN pg_stat_activity s ON (s.datid = d.oid) \nGROUP BY 2,3\nORDER BY datname\n"
];
$POSTGRES1 = {
"hosts" => 1,
"db" => [
{
"dbpass" => "",
"version" => "9.5",
"dbservice" => "",
"port" => 5432,
"dbname" => "sosproddb01",
"host" => "dkr1.2750.lowes.com",
"ok" => 1,
"dbuser" => "sosnagread",
"totaltime" => "0.11",
"slurp" => [
{
"datname" => "postgres",
"mc" => 100,
"current" => 0
},
{
"datname" => "sosproddb01",
"mc" => 100,
"current" => 11
},
{
"datname" => "template0",
"mc" => 100,
"current" => 0
},
{
"datname" => "template1",
"mc" => 100,
"current" => 0
}
],
"pname" => "port=5432 host=dkr1.2750.lowes.com db=sosproddb01 user=sosnagread"
}
],
"command" => "SELECT COUNT(datid) AS current,\n (SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,\n d.datname\nFROM pg_database d\nLEFT JOIN pg_stat_activity s ON (s.datid = d.oid) \nGROUP BY 2,3\nORDER BY datname\n"
};
POSTGRES_BACKENDS OK: DB "sosproddb01" (host:dkr1.2750.lowes.com) No Connections | time=0.11s
[nagios@lxappnagprd021 dkr1.2750.lowes.com]$
Let me know hoew to fix this issue
Re: Issue with Postgres.pl script
What about this one?
Code: Select all
/usr/local/nagios/libexec/check_postgres.pl -H dkr1.2750.lowes.com --port=5432 --dbuser=sosnagread --dbname=sosproddb01 --action=backends --include=sosproddb01 --warning=70 --critical=80 -v -v -v Re: Issue with Postgres.pl script
Output for this one as well provided in my last reply in this post. Please check
Re: Issue with Postgres.pl script
They are different commands...
Here is the original:
- Notice that dbname and include are different
Here is the new one (run this and send the full output):
- Notice that dbname and include are the same
Here is the original:
- Notice that dbname and include are different
Code: Select all
/usr/local/nagios/libexec/check_postgres.pl -H dkr1.2750.lowes.com --port=5432 --dbuser=sosnagread --dbname=sosproddb01 --action=backends --include=soslabdb01 --warning=70 --critical=80 -v -v -v - Notice that dbname and include are the same
Code: Select all
/usr/local/nagios/libexec/check_postgres.pl -H dkr1.2750.lowes.com --port=5432 --dbuser=sosnagread --dbname=sosproddb01 --action=backends --include=sosproddb01 --warning=70 --critical=80 -v -v -v