This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

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.

  • 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

  • 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?