Window 7 – No Internet Access

For the last few days I have occasionally encountered the problem whereby my local network access worked fine. However, my Internet access was “unavailable”.

In my case, the problem was due to a race condition between the Apple Bonjour service and the DHCP lookup. The easy way to check if you have the same problem is to start a Windows command and run:

C:\>ipconfig

If your Default Gateway has a 0.0.0.0 listed then the is a fair chance that you may have the same problem e.g.

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : domain.local
   IPv4 Address. . . . . . . . . . . : 192.168.0.166
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 0.0.0.0
                                       192.168.0.1

The solution is to change the Bonjour service “Startup type” from Automatic to Automatic (Delayed Start)

Windows 7 – The Peer Name Resolution Protocol

After many ours of googling I finally found the solution to the problem where the “The Peer Name Resolution Protocol” service fails to start. The error displayed in the Windows event viewer is:

The Peer Name Resolution Protocol cloud did not start because the creation of the default identity failed with error code
: 0x80630801

The solution is to delete a corrupt file:

C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\PeerNetworking\idstore.sst

Solution Reference

CPU Monitoring Script

Have you ever had a rogue process chew up all the CPU on your Linux server for a days and nobody notice?

This happens to me quite a lot so I decided to write a bash script that looks for these processes and send an alert email.

#!/bin/bash

#
# cpumon - monitors CPU usage and sends an alert email if limit is exceeded
#
# 2009 - martin [at] teamburns [dot] com
#

host=`hostname`
file="/tmp/cpumon.txt"

rm $file > /dev/null 2>&1

function sendEmail() {
   subject="High CPU on $host"
   /usr/bin/mail -s "$subject" user@domain.com < $file
}

while read a b c
do
   pid="$a"
   cmd="$b"
   cpu_percentage="$c"

   if [[ -z "$cpu_percentage" ]]
   then
      echo "process $pid $cmd is using less than zero percent of the cpu!"
      continue
   else
      cpu_percentage_integer=$(echo "$cpu_percentage"|sed 's/^\([^\.]*\)\..*$/\1/')
   fi

   if [[ $cpu_percentage_integer -gt 10 ]]
   then
      echo "$pid $cmd is using $cpu_percentage_integer percent of our CPU" >> $file
   fi
done <<< "`ps --no-heading -eo pid,comm,pcpu`"

if [[ -f $file ]]
then
   sendEmail
fi

This script can be scheduled to run periodically by placing an entry in the crontab file. Make sure use replace username with a valid name:

*/30 *  * * *   username    /home/username/cpumon >/dev/null 2>&1