Ad Widget

Collapse

Inventory OS Information Linux

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michaelp
    Junior Member
    • Jan 2024
    • 6

    #1

    Inventory OS Information Linux

    Hi,

    Just started to use Zabbix coming from Nagios, is there a way of finding out in the Inventory the OS Version ? Or OS Full version ?

    I would like to know which version of Linux is running

    Host Group OS
    xxx-xxx Linux Linux version 6.5.0-3-amd64

    What I would like to see is the version of Linux

    cat /etc/os-release | grep VERSION

    VERSION_CODENAME=trixie

    Would I need to create a new ITEM and how do I assign the NEW ITEM to all machines ?


    Also If a server needs a reboot I normally run this script

    #!/bin/bash
    if [ -f /var/run/reboot-required ]; then
    echo 'reboot required'

    fi

    Thanks if you can help me

    Michael
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    #2
    Yes you need to create a new item to obtain that info. You can use vfs.file.contents item and some preprocessing to get version name out of it. Then also check the box of "populate inventory", so you can see that info in inventory page. As this probably does not change very often, you can set quite long update period like 1d or something.. Place it to a template, that is added to all hosts.

    For second case you can use vfs.file.exists item to check if that /var/run/reboot-required file is present and then build a trigger on top of it to notify you... and then you can even build an action to reboot automatically or add a script, that you can run manually from problem menu...

    Comment

    • michaelp
      Junior Member
      • Jan 2024
      • 6

      #3
      Thanks for this,

      I create the following item vfs.file.contents[ /etc/os-release]
      I take it that I can use the Preprocessing to only return this value VERSION_CODENAME=trixie or just trixie ?

      I have tried to match a regular expression but produces all of the line i.e


      NAME="Debian GNU/Linux"
      VERSION_CODENAME=trixie
      ID=debian
      HOME_URL="https://www.debian.org/"
      SUPPORT_URL="https://www.debian.org/support"
      BUG_REPORT_URL="https://bugs.debian.org/"

      I just want VERSION_CODENAME=trixie or everything after VERSION_CODENAME= but not ID=debian


      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4806

        #4
        preprocessing -> regular expression -> VERSION_CODENAME=(.*) -> return value \1
        Should work... At least works in my computer...

        Comment

        • michaelp
          Junior Member
          • Jan 2024
          • 6

          #5
          Originally posted by cyber
          preprocessing -> regular expression -> VERSION_CODENAME=(.*) -> return value \1
          Should work... At least works in my computer...
          Tried that and get the following
          • cannot perform regular expression "VERSION_CODENAME=(.*) " match for value of type "none": pattern does not match
          Not sure what I am doing wrong ?


          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4806

            #6
            Are you sure, you have exactly "VERSION_CODENAME=trixie" there? You have there options to test and pull data from host directly...

            Comment

            • michaelp
              Junior Member
              • Jan 2024
              • 6

              #7
              Originally posted by cyber
              Are you sure, you have exactly "VERSION_CODENAME=trixie" there? You have there options to test and pull data from host directly...
              I removed the item and then re=added VERSION_CODENAME=(.*) and this seems to work

              Comment

              • michaelp
                Junior Member
                • Jan 2024
                • 6

                #8
                Looks like I used the wrong key

                vfs.file.regexp[/etc/os-release,VERSION_CODENAME=(.*)] This now produces VERSION_CODENAME=trixie which is what I needed

                I can play around with syntax and hopefully just get
                trixie
                jammy
                sid

                Thanks for you help

                Comment

                • cyber
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Dec 2006
                  • 4806

                  #9
                  You can use vfs.file.regexp as well.. There are no right or wrong.. if it works, then it works..
                  If you just want the captured name, then just set the output value... vfs.file.regexp[/etc/os-release,VERSION_CODENAME=(.*),,,,\1]

                  Comment

                  • michaelp
                    Junior Member
                    • Jan 2024
                    • 6

                    #10
                    fs.file.regexp[/etc/os-release,VERSION_CODENAME=(.*),,,,\1] this is perfect and now produces a list of machines that need upgrading.

                    Just working on the "needs rebooting" and this will make things easier !

                    Comment

                    • Nolaan
                      Junior Member
                      • Mar 2018
                      • 17

                      #11
                      Can't you use zabbix_agent2 and query for system.sw.os[name]?

                      Code:
                      # zabbix_agent2 -t system.sw.os[name]
                      system.sw.os[name] [s|Debian GNU/Linux 13 (trixie)]

                      Comment


                      • Nolaan
                        Nolaan commented
                        Editing a comment
                        Sorry for digging up an old thread
                    • cyber
                      Senior Member
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Dec 2006
                      • 4806

                      #12
                      Originally posted by Nolaan
                      Can't you use zabbix_agent2 and query for system.sw.os[name]?

                      Code:
                      # zabbix_agent2 -t system.sw.os[name]
                      system.sw.os[name] [s|Debian GNU/Linux 13 (trixie)]
                      Yes you can, still need to do some preprocessing to narrow down to required release name..

                      Comment

                      • Nolaan
                        Junior Member
                        • Mar 2018
                        • 17

                        #13
                        Originally posted by cyber

                        Yes you can, still need to do some preprocessing to narrow down to required release name..
                        This is my simple item. Maybe not the best, but it works

                        Code:
                        zabbix_export:
                          version: '7.0'
                          template_groups:
                            - uuid: af9fdc6a31d447e08b43ca38c3d8fae9
                              name: 'Debian Linux'
                          templates:
                            - uuid: 64d4c2764ac942b7b0b5e5bb684f1b1f
                              template: 'Current Debian version'
                              name: 'Current Debian version'
                              groups:
                                - name: 'Debian Linux'
                              items:
                                - uuid: 6ccc0d7374a54ffca0ac43bfc37b7925
                                  name: 'OS Name'
                                  key: 'system.sw.os[name]'
                                  delay: 1d
                                  value_type: CHAR
                                  trends: '0'
                                  tags:
                                    - tag: Application
                                      value: 'OS Version'
                                  triggers:
                                    - uuid: 657151bae03e453ab049789c0987ad6b
                                      expression: 'last(/Current Debian version/system.sw.os[name])<>"Debian GNU/Linux 13 (trixie)"'
                                      name: 'Debian version is not current (13 trixie)'
                                      priority: INFO
                                      manual_close: 'YES'

                        Comment

                        Working...