After finishing the first version of content-check, I thought about a few additional features I wanted to add. One feature was the ability to include arbitrary HTTP headers in requests, and a second feature was the ability to selectively generate email, syslog entries or logfiles entries per site. After pondering the best way to add these capabilities, I decided to rewrite content-check in Perl. The new version works similarly to the old version, but the structure of the configuration file is different.
The configuration file now contains one or more configuration stanzas, and each configuration stanza contains a site definition. Each site definitions starts with a description enclosed in brackets, followed by one or more key-value pairs. Here is the site definition file I use to monitor prefetch.net:
$ cat sites.cfg
# Monitor static content
[site pair_static]
url = http://prefetch.net/index.html
checksum = 955abe0f861480103b59f464d6037b3febd6c89c
header = "Host: prefetch.net"
logfile = /var/log/content-check/pair
syslog = yes
email = sysadmin@prefetch.net
# Monitor the PHP engine / MySQL Database
[site pair_dynamic]
url = http://prefetch.net/test.php
checksum = 0e61ac076628741cfc4d4828b1cc905e5e6e86b9
header = "Host: prefetch.net"
logfile = /var/log/content-check/pair
syslog = yes
email = sysadmin@prefetch.net
To generate the checksum for a specific URL, you can run content-check.pl with the “-g” option:
$ content-check.pl -g http://prefetch.net/index.html
Checksum for http://prefetch.net/index.html is:
955abe0f861480103b59f464d6037b3febd6c89c
Once the configuration file is created, content-check.pl can be run with the “-c” option, and the name of the configuraiton file:
$ content-check.pl -c sites.cfg
If the script locates a site that fails to checksum to the stored checksum, it will send an email, generate a syslog entry, or create a generic logfile entry similar to the following:
Content-check detected a problem with http://prefetch.net/index.html:
Site definition: prefetch_static
Date: Sun Dec 17 21:40:03T2006:00-04:00
URL: http://prefetch.net/index.html
Precomputed checksum: 955abe0f861480103b59f464d6037b3febd6c89c
Current checksum: da39a3ee5e6b4b0d3255bfef95601890afd80709
I find this script useful for monitoring the web infrastructure I support, and the new version was fun to write (this was the first time I mucked with Perl references). Shibby!
In one of my previous posts, I discussed how to add a disk to a ZFS pool. One thing I failed to mention was the fact that adding a device in this manner creates a second stripe in the pool, which adds no redundancy (in that specific example, I was using hardware RAID). Instead of using the zfs “add” command to add a second stripe to the pool, I could have instead used the “attach” option to create a two way mirror from the existing device:
$ zpool attach system c1d0s0 c2d0s0
The attach operation will cause a new top level “mirror” vdev (virtual device) to be created, and both devices will then be associated with that vdev. Once the attach completes, the first device will be synced to the second device. You can monitor the synchronization progress with the zpool utility:
$ zpool status -v
pool: system
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress, 3.13% done, 0h15m to go
config:
NAME STATE READ WRITE CKSUM
system ONLINE 0 0 0
mirror ONLINE 0 0 0
c1d0s0 ONLINE 0 0 0
c2d0s0 ONLINE 0 0 0
The more I work with ZFS, the more I dig it!
I have been trying to locate a high quality hosting provider now for 3-months, and my first two attempts have failed miserably. Dreamhost had cool features and great support, but their infrastructure was not very realiable. 1and1 also had some useful features, but their support was horrible (I was getting 500 internal server error messages for 1/2 a day, and when they finally answered my ticket 24-hours later, they closed it saying my site was working fine.), and their infrastructure was less reliable than Dreamhost. Since I wanted my site to be up and operational 99% of the time, I decided I needed to do some research to find a reliable and trustworthy hosting provider.
My reserach took me to two web sites. The first site was hostsearch, which allows you to view reliability ratings and peoples feedback for numerous hosting providers. Their site is located here:
The second site I used was hostingtalk. Hostingtalk is a large online forum for people to discuss hosting providers, and their searching capabilities are great for viewing the problems people had with a given provider. There site is located here:
After reading numerous reviews and talking to people about the providers I was thinking about using, I finally decided on Pair Networks. Here are the reasons I chose to go with them:
1. Reliability is the the most important thing at Pair Networks, and hopefully this will show over time (I can’t vouch for this yet, but will update this post once I know more).
2. Pair Networks provides problem and maintenance notifications by email.
3. The Pair Networks support staff seem to be extremely competent, and have been able to answer all of my questions so far.
4. The server prefetch.net is hosted on runs FreeBSD, which has a long track record for being extremely efficient and stable.
5. I have ssh access to the server my site is hosted on, so I can login and adjust content on the fly.
My “Advanced” hosting plan does have a few drawbacks. The plan costs $8 more per month than the other two providers, and provides considerably less bandwidth and disk storage. Luckily I don’t need 80GB of transfer or more than 1.5GB of disk space, so this isn’t an issue for me. Hopefully (fingers crossed) this provider pans out!
In a previous post, I described how to get the date for a day in the past. This method unfortunately doesn’t work on FreeBSD hosts, since FreeBSD doesn’t come with the GNU date utility. As an alternative to GNU date, you can pass a time value to the date utilities “-v” option to print a date in the past:
$ date -v-2d
Mon Jan 1 13:02:57 EST 2007
I think I prefer the GNU date syntax, but this seems to work pretty well.
I have had nothing but problems with 1and1 as a shared hosting provider, so I decided to switch providers yet again. Hopefully the third time is the charm, and my new provider (Pair Networks) will be more reliable! Let me know if you experience any issues!