Telegraf - Error in plugin [inputs.exec] exit status 120

Hello Community,

I got a problem trying to add a new feature to my grafana deployment, basically i receive this error msg every time i try to debuging:

E! [inputs.exec] Error in plugin: exec: exit status 120 for command ‘/bin/python3.9 /opt/telegraf/api/iaas/nxapi/nxos.py -u -p -n router-fqdn --show_version’

The script can be executed without errors detected with the telegraf user:

[root@vm nxapi]# sudo -u telegraf /bin/python3.9 /opt/telegraf/api/iaas/nxapi/nxos.py -u -p -n router-fqdn --show_version

nxos_system,hostname=router-fqdn biosversion=“3.1.0”,kickstartversion=“7.3(3)D1(1)”,systemversion=“7.3(3)D1(1)”,chassisid=“Nexus7700 C7706 (6 Slot) Chassis”,nxosfilename=“bootflash:///n7700-s2-dk9.7.3.3.D1.1.bin”,moduleid=“Supervisor Module-2”,modulesn=“omited”

Looks like not to be a proble with the directory permitions:

[root@vm nxapi]# ll
total 12
-rwxr-xr-x. 1 telegraf telegraf 2316 Sep 16 13:21 README.md
drwxr-xr-x. 3 telegraf telegraf 64 Sep 18 15:25 commands
drwxr-xr-x. 3 telegraf telegraf 51 Sep 18 15:30 common
drwxr-xr-x. 3 telegraf telegraf 50 Oct 8 09:17 controllers
drwxr-xr-x. 3 telegraf telegraf 21 Sep 16 13:21 hardware
-rwxrwxr-x. 1 telegraf telegraf 5575 Oct 8 09:03 nxos.py
drwxr-xr-x. 3 telegraf telegraf 48 Oct 8 09:20 view
[root@cvs1pap70 nxapi]#

Any idea? i even try to enable the telegraf debug mode but no extra errors are showing

[root@cvs1pap70 nxapi]# cat /opt/telegraf/telegraf.conf | grep debug | grep -v “#”
debug = true
[root@cvs1pap70 nxapi]#

Module exec file:

[root@vm nxapi]# cat /opt/telegraf/telegraf.d/iaas/routers_api.conf

[[inputs.exec]]
commands = [“/bin/python3.9 /opt/telegraf/api/iaas/nxapi/nxos.py -u -p -n --show_version”]
interval = “5m”
timeout = “30s”
data_format = “influx”

Thank for your help and support!

Fixed, i use the logging library from python and detect this in the log file:

2024-10-08 13:20:24,953 - ERROR - error
Traceback (most recent call last):
File “/opt/telegraf/api/iaas/nxapi/nxos.py”, line 166, in main
if int((nxosController(arg.netdevice , arg.site , arg.env , arg.discipline , arg.country).getShowVersion())) == 1:
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’

Have no idea why from CLI the script works and for the module dosn’t.

I’ll close the ticket.

@JOSE_RAFAEL_GUERRA_G Thanks for sharing your solution with the community!