Ad Widget

Collapse

Item to get PRETTY_NAME on linux agents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • senate
    Junior Member
    • Jul 2017
    • 2

    #1

    Item to get PRETTY_NAME on linux agents

    Hi,

    I'm trying to create an item on the linux os template that get value in PRETTY_NAME="" in /etc/os-release. I have trying with vfs.file.regexp[] without any luck so maybe someone can point out what I'm doing wrong or have another solution to get the value without add UserParameter on each host.


    Commands to use to get the string:
    # sed -nE 's/^PRETTY_NAME="([^"]+)".*/\1/p' /etc/os-release
    Debian GNU/Linux 8 (jessie)

    # grep -oP '^PRETTY_NAME="\K[^"]+' /etc/os-release
    Debian GNU/Linux 8 (jessie)

    # source /etc/os-release && echo "$PRETTY_NAME"
    Debian GNU/Linux 8 (jessie)


    I've focus on the first command becaue the second one is perl regexp and I don't think that's supported in vfs.file.regexp[]

    This is my item keys that zabbix_agentd -t return with [s|]
    vfs.file.regexp["/etc/os-release","^PRETTY_NAME=\"\K[^\"]+",,,,]
    vfs.file.regexp["/etc/os-release","s/^PRETTY_NAME=\"([^\"]+)\".*/\1/p",,,,]


    I'm stuck and don't know how to move on so any ideas are welcome.
  • Ferke
    Junior Member
    • May 2017
    • 13

    #2
    Hi,

    I tried your original expressions and some similar ones, but it looks like the regex grouping doesn't work properly.

    From the documancatition:
    ⇒ vfs.file.regexp[/etc/passwd,^zabbix:.[0-9]+),,,,\1] → getting the ID of user zabbix

    It doesn't work, because the quotation marks are missing.
    Okay, I put the regex between quotation marks, but with the \1 parameter I get only a "1".
    I have tried another output parameters (\0 \1 \2), but in every case the output is the number after the backslash.

    Would it be the expected result? I don't think so.

    Comment

    • senate
      Junior Member
      • Jul 2017
      • 2

      #3
      Hi,

      Thanks for your time.

      I've find one that are working from zabbix_agentd from an host and Zabbix log say it's supported but I can't see any data for the item in the frontend or in the database. And can't see any logs that indicate of error or warning.

      My code:
      Code:
      root@opt-rabbit1:~# zabbix_agentd -t vfs.file.regexp[/etc/os-release,PRETTY_NAME=\"\(.*?\)\",,,,\\1]
      vfs.file.regexp[/etc/os-release,PRETTY_NAME="(.*?)",,,,\1] [s|Debian GNU/Linux 9 (stretch)]
      And the output is as requested and it's supported.

      zabbix_server.log says
      Code:
      24893:20171027:145051.926 item "opt-rabbit1:vfs.file.regexp[/etc/os-release,'PRETTY_NAME="(.*?)"',,,,\\1]" became supported

      My item is:

      Type: Zabbix Agent
      Key: vfs.file.regexp[/etc/os-release,PRETTY_NAME=\"\(.*?\)\",,,,\\1]
      Type of information: Character


      Any idea why nothing is saved to database?

      Comment

      Working...