Ad Widget

Collapse

monitor separate excel.exe processes in zabbix per user

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xanadu
    Member
    • Sep 2014
    • 62

    #1

    monitor separate excel.exe processes in zabbix per user

    I have special request to monitor the following on a Citrix server. We notice that sometimes certain processes are still running in the background although the application is closed within the Citrix session.

    - for one separate process (eg. excel.exe)
    - cpu usage (eg 20%)
    - for a certain amount of time (eg 15 minutes)
    - and for which user

    It would be great if someone could help me with this. I found limited information on this in the forums, hence my new question.
    I'm looking to have both syntax and trigger for Zabbix.

    I think to have this monitored with a Powershell script, but I'm not sure if all is correct:

    ---BEGIN---

    Param([string]$ProcessName, [int]$SelectFirst, [switch]$GridView)

    If (! $ProcessName) { $ProcessName = '*' }
    If (! $SelectFirst) { $SelectFirst = 5 }

    If ($ProcessName -eq '*') {
    $ProcessList = gwmi Win32_PerfFormattedData_PerfProc_Process | select IDProcess,Name,PercentProcessorTime | where { $_.Name -ne "_Total" -and $_.Name -ne "Idle"} | sort PercentProcessorTime -Descending | select -First $SelectFirst
    }
    Else {
    $ProcessList = gwmi Win32_PerfFormattedData_PerfProc_Process | where {$_.Name -eq $ProcessName} | select IDProcess,Name,PercentProcessorTime | sort PercentProcessorTime -Descending | select -First $SelectFirst
    }
    $TopProcess = @()
    ForEach ($Process in $ProcessList) {
    $row = new-object PSObject -Property @{
    Id = $Process.IDProcess
    Name = $Process.Name
    User = (gwmi Win32_Process | where {$_.ProcessId -eq $Process.IDProcess}).GetOwner().User
    CPU = $Process.PercentProcessorTime
    Description = (Get-Process -Id $Process.IDProcess).Description
    }
    $TopProcess += $row
    }

    If ($GridView) {
    $TopProcess | sort CPU -Descending | select Id,Name,User,CPU,Description | Out-GridView
    }
    Else {
    $TopProcess | sort CPU -Descending | select Id,Name,User,CPU,Description | ft -AutoSize
    }

    ----END----

    example output:

    PS C:\Users\kevin\Documents\_Desktop> .\process.ps1

    Id Name User CPU Description
    -- ---- ---- --- -----------
    1920 firefox kevin 6 Firefox
    2092 srvany 0
    2140 srvany#1 0
    668 stacsv64 0
    4448 sttray64 kevin 0 IDT PC Audio

    Any help or advise is welcome!

    Kev
    Last edited by xanadu; 04-09-2014, 10:57.
  • xanadu
    Member
    • Sep 2014
    • 62

    #2
    I might have found a better script:

    $CPUPercent = @{
    Name = 'CPUPercent'
    Expression = {
    $TotalSec = (New-TimeSpan -Start $_.StartTime).TotalSeconds
    [Math]::Round( ($_.CPU * 100 / $TotalSec), 2)
    }
    }

    Get-Process |
    Select-Object -Property Name, CPU, $CPUPercent, Description |
    Sort-Object -Property CPUPercent -Descending |
    Select-Object -First 4

    ---END---

    example output:

    PS C:\Users\kevin\Desktop> .\processs.ps1

    Name CPU CPUPercent Description
    ---- --- ---------- -----------
    OUTLOOK 110,046875 3,21 Microsoft Outlook
    chrome 43,421875 3,12 Google Chrome
    firefox 9441,015625 1,59 Firefox
    mstsc 0,796875 0,63 Remote Desktop Connection
    chrome 216,953125 0,14 Google Chrome


    Now find a way to have it monitored in Zabbix. If someone could assist?
    Last edited by xanadu; 04-09-2014, 10:55.

    Comment

    • xanadu
      Member
      • Sep 2014
      • 62

      #3
      Added example outpout for those who might able to help me out..

      Comment

      • xanadu
        Member
        • Sep 2014
        • 62

        #4
        Can anyone help me to configure the Zabbix check and trigger for the powershell script?

        Comment

        Working...