Page 3 of 3

Re: Check Windows Process memory

Posted: Mon Jan 18, 2016 1:31 pm
by JohnFLi
same result

Code: Select all

Current Status:	  CRITICAL   (for 2d 20h 29m 29s)
Status Information:	CRITICAL: Memory for W3WP has passed 1,000 meg 194.66796875
Performance Data:	
CLI

Code: Select all

# ./check_nrpe -H g1vpfms02 -c check_w3wp -a '200 1000'
OK: Everything seems to be fine 194.72265625

Code: Select all

define service {
	host_name			G1VPFMS02
	service_description		W3WP Memory
	check_command			check_nrpe!check_w3wp!'200 1000'!!!!!!
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			xi_timeperiod_24x7
	notification_interval		5
	first_notification_delay	0
	notification_period		xi_timeperiod_24x7
	notification_options		w,c,u,
	contacts			My Name
	register			1
	}	
Powershell script

Code: Select all

param($warn, $crit)
    $LastExitCode = 3
    $output = ""
    $myW3WP = Get-Process w3wp |  Sort -Descending WS| select -first 1 | Measure-Object WS -Sum
    $myW3WP = $myW3WP.sum / 1mb


    if ($myW3WP -gt $crit)
            {
                $output = "CRITICAL: Memory for W3WP has passed 1,000 meg $myW3WP"
                $LastExitCode = 2
         }   
        elseif ($myW3WP -gt $warn)
            {
                $output = "WARN: Memory for W3WP is getting close to 1,000 meg $myW3WP"
                $LastExitCode = 1
            }
        else
            {
                $output = "OK: Everything seems to be fine $myW3WP"
            $LastExitCode = 0
            }

   Write-Host $output
   exit $LastExitCode
ini

Code: Select all

[/settings/external scripts/scripts]
check_w3wp=cmd /c echo C:\scripts\checkW3WP.ps1 $ARG1$; exit $LastExitCode | powershell.exe -command -

Re: Check Windows Process memory

Posted: Mon Jan 18, 2016 1:49 pm
by tgriep
On your Nagios Server, go to Core Config Manager > Services, edit the W3WP Memory service.
Change your $ARG2$ from

Code: Select all

'200 1000'
to

Code: Select all

-a '200 1000'
You need to add the -a to the $ARG2$ also.

Re: Check Windows Process memory

Posted: Mon Jan 18, 2016 2:23 pm
by JohnFLi
the pesky -a

XI seems to like it now.

Re: Check Windows Process memory

Posted: Mon Jan 18, 2016 3:25 pm
by rkennedy
:D Glad to see this script made it's full course through, and that you didn't stick with my one liner!

Did the -a flag end up fixing it then? Are we good to close this thread out?

Re: Check Windows Process memory

Posted: Tue Jan 19, 2016 11:07 am
by JohnFLi
yes, the -a did fix it. now I'm facing another issue.
as you could see i was trying to get this to work on the machine named fms02. Seems to be working fine. SO I copied all the settings and applied to FMS01. restart the nsclient service etc. and I get the "no handler" error message.

just for fun, I stopped the nsclient service on fms01.... all the nagios checks on fms02 started going off. the nagios server pings the right machines, I checked the managed host button, everything is correct. wierd.

but anyway, for this thread, you can close it.

Thank you guys yet again.

Re: Check Windows Process memory

Posted: Tue Jan 19, 2016 11:27 am
by rkennedy
The configuration may have just needed a reload. Sounds good, I'll close this out now.

If you ever need any assistance in the future, feel free to open a new thread!