[icinga-users] execute plugins with sudo

Jens.Wilke at parcIT.de Jens.Wilke at parcIT.de
Mon Aug 22 12:37:19 CEST 2016



Hi,

how is it possible to execute plugins with sudo?

while this works:

nagios at vm1:~$ sudo -u postgres /usr/lib/nagios/plugins/check_postgres.pl
--action txn-time -H 127.0.0.1 -c 60 -p 5432 -u postgres
POSTGRES_TXN_TIME CRITICAL: DB "postgres" (host:127.0.0.1) longest txn:
9183s (2 hours 33 minutes 3 seconds) PID:15086 database:postgres
username:jens query:select * from pg_stat_activity ; | time=0.04s
transaction_time=9183s;;60

using this check commend:
command = [ "sudo -u postgres " + PluginContribDir + "/check_postgres.pl" ]

icinga2 complains about no such file or directory:

[2016-08-22 12:09:01 +0200] warning/PluginCheckTask: Check command for
object 'pg-localhost-5432!pg_txn_time' (PID: 27615, arguments: 'sudo -u
postgres /usr/lib/nagios/plugins/check_postgres.pl' '--action' 'txn-time'
'-H' '127.0.0.1' '-c' '60' '-p' '5432' '-u' 'postgres') terminated with
exit code 128, output: execvpe(sudo -u
postgres /usr/lib/nagios/plugins/check_postgres.pl) failed: No such file or
directory
[2016-08-22 12:10:01 +0200] notice/Process: Running command 'sudo -u
postgres /usr/lib/nagios/plugins/check_postgres.pl' '--action' 'txn-time'
'-H' '127.0.0.1' '-c' '60' '-p' '5432' '-u' 'postgres': PID 27973
[2016-08-22 12:10:01 +0200] notice/Process: PID 27973 ('sudo -u
postgres /usr/lib/nagios/plugins/check_postgres.pl' '--action' 'txn-time'
'-H' '127.0.0.1' '-c' '60' '-p' '5432' '-u' 'postgres') terminated with
exit code 128
[2016-08-22 12:10:01 +0200] warning/PluginCheckTask: Check command for
object 'pg-localhost-5432!pg_txn_time' (PID: 27973, arguments: 'sudo -u
postgres /usr/lib/nagios/plugins/check_postgres.pl' '--action' 'txn-time'
'-H' '127.0.0.1' '-c' '60' '-p' '5432' '-u' 'postgres') terminated with
exit code 128, output: execvpe(sudo -u
postgres /usr/lib/nagios/plugins/check_postgres.pl) failed: No such file or
directory

Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.icinga.org/pipermail/icinga-users/attachments/20160822/890571f2/attachment.html>


More information about the icinga-users mailing list