Python event handler error

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
Hussk
Posts: 3
Joined: Thu Nov 19, 2020 8:23 am

Python event handler error

Post by Hussk »

I would like help with getting a python event handler working which uses boto3. I have tried the script without being caused by an event and it works without any errors.

within my Python script:

Code: Select all

import boto3
I am getting the response below in the event logs:

Code: Select all

wproc: stderr line 04: ImportError: No module named boto3
How would I go about making this work?
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Python event handler error

Post by gormank »

Are you testing as the nagios user?
Is the handler running on the nagios host or remote hosts?
Are you testing on the nagios host or remote hosts?
Hussk
Posts: 3
Joined: Thu Nov 19, 2020 8:23 am

Re: Python event handler error

Post by Hussk »

Yes, I am testing as a Nagios user and the event handler is running on the Nagios host where I am testing. To clarify I am using nagios core as I previously didn't mention.

More info:
Global event handler enabled and set up. working and tested before.

Code: Select all

define command {
    command_name    test
    command_line    /usr/local/nagios/libexec/eventhandlers/test.py $HOSTNAME$ $HOSTSTATE$
}
within my python script:

Code: Select all

#!/usr/bin/python
import sys
import boto3
I have used sys.argv to test the python script to add the macros to a file which worked with no errors.

I have boto3 installed:

Code: Select all

~$ pip show boto3

Code: Select all

Name: boto3
Version: 1.16.21
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /home/ubuntu/.local/lib/python2.7/site-packages
Requires: jmespath, s3transfer, botocore
Locked