Process List With Memory Usage Windows Machine

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

Process List With Memory Usage Windows Machine

Post by arvmanya »

Hi,

I have setup Nagios core for monitoring of windows servers. I have successfully installed Nagios core on Ubuntu machine and from there monitored another Ubuntu machine and 3 windows servers.

I have written a Powershell script(and set it up in the External Scripts section to get it executed with NSClient++) to get the process list with memory usage and send it as an email notification(email notification being sent as part of external script only), in case it reaches a specified threshold limit.

Currently, I set the threshold value within script file(not passed as an argument as case with the standard scripts). At the same time, alert is being shown in Nagios Core UI as Critical. I have deployed this script to different servers, with threshold limit set in the script itself. I am just wondering if I have to change this threshold limit, I need to log on to each server and change the value in the script, tedious task.

I am trying to find out if there is a way to get the remote servers process list along with memory usage, without being deployed the external script to server, being monitored. I meant, if script run on the nagios server, to get the remote process list along with memory usage. Just wondering, if any such plug-in is available or not.

- Is there a plug in where we can do this functionality without deploying scripts to the monitored servers.

Regards,
Arvind
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Process List With Memory Usage Windows Machine

Post by lmiltchev »

You can look for alternative scripts/solutions on the Nagios Exchange. I searched for "process memory windows", and here's the results:

https://exchange.nagios.org/index.php?o ... %20windows

You can also modify your script in a way that you can pass arguments. This will give you more control from the Nagios Core box.

Code: Select all

./check_nrpe -H <server1> -c <your script> -a <args for server1>
./check_nrpe -H <server2> -c <your script> -a <args for server2>
...
I hope this makes sense.
Be sure to check out our Knowledgebase for helpful articles and solutions!
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

Re: Process List With Memory Usage Windows Machine

Post by arvmanya »

Thanks for the reply !

But in that case, custom script needs to be on the monitored server, right ? I have to deploy the script to each server and have to do the configuration and It will be very tedious if there are more servers to monitor.

What I am looking for is to get the process list stats, as an email notification, if threshold reached a limit, running the script on Nagios server and monitored windows servers from server itself (without deploying the script to each windows servers).
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Process List With Memory Usage Windows Machine

Post by Box293 »

Have a look at Nagios Automation Framework (NAF).

This is a Nagios Reactor solution for pushing out NSClient++ along with updates from Nagios XI.

https://github.com/willemdh/naf_windows_request_install

Specifically he as an action to update the NSClient++ Scripts folder:

https://outsideit.net/naf-update-nsclie ... ts-folder/
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

Re: Process List With Memory Usage Windows Machine

Post by arvmanya »

Good to know, but I do not have Nagios XI.
Will check if it works with Nagios core.

So, to run the custom script, it has to be in the 'scripts' folder on the monitored servers, right ?

I have written an exe in c#(for the process list with memory usage details, I have the same script in powershell) but trying to find a way to use it like standard plug-in. Could someone please guide me how to do the configuration to achieve it.

Regards,
Arvind
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Process List With Memory Usage Windows Machine

Post by tmcdonald »

First off, I am moving this out of Nagios Core Development into just Nagios Core since it is not discussing the code of Nagios Core.

To the issue at hand, if you wish to run your program on a remote machine, then your program will need to be installed on the remote machine, and Nagios will need a way to run it. Nagios does not have a way to run code on a remote machine by default - that would be incredibly insecure. Instead, Nagios uses what's known as an Agent to run the check on its behalf. The agent listens on a port, and runs a check that Nagios tells it to, then returns the results. The agent we usually recommend for Windows is called NSClient++:

http://docs.nsclient.org/tutorial/core/index.html

For Linux, we maintain NRPE (Nagios Remote Plugin Executor):

https://github.com/NagiosEnterprises/nrpe

And we are working on a new release for NCPA (Nagios Cross-Platform Agent) which will hopefully take the place of the above two:

https://assets.nagios.com/downloads/ncp ... index.html

NSClient or NCPA can be used to run your plugin, however you will need to code it in such a way that it can accept arguments to be passed in, otherwise you will need to modify it on each server.

Give the above a good read, and if you have further questions we'd be happy to help.
Former Nagios employee
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Process List With Memory Usage Windows Machine

Post by rkennedy »

I'm not familiar with how an exe or c# would accomplish this exactly, but as long as you use exit codes you should be fine. Are you using exit codes?

I'm sure you could create a script, to handle updating on the fly. I don't know of a way to do this without an agent though, especially on Windows.

Here's a one liner that will return the top 10 processes on Windows -- if c#/exe won't work I'd reccomend PowerShell.

Code: Select all

Get-Process | Sort CPU | Select -last 10 | Out-File "C:\Program Files\NSClient++\scripts\powershell\topcpu.txt" -append
At first you wanted to do this without a file on the remote system, now it's an exe, can you please describe what you're looking for specifically?
Former Nagios Employee
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

Re: Process List With Memory Usage Windows Machine

Post by arvmanya »

Yes, I did use exit codes. I have written powershell and vbscript (with arguments as server name, warning and critical limits) and able to invoke it successfully through Nagios. I am sending an email within script(in case of usage equals or more than critical limit) and returning return codes with percentage usage and process name consuming highest memory, back to Nagios, to show in UI.

Regarding C#, I thought of creating a dll and use that dll, within Nagios.

As of now, I am good.
Thanks all for the help !
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Process List With Memory Usage Windows Machine

Post by lmiltchev »

Sounds good, arvmanya! If you have any more questions, start a new thread. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked