2011
03.14

After racking up my new APC Netbotz appliance this weekend and setting up the obligatory snmp, syslog and email alerts, I also wanted to be able to monitor and view my computer lab’s environmental temperatures in realtime on my desktop, without the need to manually login and check web portals or system logs every time. No problem I thought; I would just pipe the output of the syslog file into a regular expression editor, extract the info I was after and finish by outputting the results into conky to display all nice and neat on my desktop.

Without going into too much detail about how the Netbotz appliance works, it turned out that retrieving the information I was after by leveraging the already existing Netbotz logging facilities in order to monitor my homecomputerlab environment with the relevant stats embedded on my laptop’s desktop in realtime was not going to be as straight forward as I had first hoped. I was going to have to write my own scripts to achieve what I wanted.

Below is a screenshot of the end result and the scripts I wrote to achieve this.

#Expect_telnet_login.sh
#!/usr/bin/expect -f
log_file -noappend /home/tyrell/APC.temp
spawn telnet 192.168.0.251
expect "User Name :"
send "username\r"
expect "Password:"
send "password\r"
send "1\r"
send "1\r"
send "1\r"
expect {*#}
close

#APC_temp_humidity_last_syslog_msg.sh
#!/bin/bash
/home/tyrell/scripts/Netbotz_temp/Expect_telnet_login.sh > /dev/null
grep "homecomputerlab rack" /home/tyrell/APC.temp | awk '{print $3}'
grep "homecomputerlab rack" /home/tyrell/APC.temp | awk '{print $4}' | cut -c1-3
ssh tyrell@syslogserver tail -n 1 /home/apc/netbotz/netbotz.log | fold -w47

No Comment.

Add Your Comment