2 Replies Latest reply on Nov 18, 2019 3:51 PM by chaldz

    Count processes - IPMonitor

    urownzee

      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.

        • Re: Count processes - IPMonitor
          wizard_from_oz

          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)