Ad Widget

Collapse

Trigger: compare a regexp() on the current and previous value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mojah
    Member
    • Apr 2010
    • 60

    #1

    Trigger: compare a regexp() on the current and previous value

    Here's what I'm trying to accomplish: I want to create a trigger that sends an alert when the mayor version of PHP on the server changes.

    I currently have the version of PHP as a custom parameter with output such as:
    [2012.Sep.06 16:36:44] PHP 5.3.6 (cli) (built: test env)
    [2012.Sep.06 16:14:51] PHP 5.2.17 (cli) (built: Nov 15 2011 09:03:28)
    [2012.Sep.06 15:59:51] PHP 5.2.17 (cli) (built: Nov 15 2011 09:03:28)

    So the value is 'PHP 5.2.17 (cli) (built: Nov 15 2011 09:03:28)'.

    I don't want to use a trigger based on .diff(), as that would also report it when a minor version (such as PHP 5.2.15 upgraded to 5.2.17) would change. I only want to trigger when PHP 5.2 would upgrade to 5.3.

    I had the following in mind:
    {Application - PHPhp.version.regexp("^PHP 5.2",#1)}=1 & {Application - PHPhp.version.regexp("^PHP 5.3")}=1

    Basically: if the previous value of the php.version matches 'PHP 5.2' and the current value matches 'PHP 5.3', I know it was upgraded. However, this does not work, and I'm guessing it's because of the second parameter in .regexp() where I now use #3. I also tried simply entering 300 to express the time-shift in seconds, but to no avail.

    We're running Zabbix 1.8, so according to the trigger wiki I don't think it's possible to do? Did anyone else accomplish something similar to compare text-values from previous & current values using regular expressions?

    Or am I missing a more obvious and simple solution?
  • mattsmith
    Member
    Zabbix Certified Specialist
    • Aug 2010
    • 33

    #2
    Hi Mojah,

    A quick and easy way to achieve this would be to use a second UserParameter that collects only the PHP Major version (I.E 5.2) then just trigger based on a change in value. Using cut/awk you should be able to chop that string down :-)

    I've not really looked a great deal at the regex triigers as of yet but after we have upgraded to 2.0 im sure I will :-)

    Regards
    Matt

    Comment

    • Mojah
      Member
      • Apr 2010
      • 60

      #3
      Hi Matt,

      Thanks for the response!

      Was hoping for a way to do it with regexp()'s to avoid storing a second value, but I'll store it as a minimalized version instead.

      This'll work, thanks.

      Regards,
      Mattias

      Comment

      Working...