Ad Widget

Collapse

Monitor the version of Centos/Debian/Ubuntu

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Monitor the version of Centos/Debian/Ubuntu

    Hi Guys,

    ***Preface (Feel free to skip)***

    Something I've been wanting for a while was a way to monitor what version of CentOS/Debian/Ubuntu was running. In a large environment, it's easy for a box to slip through the cracks and get stuck running Debian Lenny.

    What I wanted to do was retrieve that data periodically, without enabling remote commands OR defining a UserParameter. User parameters are my last resort.

    RHEL derivatives maintain a file - /etc/redhat-release. Debian derivatives maintain /etc/debian_version (although Ubuntu uses /etc/issue instead). These files indicate what version of the OS is installed.

    Unfortunately, Zabbix Agent doesn't have an easy way of retrieving a single line of text from a file and storing it (at least that I was able to find. The log file functionality just didn't cut it for this kind of work. After some labor in the IRC, though...

    ***The Solution***


    Create a Value Map:
    Name: OS Checksum Map
    Mappings:
    2451495184 ⇒ CentOS 5.5
    2620017813 ⇒ CentOS 5.6
    etc...
    (run cksum /etc/redhat-release to get the checksums of other versions)


    Create a new item:
    Description: CentOS Version
    Type: Zabbix Agent
    Key: vfs.file.cksum[/etc/redhat-release]
    Info Type: Numeric (unsigned)
    Data Type: Decimal
    Update Interval: 7200 (or whatever you like)
    Show Value: OS Checksum Map

    Bingo presto - Zabbix checksums the release file, and the value map translates that into the OS version.
    Last edited by suran; 22-07-2011, 23:28.

    #2
    A more complete checksum map.

    2911250180 ⇒ Ubuntu 11.04
    3676339761 ⇒ Debian Squeeze 6.0.2
    128842548 ⇒ Debian Lenny 5.0.8
    207870105 ⇒ Debian Lenny 5.0.6
    230388766 ⇒ Debian Lenny 5.0.6
    265453975 ⇒ Debian Lenny 5.0.5
    184642181 ⇒ Debian Lenny 5.0.3
    2620017813 ⇒ CentOS 5.6
    2451495184 ⇒ CentOS 5.5

    Comment


      #3
      hey, that's a nice idea. care to document somewhere on http://zabbix.org ?
      Zabbix 3.0 Network Monitoring book
      Zabbix tips and inspiration (blog)

      Comment


        #4
        hello

        thanks for the idea.

        just to complete the list :


        if (strpos($os, '1398802666') !== false) { $osversion ='CentOS 5.8' ; return $osversion;}
        if (strpos($os, '2451495184') !== false) { $osversion ='CentOS 5.5' ; return $osversion;}
        if (strpos($os, '2620017813') !== false) { $osversion ='CentOS 5.6' ; return $osversion;}
        if (strpos($os, '2650955864') !== false) { $osversion ='CentOS 7.0' ; return $osversion;}
        if (strpos($os, '3009025442') !== false) { $osversion ='CentOS 6.3' ; return $osversion;}
        if (strpos($os, '1453308230') !== false) { $osversion ='CentOS 6.4' ; return $osversion;}
        if (strpos($os, '2939371176') !== false) { $osversion ='CentOS 6.5' ; return $osversion;}
        if (strpos($os, '2701634349') !== false) { $osversion ='CentOS 6.6' ; return $osversion;}
        if (strpos($os, '3535486839') !== false) { $osversion ='CentOS 7.4' ; return $osversion;}
        if (strpos($os, '3422160843') !== false) { $osversion ='CentOS 7.2' ; return $osversion;}
        if (strpos($os, '3646971721') !== false) { $osversion ='CentOS 7.3' ; return $osversion;}
        if (strpos($os, '205827841') !== false) { $osversion ='CentOS 7.5' ; return $osversion;}
        if (strpos($os, '128842548') !== false) { $osversion ='Debian Lenny 5.0.8' ; return $osversion;}
        if (strpos($os, '184642181') !== false) { $osversion ='Debian Lenny 5.0.3' ; return $osversion;}
        if (strpos($os, '207870105') !== false) { $osversion ='Debian Lenny 5.0.6' ; return $osversion;}
        if (strpos($os, '2911250180') !== false) { $osversion ='Ubuntu 11.04' ; return $osversion;}
        if (strpos($os, '1468803655') !== false) { $osversion ='Red Hat Entr. 7.5' ; return $osversion;}


        to be continued

        Comment


          #5
          Hi,

          Thanks for the idea! But for me i, i don't want to add manual items for each different distribution so i ended up with create a userparameter called linux.os.version

          Code:
          UserParameter=linux.os.version,hostnamectl | awk '/Operating System/' | awk '{d = ""; for (f=3; f<=NF; ++f) {printf("%s%s", d, $f); d = OFS}; printf("\n") }'
          And now i'm able to add an item in the Template OS Linux and i will receive the version like: Ubuntu 18.04.3 LTS

          Maybe someone want's to do it in this way and found this topic like me

          Regards
          Kevin
          Last edited by Linuxjohnny; 19-09-2019, 06:17.

          Comment


            #6
            Sometimes people like rising old thread...

            Using agent? Then why not use it's functions like:
            Operating system information. String info - possible values:
            full (default), short or name
            Example:
            ⇒ system.sw.os[short]→ Ubuntu 2.6.35-28.50-generic 2.6.35.11

            Info is acquired from (note that not all files and options are present in all distributions):
            /proc/version (full)
            /proc/version_signature (short)
            PRETTY_NAME parameter from /etc/os-release on systems supporting it, or /etc/issue.net (name)

            Supported since Zabbix agent version 2.0.

            Comment


              #7
              splitek Thanks for the tip i didn't know this function

              Comment


                #8
                How about this one?

                Code:
                UserParameter=linux.system.name.version,(lsb_release -d > dev/null 2>&1) && lsb_release -d || (cat /etc/centos-release > /dev/null > /dev/null 2>&1 && cat /etc/centos-release || cat /etc/redhat-release)
                One-liner to get OS Name and Version.
                Works on Ubuntu 12/14/16, Centos/RedHat 5/6/7

                Comment


                  #9
                  Originally posted by splitek View Post
                  Sometimes people like rising old thread...

                  Using agent? Then why not use it's functions like:
                  Operating system information. String info - possible values:
                  full (default), short or name
                  Example:
                  ⇒ system.sw.os[short]→ Ubuntu 2.6.35-28.50-generic 2.6.35.11

                  Info is acquired from (note that not all files and options are present in all distributions):
                  /proc/version (full)
                  /proc/version_signature (short)
                  PRETTY_NAME parameter from /etc/os-release on systems supporting it, or /etc/issue.net (name)

                  Supported since Zabbix agent version 2.0.
                  This is not supported in Zabbix since ever. Or at most it barely works and produces not desired output.
                  That's why people try to find a solution.

                  Comment


                    #10
                    An item with the key:
                    Code:
                    system.sw.os[name]
                    Is working correct for me.


                    Click image for larger version  Name:	19-09-_2019_06-16-54.jpg Views:	1 Size:	38.8 KB ID:	386474

                    Comment


                      #11
                      Originally posted by Linuxjohnny View Post
                      An item with the key:
                      Code:
                      system.sw.os[name]
                      Is working correct for me.


                      Click image for larger version Name:	19-09-_2019_06-16-54.jpg Views:	1 Size:	38.8 KB ID:	386474
                      No, it doesn't work.
                      Because unlike for Ubuntu it doesn't show the minor version of Centos, which would be like 7.4.

                      Comment

                      Working...
                      X