Tech Tips

Sonar Ping

I use this simple script when troubleshooting network problems on machines when I can't see the screen—for example, when I'm under a desk, wiggling Ethernet cables to find a bad one. When I hear the pings, I know it's fixed. Or, you can use this to drive your coworkers nuts by running it on their machines and sending single pings at random times during the day (or perhaps substitute moo for ping).

I made this into a script because I can't remember that big long line, and I would hate to type it in a lot. Here's

# Written by Mike Studer a long time ago
# Make sure you obtain a nice submarine ping sound.
# ie., ping with an echo ( used here)

/usr/sbin/icmpinfo -vv | \
  /usr/bin/nawk '$4 == "ICMP_Echo"
                   {print $0;
                    system("/usr/bin/aplay -q ~/sounds/")}'

You need to install icmpinfo and aplay to use this.

Usage: Run this on the machine on which you want to make noise (test):


Run this on a machine that is trying to get to the test machine for a nonstop ping barrage:

ping {testmachine}

For a single ping, run this:

ping -c 1 {testmachine}

—Mike Studer

Get Even More from Less

In addition to viewing text, the less command can be used for viewing nontext files. This is done by using less' ability to invoke a preprocessor for input files. These preprocessors then can change the way the file's contents are displayed. For example, suppose you had a script

#! /bin/sh
case "$1" in
    *.tar.gz) tar -tzvf $1 2>/dev/null

Make sure the script is executable, and set the LESSOPEN environment variable to:

LESSOPEN='|/path/to/ %s'

Now you can use less to view the contents of .tar.gz files:

$ less autocorrect.tar.gz
-rwxrwxrwx raogr/raogr  84149 2009-02-02 03:20 autocorrect.dat
-rwxrwxrwx raogr/raogr    443 2009-02-02 03:21 generator.rb
-rwxrwxrwx raogr/raogr 181712 2009-02-02 03:21 autocorrect.vim

More-sophisticated versions of are available. You already may have a version installed, or you may have the script installed. If not, search the Internet for With the more-sophisticated versions, you can do things like this:

$ less knoppix_5.1.1.iso
CD-ROM is in ISO 9660 format
System id: LINUX
Volume id: KNOPPIX
Volume set id:
Publisher id: KNOPPER.NET

—Gururaj Rao

Keep Laptop Temperature under Control

I work all the time with a laptop, and as you all know, from time to time laptops can get hot. When you're actually using it as a “lap”-top, or when you're close enough to hear the fans, you know when it's heating up. But, when the conditions are such that you don't realize it's heating up, your laptop can get pretty hot. And, you've all heard the stories about laptops catching fire.

The following script monitors the temperature and slows down your system when it gets too hot. The script should be run as root from cron every minute or so. You need to install cpufrequtils to get it to work:


# Get the temp of the core 0
core_O=`acpi -t | awk {'print $4'} | head -n 1`

# Get the temp of the core 1
core_1=`acpi -t | awk {'print $4'} | tail -n 1`

# Round the result of core_O
convert_O=$(echo "scale=0; $core_O/1.0" | bc)

# Round the result of core_1
convert_1=$(echo "scale=0; $core_1/1.0" | bc)

# Set maximum permissible temperature.

# Set temperature at which the CPU frequency can
# be increased again (if needed).

if (( $convert_O >= $max )) ; then
    # Too hot, slow down to 800MHz.
    cpufreq-set -f 800
    echo "CPU temp higher than desired!!!" | \
        mail -s "CPU temp too high, set frequency to half" root
elif (($convert_O <= $min)) ; then
    # Cooled down, allow frequency to increase again if needed.
    cpufreq-set -g ondemand

As you can see, in the script, I actually use the temperature only of core 0, because I know that this core tends to overheat before core 1.



White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState