.

Load Monitoring |

As many of you know I’m a computer guy. If you’ve been following my blog it may come as a shock as I haven’t really posted anything super geeky. Well that’s about to change. Please note that word press has word wrapped the code blocks bellow. So if you’re going to use this script copy and paste them into a text editor, that way you get the line breaks where they should be.

My web host (the people who host thehaggertys.net) sucks at managing servers. It seems as though my sites and email are down at least once a day. I would never know it until some one would say that they couldn’t get email or get to the blogs or the gallery. I had enough and asked my host to fix it. They refused to do anything about it, or even move me to one of there other 20+ servers. This all prompted me to write some scripts to monitor the load of my server. I know this has probably been done a million times in the past, but I wrote this solution and I’m proud of it. So here it is if anyone wants to use it on there web server.

The first step was to create a HTML file that will hold the output from the scripts. I called mine index.html and threw it in it’s own directory. Here’s what it consists off:

Time One Minute Average Five Minute Average Fifteen Minute Average

The next step is to write a script to fill in the table with data. For this I wrote a small korn shell script that runs the “uptime” command, it parses out the time, what the load is, and it then fills in the table in the index.html file. I have a cron job running it every 15 minutes. The effectively gives me what the load averages are on the box every 15 minutes. I also told the script to print out “High Load” followed by the load averages if the average was higher than 15. I then set cron to email me any output to standard out when it runs. So now I am emailed (and it’s send to my blackberry!) when ever the load is greater than 15. This means that if the web server was running on a machine with 15 processors it would be using 100% of the processor power. Since my host is using a 2 processor box a load of 15 would mean it is trying to run at 750% processing power. I think I did my math right. Anyway, 15 is way to high for a 2 processor server.

My shell script is as follows:

#! /bin/ksh

if [[ `uptime |wc -w` -eq 12 ]]
then
one=`uptime |awk ‘{print $10}’ |sed ’s/,//g’`
five=`uptime |awk ‘{print $11}’ |sed ’s/,//g’`
fifteen=`uptime |awk ‘{print $12}’`
time=`uptime |awk ‘{print $1}’`
elif [[ `uptime|wc -w` -eq 13 ]]
then
one=`uptime |awk ‘{print $11}’ |sed ’s/,//g’`
five=`uptime |awk ‘{print $12}’ |sed ’s/,//g’`
fifteen=`uptime |awk ‘{print $13}’`
time=`uptime |awk ‘{print $1}’`
fi

echo “

\n

$time

\n

$one

\n

$five

\n

$fifteen

\n

” >> /home/haggerty/public_html/load/index.html

newone=`echo $one |awk -F. ‘{print $1}’`
newfive=`echo $five |awk -F. ‘{print $1}’`
newfifteen=`echo $fifteen |awk -F. ‘{print $1}’`

if [[ $newone -gt 15 || $newfive -gt 15 || $newfifteen -gt 15 ]]
then
echo “High Load:\n$one, $five, $fifteen”
fi

Now since this script is running every 15 minutes for 24 hours, the page will have 96 entries per day. After a week you would have a table with 672 entries. After a month there would be 2688 to 2976 entries depending on the month. That’s a lot of data to be faced with.

So I decided that I would write another script that will archive the data at the end of the day. What this script does is copy the content of index.html to a file labeled with the date with an extension of .html. For example the data from Feb 09, 2006 would be called 20060209.html. I then add an entry to a table of contents page that adds a link to the newly created archive. After creating the new file it then clears index.html and recreates the above table.

The archive script is ran each night at 23:55:00 via cron. The script is as follows:


#!/bin/ksh

year=`date +%Y`
month=`date +%m`
day=`date +%d`

echo “$month/$day/$year Load\n

$month/$day/$year Load

\n“ > /home/haggerty/public_html/load/archive/$year$month$day.html

cat /home/haggerty/public_html/load/index.html >> /home/haggerty/public_html/load/archive/$year$month$day.html
echo “

  • $month/$day/$year
  • ” >> /home/haggerty/public_html/load/archive/index.html
    echo “Today’s Load on\n

    \n

    \n

    \n

    \n

    \n

    \n

    \n“ > /home/haggerty/public_html/load/index.html

    Time One Minute Average Five Minute Average Fifteen Minute Average

    I think that’s it. I’ve only had it up and running for about a day and a half now. I’ve already seen loads ranging from 0 to 189. I definitely will not be staying with this company after my contract is up.

    If you want to see the scripts in action you can see today’s loads at http://www.thehaggertys.net/load, archived loads are at http://www.thehaggertys.net/load/archive.


    Papers, Procrastination, and the Super Bowl |

    As I’m sure most of you know the Super Bowl is on February 5th. I’m taking two classes this semester, we meet on Monday and Tuesday nights. Both of my professors have assigned papers. One is due February 6th, the other on the 7th.

    I know what you’re thinking. I have plenty of time to work on it now and get it done before the Super Bowl. This works in theory. Just one small problem. I am the biggest procrastinator ever when it comes to school work. I really should buy this poster:
    procrastination.jpg

    So here’s my plan. Going to get one paper done this weekend. This gives me all next week and Saturday to get the other one done. I’ll keep you posted if this really happens.

    Go Seattle.


    I’m Still Around |

    Believe it or not I’m still alive and kicking. It’s been over 2 weeks since my last post. Anyway, I’ll try to keep up. So what’s new with me?

    As of January 1st, my job title at work changed to Senior System Administrator. Along with this came a hefty raise and an increase of vacation accrual rate. I now accrue 24 days of vacation a year.

    I have been pretty tied up at work ironing out problems with our WebCT Vista install and our F5 BigIP Load balancers. Again people didn’t test everything they should have when the systems were implemented so it meant a crisis situation for me. Got to love incompetence. I have one more problem to figure out this week and I should be done with this.

    It has been a great time to be a Mountaineer fan over the last couple weeks. WVU football won the Sugar Bowl. This is the first bowl win under Coach Rod. It’s also the first BCS win in school history. We ended the season with a #5 ranking. Slaton rushed for 1128 as a true freshman and White rushed for 952 as a red shirt freshman, I see a bright future in Morgantown. WVU Men’s Basketball is doing great too. We’re now ranked #16, and have beat two top 10 teams in the last 2 weeks, both on the road. We are on a 10 game winning streak, making our record 12-3, 4-0 in the Big East. This puts us in 1st place in the Big East. Yesterday WVU broke a school record and made 20 3 point shots (60 points!) in a single game. 8 of those came from Mike Gansey (tying a school record), he ended the night with a career best 33 points. Kevin Pittsnogle added 30 points, with 4 3’s. I think we’ll be around #12 when the new poll comes out this week. On a side note Pitt is one of the 3 teams in the nation that is still undefeated. They’re playing Louisville today and Louisville is up at the start of the 2nd half. Keep your fingers crossed that the Cards hand Pitt there first loss. Another side note is that 6 Big East teams are in the top 25.

    The weather in Morgantown has been crazy lately. I think we hit 70 degrees on Friday, then I woke up to snow on Saturday.

    I think that’s it for now. Stay tuned for my next post as to why best buy has made there way onto my walmart list.


    Christmas with the Haggerty’s & Bickford’s |

    Well Christmas has come and gone. Treah and I are in Vermont spending the holidays with my family.

    On Christmas Eve we went to the Inn at Essex for lunch. This was to celebrate Grampa and Grammy’s 55th wedding anniversary. We had so many people that they gave us our own room in the restaurant. Later we went to the late night church service. This was the first time I have been back to our church since our old minister retired. It was kind of strange to see some one else giving the sermon. The service was nice. Lots of music. Uncle Bill sang his traditional solo of Oh Holy Night. The men’s choir also sang a few songs. Most of the classic Christmas songs were covered either by the congregation or by one of the groups performing.

    After church we came home and opened presents with my parents and brother. This has become sort of a tradition to open presents from my immediate family at mid night when we get home from church. We’ve been doing it since we moved back to Vermont (about 5 or 6 years).

    Christmas morning Santa had come and dropped off our stockings. We got up and opened those. Mom and Treah made prime rib and the fixings for lunch. Then we went to my grand parent’s house for presents with the rest of the family and to eat Christmas dinner.

    I racked up some more great presents this week:

    • Remote starter for my jeep
    • Best Buy gift card
    • Napoleon Dynamite t-shirt
    • Drum sticks
    • The Office – Season 1 DVD (NBC version)
    • Clay poker chip set
    • Van Heusen coat
    • Quesadilla maker
    • Drunk Chicken Rack
    • 2 more disc golf discs
    • Movie theater gift card
    • Cash
    • A new hammer
    • Leatherman Micro

    I think that’s it. I’ll update the list if I forgot anything. Thanks to everyone for the great gifts.

    Tomorrow I’m going to be spending most of the day at my grand parent’s house. They want me to put in DSL, setup a small network, install a new hard drive, and teach them how to use there new digital camera. Treah is leaving tomorrow to spend a few days in NY visiting some family. I think that’s it. Sorry for such a long post.


    WordPress Upgrade |

    I am working on a WordPress upgrade. I don’t think it will take very long, but things may look a bit hairy until it is done.

    ***UPDATE***
    The Upgrade went flawless. I’m now running WordPress version 2.0. If you’re looking to upgrade I followed this guide:
    http://codex.wordpress.org/Upgrading_WordPress

    It probably took about 10 minutes to upgrade, including making all of my backups.


    Calendar
    October 2026
    S M T W T F S
    « Jan    
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
    Categories
    Archive

    .