errors in config - CHECK_PGACTIVITY plugin

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
wolf57
Posts: 20
Joined: Tue Dec 22, 2015 11:49 am

errors in config - CHECK_PGACTIVITY plugin

Post 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
}
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post 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
}
Former Nagios Employee
wolf57
Posts: 20
Joined: Tue Dec 22, 2015 11:49 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post by wolf57 »

That fixed it - thanks
wolf57
Posts: 20
Joined: Tue Dec 22, 2015 11:49 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post by wolf57 »

Sorry the restart worked but in Nagios under the Services it shows (Service check did not exit properly)
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post by rkennedy »

Can you run the command over command line and post the result?
Former Nagios Employee
wolf57
Posts: 20
Joined: Tue Dec 22, 2015 11:49 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: errors in config - CHECK_PGACTIVITY plugin

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
wolf57
Posts: 20
Joined: Tue Dec 22, 2015 11:49 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: errors in config - CHECK_PGACTIVITY plugin

Post 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
    }
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
wolf57
Posts: 20
Joined: Tue Dec 22, 2015 11:49 am

Re: errors in config - CHECK_PGACTIVITY plugin

Post 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
Locked