Hi. I'm trying to set up an item with a trigger attached to it to verify if the "current" folder of the backup has been changed , so i'm using vfs.file.time[/path/to/directory/] afterwards i attach the trigger to it for 30h countdown and its like this {vfs.file.time[/path/to/directory].fuzzytime(108000)}=0 and it won't work the items settings are as follow all default , update interval set on 30s , unit set to unixtime , the problem is that on other host that i'm monitoring it works, but on others it wont work, i'm using this to monitor a symlinked directory. Can anyone help ?
Ad Widget
Collapse
Zabbix file age problem
Collapse
X
-
I don't think all filesystems provide all the time attributes and sometimes mounted filesystems don't update them. You'll have to check for your specific setup.
I've used vfs.file items for files, are you referencing a directory? If the backup just updates files, does the directory change? I think it would if files are added or deleted.
Finally, for a 30 hour trigger, a 30 second update interval is storing a lot of history you probably don't need. For one item, it's no big deal, but if you sample a lot of items on a lot of hosts too frequently....-
i have a current folder or latest that is storing the current folder after it's finished with restoring the data from a specific time it moves to the next folder changing its name automatically. the current folder is just the symlinked folder where the backup is atm. I also tried the scheduled update interval for once a day but it still wont fire the alarm correctly , it would just trigger after 60s or so ~ , with udpate interval set to 0 and schedule every 11am. It backups a whole directory, so it should change time of the backup when it moves to the next current folder.
-
-
I would advise to use the return code of the backup script and zabbix_sender to send it to the Zabbix server. Because a folder or file with a different time does not mean a successful result of the backup.Comment
-
Well it has been discussed with my collegue and we opted to use the time of <current folder> to see if it has been succesful, but since you pointed out the idea , you mean to make an Log veryfing item that would search for specific error keywwords or what exactly did you mean ? Thank. max.ch.88
-
-
I've done a bit more digging and seems like one one monitoring server that i'm supervising it is working to checkup on the file.time and returns the true or false as it should, but on the other server where i want to implement this feature it won t work receiving wrong value (like always false) but are the same items,triggers , conditions, anyone has an idea where i should look for and for what? I've enabled the debugg mode and everything seems to be the same , except the value it returns :-? any help would be appreciated. Thanks. LenR & max.ch.88 any ideas ?
Edit: Apparently it takes the date of the symlinked file thats from 2018 and not the date of the link file 2019 where it moves, pretty weird because on the first monitoring server it gets it and on the second one it passes trough it to the directory that is symlinked getting the creation/modified date of the file that is being backed up, that being 2018, what i want is the actual date of the 2019. any ideas?Last edited by Alex23; 19-03-2019, 10:03.Comment
-
No, you don't need the Log for item. Your backup script execute the set of commands to make the data backup, isn't it? Any system commands have the return codes. So you can get the error code to exit the script with this code. Usually 0 means the success and more 0 mean something wrong. Then you send this code to the Zabbix server. And for this item you could create the triggers with different conditions depends on the value of the item.
Comment
-
well... my supervisors want to monitor the folders time since not all the errors of the backups will be on the log as they said. when i try to implement the vfs.file.time on this path "current -> /mnt/backups/<directory-name>/the-symlynked-dir" . The problem is that it's not showing the "current" (this is the new folder) folder time , but the time of the /mnt/backups/<directory-name>/the-symlynked-dir (and this one is old), i want to acces the new folders time, but it redirects me to the old folder when i go to /mnt/backups/<directory-name>/current . The backup is on a different server using the rsync. They said to keep it simple and just monitor the file.time, which i did , but on this specific monitoring server won't work normally , on others servers where i did the same settings seems to work. So.. i'm looking for the problem , or how can i stop it from being redirected to the old backup directory and get the new folder creation time ? Maybe u ask why i monitor the time ? Because the script won't go any further if it has an error and it will spam only one message, because there are other backups going on , since we are migrating to new servers. If i can provide other informations... thanks again for taking ur time replying max.ch.88. And if u said exactly what i've said since im a newbie, how i should do this ? I assume i should get the return code of the script when it has an error but wont that be in a log file as you mentioned , how should i access it if not trough log ? Could you provide me with some detailed explanation or an example ? Thanks a lot.
PS. It's only receiving the 0 value. since it displayed the data of the old file not the new folder time, i want the new folder time , because when the folder changes it will be another folder time , that meaning the backup is successful if the folder has been changed under 30h ~~ or so.Comment
-
I managed to fix it, it seemed that the backup was keeping the old time of the files but the symlink was at current date , making it get old date time from 2018 (from where the backup was) , and by monitoring the whole directory it will only check for newer folders which will be the "current" directory which is the symlink and like that will parse the requested value. Thanks for your time.Comment
-
Example:... Maybe u ask why i monitor the time ? Because the script won't go any further if it has an error and it will spam only one message, because there are other backups going on , since we are migrating to new servers. If i can provide other informations... thanks again for taking ur time replying max.ch.88. And if u said exactly what i've said since im a newbie, how i should do this ? I assume i should get the return code of the script when it has an error but wont that be in a log file as you mentioned , how should i access it if not trough log ? Could you provide me with some detailed explanation or an example ? Thanks a lot.
PS. It's only receiving the 0 value. since it displayed the data of the old file not the new folder time, i want the new folder time , because when the folder changes it will be another folder time , that meaning the backup is successful if the folder has been changed under 30h ~~ or so.
rsync .... && echo "host key $?" | zabbix_sender -z server -i - >/dev/nullLast edited by max.ch.88; 19-03-2019, 21:20.Comment
-
Sorry for reviving this old topic, but i've hit a deadend with my fix. If a backup fails or internet connection is lost or a cron job won't work , i want zabbix to fire a trigger, my previous fix wont cover the case in which the backup fails and the script puts everything in a "inprocess" folder because it wont get any new current date time. So i'm going back to square one , is it possible to attach a trigger to symlink ? max.ch.88 if i use what you've mentioned in the cronjob set for backup if internet connection is poor or lost the server wont manage to send the value to the zabbix server since is on another host, am i right ? I think it will be best if the checkup will be made from zabbix monitoring service server and not be received from other server,because there are other cases that might pop up, the best checkup would be from zabbix server i believe.
Thanks for your time.Comment
-
Hi.
...is it possible to attach a trigger to symlink ? - Yes.
... am i right ? - Yes.
You could use zabbix-proxy on the remote host or create an empty file as the flag of the successful backup and check it existence from zabbix-server. It maybe as solution against the unstable internet connection.Comment
-
For anyone who's looking for a fix for this because i forgot to write it up, i've added an userparameter which verifies if the folder exists and echo's 1 or 0 depending on its existence and i've pulled a dependency trigger on the files, the inprogress folder being the first and like this it will fire a message if the inprogress exists if not it will go to the too_old trigger for backup that's been setup as a fuzzytime for a period of 26h ~ and works as expected. Hope it helps anyone. Thanks to all for your help and time.Comment
-
I wrote a set of scripts for this 6 years ago
latestfileage(), latestfilename()
It will give you the age of the newest file in a certain folder and you can give some filters like minimal size and name.
Look at the code to find out how it works.
I'm using it to test if a back-up has been made.
I also made a script to get the age of the oldest file in a tree structure. oldestyoungestage()
This is handy if you have a folder in which you have folder where devices upload their config back-up (like 3CX).
It does this every night....
If one of the 3CX's doesn't back-up anymore, it can warn you....
Code:/etc/zabbix/zabbix_agentd.conf:UserParameter=vfs.file.latestfilename[*], sudo /usr/local/sbin/latestfilename "$1" "$2" "$3" /etc/zabbix/zabbix_agentd.conf:UserParameter=vfs.file.latestfiledate[*], sudo /usr/local/sbin/latestfiledate "$1" "$2" "$3" /etc/zabbix/zabbix_agentd.conf:UserParameter=vfs.file.latestfileage[*], sudo /usr/local/sbin/latestfileage "$1" "$2" "$3"
cat /etc/sudoers.d/zabbix
Code:Defaults:zabbix !requiretty zabbix ALL =(ALL) NOPASSWD: /usr/local/sbin/latestfileage zabbix ALL =(ALL) NOPASSWD: /usr/local/sbin/latestfiledate zabbix ALL =(ALL) NOPASSWD: /usr/local/sbin/latestfilename zabbix ALL =(ALL) NOPASSWD: /usr/local/sbin/oldestyoungestname zabbix ALL =(ALL) NOPASSWD: /usr/local/sbin/oldestyoungestage
cat latestfilename
Code:#!/bin/bash export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin FOLDER="`echo "$1" | sed 's/\/$//'`" [ -z "${FOLDER}" ] && exit MAXDEPTH=`echo "${2}" | tr -cd '0-9'` [ -z "${MAXDEPTH}" ] && MAXDEPTH=1 REGEXP='.*' [ -z "${3}" ] || REGEXP="${3}" MINSIZE=`echo "$4" | tr -cd '[0-9]'` FINDOPT='' [ -z "${MINSIZE}" ] || FINDOPT="-size +${MINSIZE}k" [ -h "${FOLDER}" ] && FOLDER="`readlink "${FOLDER}"`" if [ -d "${FOLDER}" ] ; then FILE="`find "${FOLDER}" -maxdepth ${MAXDEPTH} -type f ${FINDOPT} | egrep "${REGEXP}$" | xargs -I{} stat -c '%Y %n' {} | sort -rn | head -n1 | sed 's/^[0-9]* //g'`" FILE="${FILE##${FOLDER}/}" RETVAL=. [ -z "${FILE}" ] || RETVAL="${FILE}" echo "${RETVAL}" fi
cat latestfileage
Code:#!/bin/bash export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin FOLDER="`echo "$1" | sed 's/\/$//'`" [ -z "${FOLDER}" ] && exit MAXDEPTH=`echo "${2}" | tr -cd '0-9'` [ -z "${MAXDEPTH}" ] && MAXDEPTH=1 REGEXP='.*' [ -z "${3}" ] || REGEXP="${3}" MINSIZE=`echo "$4" | tr -cd '[0-9]'` FINDOPT='' [ -z "${MINSIZE}" ] || FINDOPT="-size +${MINSIZE}k" [ -h "${FOLDER}" ] && FOLDER="`readlink "${FOLDER}"`" if [ -d "${FOLDER}" ] ; then STAMP="`find "${FOLDER}" -maxdepth ${MAXDEPTH} -type f ${FINDOPT} | egrep "${REGEXP}$" | xargs -I{} stat -c '%Y %n' {} | sort -rn | head -n1 | awk '{print $1}'`" if [ -z "${STAMP}" ] ; then echo '-1' else echo "`date +%s` ${STAMP}" | awk '{print $1 - $2}' fi fi
cat /usr/local/sbin/latestfiledate
Code:#!/bin/bash export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin FOLDER="`echo "$1" | sed 's/\/$//'`" [ -z "${FOLDER}" ] && exit MAXDEPTH=`echo "${2}" | tr -cd '0-9'` [ -z "${MAXDEPTH}" ] && MAXDEPTH=1 REGEXP='.*' [ -z "${3}" ] || REGEXP="${3}" MINSIZE=`echo "$4" | tr -cd '[0-9]'` FINDOPT='' [ -z "${MINSIZE}" ] || FINDOPT="-size +${MINSIZE}k" [ -h "${FOLDER}" ] && FOLDER="`readlink "${FOLDER}"`" if [ -d "${FOLDER}" ] ; then STAMP="`find "${FOLDER}" -maxdepth ${MAXDEPTH} -type f ${FINDOPT} | egrep "${REGEXP}$" | xargs -I{} stat -c '%Y %n' {} | sort -rn | head -n1 | awk '{print $1}'`" if [ -z "${STAMP}" ] ; then echo '-1' else echo "${STAMP}" fi fi
cat oldestyoungestage
cat /usr/local/sbin/oldestyoungestnameCode:#!/bin/bash export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin FOLDER="`echo "$1" | sed 's/\/$//'`" [ -z "${FOLDER}" ] && exit TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX` REGEXP='.*' [ -z "${2}" ] || REGEXP="${2}" MINSIZE=`echo "$3" | tr -cd '[0-9]'` FINDOPT='' NOW=`date +%s` [ -z "${MINSIZE}" ] || FINDOPT="-size +${MINSIZE}k" [ -h "${FOLDER}" ] && FOLDER="`readlink "${FOLDER}"`" if cd "${FOLDER}" 2>/dev/null ; then find . -mindepth 1 -maxdepth 1 -type d >${TMPDIR}/folders OLDEST=0 while read DIR ; do STAMP="`find "${DIR}" -maxdepth 1 -type f ${FINDOPT} | egrep "${REGEXP}$" | xargs -I{} stat -c '%Y %n' {} | sort -rn | head -n1 | awk '{print $1}'`" if [ -n "${STAMP}" ] ; then YOUNGEST=`echo "${NOW} ${STAMP}" | awk '{print $1 - $2}'` [ ${YOUNGEST} -gt ${OLDEST} ] && OLDEST=${YOUNGEST} fi done<${TMPDIR}/folders if [ ${OLDEST} -eq 0 ] ; then echo -1 else echo ${OLDEST} fi fi rm -rf ${TMPDIR}
Code:#!/bin/bash export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin FOLDER="`echo "$1" | sed 's/\/$//'`" [ -z "${FOLDER}" ] && exit TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX` REGEXP='.*' [ -z "${2}" ] || REGEXP="${2}" MINSIZE=`echo "$3" | tr -cd '[0-9]'` FINDOPT='' NOW=`date +%s` [ -z "${MINSIZE}" ] || FINDOPT="-size +${MINSIZE}k" [ -h "${FOLDER}" ] && FOLDER="`readlink "${FOLDER}"`" if cd "${FOLDER}" 2>/dev/null ; then find . -mindepth 1 -maxdepth 1 -type d >${TMPDIR}/folders OLDEST=0 OLDESTNAME= while read DIR ; do YOUNGESTNAMEDATE="`find "${DIR}" -maxdepth 1 -type f ${FINDOPT} | egrep "${REGEXP}$" | xargs -I{} stat -c '%Y %n' {} | sort -rn | head -n1`" STAMP="`echo "${YOUNGESTNAMEDATE}" | awk '{print $1}'`" if [ -n "${STAMP}" ] ; then YOUNGEST=`echo "${NOW} ${STAMP}" | awk '{print $1 - $2}'` if [ ${YOUNGEST} -gt ${OLDEST} ] ; then OLDEST=${YOUNGEST} OLDESTNAME="`echo "${YOUNGESTNAMEDATE}" | awk '{print $2}'`" fi fi done<${TMPDIR}/folders if [ ${OLDESTNAME} ] ; then echo ${OLDESTNAME} else echo -1 fi fi rm -rf ${TMPDIR}Last edited by frater; 06-09-2022, 22:55.Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAPComment
Comment