Archive for October, 2006

PHP Script to monitor server uptime

Tuesday, October 31st, 2006

Recently at work I needed to create a script to check a server’s response time. This was for the purposes of tracking and graphing the response time (or lack of) of a server that was acting up when most people had better things to do. I also wanted to send out an E-Mail to my cell phone when the server went down.

responcegraph.png

A cursory look around the net indicated there was nothing I could directly grab and deploy, so I created my own script in PHP. This script can be run from the web or from the command line.

To use this script create another file and include this file with the absolute file name (absolute names are important on the command line).
Include example:
include(‘/var/www/html/monitor/server_monitor.php’);

You can then call the timer_check function.
This function takes following peramitors, you must set a URL, all other peramitors are optional.

  • url: ie ‘http://news.google.ca’
  • time limit: default is 10 seconds
  • E-Mail Address: If it takes longer than the time limit who do we call? This should be an array.
  • Should we print anything to the screen, or just send E-Mail if ther’s a problem? true/false
  • Maximum attempts: By default this script makes 10 attemps in a row and averages the results, you can set it to one 1 or even 100

Example of a script that might be called google.php:

〈?PHP
include('/var/www/html/monitor/server_monitor.php');
$url = 'http://google.ca/';
$email = array('[email protected]','[email protected]);
timer_check ($url,10,$email); ?>

If you wanted to make this a cron job (scheduled task under Linux/OSX) here’s two examples that run every 10 minutes.
These examples keep a log file called server_uptime that can be imported into something like MS Excel and graphed:

Man Arrested for Criticizing Dick Cheney

Monday, October 30th, 2006

Steven Howards, like many of us, is outraged with the Iraq war, and knew exactly what he wanted to tell the president and vice president. He got his chance when Dick Cheney made an unscheduled appearance at his local mall. Apparently the current republican administration’s reputation for an unwillingness to accept criticism with well earned: Howards was arrested.
Read more in the Rocky Mountain News article, Man files suit over Cheney encounter.

Howards was arrested for assault and hauled off and as he was hauled-off he pointed out that they had left his son there at the mall alone. The secret service agents callously replied “we’ll call social services”. Fortunately they passed Steven’s wife on the way out of the mall to lock him up. The charge was then lowered from assault to harassment, and finally dropped.

In a suit filed Howards recently filed he claims that he was arrested in retaliation for having exercised his First Amendment right of free speech, and that his arrest also violated his Fourth Amendment protection against unlawful arrest.

Mr. Cheney appears to be rather confused about these issues, he’s spoken some of the rare items of truth one shouldn’t legally speak (outing an undercover CIA agent) and he’s shot someone. One man complains to him about the death tolls in Iraq and he has him arrested.

I hope that Howards wins, freedom of speech is upheld, and I hope that this isn’t the last we hear of this!

St. Catharines

Saturday, October 28th, 2006

I’ve always said living here was like a prison sentence.  Apparently the U.S. justice system agrees.  As an extra-territorial detention location that puts St. Catharines in the same category as Guantanamo Bay. (Sex offender could serve term in U.S., The Toronto Star).

Supporting a fellow blogger: Garth Turner

Thursday, October 19th, 2006

I’ve always thought Garth Turner was a decent guy. If he had won any of the PC (Conservative) party leadership contests he had run for the PC party would have been a better stronger party than it is now. He’s always spoke his mind, he gets the Internet, and has a sensible stance on gays and gay marriage and the environment. It was all of those tenancies that made him an anomaly in the modern Conservative party, and ultimately what got him kicked out.

Fall - Rattlesnake PointThe speculation is that his recent blog postings about today’s environmental strategy/clean air act and his scepticism about Environment Minister Rona Ambrose and praise for new Green Party leader Elizabeth May. I don’t think anyone can suggest that loosening target emissions restrictions and moving the target date to 2050 from Kyoto’s 2012 is an improvement.
Many Ontario MPs were not happy with what he was saying on his blog, and I’m sure all those old western Reformers who been read the riot act about speaking out and straying from the party line were not at all happy with this former PC Ontario MP who was getting away with straying from the party line.
For the moment Turner is kicked out of the Conservative caucus, but I don’t think that will last long. The Green party is actually a pretty conservative party, in fact if you’re a leftie and want to vote with the environment as your primary issue I’d recommend the Marijuana’s part (they’re on a roll) over the Greens. But for Turner its a great fit.

Ultimately, in kicking Turner out he might have gone from being just another back-bencher to the first sitting Green MP in Canada (to the best of my knowledge) — and I think he’d love to have that distinction, it’d be the closest to leader of a party he’s ever been.

The Hour

Monday, October 9th, 2006

George Stroumboulopoulos, The Hour

George Stroumboulopoulos started his third season of “The Hour” on the main CBC network this evening, and since Google seems to direct people to my blog for George Stroumboulopoulos info I feel I have to comment.

The show seems tight, and looks good. It still moves quickly and is very self-aware. George continues to demonstrate why he’s been drafted into so many media organizations in his young career and why he’s moved more and more towards current events. George is still willing to ask tough questions and make tough jokes in front of Belinda Stronch and other guests. He was even was wiling to make fun of the Leafs in front of Wade Belak.

The Hour looks like it’s going to be even better this year…. except it’s on at 11:00PM against the Daily Show and The Colbert Report, so I’ll only see what goes on during their commercials.