XanTrax
March 12th, 2009, 12:01 AM
Hi everyone,
I noticed when using Conky and hddtemp application that most conky scripts will query hddtemp through
nc localhost <hddtemp_port>
and would populate netstat command with a whole ton of TIME_WAIT connections. I have developed a fix for this.
1.) First, edit the hddtemp script where you report the temperature to look something like this:
Temperature: ${alignr}${exec cat /etc/hddtmp_out }
Then:
sudo touch /etc/hddtmp_out
Then, utilize this script or create a simliar to generate the same effects:
#!/bin/bash
date=`date`
touch /root/logs/gettemp.log
/usr/sbin/hddtemp /dev/sda1 | cut -d ":" -f3 > /etc/hddtmp_out
if [ $? -eq 0 ]; then
echo "Command completed successfully"
elif [ $? -gt 0 ] || [ $cmd != " " ]; then
echo "Caught error"
fi
temp=`hddtemp /dev/sda1 | cut -d ":" -f3`
log=`echo Get temp finished @ $date reporting $temp >> /root/logs/gettemp.log`
exit 0
What this script does:
First it gets the date and touches gettemp.log in /root/logs/ to ensure it is there. Then, it executes the hddtemp executable querying the appropriate hard drive. Make sure to change to your appropriate hard drive (read hddtemp manual). The script then parses out the temperature and outputs it to /etc/hddtmp_out (hint: cat /etc/hddtmp_out from the conky script). Finally, for logging and error reporting purposes, it outputs to the gettemp.log file in the root directory. This was more or less used when I was debugging so you can remove it if you like. You can place that in /usr/local/bin for easy access as that is how I created the cron job (read below).
Then create a cron job to run every minute. This wont be too intensive on the system seeing as to query the temperature through the cron job is about as equal as running the netcat command.
sudo su -
crontab -e
Add this line:
* * * * * test -x /usr/local/bin/gettemp && ( sudo /usr/local/bin/gettemp )
This will create a cron job to execute every minute to report and output to the hddtmp_out file in /etc.
I noticed when using Conky and hddtemp application that most conky scripts will query hddtemp through
nc localhost <hddtemp_port>
and would populate netstat command with a whole ton of TIME_WAIT connections. I have developed a fix for this.
1.) First, edit the hddtemp script where you report the temperature to look something like this:
Temperature: ${alignr}${exec cat /etc/hddtmp_out }
Then:
sudo touch /etc/hddtmp_out
Then, utilize this script or create a simliar to generate the same effects:
#!/bin/bash
date=`date`
touch /root/logs/gettemp.log
/usr/sbin/hddtemp /dev/sda1 | cut -d ":" -f3 > /etc/hddtmp_out
if [ $? -eq 0 ]; then
echo "Command completed successfully"
elif [ $? -gt 0 ] || [ $cmd != " " ]; then
echo "Caught error"
fi
temp=`hddtemp /dev/sda1 | cut -d ":" -f3`
log=`echo Get temp finished @ $date reporting $temp >> /root/logs/gettemp.log`
exit 0
What this script does:
First it gets the date and touches gettemp.log in /root/logs/ to ensure it is there. Then, it executes the hddtemp executable querying the appropriate hard drive. Make sure to change to your appropriate hard drive (read hddtemp manual). The script then parses out the temperature and outputs it to /etc/hddtmp_out (hint: cat /etc/hddtmp_out from the conky script). Finally, for logging and error reporting purposes, it outputs to the gettemp.log file in the root directory. This was more or less used when I was debugging so you can remove it if you like. You can place that in /usr/local/bin for easy access as that is how I created the cron job (read below).
Then create a cron job to run every minute. This wont be too intensive on the system seeing as to query the temperature through the cron job is about as equal as running the netcat command.
sudo su -
crontab -e
Add this line:
* * * * * test -x /usr/local/bin/gettemp && ( sudo /usr/local/bin/gettemp )
This will create a cron job to execute every minute to report and output to the hddtmp_out file in /etc.