quick action item
quick action item
I was wondering if you guys know of a way to run TOP from the Quick Action screen ? I know you can add custom items but I am not sure what script could be run in the background to produce TOP results remotely ?
You do not have the required permissions to view the files attached to this post.
Re: quick action item
Here's one one you can do it. I have a host that I am monitoring via NRPE. I set up the following command on the remote box (client):
and restarted xinetd:
I made sure it works from the command line on the Nagios XI server:
I put the command in a bash shell script, called "top.sh" in the "libexec" directory:
I added the command (script) to the "Actions" component:
Admin->Manage Components->Actions->Edit Settings
and clicked on "Apply Settings".
Now, when I click on my host under "Home->Host Detail", I can see the "Top" link under "Quick Actions":
When I click on it, I can see the top output:
Code: Select all
command[check_top]=top -b -n 1Code: Select all
service xinetd restartCode: Select all
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_top
top - 13:53:09 up 1:01, 1 user, load average: 1.17, 1.15, 1.69
Tasks: 177 total, 3 running, 174 sleeping, 0 stopped, 0 zombie
Cpu(s): 13.7%us, 10.0%sy, 0.0%ni, 53.0%id, 22.2%wa, 0.3%hi, 0.8%si, 0.0%st
Mem: 4019476k total, 1057168k used, 2962308k free, 187104k buffers
Swap: 2064380k total, 0k used, 2064380k free, 341756k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1078 root 20 0 34152 14m 3472 R 15.7 0.4 0:07.80 ncpa_posix_list
1833 root 20 0 47864 4752 2704 S 2.0 0.1 0:30.68 fprobe
26350 nagios 20 0 12240 3632 2520 S 2.0 0.1 0:00.01 sendmail
27007 nagios 20 0 2696 1064 784 R 2.0 0.0 0:00.01 top
1 root 20 0 2900 1416 1204 S 0.0 0.0 0:02.30 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.90 migration/0
4 root
Code: Select all
[root@testbox libexec]# pwd
/usr/local/nagios/libexec
[root@testbox libexec]# cat top.sh
#!/bin/bash
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c check_top
exit 0Admin->Manage Components->Actions->Edit Settings
and clicked on "Apply Settings".
Now, when I click on my host under "Home->Host Detail", I can see the "Top" link under "Quick Actions":
When I click on it, I can see the top output:
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: quick action item
this look very good thank you !
Re: quick action item
Check it out and let us know if you have any questions.
Re: quick action item
This is what we are looking for but, we are going to try to use check_by_ssh instead of NRPE if possible
Re: quick action item
this is working from command line need to figure out the quick action part...
-------------------------------
su nagios top.sh
------------------------------
top.sh
#!/bin/bash
/usr/local/nagios/libexec/check_by_ssh -H xxxxx -C "top -cSbn 1"
exit 0
Need to figure out how to inject the name of the server from the quick action to the -H .....
-------------------------------
su nagios top.sh
------------------------------
top.sh
#!/bin/bash
/usr/local/nagios/libexec/check_by_ssh -H xxxxx -C "top -cSbn 1"
exit 0
Need to figure out how to inject the name of the server from the quick action to the -H .....
Re: quick action item
What you could do is edit the quick action and set the command to:
Then change the top.sh script to:
Then you should be golden!
Code: Select all
/usr/local/nagios/libexec/top.sh '%hostaddress%'Code: Select all
#!/bin/bash
HOST=$1
/usr/local/nagios/libexec/check_nrpe -H $HOST -c check_top
exit 0Re: quick action item
This is the last piece, I need to make the quick action run in the context of my nagios account , I think it's running as root
From the launched screen ...
Running: /usr/local/nagios/libexec/top.sh '172.29.10.169'
Remote command execution failed: Could not create directory '/var/www/.ssh'.
From the launched screen ...
Running: /usr/local/nagios/libexec/top.sh '172.29.10.169'
Remote command execution failed: Could not create directory '/var/www/.ssh'.
Re: quick action item
Did you setup password-less login by ssh for that host?
If not, you need to following the instructions below.
https://assets.nagios.com/downloads/nag ... ng_SSH.pdf
For every host you want to use the quick action item, you will need to follow that procedure.
Edit.
I forgot to add that the Quick Action Item runs as apache so the password less login will have to be setup as the apache user.
And the command will have to be edited to use the nagios login like below.
If not, you need to following the instructions below.
https://assets.nagios.com/downloads/nag ... ng_SSH.pdf
For every host you want to use the quick action item, you will need to follow that procedure.
Edit.
I forgot to add that the Quick Action Item runs as apache so the password less login will have to be setup as the apache user.
And the command will have to be edited to use the nagios login like below.
Code: Select all
/usr/local/nagios/libexec/check_by_ssh -H xxxxx -C "top -cSbn 1" -l nagiosBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: quick action item
Ok is there anyway to make the quick launch use the "nagios" account instead of "apache" ?