plugin error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
progressive.nagiosXI
Posts: 277
Joined: Mon Jul 31, 2017 5:54 am

plugin error

Post by progressive.nagiosXI »

Hi Support Team,

Please help with the below error

URL:- https://exchange.nagios.org/directory/P ... cs/details
tried gem install fog, but failed

[root@ip ~]# RUBYOPT=rubygems ruby /usr/local/nagios/libexec/check_cloudwatch_status-6.4.44.rb ....
Traceback (most recent call last):
4: from /root/tmp1/check_cloudwatch_status-6.4.44.rb:13:in `<main>'
3: from /root/tmp1/check_cloudwatch_status-6.4.44.rb:13:in `each'
2: from /root/tmp1/check_cloudwatch_status-6.4.44.rb:13:in `block in <main>'
1: from /opt/rh/rh-ruby25/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:59:in `require'
/opt/rh/rh-ruby25/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- fog (LoadError)
[root@ip ~]# ruby --version
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]


[root@ip ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"



Thanks


Thanks
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: plugin error

Post by ssax »

Here is how I got it installed - Unfortunately, I can't test it because I don't have any Amazon instances:

Code: Select all

cd /usr/local/nagios/libexec/
wget "https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2647&cf_id=24" -O check_cloudwatch_status.rb
wget "https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=2647&cf_id=35" -O encrypt_credentials.rb
chmod +x /usr/local/nagios/libexec/encrypt_credentials.rb
chmod +x /usr/local/nagios/libexec/check_cloudwatch_status.rb
yum install libcurl libcurl-devel -y
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm reload
rvm install 2.7.2
rvm use 2.7.2 --default
gem install fog-aws -V
mkdir /etc/cloutomate/
touch /etc/cloutomate/cloutomate.pem
That gem install fog-aws -V command may take a long time to run, it has to download a bunch of things to build an index (you may see a bunch of 302 message, that's ok), just let it run.

Run this command to generate the credentials (Replace the XXXXX options with yours):

Code: Select all

RUBYOPT=rubygems ruby /usr/local/nagios/libexec/encrypt_credentials.rb -A XXXXXXXXXXXXXXXXXXXX -S XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -f /usr/local/nagios/libexec/rds_credentials_1.cfg 
Now you can test it from the command line (Rplace the XXXXX options with yours):

Code: Select all

RUBYOPT=rubygems ruby /usr/local/nagios/libexec/check_cloudwatch_status.rb -i RDS_IDENTIFIER -a RDS_IDENTIFIER.XXXXXX.rds.amzonaws.com -f /usr/local/nagios/libexec/rds_credentials_1.cfg -D CPUUtilization -c 90 -w 75
If it's working properly, in the XI interface go to Configure > Core Config Manager > Commands
- Click the Add New button
- Command Name: check_cloudwatch_status
- Command Line

Code: Select all

RUBYOPT="rubygems" /usr/local/nagios/libexec/check_cloudwatch_status.rb -a $HOSTADDRESS$ -i $ARG1$ -f $ARG2$ -C $ARG3$ --warning $ARG4$ --critical $ARG5$
- Command type: check_command
- Make sure the box is checked for Active
- Click Save

Now go to Configure > Core Config Manager > Services
- Click the Add New button
- Select check_cloudwatch_status from the Check command dropdown
- $ARG1$: Your RDS Identifier
- $ARG2$: /usr/local/nagios/libexec/rds_credentials_1.cfg
- $ARG3$: CPUUtilization OR whatever else you can check
- $ARG4$: 50 OR warning number you want
- $ARG5$: 80 OR critical number you want
- Select your host that you want it on and setup all the rest of the options you want for the service
- Click Save
- Apply Configuration

Let us know if you have any questions.


Thank you!
progressive.nagiosXI
Posts: 277
Joined: Mon Jul 31, 2017 5:54 am

Re: plugin error

Post by progressive.nagiosXI »

Thanks, Sean,

both scripts are now running but we are getting below error please help

Error occured while encrypting AWS credentials: key must be 16 bytes

Code: Select all

[root@ip ~]# RUBYOPT=rubygems ruby /usr/local/nagios/libexec/encrypt_credentials.rb -A XXXXXXXXXXXXXXXXXXXX -S XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -f /usr/local/nagios/credentials/myrds1.cfg
Error occured while encrypting AWS credentials: key must be 16 bytes
Please also note if I remove RUBYOPT=rubygems ruby and run as below then /usr/local/nagios/credentials/myrds1.cfg created successfully ,but here check_cloudwatch_status.rb gives error

Code: Select all

[root@ip cloutomate]# /usr/local/nagios/libexec/encrypt_credentials.rb -A AKIAZN34BCHRYMDXXXXX -S n5wjNGSrzvJ3cIOxMhfnNoFjbzs8MQ5XVXXXXXXX -f /usr/local/nagios/credentials/myrds1.cfg

[root@ip ~]# cat /usr/local/nagios/credentials/myrds1.cfg
 ec2_access_id N85lOeIGXaU/erhfyUGXb1ToXXXXXXXX
 ec2_access_key XxmpE3ruEvF/xv+2TigpI6lfR6j3JytWaNtQveEPYYpwJCLpXXXXXXXXX+d
kDLJ


[root@ip cloutomate]# /usr/local/nagios/libexec/check_cloudwatch_status.rb -i database-1 -a database-1.c77haurdncoq.ap-south-1.rds.amazonaws.com:3306 -f /usr/local/nagios/credentials/myrds1.cfg -D CPUUtilization -c 90 -w 75
/usr/share/rubygems/rubygems/dependency.rb:296:in `to_specs': Could not find 'json' (~> 2.0) among 95 total gem(s) (Gem::LoadError)
        from /usr/share/rubygems/rubygems/specification.rb:1212:in `block in activate_dependencies'
        from /usr/share/rubygems/rubygems/specification.rb:1201:in `each'
        from /usr/share/rubygems/rubygems/specification.rb:1201:in `activate_dependencies'
        from /usr/share/rubygems/rubygems/specification.rb:1183:in `activate'
        from /usr/share/rubygems/rubygems.rb:186:in `rescue in try_activate'
        from /usr/share/rubygems/rubygems.rb:183:in `try_activate'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:144:in `require'
        from /usr/local/nagios/libexec/check_cloudwatch_status.rb:12:in `block in <main>'
        from /usr/local/nagios/libexec/check_cloudwatch_status.rb:12:in `each'
        from /usr/local/nagios/libexec/check_cloudwatch_status.rb:12:in `<main>'

[root@ip ~]#  RUBYOPT=rubygems ruby /usr/local/nagios/libexec/check_cloudwatch_status.rb -i database-1 -a database-1.c77haurdncoq.ap-south-1.rds.amazonaws.com:3306 -f /usr/local/nagios/credentials/myrds1.cfg -D CPUUtilization -c 90 -w 75
Error occured while retrieving and decrypting credentials for instance database-1 on Amazon Server: database-1.c77haurdncoq.ap-south-1.rds.amazonaws.com:3306: key must be 16 bytes


[root@ip cloutomate]# gem list --local|grep -i json
fog-json (1.2.0)
json (default: 2.3.0)
multi_json (1.15.0)




Thanks
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: plugin error

Post by ssax »

Edit both of these files:

Code: Select all

/usr/local/nagios/libexec/check_cloudwatch_status.rb
/usr/local/nagios/libexec/encrypt_credentials.rb
Change this line:

Code: Select all

cipher = OpenSSL::Cipher::Cipher.new('bf-cbc')
To this:

Code: Select all

cipher = OpenSSL::Cipher::AES256.new('CBC')
Then encrypt the credentials again and test.
progressive.nagiosXI
Posts: 277
Joined: Mon Jul 31, 2017 5:54 am

Re: plugin error

Post by progressive.nagiosXI »

Thanks sean,

PFA,

The plugin is now working and giving output at the ssh-terminal.

But after added in Nagios showing error, Please check and help.

Thanks
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: plugin error

Post by ssax »

Try editing your command and change it to this:
- You're just prepending the command with the GEM_PATH

Code: Select all

GEM_PATH=/usr/local/rvm/gems/ruby-2.7.2:/usr/local/rvm/gems/ruby-2.7.2@global RUBYOPT=rubygems ruby ... ... ... ...
progressive.nagiosXI
Posts: 277
Joined: Mon Jul 31, 2017 5:54 am

Re: plugin error

Post by progressive.nagiosXI »

Thanks, sean,

PFA,

The plugin still is working and giving output at the ssh-terminal with a new command.

But after a change in Nagios showing another json dependency error, Please check and help.

Thanks
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: plugin error

Post by ssax »

It's a different error now. Please run this command:

Code: Select all

gem install json -V
Then test again and if it errors again send me the full output again.
progressive.nagiosXI
Posts: 277
Joined: Mon Jul 31, 2017 5:54 am

Re: plugin error

Post by progressive.nagiosXI »

Hi Sean,

Please check the attachment, still in the trap of dependencies error at Nagios web interface.

At ssh console/terminal command running ok for the root user as well as for the Nagios user.

Thanks
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: plugin error

Post by ssax »

You'll need to keep going and install everything it says to, look at the output from the rds1.PNG you attached, see how it says:

Code: Select all

Could not find 'rexml'
Take that value in quotes and use it to install the next package.

Then run the check and look at the output again, see another error about another gem? if so, install it by looking at the output and using it in this command:

Code: Select all

gem install rexml -V
Continue doing that until you can't anymore or you get another error besides it being unable to find a gem file that isn't installed.
Locked