Python error executing command

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.
Locked
JTWilkins
Posts: 1
Joined: Wed Sep 12, 2018 8:15 am

Python error executing command

Post by JTWilkins »

I'm trying to send a notification to Telegram.

I've got a python script that I am calling to send the notification but getting a module import error. I've tried installing the missing module but not having any luck.

Here is my code for the command.

Code: Select all

define command {
  command_name     notify-service-by-telegram
  command_line     /usr/local/bin/nagios_telegram.py --token $USER4$ --object_type service --contact $USER3$ --notificationtype "$NOTIFICATIONTYPE$" --servicestate "$SERVICESTATE$" --hostname "$HOSTNAME$" --hostaddress "$HOSTADDRESS$" --datetime "$LONGDATETIME$" --output "$SERVICEOUTPUT$" --servicedesc "$SERVICEDESC$" --servicename "$SERVICENAME$"
}
This is the code for the python script that I am using. https://github.com/dariomas/nagios_tele ... elegram.py

I have tried to execute the script outside of Nagios and it was working so why it won't load the modules I don't know any help would be appreciated.

Thanks
Jonathan
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Python error executing command

Post by scottwilkerson »

When you test it outside of nagios, are you running it as the nagios user?

Code: Select all

su nagios
It is possible that when you added the missing packages you added them to a path that isn't accessible by the nagios user.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked