Update temp.inc.sh
This commit is contained in:
@@ -311,30 +311,8 @@ CHECKTEMP_SERVICE(){
|
||||
SENSORS_CHECKED=()
|
||||
for SENSORa in ${PW_SENSOR_ORD[@]}; do
|
||||
start_sub=`date +%s`
|
||||
logtemp=${PW_LOGFOLDER}/log-temp-${SENSORa}
|
||||
[ ! -f ${logtemp} ] && touch ${logtemp}
|
||||
[ $(expr `date +%s` - $(stat -c %Y ${logtemp})) -ge $(echo "scale=0; ${PW_LOG_INTERVAL_NORMAL}*60" | bc) ] && relog=1 || relog=0
|
||||
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "lacrosse" ] || ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ]) || ([ "${PW_HOST_ADDRESSES[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_HOST_ADDRESSES[${SENSORa}]})" != "false" ]); then
|
||||
# if ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ]); then
|
||||
if [ -f ${PW_TMPFOLDER}/${SENSORa}.down ]; then
|
||||
SENDNOTICE "${SENSORa} Online" "${SENSORa} Sensor is back online"
|
||||
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSORa} - Sensor is back online" >> ${logtemp}
|
||||
rm -f ${PW_TMPFOLDER}/${SENSORa}.down
|
||||
fi
|
||||
CHECKTEMP_SERVICE_RUNSENSOR ${SENSORa} &
|
||||
SENSORS_CHECKED+=(${SENSORa})
|
||||
|
||||
else
|
||||
[ ! -f ${PW_TMPFOLDER}/${SENSORa}.down ] && touch ${PW_TMPFOLDER}/${SENSORa}.down
|
||||
if [ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.reading ]; then
|
||||
touch ${PW_TMPFOLDER}/${SENSORa}-error.reading
|
||||
elif [ ! -f ${PW_TMPFOLDER}/${SENSORa}.disable ] && (([ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.reading)) -ge 60 ]) || ([ -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | bc) ])); then
|
||||
touch ${PW_TMPFOLDER}/${SENSORa}-error.sent
|
||||
SENDNOTICE "${SENSORa} Sensor ERROR" "ERROR reading sensor data" 1
|
||||
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSORa} Sensor - ERROR reading sensor data" >> ${logtemp}
|
||||
fi
|
||||
fi
|
||||
end_sub=`date +%s`; runtime_sub=$((end_sub-start_sub)); echo "${SENSORa} - runtime: ${runtime_sub}s"
|
||||
done
|
||||
|
||||
@@ -357,6 +335,17 @@ CHECKTEMP_SERVICE(){
|
||||
}
|
||||
CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
SENSORa=${1}
|
||||
logtemp=${PW_LOGFOLDER}/log-temp-${SENSORa}
|
||||
[ ! -f ${logtemp} ] && touch ${logtemp}
|
||||
[ $(expr `date +%s` - $(stat -c %Y ${logtemp})) -ge $(echo "scale=0; ${PW_LOG_INTERVAL_NORMAL}*60" | bc) ] && relog=1 || relog=0
|
||||
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "lacrosse" ] || ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ]) || ([ "${PW_HOST_ADDRESSES[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_HOST_ADDRESSES[${SENSORa}]})" != "false" ]); then
|
||||
# if ([ "${PW_REMOTE_SENSORS[${SENSORa}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSORa}]})" != "false" ]); then
|
||||
if [ -f ${PW_TMPFOLDER}/${SENSORa}.down ]; then
|
||||
SENDNOTICE "${SENSORa} Online" "${SENSORa} Sensor is back online"
|
||||
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSORa} - Sensor is back online" >> ${logtemp}
|
||||
rm -f ${PW_TMPFOLDER}/${SENSORa}.down
|
||||
fi
|
||||
if [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "esxi" ]; then
|
||||
vHOST_TEMPNAMES=$(snmpwalk -v 1 -c public -t 2 ${PW_HOST_IDRACS[${SENSORa}]} .1.3.6.1.4.1.674.10892.5.4.700.20.1.8 -O vq | sed -e 's/"//g' | sed -e 's/ Temp//g')
|
||||
IFS=$'\n'
|
||||
@@ -645,6 +634,17 @@ CHECKTEMP_SERVICE_RUNSENSOR(){
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
else
|
||||
[ ! -f ${PW_TMPFOLDER}/${SENSORa}.down ] && touch ${PW_TMPFOLDER}/${SENSORa}.down
|
||||
if [ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.reading ]; then
|
||||
touch ${PW_TMPFOLDER}/${SENSORa}-error.reading
|
||||
elif [ ! -f ${PW_TMPFOLDER}/${SENSORa}.disable ] && (([ ! -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.reading)) -ge 60 ]) || ([ -f ${PW_TMPFOLDER}/${SENSORa}-error.sent ] && [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/${SENSORa}-error.sent)) -ge $(echo "scale=0; ${PW_RENOTIFY_TIMEOUT}*60" | bc) ])); then
|
||||
touch ${PW_TMPFOLDER}/${SENSORa}-error.sent
|
||||
SENDNOTICE "${SENSORa} Sensor ERROR" "ERROR reading sensor data" 1
|
||||
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${SENSORa} Sensor - ERROR reading sensor data" >> ${logtemp}
|
||||
fi
|
||||
fi
|
||||
touch ${PW_TMPFOLDER}/zservicerun.${SENSORa}.done
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user