Aktionen
external Scripts¶
See also http://lab4.org/wiki/Zabbix_erweitern_mit_External_Checks
This script is based on https://87.110.183.172/forum/showthread.php?t=22666
vim /etc/zabbix/externalscripts/fileage.sh
#!/bin/bash
#echo out parameter:
#echo $1 $2>/tmp/zabbix_external_script_fileage.log
# Usage instructions:
if [ -z "$2" ]; then
echo "Usage: "
echo " $0 host-IP filename"
echo "will tell you the age of the file in seconds, "
echo "or -1 if the file does not exist, "
echo "or -2 if the OS is not supported"
exit
fi
# Test if the file exists:
if [ ! -f "$2" ]; 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 $2)
(( DIFF = (NOW - $st_ctime) ))
echo $DIFF;
exit
fi
if [ `uname` == 'Linux' ]; then
OLD=`stat -c %Z $2`
NOW=`date +%s`
(( DIFF = (NOW - OLD) ))
echo $DIFF;
exit
fi
#echo "Unsupported operating system"
echo -2
Von Jeremias Keihsler vor fast 8 Jahren aktualisiert · 1 Revisionen