cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Level 7

Count processes - IPMonitor

I need to monitor the number of specific process on a server where i have limited concurrent user license for an application.

Multiple users login to the application & the task manager on the server shows "ntbshell" as process name for each user. I can count these processes using batch file countbshell.bat as following :

@echo off

Powershell.exe @(Get-Process -Name ntbshell -ErrorAction SilentlyContinue).Count

pause

However, i need to automate it through IPMonitor to prompt us if the active users exceeds a certain number. Any help would be appreciated.

0 Kudos
2 Replies
Highlighted

Re: Count processes - IPMonitor

This is one of the ways we do it: (we also have bat files and perl versions)

You need to exit the PowerShell script as per below example - setting the exit code to be either the actual number of processes - or do the compare in the script. Below is part of a PowerShell script we use for running process checking.

The monitor type is external script where you invoke PowerShell to run a script and you use the compare process return code to match what you want from the script. I have included a pic so you can see how we do it.

We use non-standard return codes so we know that the script is setting them - allows us to pick up when PowerShell goes weird and returns zero.

#If the contents are string "true", exit with a success code, anything else prompts an exit with failure code.

if ($content -eq $true) {

    Write-Host "True"

    [Environment]::Exit(2)

}

    [Environment]::Exit(7)

ipmon_powershell_example_monitor.png

0 Kudos
Highlighted
Level 11

Re: Count processes - IPMonitor

I'm trying to execute a powershell script and I always get a return value of 1.  I used your example [Environment]::Exit(2) and 7 but still the same always a 1.  My executable name, directory and startup directory are the same as yours.  Any ideas?

0 Kudos