Ad Widget

Collapse

How do I create a trigger at an application its version

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jpmorgan29
    Junior Member
    • Apr 2018
    • 9

    #1

    How do I create a trigger at an application its version

    Let's say, I have some applications:
    Name software Version Host
    aaa.exe v3.0 John
    aaa.exe v4.5 Tom
    aaa.exe v4.5 Kenny
    aa.exe v3.0 Jim
    And so far, I have been able to show the versions onto Zabbix by using a Powershell script:

    Code:
    $version = get-item 'D:\Programs\aaa\aaa.exe' | Select -ExpandProperty VersionInfo | Select FileVersion | ft - hidetableheaders
    $aaa = (get-item 'D:\Programs\aaa\aaa.exe' | Select-Object "Name")
    if ($aaa -Match "aaa.exe")
    {echo $version}
    else
    {echo "Not found}
    Created an item:
    Type: Zabbix Agent
    Key: system.run["powershell.exe -NoProfile -ExecutionPolicy ByPass -File C:\zabbix\scripts\aaa_version.ps1"]

    Runs perfect but very primitive.

    As you can see in the table, Tom and Kenny have newer versions. How can I show through Zabbix that John and Jim have to update the software?

    Do I make a JSON file where I maintain all the newest versions and if they don't match with the JSON, it should trigger?
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #2
    Hi, jpmorgan29!

    Are you planning to manage software per system (I mean every user on this computer uses the same executable) or per user (custom exe file individually somewhere in %userprofile% or in other custom dir)?

    Regards,

    Comment


    • jpmorgan29
      jpmorgan29 commented
      Editing a comment
      Manage software per system. The path doesn't change for a different user.
  • tcilmo
    Senior Member
    • Nov 2016
    • 122

    #3
    Are these traditionally installed programs? If so, this data is probably in WMI and Zabbix can look in WMI at values OOB. You can then create triggers based on those values.

    Here is an example key: wmi.get["root\cimv2","SELECT version FROM Win32_Product WHERE Name LIKE '%Box Tools%'"]

    Here is what the item config would look like.

    Click image for larger version  Name:	Capture.JPG Views:	2 Size:	74.6 KB ID:	357928

    From Latest Data:

    Click image for larger version  Name:	Capture.JPG Views:	1 Size:	9.3 KB ID:	357929


    Another option would be to compute the data with a PowerShell script and send the data to Zabbix using Zabbix Sender. We do this a lot for data pulled out of databases.

    Hope this helps!

    Comment

    • jpmorgan29
      Junior Member
      • Apr 2018
      • 9

      #4
      tcilmo,

      Thanks for replying and sharing your knowledge , but I am trying to make a type of "control panel" in JSON where I say:

      Code:
      {
      "aaa.exe":4.5
      }
      and make a IF ELSE statement in the trigger expression where I say:

      Code:
      $newestversion = jsonfile?aaa
      
      If ($output != $newestversion){
          Trigger("aaa.exe is outdated")
      }
      Else{
          echo $output
      }
      (You get what I'm trying to say here or am I being to vague?) haha

      Thanks anyway !

      Comment

      • jpmorgan29
        Junior Member
        • Apr 2018
        • 9

        #5
        Is it maybe possible to send a JSON file through a zabbix trapper, store each value in a Macro and then trigger with a comparison if it doesn't match?

        Comment

        • aigars.kadikis
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Mar 2018
          • 208

          #6
          Originally posted by tcilmo
          Are these traditionally installed programs? If so, this data is probably in WMI and Zabbix can look in WMI at values OOB. You can then create triggers based on those values.

          Here is an example key: wmi.get["root\cimv2","SELECT version FROM Win32_Product WHERE Name LIKE '%Box Tools%'"]

          Here is what the item config would look like.

          Click image for larger version Name:	Capture.JPG Views:	2 Size:	74.6 KB ID:	357928

          From Latest Data:

          Click image for larger version Name:	Capture.JPG Views:	1 Size:	9.3 KB ID:	357929


          Another option would be to compute the data with a PowerShell script and send the data to Zabbix using Zabbix Sender. We do this a lot for data pulled out of databases.

          Hope this helps!
          Of course the most hardes way would be to create multiple UserParamer keys per application. Just tested out and this works quite well even for custom app:
          Code:
          UserParameter=activepresenter.exe.version,PowerShell.exe -nologo -command "get-item \"C:\\Program Files (x86)\\ATOMI\\ActivePresenter\\ActivePresenter.exe\" | Select -ExpandProperty VersionInfo | Select FileVersion | ft -hidetableheaders"
          And the item configuration:
          Click image for larger version  Name:	active-presenter-version.png Views:	1 Size:	182.5 KB ID:	357958

          Unfortunately, did not find how to create item with argument to pass full path + filename for key.
          Reason: '\' is not supported in argument field.

          Comment

          • jpmorgan29
            Junior Member
            • Apr 2018
            • 9

            #7
            I honestly think I have an even better idea which I am trying to implement at this very moment:

            I can create a trigger:


            {host:system.run["powershell.exe -NoProfile -ExecutionPolicy ByPass -File C:\zabbix\scripts\aaa.ps1"].str("Error")}=1


            And I adjust the powershell script:

            Code:
            ##Get content from txtfile
            
            ## Assign a variable to the correct version
            ## $Newestversion_aaa = 4.5
            
             $version = get-item 'D:\Programs\aaa\aaa.exe' | Select -ExpandProperty VersionInfo | Select FileVersion | ft - hidetableheaders
            $aaa = (get-item 'D:\Programs\aaa\aaa.exe' | Select-Object "Name")
            if ($aaa -Match "aaa.exe")    
            {
                  if ($version -Match $Newestversion_aaa)
                     echo $version
                  else
                     echo "Error"
               }
            else
            {
            echo "Not found
            }
            Correct me if I'm wrong. I havent done it yet, I'll let you how it turns out!

            Comment

            • aigars.kadikis
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Mar 2018
              • 208

              #8
              Originally posted by jpmorgan29
              I honestly think I have an even better idea which I am trying to implement at this very moment:

              I can create a trigger:


              {host:system.run["powershell.exe -NoProfile -ExecutionPolicy ByPass -File C:\zabbix\scripts\aaa.ps1"].str("Error")}=1


              And I adjust the powershell script:

              Code:
              ##Get content from txtfile
              
              ## Assign a variable to the correct version
              ## $Newestversion_aaa = 4.5
              
              $version = get-item 'D:\Programs\aaa\aaa.exe' | Select -ExpandProperty VersionInfo | Select FileVersion | ft - hidetableheaders
              $aaa = (get-item 'D:\Programs\aaa\aaa.exe' | Select-Object "Name")
              if ($aaa -Match "aaa.exe")
              {
              if ($version -Match $Newestversion_aaa)
              echo $version
              else
              echo "Error"
              }
              else
              {
              echo "Not found
              }
              Correct me if I'm wrong. I havent done it yet, I'll let you how it turns out!


              I think you definitely need to detect only versions which is older than $Newestversion_aaa:
              if ([System.Version]"$version" -lt [System.Version]"$Newestversion_aaa")

              Otherwise if you forget to maintain your script (and the newer version somehow happens to be distributed on station) then you will get kind a false alarms unles you want to forse someone to use older version than latest

              Regards,

              Comment

              • jpmorgan29
                Junior Member
                • Apr 2018
                • 9

                #9
                In case anyone was wondering;
                I created a powershell script that I can execute and i give it an argument to show a version of the specific:

                For example in powershell:

                Code:
                & '.\test.ps1' -brackets
                shows:
                Code:
                Release 1.11.0

                I have compared versions from a textfile where I keep track and put in the most recent versions:

                fileversions.txt:

                Code:
                NAME#VERSION#PATH
                Brackets#Release 1.11.0#Path-to-executable
                Test.ps1:

                Code:
                $notfound = "Not found"
                $outdated = "Outdated"
                
                Param (
                [Switch]$brackets
                )
                
                If ($brackets){
                $vBrackets = (get-item 'C:\Brackets\Brackets.exe' | Select -ExpandProperty VersionInfo).FileVersion
                $nBrackets = (get-item 'C:\Brackets\Brackets.exe').Name
                if ($nBrackets -Match "Brackets.exe"){
                $Brackets_DEST = ((Get-Content -Path C:\xxx\fileversions.txt | Where-Object { $_ -match '^Brackets' }) -Split '#')[1]
                if($vBrackets -match $Brackets_DEST){
                echo $vBrackets
                }
                else{
                echo $outdated + $vBrackets
                }
                }
                else{
                echo $notfound
                }
                }
                I just put it in a Zabbix Agent Item and done. Created a trigger if "Outdated" shows up.

                Comment

                Working...