Hi,
I have downloaded external plugin check_cpu_usage.sh for monitoring the cpu. It is working as expected on Nagios main server, but when I am trying to execute on remote server I am getting below error. Can someone help me with this.
./check_cpu_usage.sh -w 90 -c 98
(standard_in) 1: syntax error
./check_cpu_usage.sh: line 15: [: 90: unary operator expected
OK - CPU Usage = %|CPU Usage=%;;;;
Nagios plugin not working as expected on remote server
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Nagios plugin not working as expected on remote server
Is https://exchange.nagios.org//directory/ ... t)/details the one you are using? You could potentially change it to use bash rather than sh. On what OS/version are you trying to run the remote script? Has it worked on any remote hosts? What user are you running the script as on the remote host?
Re: Nagios plugin not working as expected on remote server
Thank you for your quick response. I am using the plugin from below link.
https://exchange.nagios.org/directory/P ... 29/details
Plugin is working as expected in Nagios server in Linux SuSe version 11.4
Plugin is not working in remote host in in Linux SuSe version 12.2
https://exchange.nagios.org/directory/P ... 29/details
Plugin is working as expected in Nagios server in Linux SuSe version 11.4
Plugin is not working in remote host in in Linux SuSe version 12.2
-
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Nagios plugin not working as expected on remote server
That script has a couple of debug options. Can you uncomment those? It doesn't seem to work on ubuntu 17.04 either. It's possible there has been some change in sh and bash since the older SUSE 11.4. I tried both bash and sh with no difference. One thing that's interesting though is with a single-digit warning I was able to get a different error message. You can see in my debug output that the variables aren't getting populated.
Honestly, your best bet is probably to find a different plugin.
Code: Select all
d@d-Vostro-420-Series:~$ sudo ./check_cpu_usage.sh -w 7 -c 98
(standard_in) 1: syntax error
./check_cpu_usage.sh: 15: [: -lt: argument expected
OK - CPU Usage = %|CPU Usage=%;;;;
d@d-Vostro-420-Series:~$ sudo ./check_cpu_usage.sh -w 70 -c 98
(standard_in) 1: syntax error
DEBUG: head: tail:
DEBUG: |||| , ||||
./check_cpu_usage.sh: 15: [: -lt: argument expected
OK - CPU Usage = %|CPU Usage=%;;;;
Re: Nagios plugin not working as expected on remote server
Hi @dwhitfield,
Thank you for your time, even I tried the same but it didn't worked for me. Can you please suggest me the alternative plugin for monitoring cpu percentage.
Thank you for your time, even I tried the same but it didn't worked for me. Can you please suggest me the alternative plugin for monitoring cpu percentage.
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Nagios plugin not working as expected on remote server
@anusha, There's a standard Nagios plugin called check_load. You'd need to run it on the remote server locally. If you already compiled nrpe it is probably already installed in /usr/local/nagios/libexec/ folder.
Here's an example:
-w 1,1,1 that provides a warning threshold for 1 minute, 5 minutes and 15 minutes. -c 2,2,2 also privdes thresholds for 1,5, and 15 minutes.
Let us know if that works for you.
Here's an example:
Code: Select all
./check_load -w 1,1,1 -c 2,2,2
OK - load average: 0.00, 0.01, 0.05|load1=0.000;1.000;2.000;0; load5=0.010;1.000;2.000;0; load15=0.050;1.000;2.000;0;
Let us know if that works for you.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Nagios plugin not working as expected on remote server
Hi Npolovenko,
My idea is to get the CPU percentage from top command and check_load didnt helped me in this case...
My idea is to get the CPU percentage from top command and check_load didnt helped me in this case...
Re: Nagios plugin not working as expected on remote server
Monitoring "percent CPU usage" is a tricky thing to do generally speaking.
If you're able to install an agent in the machine, you might try leveraging NCPA which takes advantage of the psutil Python package to provide, among other things, % CPU usage:
https://www.nagios.org/ncpa/help.php#api-modules-cpu
Here's a guide to setting up NCPA with Nagios Core:
https://www.nagios.org/ncpa/getting-started.php#linux
If you're able to install an agent in the machine, you might try leveraging NCPA which takes advantage of the psutil Python package to provide, among other things, % CPU usage:
https://www.nagios.org/ncpa/help.php#api-modules-cpu
Here's a guide to setting up NCPA with Nagios Core:
https://www.nagios.org/ncpa/getting-started.php#linux
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Nagios plugin not working as expected on remote server
There are a few plugins on the exchange that supposed to check the CPU usage, but they haven't really been tested. Like this one for example:
https://exchange.nagios.org/directory/P ... ux/details
I agree with @mcapra that installing NCPA would probably be a better solution if you want more accurate usage reading.
https://exchange.nagios.org/directory/P ... ux/details
I agree with @mcapra that installing NCPA would probably be a better solution if you want more accurate usage reading.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.