Ad Widget

Collapse

LLD for vfs.file.time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ang3lwich
    Junior Member
    • Dec 2020
    • 7

    #1

    LLD for vfs.file.time

    Looking for a better way to get file.time from all individual directories in /backups/$company-name
    So basically looking for zabbix to show me individually all time stamps for company-name directories

    Currently it is a manual/cloning process.

    currently my manual key is as follows:
    vfs.file.time[/backups/super-company,modify]

    Item works well and gives me the correct timestamp, just need a faster,better way of doing that.

    I can only think with some macros
  • ang3lwich
    Junior Member
    • Dec 2020
    • 7

    #2
    Yes, I suppose that is the solution.
    Thanks for the reply.

    Comment

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

      #3
      I guess yo need to choose your favourite language, make a script that lists all directories and performs stat on them and then formats output nicely as json. Define it as UserParameter and use it for discovery, create items and gather data.

      Comment

      • mwildam
        Member
        • Feb 2021
        • 72

        #4
        You would create an item that runs an external script directly (or use an item key that is defined in userparams) which basically does something like this (bash script here - and you should pass the MACRONAME as a prefix for your reported variables to the script*):
        Code:
        [...]
        ZABBIXCFG="/etc/zabbix/zabbix_agentd.conf"
        HOSTNAME=$(hostname)
        MACROFULLNAME=${MACRONAME}FULLNAME
        MACRODIRNAME=${MACRONAME}DIR
        MACROFILENAME=${MACRONAME}FILENAME
        MACROFNAME=${MACRONAME}NAME
        MACROFEXT=${MACRONAME}EXT
        RESPONSE=""
        [...]
        for FILE in $FILES; do
            DIRNAME=$(dirname $FILE)
            FILENAME=$(basename $FILE)
            FNAME=${FILENAME%.*}
           FEXT=${FILENAME##*.}
            ITEM="{"
           ITEM+="\"{#$MACROFULLNAME}\":\"$FILE\", \"{#$MACROFILENAME}\":\"$FILENAME\", \"{#$MACRODIRNAME}\":\"$DIRNAME\""
           ITEM+=", \"{#$MACROFNAME}\":\"$FNAME\", \"{#$MACROFEXT}\":\"$FEXT\""
           ITEM+="}"
           RESPONSE+=$ITEM
        done
        [...]
        zabbix_sender -c $ZABBIXCFG -s $HOSTNAME -k "$RECEIVERITEM" -o "$RESPONSE"
        Then you can use these macros in your item prototypes.

        *) You will need different macro prefix names if you want to use your script several times for different directories and file sets - otherwise on LLD either one or the other set will get potentially removed.
        Or you can also alternatively have one script that collects all files in all directories together. - However then you will not be able to have different configurations for them.

        Comment

        Working...