Page 1 of 1

Python error executing command

Posted: Thu Sep 13, 2018 3:12 am
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

Re: Python error executing command

Posted: Thu Sep 13, 2018 11:09 am
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.