Hi, I am testing the Check_AWS_CloudWatch_metrics (http://exchange.nagios.org/directory/Pl ... cs/details).
I am able to use the plug-in within linux, but I must be doing something wrong in Nagios. My assumption is that it is related to sudo rights. I attempted to insert that option in the command, but I get the error “Return code of 127 is out of bounds - plugin may be missing”. Besides the info provided on the plug-in download page, I added the amazon-ec2 and the CloudyScripts gems because I was getting errors about them not being installed.
When I “Test Check Command” from within Nagios, the output is blank. Maybe I have something misconfigured in the “commands” and “service management” settings. Thanks for your help
Cloudwatch monitoring
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Cloudwatch monitoring
What is the output of:
Can you share your command definition in XI for this plugin? Also, depending on what you are passing the plugin, it may not show output with the Test button, you may have to assign it to a host/service pair and check the service itself from Home > Services to see if it is giving you the correct output.
Code: Select all
ll /usr/local/nagios/libexec/Check_AWS_CloudWatch_metrics
Re: Cloudwatch monitoring
I have to run the command with options and I need to run as sudo. Here is the command I am running:
sudo ruby check_cloudwatch_status-2.1.77.rb -a IP_ADDRESS -i i-INSTANCE_NAME -f ec2_credentials.cfg -C CPUUtilization -c 90 -w 75
The response is:
CloudWatch Metric: CPUUtilization, Average: 8.97, Maximum: 10.17, Minimum: 8.50|
metric_average=8.97 metric_maximum=10.17 metric_minimum=8.50
From within Nagios, here are the current command lines. I have tried both commands with and without sudo. I am learning this on the fly; so I do not know if this is needed:
command1 = $$USER1$/ruby check_cloudwatch_status-2.1.77.rb -a $ARG1$ -i $ARG2$ -f $ARG3$ -C $ARG4$ -c $ARG5$ -w $ARG6$
command2 = $USER1$/sudo ruby check_cloudwatch_status-2.1.77.rb -a ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com -i i-xxxxxxxx -f ec2_credentials.cfg -C CPUUtilization -c 90 -w 75
Under Service Management I have:
Check Command = check_clouldwatch_status
It is active
Config Name = localhost
Description = cloudwatch-service management
Display name = cloudwatch-service management
Under Manage Hosts, I have the localhost selected
Under Manage Templates, I have the generic-service selected
ARG1 = ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com
ARG2 = i-xxxxxxxx
ARG3 = ec2_credentials.cfg
ARG4 = CPUUtilization
ARG5 = 90
ARG6 = 75
I did not enter any more information on this page
--------------
I also created another Service for "command2":
Check Command = check_clouldwatch_status
It is active
Config Name = localhost
Description = cloudwatch-service management2
Display name = cloudwatch-service management2
Under Manage Hosts, I have the localhost selected
Under Manage Templates, I have the generic-service selected
I have no arguments defined.
I did not enter any more information on this page.
When I look at the status of services, I have 2 critical errors. The one for command1 states "(Return code of 127 is out of bounds - plugin may be missing)"; the one for command2 states "(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/sudo, ...) failed. errno is 2: No such file or directory".
If Test Check Command is selected from Service Management, both commands look correct. I will be revising the second command to see if I can get this to work. Thanks for your help.
sudo ruby check_cloudwatch_status-2.1.77.rb -a IP_ADDRESS -i i-INSTANCE_NAME -f ec2_credentials.cfg -C CPUUtilization -c 90 -w 75
The response is:
CloudWatch Metric: CPUUtilization, Average: 8.97, Maximum: 10.17, Minimum: 8.50|
metric_average=8.97 metric_maximum=10.17 metric_minimum=8.50
From within Nagios, here are the current command lines. I have tried both commands with and without sudo. I am learning this on the fly; so I do not know if this is needed:
command1 = $$USER1$/ruby check_cloudwatch_status-2.1.77.rb -a $ARG1$ -i $ARG2$ -f $ARG3$ -C $ARG4$ -c $ARG5$ -w $ARG6$
command2 = $USER1$/sudo ruby check_cloudwatch_status-2.1.77.rb -a ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com -i i-xxxxxxxx -f ec2_credentials.cfg -C CPUUtilization -c 90 -w 75
Under Service Management I have:
Check Command = check_clouldwatch_status
It is active
Config Name = localhost
Description = cloudwatch-service management
Display name = cloudwatch-service management
Under Manage Hosts, I have the localhost selected
Under Manage Templates, I have the generic-service selected
ARG1 = ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com
ARG2 = i-xxxxxxxx
ARG3 = ec2_credentials.cfg
ARG4 = CPUUtilization
ARG5 = 90
ARG6 = 75
I did not enter any more information on this page
--------------
I also created another Service for "command2":
Check Command = check_clouldwatch_status
It is active
Config Name = localhost
Description = cloudwatch-service management2
Display name = cloudwatch-service management2
Under Manage Hosts, I have the localhost selected
Under Manage Templates, I have the generic-service selected
I have no arguments defined.
I did not enter any more information on this page.
When I look at the status of services, I have 2 critical errors. The one for command1 states "(Return code of 127 is out of bounds - plugin may be missing)"; the one for command2 states "(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/sudo, ...) failed. errno is 2: No such file or directory".
If Test Check Command is selected from Service Management, both commands look correct. I will be revising the second command to see if I can get this to work. Thanks for your help.
-
sreinhardt
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: Cloudwatch monitoring
You should never have nagios sudo things, if that needs to be done, use the suid bit instead. Otherwise, please respond to slansings question, 127 in your case likely means that nagios does not have permissions to that file. Another one to return the output from:
Code: Select all
ls -lart /usr/local/nagios/libexec | grep rbNagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Re: Cloudwatch monitoring
The "/usr/local/nagios/libexec/Check_AWS_CloudWatch_metrics" returns nothing (missing file). When I change it to "check_cloudwatch_status-2.1.77.rb", I get the message below:
Ignoring executable-hooks-1.3.2 because its extensions are not built. Try: gem pristine executable-hooks-1.3.2
Ignoring gem-wrappers-1.2.4 because its extensions are not built. Try: gem pristine gem-wrappers-1.2.4/usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:54:in `gem_original_require': no such file to load -- AWS (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rb:12
from /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rb:12:in each'
from /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rb:12
-----------------
The output of "ls -lart /usr/local/nagios/libexec | grep rb" returns
-rwxr-xr-x 1 apache apache 23340 Aug 19 14:01 check_cloudwatch_status-2.1.77.rb
-rwxr-xr-x 1 apache apache 3268 Aug 19 14:01 encrypt_credentials.rb
I then applied SUID and this is the new output.
[ec2-user@ip-10-238-232-98 libexec]$ ls -lart /usr/local/nagios/libexec | grep rb
-rwsr-xr-x 1 apache apache 23340 Aug 19 14:01 check_cloudwatch_status-2.1.77.rb
-rwsr-xr-x 1 apache apache 3268 Aug 19 14:01 encrypt_credentials.rb
Results are the same. I then removed the plug-in and added it again, but this did not help. Thanks.
Ignoring executable-hooks-1.3.2 because its extensions are not built. Try: gem pristine executable-hooks-1.3.2
Ignoring gem-wrappers-1.2.4 because its extensions are not built. Try: gem pristine gem-wrappers-1.2.4/usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:54:in `gem_original_require': no such file to load -- AWS (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rb:12
from /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rb:12:in each'
from /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rb:12
-----------------
The output of "ls -lart /usr/local/nagios/libexec | grep rb" returns
-rwxr-xr-x 1 apache apache 23340 Aug 19 14:01 check_cloudwatch_status-2.1.77.rb
-rwxr-xr-x 1 apache apache 3268 Aug 19 14:01 encrypt_credentials.rb
I then applied SUID and this is the new output.
[ec2-user@ip-10-238-232-98 libexec]$ ls -lart /usr/local/nagios/libexec | grep rb
-rwsr-xr-x 1 apache apache 23340 Aug 19 14:01 check_cloudwatch_status-2.1.77.rb
-rwsr-xr-x 1 apache apache 3268 Aug 19 14:01 encrypt_credentials.rb
Results are the same. I then removed the plug-in and added it again, but this did not help. Thanks.
-
slansing
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Cloudwatch monitoring
Try changing ownership to nagios:nagios, as the nagios group does include apache as well, some plugins can be finicky like this. I'd also suggest reaching out to the dev, who's information is here:
http://exchange.nagios.org/directory/Pl ... cs/details
http://exchange.nagios.org/directory/Pl ... cs/details
Code: Select all
chown nagios:nagios /usr/local/nagios/libexec/check_cloudwatch_status-2.1.77.rbRe: Cloudwatch monitoring
Issue is fixed. Basically, I had issues with Ruby EC2 gem and I had to modify 2 of the files provided. I obtained the solution from this site: http://blog.nclouds.com/?author=3
Thanks
Thanks