Ad Widget

Collapse

Show Uptime in human readable time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Roberto Machado
    Junior Member
    • Jun 2020
    • 11

    #1

    Show Uptime in human readable time

    In Media Types > Email > Message templates I'm trying to return host uptime and it's not showing human readable time, only in seconds.

    Uptime: {?last(//system.uptime)}

    Even version 5.4 worked perfectly. It's not working in version 6.0.
    Last edited by Roberto Machado; 10-06-2022, 04:26. Reason: Version information.
  • derli1988
    Member
    • Apr 2021
    • 60

    #2
    Well...

    Create an item like this:

    Name: System Uptime
    Type: Zabbix agent
    Key: system.uptime
    Type of information: Numeric (unasigned)
    Host interface: Your target IP
    Units: uptime
    Update interval: Your choice, mine is 10m

    Comment

    • Roberto Machado
      Junior Member
      • Jun 2020
      • 11

      #3
      This is my item:
      Attached Files

      Comment

      • Roberto Machado
        Junior Member
        • Jun 2020
        • 11

        #4
        This is my item:

        Click image for larger version

Name:	zz.png
Views:	2561
Size:	47.0 KB
ID:	446150

        Comment

        • derli1988
          Member
          • Apr 2021
          • 60

          #5
          Does it work now?

          Comment

          • Roberto Machado
            Junior Member
            • Jun 2020
            • 11

            #6
            No.

            Even version 5.4 worked perfectly. It's not working in version 6.0.

            Comment

            • Roberto Machado
              Junior Member
              • Jun 2020
              • 11

              #7
              Could anyone help?

              Comment

              • vladimir_lv
                Senior Member
                • May 2022
                • 240

                #8
                Are you use Trigger action to send emails?

                Comment

                • Roberto Machado
                  Junior Member
                  • Jun 2020
                  • 11

                  #9
                  Yes, Trigger actions.

                  Comment

                  • Roberto Machado
                    Junior Member
                    • Jun 2020
                    • 11

                    #10
                    I solved the problem as follows:

                    1. I created a dependent item

                    Click image for larger version

Name:	image.png
Views:	170
Size:	69.2 KB
ID:	507082

                    I added Preprocessing: JavaScript

                    Parameters:

                    var sec = parseInt(value, 10);
                    if (isNaN(sec)) return “N/A”;
                    var d = Math.floor(sec / 86400);
                    var h = Math.floor((sec % 86400) / 3600);
                    var m = Math.floor((sec % 3600) / 60);
                    var s = sec % 60;
                    var parts = [];
                    if (d > 0) parts.push(d + ‘d’);
                    if (h > 0) parts.push(h + ‘h’);
                    if (m > 0) parts.push(m + ‘m’);
                    parts.push(s + ‘s’);
                    return parts.join(‘ ’);



                    In Media type, Email, I changed it to:

                    Uptime: {?last(/{HOST.HOST}/system.uptime.human)}

                    Click image for larger version

Name:	image.png
Views:	177
Size:	9.1 KB
ID:	507084​​
                    Attached Files

                    Comment

                    Working...