#!/bin/sh
# ~jhs/bin/.sh/mbmon.sh
# needs to move to /site so hosts dont need to find it by a.d of /usr/home/jhs
# crontab calls this, 
# as I turn off some machines overnight in hot summers,
# its best to call this during the day, else it might not get run.
# procmail stores the result.
# If a machine crashes & the previous weeks log shows progressively 
# higher temperature, likely a fan is stuck with dirt or a bearing gone.

# echo "mbmon.sh started on `hostname -s` `date -u +%Y-%m-%dT%H:%M:%SZ`" | \
# 	mail -s "Cron: `hostname -s`" jhs

# xs touch /var/log/mbmon ; xs chown jhs:staff /var/log/mbmon
# xs touch /var/log/mbmon.today ; xs chown jhs:staff /var/log/mbmon.today

cat /var/log/mbmon.today 		# Yesterday's values for comparison
echo
date -u +%Y-%m-%dT%H:%M:%SZ
/usr/local/bin/mbmon -c 1	# Today's

# This script is called by crontab,
# On host=fire the output goes to mail, 
# the headers only show localhost, not through gate, yet
# also have header: To: jhs_ERASE_@berklix.com
# so ~/.procmailrc_system_logs fails to sort by individual host.
# Maybe I have too much masquerad turned on local internal hosts ?
# best solve that by getting uucp fowarding of js.berklix, then
# reduce the masquerading.

date -u +%Y-%m-%dT%H:%M:%SZ			  >> /var/log/mbmon 	# Cumulative
/usr/local/bin/mbmon -c 1 >> /var/log/mbmon 	# Cumulative
date -u +%Y-%m-%dT%H:%M:%SZ			  > /var/log/mbmon.today 	# Store today's
/usr/local/bin/mbmon -c 1 >> /var/log/mbmon.today 	# Store today's

# echo "mbmon.sh finished on `hostname -s` `date -u +%Y-%m-%dT%H:%M:%SZ`" | \
# 	mail -s "Cron: `hostname -s`" jhs
exit 0
