Ad Widget

Collapse

Monitor event'task

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nguyentrungthanh
    Junior Member
    • Dec 2018
    • 1

    #1

    Monitor event'task

    Hi,

    I have a requirement to monitor only 3 schedule tasks out of big list of tasks.

    Example for 1 task is :

    Entry in zabbix_agentd.win.conf

    UserParameter=TaskSchedulerMon[*],powershell -NoProfile -ExecutionPolicy Bypass -File C:\zabbix\WindowScheduleTasks.ps1 WSTask


    Item property file:

    $TaskInfo = Get-ScheduledTask -TaskName "$name1"
    Write-Output ($TaskInfo.State)

    Trigger Property file:
    {TaskSchedulerMon[WSTask].prev()}<>0

    getting error as "Unsupported Item Key.
    Micheal
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #2
    Hello, nguyentrungthanh.

    Since text storing in the database will cost a lot of Megabytes I offer you to substitute "Ready", "Disabled", "Running" with numbers. Here is how the UserParameter (one-liner) looks at the end:

    Code:
    UserParameter=TaskSchedulerMon[*],powershell -nologo -command "(Get-ScheduledTask -TaskName \"$1\" | foreach { $_.State }) | foreach { $_ -replace \"Disabled\", \"0\" -replace \"Ready\", \"1\" -replace \"Running\", \"2\" }"
    Usage:
    Code:
    TaskSchedulerMon[CacheTask]
    TaskSchedulerMon[Recovery-Check]
    TaskSchedulerMon["Adobe Acrobat Update Task"]

    Comment

    • Donaldcotton
      Junior Member
      • Jan 2019
      • 3

      #3
      The only answer to this question is available on GitHub. Go and check out there.

      Comment

      Working...