Page 1 of 4

errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 12:15 pm
by wolf57
How do I integrate plugin CHECK_PGACTIVITY to Nagios?
Getting this error after restart of nagios
Checking services...
Error: Service check command 'check_pgactivity -s backends -w 80 -c 95' specified in service 'check_pgactivity' for host 'pgtest-db' not defined anywhere!

I have entered this in /etc/nagios3/objects/command.cfg
define command {
command_name check_pgactivity
command_line $USER1$/check_pgactivity -h $HOSTADDRESS$
register 1
}

And this in /etc/nagios3/objects/services/check_pgactivity.cfg
define service {
host_name pgtest-db
service_description check_pgactivity
check_command check_pgactivity -s backends -w 80 -c 95
max_check_attempts 3
check_interval 3
retry_interval 3
check_period 24x7
notification_interval 5
notification_period 24x7
contacts wolf
contact_groups db-group
register 1
}

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 1:54 pm
by rkennedy
You'll need to make a few changes to this -

Add $ARG1$ after $HOSTADDRESS$ -

Code: Select all

I have entered this in /etc/nagios3/objects/command.cfg
define command {
command_name check_pgactivity
command_line $USER1$/check_pgactivity -h $HOSTADDRESS$ $ARG1$
register 1
}
and for this one, the argument needs to be seperated. $ARG1$ will be equal to -s backends -w 80 -c 95 -

Code: Select all

define service {
host_name pgtest-db
service_description check_pgactivity
check_command check_pgactivity!-s backends -w 80 -c 95
max_check_attempts 3
check_interval 3
retry_interval 3
check_period 24x7
notification_interval 5
notification_period 24x7
contacts wolf
contact_groups db-group
register 1
}

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:04 pm
by wolf57
That fixed it - thanks

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:07 pm
by wolf57
Sorry the restart worked but in Nagios under the Services it shows (Service check did not exit properly)

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:19 pm
by rkennedy
Can you run the command over command line and post the result?

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:27 pm
by wolf57
It works from the command line but errors on monitoring output of Nagios

~# check_pgactivity -h pgtest-db -s backends -w 80% -c 95%
POSTGRES_BACKENDS OK: 2 connections on 297 | postgres=1;237;282;0;297 nagios=0;237;282;0;297 phppgadmin=0;237;282;0;297 repmgrdb=0;237;282;0;297 opm=0;237;282;0;297 test4=0;237;282;0;297 template1=1;237;282;0;297 ima=0;237;282;0;297 test2=0;237;282;0;297 test1=0;237;282;0;297 test3=0;237;282;0;297 maximum_connections=297;237;282;0;297

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:30 pm
by Box293
Can you run it as the nagios user please:

Code: Select all

su nagios
check_pgactivity -h pgtest-db -s backends -w 80% -c 95%
The monitoring engine executes all plugins as this account.

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:41 pm
by wolf57
root@montwo:~# su - nagios
nagios@montwo:~$ check_pgactivity -h pgtest-db -s backends -w 80% -c 95%
POSTGRES_BACKENDS OK: 2 connections on 297 | postgres=1;237;282;0;297 nagios=0;237;282;0;297 phppgadmin=0;237;282;0;297 repmgrdb=0;237;282;0;297 opm=0;237;282;0;297 test4=0;237;282;0;297 template1=1;237;282;0;297 ima=0;237;282;0;297 test2=0;237;282;0;297 test1=0;237;282;0;297 test3=0;237;282;0;297 maximum_connections=297;237;282;0;297

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 2:53 pm
by Box293
I think I found the problem. In the service we updated, the -w and -c values do not have a % sign. This should work:

Code: Select all

define service {
    host_name pgtest-db
    service_description check_pgactivity
    check_command check_pgactivity!-s backends -w 80% -c 95%
    max_check_attempts 3
    check_interval 3
    retry_interval 3
    check_period 24x7
    notification_interval 5
    notification_period 24x7
    contacts wolf
    contact_groups db-group
    register 1
    }

Re: errors in config - CHECK_PGACTIVITY plugin

Posted: Tue Dec 22, 2015 3:02 pm
by wolf57
The command works with or without % I changed it the .cfg file but still the same error

Here is the output without % from the command line
nagios@montwo:~$ check_pgactivity -h pgtest-db -s backends -w 80 -c 95
POSTGRES_BACKENDS OK: 2 connections on 297 | postgres=1;80;95;0;297 nagios=0;80;95;0;297 phppgadmin=0;80;95;0;297 repmgrdb=0;80;95;0;297 opm=0;80;95;0;297 test4=0;80;95;0;297 template1=1;80;95;0;297 ima=0;80;95;0;297 test2=0;80;95;0;297 test1=0;80;95;0;297 test3=0;80;95;0;297