NagiosEnterprises / ncpa

Nagios Cross-Platform Agent
Other
176 stars 95 forks source link

Plugin args suggested by API UI don't work from the CLI, but alternate approach with -a instead of -q works #1165

Open jdunitz opened 1 month ago

jdunitz commented 1 month ago

This works: ./check_load -w 0.14,0.13,0.12 -c 0.22,0.21,0.20 CRITICAL - load average: 0.56, 0.37, 0.28|load1=0.560;0.140;0.220;0; load5=0.370;0.130;0.210;0; load15=0.280;0.120;0.200;0;

So putting it in the ncpa plugins directory and building a command through the UI should work. The UI suggested this: ./check_ncpa.py -v -H 192.168.1.7 -t 'atoken' -M 'plugins/check_load' -q 'args= -w0.14,0.13,0.12 -c0.22,0.21,0.20' An error occurred: need more than 1 value to unpack (I added the -v, but otherwise it's what the "show as a nagios command" menu item suggested)

I thought maybe it needed to be URL-encoded: [root@xi7 libexec]# ./check_ncpa.py -v -H 192.168.1.7 -t 'atoken' -M 'plugins/check_load' -q 'args=-w0.14,0.13,0.12%20-c0.22,0.21,0.20' An error occurred: need more than 1 value to unpack [root@xi7 libexec]#

MB suggested after some head-scratching that this works:

[root@xi7 libexec]# ./check_ncpa.py -H 192.168.1.7 -t 'atoken' -M 'plugins/check_load' -a '-w 0.14,0.13,0.12 -c 0.22,0.21,0.20' -v Connecting to: https://192.168.1.7:5693/api/plugins/check_load/-w/0.14%2C0.13%2C0.12/-c/0.22%2C0.21%2C0.20?token=atoken&check=1 File returned contained: {"returncode": 0, "stdout": "OK - load average: 0.02, 0.09, 0.12|load1=0.020;0.140;0.220;0; load5=0.090;0.130;0.210;0; load15=0.120;0.120;0.200;0;", "cmd": "/usr/local/ncpa/plugins/check_load -w 0.14,0.13,0.12 -c 0.22,0.21,0.20"} OK - load average: 0.02, 0.09, 0.12|load1=0.020;0.140;0.220;0; load5=0.090;0.130;0.210;0; load15=0.120;0.120;0.200;0; [root@xi7 libexec]#

and indeed, when I put that into the ARG1 field, it works in XI.

This seems like unexpected behavior, or perhaps an unclear error message. I also think the UI should suggest things that work as expected.