Ad Widget

Collapse

vfs.file.timedelta - File age as an item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rts
    Member
    • May 2007
    • 54

    #1

    vfs.file.timedelta - File age as an item

    Hi,

    I know that I can use vfs.file.time and then put .fuzzytime in a trigger if I want to be alerted to a file being modifier / not being modified.

    However, if I then view the item's data, I just get a straight line since 1970. What I want is for the individual item to record the age of the file on disk, as a number of seconds ago.

    Currently, to do this, we use a small shell script as a UserParameter, but this feels like something that perhaps many Zabbix users would like to have.

    The patch necessary to libs/zbxsysinfo/common/file.c is very small, and I'm happy to supply this if someone can suggest a suitable function name or syntax. Should it be vfs.file.timedelta, whose syntax is identical to vfs.file.time, or would it be preferable to have an additional parameter to the existing vfs.file.time item to control whether to return absolute file age in epoch seconds, or the delta between now and file time?

    Of course, if this functionality already exists, I'd be really grateful if someone can point it out.
  • rts
    Member
    • May 2007
    • 54

    #2
    Sorry to bump this, but I'm keen to implement something and would like some feedback as to which is the most 'zabbixy' way to do this.

    Comment

    • richlv
      Senior Member
      Zabbix Certified Trainer
      Zabbix Certified SpecialistZabbix Certified Professional
      • Oct 2005
      • 3112

      #3
      i haven't tried, by maybe you can implement it as a calculated item ?
      something like now()-vfs.file.time()
      Zabbix 3.0 Network Monitoring book

      Comment

      • ghoz
        Senior Member
        • May 2011
        • 204

        #4
        the problem with calculated items is the synchronization .
        AFAIHT (AFAI have tested), the calculated item has it's own schedule,
        so depending on the source item frequency , you may get stange results..


        I would vote for a .timedelta , seems more consistent...
        Last edited by ghoz; 29-08-2011, 15:10.

        Comment

        • richlv
          Senior Member
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Oct 2005
          • 3112

          #5
          might be worth filing as a feature request then
          Zabbix 3.0 Network Monitoring book

          Comment

          • rts
            Member
            • May 2007
            • 54

            #6
            As I said, I'm happy to implement a patch for this functionality, but would just appreciate direction as to which of the two proposed strategies would be most likely to be accepted by Zabbix.

            Comment

            • rts
              Member
              • May 2007
              • 54

              #7
              It's been a year since my offer to patch zabbix was made, and no-one accepted it. So, here's a proposed fileage script to use with a custom monitor:

              #!/bin/bash

              # Usage instructions:
              if [ -z "$1" ]; then
              echo "Usage: "
              echo " $0 filename"
              echo "will tell you the age of the file in seconds, or -1 if the file does not exist"
              exit
              fi

              # Test if the file exists:
              if [ ! -f "$1" ]; then
              echo -1
              exit
              fi

              # Output the age, but note that the same command cannot be used on Mac and Linux:
              # Note: On Mac, stat -s filename sts environment variables based on the file's properties.
              if [ `uname` == 'Darwin' ]; then
              NOW=`date +%s`
              eval $(stat -s $1)
              (( DIFF = (NOW - $st_ctime) ))
              echo $DIFF;
              exit
              fi
              if [ `uname` == 'Linux' ]; then
              OLD=`stat -c %Z $1`
              NOW=`date +%s`
              (( DIFF = (NOW - OLD) ))
              echo $DIFF;
              exit
              fi

              echo "Unsupported operating system"

              Comment

              Working...