#!/bin/sh # This script takes the last readings of the chilled water meters and the # electrcical meters and generates a printout of it: # define logging root # lg=/home/chris/BTUmetering lg=MAINPROGROOT # General header echo -e "Hello,\n" echo -e "this is your friendly CQT utility consumption server. We proudly present \nthe latest readings of our utility meters.\n" # some text for water meters: echo "First, the direct readings of the chilled water meters:" #logfilenamelist logroot=("AHU1" "AHU2" "AHU3" "AHU4" "AHU5" "AHU6" "PCW2" "S14L3") # go through the list for unit in ${logroot[@]} do logfile=$lg/log/heat_$unit.log # generate time and response from water meter t=($(tail -n 1 $logfile)) d1=${t[0]} d2=$(date -d $d1 +"%d %b %Y") #echo $logfile ${t[1]} echo "$unit: On $d2, ${t[1]}SGT: Heat reading = ${t[2]} kWh" done echo echo "Then the direct reading of the electrical meters:" # serial number list of Landis&GYR measurement units. adrlist=("94529479" "94529480" "94529485" "94529481" "94529484" "94529486" "94529482" "94529487" "94529483" "94529488" "99828529" "99828528") loglist=("MDB1" "E-MDB1" "EAHU1" "MDB2" "E-MDB2" "EAHU2" "MDB3" "EAHU3" "MDB4" "EAHU4" "MDB6" "EAHU6") for (( i=0 ; $i<${#adrlist[*]} ; i++)) do adr=${adrlist[$i]} unit=${loglist[$i]} logfile=$lg/log/emeter_$adr.log t=($(tail -n 1 $logfile 2>/dev/null )) u=$? if (($u == 0)) then d1=${t[0]} d2=$(date -d $d1 +"%d %b %Y") echo -e "$unit\t(serial: $adr): On $d2 ${t[1]}SGT: Energy reading: ${t[2]} kWh" else echo -e "$unit\t(serial: $adr): No data available yet" fi done echo -e "\nPlease note that the units E-MDB1 and E-MDB2 are labelled differently in the\nelectrical risers (probably MDB6 and MDB7). These taps are supposedly connected to \nthe emergency power supply lines in levels 1 and 2." echo -e "\nThis is an automatically generated email; please do not respond to this address." echo -e "The CQT team is relentlessly working to improve the quality of this readout service.\nFeel free to send any feedback to phyck@nus.edu.sg\n\nWith Best Regards,\n\nYour CQT utility server"