Run command
Run command
Is it possible to run direct command via nagios on my remote linux and capture that into my nagios to get me the status of specific process. Like run a command to find the status of the cluster is up or not.
Re: Run command
Absolutely. There are a couple of different ways to achieve this. Assuming that the command on your Linux server is called check_mycluster.py, and it returns 0 for good, 1 for warning, 2 for critical, and anything else for unknown. If your command doesn't do this, you could also write a wrapper shell script that runs your command, and returns one of those codes. For now, let's just work with check_mycluster.py.
In order to get Nagios to run this command, you can:
* install an agent (like NCPA) on the Linux system, and copy check_mycluster.py to the plugins directory. From there, you can create an NCPA check that calls your check_mycluster.py plugin. More information here,
https://www.nagios.org/ncpa/help/2.1/active.html
* use the check_by_ssh plugin, which will ssh into a remote system, execute a given command, and bring the return message and exit code back to Nagios. More information here,
https://nagios-plugins.org/doc/man/check_by_ssh.html
In order to get Nagios to run this command, you can:
* install an agent (like NCPA) on the Linux system, and copy check_mycluster.py to the plugins directory. From there, you can create an NCPA check that calls your check_mycluster.py plugin. More information here,
https://www.nagios.org/ncpa/help/2.1/active.html
* use the check_by_ssh plugin, which will ssh into a remote system, execute a given command, and bring the return message and exit code back to Nagios. More information here,
https://nagios-plugins.org/doc/man/check_by_ssh.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Run command
installing NCPA is a must ??? I need to check if redhat certify installing packages outside the repos
Re: Run command
No, my apologies. These are two different ways of accomplishing this task. If you don't want to, or can't install NCPA in your environment, you can use the check_by_ssh plugin from the Nagios XI server. That will ssh into your Linux host, and execute a command without needing any additional clients on the Linux host.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Run command
100% ... I can not install any third party on these servers, it would be great if you could show me an example how to work with check_by_ssh call a command and get it the response back and sending it out to admin via mail or sms.
Re: Run command
check_by_ssh uses a lot of the same command line switches as the standard OpenSSH client.
-H for your host
-p for your port
-l for your user
-i for your identity file
There's also -C, for the command that you want to have run on the Linux host. So your command looks something like this.
Also, there's this document which may be helpful.
https://assets.nagios.com/downloads/nag ... ng_SSH.pdf
-H for your host
-p for your port
-l for your user
-i for your identity file
There's also -C, for the command that you want to have run on the Linux host. So your command looks something like this.
Code: Select all
/usr/local/nagios/libexec/check_by_ssh -H <LinuxHostIP> -p <port> -l <username> -i <sshkey> -C "/path/to/check_mycluster.py"https://assets.nagios.com/downloads/nag ... ng_SSH.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Run command
Fair ... but how I can call these command from core config manager / config wizard ... since i use only that to add my hosts for notifications
Re: Run command
Oh I see, I was coming at this from angle of running the plugin. From inside of Nagios XI, we need to create the check command, then create the service to monitor, etc. Here is a doc that talks about plugins, and getting check commands setup.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Since check_by_ssh is a plugin that is already part of Nagios XI, you can skip down to the section titled, Define A Command. I'm also going to include a screenshot of the command definition page with our example check_by_ssh populated. One of the things I like to do when creating new commands in Nagios is to create them with my own prefix. Or at the very least, avoid the check_ prefix. This helps to quickly identify which check commands are the commands that I've created.
Edit:
I just realized that you had another thread, and I've already sent you that document. But that document should help in both cases.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Since check_by_ssh is a plugin that is already part of Nagios XI, you can skip down to the section titled, Define A Command. I'm also going to include a screenshot of the command definition page with our example check_by_ssh populated. One of the things I like to do when creating new commands in Nagios is to create them with my own prefix. Or at the very least, avoid the check_ prefix. This helps to quickly identify which check commands are the commands that I've created.
Edit:
I just realized that you had another thread, and I've already sent you that document. But that document should help in both cases.
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Run command
Great I will try it and get back to you
Re: Run command
Okay, we will leave this thread open and wait to hear back.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!