Ad Widget

Collapse

Check if a logfile is updated regularly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vorik
    Junior Member
    • Jun 2006
    • 4

    #1

    Check if a logfile is updated regularly

    Hi,

    I need to check if a logfile is updated regularly in order to check if some software is still doing what it is supposed to do and hasnt crashed or hangs.

    This is the expression i came up with for my trigger:
    ({leonardo:system.localtime.last(0)}-{leonardo:vfs.file.time[/root/testfile].last(0)})>60

    The general idea is to do current-time - timestamp-of-last-modification-to-file = time that it has not been updated.

    This gives the error that (0-0)>60 is not a valid expression.

    Any help VERY MUCH appreciated.

    Vorik.
  • knarfling
    Member
    • Sep 2006
    • 47

    #2
    Ran into same problem

    I ran into the exact same trouble. The bug is actually in the PHP frontend because the functions take time to evaluate. When PHP tests the formula, it cannot get the correct values and returns a zero. PHP then decides that you cannot have a 0-0 expression.

    The workaround is huge pain, but I have found a way to make it work. The first step it to change the expression a little. I did it with
    {server:system.localtime.last(0)}+60>{server:vfs.f ile.time[file].last(0)}
    This accepts the formula and, after a short wait as it evaluates the functions, returns true. Unfortunately, this formula always evaluated true for me, even when it was false. If this works, you can stop here.

    For me, however, it returned true all the time, so I made another change. I checked the system log and found a couple of lines similar to this.
    Code:
    031506:20060921:202042 Evaluation of expression [(1158870042.000000)+600>({12404})] failed [Unable to get value for functionid [12404]]
    031506:20060921:202042 Expression [({12403})+600 >({12404})] cannot be evaluated [Unable to get value for functionid [12404]]
    I then went into the mysql, looked at the functions table and confirmed that fuctions 12403 and 12404 actually had values. I then looked at the triggers table and found the trigger id for that expression. I then manually updated the expression with
    UPDATE triggers set expression = "({12403} - {12404} > 600" where triggerid = <trigger id>;

    Then go back to the web and make sure that it is working. (Make sure you do not refresh the page where you saved the time+60>last update formula, because it will resave that formula and you will have to make the manual changes again.)

    This is not the best way, because you can not make any changes to the trigger. If you need to change something, such as adjusting the time, or changing the description, you will get the same 0-0>60 error. And when you change it back to the time+60>last update type of formula, the function numbers change and you have to go through the entire proccess again.

    Not the best workaround, but it does work for me since I HAVE to test a file to see if it has changed within a specific time.

    Hope this helps.

    Comment

    • vorik
      Junior Member
      • Jun 2006
      • 4

      #3
      It worked!

      Wow, thanks a lot, it works now!

      I didnt have to go to MySQL, because I spotted the flaw in this expression:
      {server:system.localtime.last(0)}+60>{server:vfs.f ile.time[file].last(0)}

      It only evaluates as false if the file has a date in the FUTURE.

      You take the current time and add 60 seconds, while you should add the 60 seconds to the date of the file...

      Anyway, you really helped me a lot, thanks!

      Vorik.

      Comment

      • vorik
        Junior Member
        • Jun 2006
        • 4

        #4
        Hi,

        I'm getting some false positives using this expression, although it should evaluate as false. (About 10 false positives per day per trigger)

        This is one of the trigger-happy-triggers:
        {Mariner:system.localtime.last(0)}>{Mariner:vfs.fi le.time[/data/wmes/log/CompuSlave_global.log].last(0)}+1200

        I even increased the interval to 20 minutes (1200) but to no avail.
        In the log, no mention of the trigger is found. (debuglevel=3)
        I've looked at the history of the triggers and can see that that should not be a problem. All filetimes registered are within 400 seconds of the system.localtimes registered at the same time, so it looks like the Items are not evaluated correctly when the trigger expression is parsed.

        Most of the times though, it works fine.. Just 10 times a day it misfires.

        How might I resolve this?

        Any help very much appreciated.

        Vorik.

        Comment

        Working...