Hi,
I am running zabbix 3.0 and the agent on the linux host is 2.0.x
I need to check if there are files older than one hour in a specific folder.
Also I need to exclude subfolders from the check and the modify time needs to be in Unix time.
I did get the job done with this;
UserParameter=vfs.file.age[*],find $1 -maxdepth 1 -type f -mmin +60 -printf "%TY.%Tm.%Td %TH:%TM:%.2TS %p\n" | sort | head -n 1
which prints a files modification time and filename, if a file has been modified over an hour ago.
But the problem with this is that I need this kind of implementation in other hosts as well (with different modify times) and it would be nice that I could use one userparameter for all those.
So, currently I have userparameter like this;
UserParameter=vfs.oldest.age[*],find $1 -maxdepth 1 -type f | xargs -i stat -c '%Y' '{}'
which does the job well, until the folder becomes empty and then the item goes to 'unsupported' because it gets an empty value from the agent.
Does anybody have any clue about how to modify the command so that even if the folder is empty it returns value '1' for example?
Many thanks!
I am running zabbix 3.0 and the agent on the linux host is 2.0.x
I need to check if there are files older than one hour in a specific folder.
Also I need to exclude subfolders from the check and the modify time needs to be in Unix time.
I did get the job done with this;
UserParameter=vfs.file.age[*],find $1 -maxdepth 1 -type f -mmin +60 -printf "%TY.%Tm.%Td %TH:%TM:%.2TS %p\n" | sort | head -n 1
which prints a files modification time and filename, if a file has been modified over an hour ago.
But the problem with this is that I need this kind of implementation in other hosts as well (with different modify times) and it would be nice that I could use one userparameter for all those.
So, currently I have userparameter like this;
UserParameter=vfs.oldest.age[*],find $1 -maxdepth 1 -type f | xargs -i stat -c '%Y' '{}'
which does the job well, until the folder becomes empty and then the item goes to 'unsupported' because it gets an empty value from the agent.
Does anybody have any clue about how to modify the command so that even if the folder is empty it returns value '1' for example?
Many thanks!
Comment