Ad Widget

Collapse

How to handle Multiple Values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ActiveAgent
    Member
    • Oct 2021
    • 41

    #1

    How to handle Multiple Values

    --- I created another Post with the same name. Unforutnately I couldn´t find a way to edit it an add further Info, so I had to vreate a new one. Feel free to delete the incomplete one ---

    Dear Zabbix-Friends,


    I am pretty new to Zabbix and I´m sharing this challenge with out:

    I created a windows tasks, that I want to monitor. The easiest (for me) would be to issue a Powershell command through a custom item and process the given output. The Powershell-command itself is quite simple:
    Powershell -NoProfile -ExecutionPolicy bypass -Command "Get-ScheduledTaskInfo -TaskName 'Zabbix-Agent - Deploy Data'"

    The Item in Zabbix is this right now:
    Click image for larger version

Name:	brave_R1qhEXb05j.png
Views:	5894
Size:	35.1 KB
ID:	433959
    Test is successful:
    Click image for larger version

Name:	brave_3dorcQ4vGd.png
Views:	5840
Size:	18.2 KB
ID:	433960
    Click image for larger version

Name:	brave_3dorcQ4vGd.png
Views:	5850
Size:	18.2 KB
ID:	433963

    Right now I’m interested in the Value “LastTaskResult”, but want to build up on that and monitor other items too (like “NumberOfMissedRuns”, “LastRunTime”, “NextRunTime” etc):
    Click image for larger version

Name:	Code_9KD0KaAgLM.png
Views:	5846
Size:	8.1 KB
ID:	433962
    As you can see right now the output is not optimised. As far as I understand Zabbix/Monitoring works best with single and numeric values. Since I´m new I don´t know what´s best in general. Either make one Item for each value (with the same Powershell), or issue the command once and split the output into several values.
    From the perspective of the client-performance, I´d rather use one single command and process the output into Zabbix, than do this job 3 or four time to get every out in single items.
    I know there´s a template for scheduled tasks, already: https://share.zabbix.com/operating-s...hes-planifiees
    But I this didn’t work right away, so I thought let´s take it as a challenge to get to know zabbix more. Its gonna help me on the long run, since I´ll have more skripts coming up with similar things.

    Thanks so much in advance for all your ideas and your help!
    Attached Files
  • niveastn
    Member
    • Oct 2021
    • 82

    #2
    Hey there!

    You can create dependent items! (a bit more about them here https://www.zabbix.com/documentation...ependent_items)
    So here is what you can do: with one item, you collect the entire block of information, the entire result of your command, and from that, you create dependent items (it's an item type, like zabbix agent, ssh agent, etc.) which is going to reference this first item with the information block, and using the preprocessing tab, you're going to use regex to get LastTaskResult, LastRunTime and everything you need.

    This site can help you with the regex https://regex101.com/ (Play it around here and than test it in zabbix)

    Comment

    • ActiveAgent
      Member
      • Oct 2021
      • 41

      #3

      Thank a Lot! I´ve read through your post and the linked pages. That was exactly what I needed.

      The Powershell-Output is:

      LastRunTime : 11.11.2021 08:04:04
      LastTaskResult : 267014
      NextRunTime : 12.11.2021 08:00:00
      NumberOfMissedRuns : 0
      TaskName : Zabbix-Agent - Deploy Data
      TaskPath :
      PSComputerName :
      With regex I selet the Value behind Title "LastRunTime", "LastTaskResult", "NumberOfMissedRuns" (see the attached pictures.

      And get the digit ouput. Now I only need to format "LastRuntime" into a date-format and tell zabbix that everything above Zero from "NumberOfMissedRuns" should throw a warning

      Attached Files

      Comment

      • ActiveAgent
        Member
        • Oct 2021
        • 41

        #4
        Once I got that I will setup another item/template, where I can check all tasks for missed runs

        Comment

        Working...