Hi Xavier, Try the following as system sudo user or system root user
1. ICINGA2_API_PASSWORD=api_user_password icinga2 console --connect 'https://api_user@localhost:5665/' 2. s = get_service("hostname","icinga_internal_servicename").last_check_result.command 3. s Post your result if you can't see what is wrong. Kind Regards, Ivo Kidze -----Original Message----- From: icinga-users [mailto:icinga-users-boun...@lists.icinga.org] On Behalf Of Xavier Humbert Sent: Tuesday, January 22, 2019 9:30 AM To: icinga-users <icinga-users@lists.icinga.org> Subject: [icinga-users] Nagios plugin fails to execute, but OK in command line Hello, I've ran into a strange behaviour, a nagios plugin does not execute correctly when called from icinga2, but is OK from command line. The check is (cmk_load.pl and check_mk_agent.pl are perl scripts of mine): > object CheckCommand "Check_Load" { > import "plugin-check-command" > command = [ PluginDir + "/cmk_checks/cmk_load.pl" ] > arguments = { > "-H" = "$address$" > "-w" = "$warn$" > "-c" = "$crit$" > "-vd" = "" > } > > vars.warn = "4,4,4" > vars.crit = "8,8,8" > } When running from command line *as icinga user* it is OK : > # su icinga > bash-4.2$ /usr/lib64/nagios/plugins/cmk_checks/cmk_load.pl -vd > DEBUG: $VAR1 = [ > '0.10 0.11 0.11 1/302 31501 2' > ]; > > CMK_LOAD OK - load average 0.10, 0.11, 0.11|load1=0.100;1.000;5.000;0; > load5=0.110;1.000;5.000;0; load15=0.110;1.000;5.000;0; But inside icinga, I got this result : > DEBUG: $VAR1 = undef; > Use of uninitialized value $load_datas in split at > /usr/share/perl5/check_mk_agent.pm line 132. > Use of uninitialized value $l1 in numeric gt (>) at > /usr/share/perl5/check_mk_agent.pm line 134. > Use of uninitialized value $l5 in numeric gt (>) at > /usr/share/perl5/check_mk_agent.pm line 134. debug.log show me that the plugin is called with the correct parameters. I have an idea of what fails (DEBUG: $VAR1 = undef; is self explanatory), but I don't have a clue about how to debug it, aside from running from cli as user icinga, which does not fail... If you're curious, the full (dirty) code is here : https://github.com/xavier8854/check-mk-agent-perl Thanks for any help, Cheers, Xavier -- Xavier Humbert CRT Supervision et Exploitation de Niveau 1 Rectorat de Nancy-Metz 03 83 86 27 39 _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users