Fun with proc, grep, and sed
First, the facts:
- /proc -- a filesystem containing information about the computer and OS etc
- grep string file -- print out lines from file (or stdin) that contain string
- sed s/pattern/string/ -- replace pattern in stdin by string
Now the application:
#!/bin/bash echo "CPU MHz: $(grep MHz /proc/cpuinfo | sed 's/cpu MHz\t\t: //')" echo "CPU C: $(sensors | grep CPU\ Temp | sed 's/CPU Temp: *+//' | sed 's/ C.*(.*).*//')" echo "Mobo C: $(sensors | grep M/B\ Temp | sed 's/M\/B Temp: *+//' | sed 's/ C.*(.*).*//')"
This is a simple CPU speed and temperature monitor, handy for my new laptop to check everything is tickety-boo :-) Some output:
$ ./cpu.sh CPU MHz: 1600.467 CPU C: 48.5 Mobo C: 46 $ ./cpu.sh CPU MHz: 600.175 CPU C: 50.4 Mobo C: 47 $ ./cpu.sh CPU MHz: 1600.467 CPU C: 50.6 Mobo C: 47
These tests show that the CPU frequency scaling works, changing as the need requires with the ondemand policy (I'm installing Apache and PHP, compiling needs lots of CPU power, but downloading doesn't). I will do a full update about my new laptop once I have configured everything well enough :-) Suffice to say, it rocks!
BBC Radio 2
motherboard 3 power