Go to All Forums

Executing Nagios Script (check_aws_ec2_backup) With Site24x7 "nagios_plugins.json" ?

Hi all,

I'm trying to use this script (check_aws_ec2_backup) which is found in github (github.com/tommarshall/nagios-check-aws-ec2-backup) to monitor EC2 automated snapshot backups (using Lifecycle Manager).  Usually Nagios scripts such as this requires dedicated Nagios server to execute.  Site24x7 Nagios plugins are mostly used for individual client monitoring, correct me if I'm wrong but is there no way to execute this script in Site24x7 similar to a Nagios config file's "define command" to point the script to whichever EBS volumes for monitoring?

Can the "nagios_plugins.json" in /opt/site24x7/monagent/plugins used to run commands for this script?

Thank you!

Like (1) Reply
Replies (7)

Hi,

Sure, please read our documentation to execute your Nagios plugin in Site24x7. 

 

 

Happy Monitoring!

Like (0) Reply

Hi Mathangi,

 

Thanks for the prompt reply.  I have read that documentation you pointed out before posting here.  I get the general idea of how this works if I'm simply executing the script for that 1 client, but the script I want to use is for multiple clients / infrastructure on AWS. 

Normally Nagios has a config file (e.g. nagios.cfg) that I can use to point the script to it's target / IP address, but since Site24x7 plugin is not a dedicated Nagios server, it does not have that config file.  This is why I'm curious as to how to use the "nagios_plugins.json" to act as the config file to point the script to multiple targets.

Do I do this in the json file:

{
"nagios": [
"/usr/local/nagios/libexec/check_aws_ec2_backup",
"define command {
command_name check_aws_ec2_backup
command_line $USER1$/check_aws_ec2_backup -r ap-southeast-1a -v vol-abcde12345
}"
]
}

Your help is greatly appreciated!

Like (0) Reply

Hi,

We consider each entry as a separate monitor with its command line arg. However, we do not have an option to support the same script with different arguments. As a workaround, you can duplicate the Nagios integration and execute it with different args.

For example:
{
  "nagios": [
       "$USER1$/check_aws_ec2_backup_1 -r ap-southeast-1a -v vol-abcde12345",
       "$USER2$/check_aws_ec2_backup_2 -r ap-northeast-1a -v vol-abcde12345"
    ]
}

where, backup_1 and backup_2 will be the copies of your existing Nagios scripts. And, a monitor will be created for southeast and northeast respectively.  

Hope this helps. For any further queries, comment in the below thread. 

Like (0) Reply

Thanks for your input, I followed your example with some differences like this:

{
"nagios": [
"$USER1$/check_aws_ec2_backup"
]
}

I didn't put the arg into it because it seems that the script has a section to put those different arg

After re-registering the plugin, new error shows "

  /bin/sh: 1: $/check_aws_ec2_backup: not found  

Note: I tried the below method (taken from your KB) and edited the script for the python3 path to the location in my server

  1. Replace the shebang character "#!" with the appropriate path for Python 3 in your system.
    Eg : #!/usr/bin/python3

But same error still shows.  Any ideas?  Thanks.

Like (0) Reply

Hi Ken,

The server monitoring agent will execute the path mentioned in the JSON file. Please try executing with the actual physical path of the script file. Refer this kb for more details on why the nagios script is failing.

Hope this resolves your issue. Let us know for your feedback or any other comments, if any, in the below thread.

 

Thanks

Anita

Like (0) Reply

I have configured another bash script which is not using Nagios plugin, just a regular bash.  It registered successfully and I can see it in site24x7.  Now the problem is how do I setup a template to properly display the data

I can run the script manually inside the EC2 instance and it can output the results as intended (see results below), please advise how to translate this type of result to site24x7 template for display:

<27>May 14 17:53:58 [PID:26960]-[/opt/site24x7/monagent/plugins/check-snapshots/check-snapshots.sh]: Alert! Instance: i-0b17e80ea644b861d (Shang UNSUB 20181116) Volume: vol-05b95956e4d95ffc9 has no recent snapshots.
[05:53:59 PM] [PID:26960]-[/opt/site24x7/monagent/plugins/check-snapshots/check-snapshots.sh]: Checking i-0d1070a43a252f01a: (QSL.manager201702)
[05:54:01 PM] [PID:26960]-[/opt/site24x7/monagent/plugins/check-snapshots/check-snapshots.sh]: Checking i-03a582a8b804ce41e: (SITE24X7.Test)
<27>May 14 17:54:03 [PID:26960]-[/opt/site24x7/monagent/plugins/check-snapshots/check-snapshots.sh]: Alert! Instance: i-03a582a8b804ce41e (SITE24X7.Test) Volume: vol-0e8081878e286e133 has no recent snapshots.

 

Like (0) Reply

Hi Ken,

To create a Site24x7 plugin, the Shell script must print the data in the format 'key1:value1|key2:value2', as it will monitor only a key-value pair.

I would suggest you to change your script to print the instance name as the key and the values you want to monitor, separated by the pipe symbol (|). You can configure alerts through threshold profiles.

Refer a sample plugin script in Shell for monitoring the number of files & directories in a Linux server. For any queries, comment in the below thread.

 

Regards

Anita

Like (0) Reply

Was this post helpful?