Ad Widget

Collapse

Formula to count host Uptime during last 1 hour (day, week, month)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rihis
    Junior Member
    • Aug 2021
    • 14

    #1

    Formula to count host Uptime during last 1 hour (day, week, month)

    Hi,

    I am trying to create Item which calculates the host Uptime during the last 1 hour (day, week, month). The result is always multiplied by 2 (see attached picture). I suspect this is caused by incorrect syntax in the definition of the time span - "count(//system.uptime,1h)"
    Could someone please assist me with the correct one? Thank you in advance.

  • johndoe2374
    Member
    • Aug 2021
    • 80

    #2
    Well, explaination is pretty simple: you check for your uptime every 30s, so there will be 120 checks within one hour. Your calculated item only gives you amount of retrieved values, which is obviously equals to 120.

    So if you want to do it your way, you can either add some preprocessing rule (like dividing value by 2 if it's being polled every 30s, or by 4 for every 15s if you want to get result in minutes) or change polling interval to 1 minute.

    But it's a strange thing to do. You can get same result using any other key, not only agent's system.uptime. So better way would be to use functions to calculate your item:
    https://www.zabbix.com/documentation...ndix/functions

    For example you can calculate delta between min/max or first/last last functions like so (to get uptime for last 1 hour):

    Code:
    max(<hostname>/system.uptime,1h)-min(<hostname>/system.uptime,1h)
    or
    Code:
    last(<hostname>/system.uptime,1h)-first(<hostname>/system.uptime,1h)
    You'll get the result in seconds. If you need to get result strictly in minutes, days and so on, you can put calculation into brackets and divide it:
    Code:
    (last(<hostname>/system.uptime,1h)-first(<hostname>/system.uptime,1h))/60
    But even better would be to use units field. From agent's key description:
    https://www.zabbix.com/documentation...zabbix_agent?s[]=system&s[]=uptime

    In item configuration, use s or uptime units to get readable values.
    So simply put s or uptime to your calculated delta (without dividing it) and it will give you human-readable result like so: "Uptime (1 week): 5 days, 4 hours, 38 seconds".
    Last edited by johndoe2374; 05-08-2021, 16:08.

    Comment

    • Rihis
      Junior Member
      • Aug 2021
      • 14

      #3
      Hi johndoe2374, thank you so much for your explanation!
      My goal is to create Item which calculates the availability (Uptime in %) of the host in the given period of the time. I ended up with the following formula:

      100*(count(//system.uptime,1d)/2/1440)

      System Uptime for 1day is divided to 2 (to get value in the minutes) then divided by the number of minutes in one day and then multiplied by 100 to get value in %. Could you please feedback on that. Probably you have better idea? The ultimate goal is to calculate host availability for the customer report. Thank you in advance

      Click image for larger version

Name:	Formula02.JPG
Views:	5586
Size:	124.7 KB
ID:	429357

      Comment

      • johndoe2374
        Member
        • Aug 2021
        • 80

        #4
        Well, I think in case of getting availability you can use availability reports. You can get them per host, host group or per trigger template. They're not really comfortable to operate with and I didn't found out how to get result for only one trigger, not all of them for one host, but it can get the job done.

        The benefit is that you can just choose any time interval you want with filter (like in graphs or latest data: "now-2w - now" - last 2 weeks) and it will give you result in percentage. It may be not extremely accurate, because it's basically the time some trigger (for example host ICMP ping unavailability) being active divided by your chosen time range. So if your trigger activates only after 5 minutes after host stopped being available, this report will assume that during these 5 minutes host was online and only after that became offline. Just depends which item and trigger with which settings you'll use. I think this feature would be easier to use.
        Click image for larger version

Name:	1.jpg
Views:	5475
Size:	276.4 KB
ID:	429361
        Last edited by johndoe2374; 06-08-2021, 10:40.

        Comment

        • Rihis
          Junior Member
          • Aug 2021
          • 14

          #5
          Availability reports currently are clumsy and really uncomfortable. You can choose only one trigger and the host group if you choose mode By trigger template and that gives you pretty much acceptable look. But the problem is that you can not integrate it in any Dashboard. My customers are looking for informative, customizable, fully automated and good looking Reports which contains all the necessary data about their servers. Therefore I am trying to create example Dashboard. Its just the beginning but looks good so far.

          Click image for larger version

Name:	By trigger Template.JPG
Views:	5549
Size:	119.0 KB
ID:	429368
          Click image for larger version

Name:	Server reports.JPG
Views:	5697
Size:	130.0 KB
ID:	429369

          Comment

          • johndoe2374
            Member
            • Aug 2021
            • 80

            #6
            Agree about reports, they're almost useless, especially the graph pictures if you press "Show" link.

            Well, it's just math, working with numbers. You can find number of ways to optimise it, but still, if it gets the job done, you've found your solution then

            Comment

            • Rihis
              Junior Member
              • Aug 2021
              • 14

              #7
              Correct! Thank you for your help

              Comment

              • Rihis
                Junior Member
                • Aug 2021
                • 14

                #8
                BTW, probably you have idea how to create Item or Trigger (or something else) which generates Status "Compliant" if Value is 0 and "Non Compliant" if value is >0

                Click image for larger version

Name:	Server reports Compliant.JPG
Views:	5484
Size:	137.2 KB
ID:	429378

                Comment

                • johndoe2374
                  Member
                  • Aug 2021
                  • 80

                  #9
                  Actually I was unable to create panel witch such widgets as yours (where you have host list and only items you've picked). Which version you're using and which widget type you're picking? I was only able to get close to similar result by using "Plain text" type, but it displays all previous items values.

                  Comment

                  • Rihis
                    Junior Member
                    • Aug 2021
                    • 14

                    #10
                    I am using Zabbix 5.4.2 and Widget type - Data Overwiev. In the new versions of Zabbix you can add Tags to Item and I use Item Tags to filter out necessary info. In the picture below I used Items and Tags which comes Out-of-box in Zabbix but in all others I created the Calculated Items and Tagged them with my Tags.

                    Click image for larger version

Name:	Server reports Tags.JPG
Views:	5523
Size:	137.3 KB
ID:	429383

                    Comment

                    • johndoe2374
                      Member
                      • Aug 2021
                      • 80

                      #11
                      Oh, thanks a lot, never used new tags system before. Now I know, where it can be used )

                      Well, about "Compliant" and "Non Compliant": I've never seen such statuses anywhere yet, but I'm using Russian language for my interface, so it may be translated in non-obvious way. Did you create "Missing Updates Count" item yourself? If you're using some template created by other people, probably there's also a corresponding trigger for it. Besides that I don't really know, where this status comes from.

                      Comment

                      • Rihis
                        Junior Member
                        • Aug 2021
                        • 14

                        #12
                        I created a new custom Item which uses UserParameter to run simple script on the host. This script returns the needed value. I know how to create the trigger for this Item but do not know how to display it in the Dashboard.

                        $UpdateSession = New-Object -ComObject "Microsoft.Update.Session"
                        $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
                        $SearchResults = $UpdateSearcher.Search("IsInstalled=0")
                        $SearchResults.Updates.Count

                        Click image for larger version

Name:	MissingUpdatesCount.JPG
Views:	5474
Size:	83.2 KB
ID:	429392

                        Comment

                        • johndoe2374
                          Member
                          • Aug 2021
                          • 80

                          #13
                          Well, it's a mystery for me where it comes from then. I guess you'll have to use "Trigger overview" widget separately or something about "problems". Don't think panels have functionality to display mixed types of data in the same widget...

                          Comment


                          • johndoe2374
                            johndoe2374 commented
                            Editing a comment
                            Oh, aren't these label made by you on screenshot? I've just realized, and I've thought they're created by Zabbix itself
                        • Rihis
                          Junior Member
                          • Aug 2021
                          • 14

                          #14
                          This is fully automated Zabbix dashboard. You just add host to Zabbix and it populates Dashboard fields without any user intervention. I am trying to make it more informative and good looking - customers like it

                          Click image for larger version

Name:	Server reportsLatest.JPG
Views:	5447
Size:	147.5 KB
ID:	429397

                          Comment

                          • Kos
                            Senior Member
                            Zabbix Certified SpecialistZabbix Certified Professional
                            • Aug 2015
                            • 3404

                            #15
                            Originally posted by Rihis
                            BTW, probably you have idea how to create Item or Trigger (or something else) which generates Status "Compliant" if Value is 0 and "Non Compliant" if value is >0
                            Hi!
                            Did you try to use a value mapping for this item?
                            Something like the following:
                            Code:
                            0 => Compliant
                            Default: => Non Compliant

                            Comment

                            Working...