Ad Widget

Collapse

Checking a file, for a version number

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • highway_fixer_man
    Member
    • Jun 2022
    • 35

    #1

    Checking a file, for a version number

    Hi Guys,

    I would like to run a check on a specific file - its a text file that contains the software vendors info, and the version number.

    I can clean it up to become an environment variable that gives me exactly the number I want:

    Code:
    root@lane-8304:~#software_version=$(cat /path/to/fileIwanttocheck.txt | head -n 1| cut -b 16,17,18,19,20) 
    
    root@lane-8304:~#echo $software_version
    
    1.2.3
    The above is an example, but this is exactly what I have, just with different values for the software version file, etc.

    How can I get this variable to show up in Zabbix? I just want to be able to check this version number periodically.



    Can anyone help me? A link to a similar question, what to search (google or this forum), anything would be appreciated. I have poked around on this forum and not found anything that suits my query - unless I am searching for the wrong things.
  • Answer selected by highway_fixer_man at 18-11-2022, 21:42.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    Look like job for UserParameters

    Comment

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

      #2
      Look like job for UserParameters

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #3
        Originally posted by highway_fixer_man
        Code:
        root@lane-8304:~#software_version=$(cat /path/to/fileIwanttocheck.txt | head -n 1| cut -b 16,17,18,19,20)
        A minor quibble, but this is a pet peeve of mine: do a web search for "useless use of cat". 'head' can read a file, you don't need 'cat' to pipe it to 'head'.

        Comment

        • highway_fixer_man
          Member
          • Jun 2022
          • 35

          #4
          Originally posted by tim.mooney

          A minor quibble, but this is a pet peeve of mine: do a web search for "useless use of cat". 'head' can read a file, you don't need 'cat' to pipe it to 'head'.
          Good point - I just go in one direction in my mind (if that makes sense to anyone but me), I often get called out for it, bad habit - I'll clean it up, thanks.


          I managed to get exactly what I wanted thanks to cyber's direction.

          Added the relevant line to the zabbix agent config, restarted the agent, and added the item to a template, and got what I wanted.

          Thanks all.

          Comment

          Working...