Posted on Wed 19th May 2010 · Development · 12 Comments
So since launch, I have been using Twitters @anywhere to handle user data, I quickly (on the first round of testing) noticed it was quite slow & also at times just didn't load. A few people also had the same problem, others suggested I ported to Facebook Connect.
Well after a successfull night of doing some house keeping on here, Facebook Connect is now live, I hope this also allows for more people to comment aswell.
Note: When posting comments or wall posts, the only data that i gather is your name & facebook user id, from the user id I can then link to your profile & use the Graph API to snatch your current profile picture. No other data is used, paulOr.net will NEVER post anything on your wall or anything else like that.
Showing Server Load As A Graph With PHP
Posted on Wed 19th May 2010 · Development · 0 Comments
Along side yesterdays blog post regarding Tweeting out your server status, there are more proactive ways of keeping an eye on whats happening. One of my favorites is showing the server load as a graph/progress bar thing.
Heres a demo of it working here.
Showing the server load alone is pretty nice, however with a little help from jQuery, we can make it bloody epic! - Showing it in real time.
index.php
load.php
<?php
preg_match('/([\d]+\.[\d]+), ([\d]+\.[\d]+), ([\d]+\.[\d]+)$/', exec('uptime'), $matches);
$total_width = 121;
list(,$status['one'],$status['five'],$status['fifteen'])=$matches;
foreach ($status as $k=>$int)
$status_i[$k]=(($int<0.25)?'green':(($int<0.75)?'orange':'red'));
?>
Current Load: <?=ceil($status['one']*100)?>%
Very simple, the results however are amazing :]
With thanks to Arkin aswell :]
Posted on Tue 18th May 2010 · Development · 1 Comments
One of my favorite things about Twitter is that its a complete snapshot of everything happen, all at once, in one place.
What better tool to use to monitor server loads and uptimes. I created a twitter account for all the servers I look after, its @EckoServers and once every two hours, it spits out information i can use to make sure everything on each server is working perfectly :)
<?php
## QUERY THE SERVER FOR SOME DETAILS
$uptime = system("uptime");
$apache = @fsockopen("localhost", 80, $errno, $errstr, 30);
$mysql = @fsockopen("localhost", 3306, $errno, $errstr, 30);
## GRAB THE STATS FROM $UPTIME
preg_match_all('/([\d]+) days.+load average: ([\d].[\d]+), ([\d].[\d]+), ([\d].[\d]+)/', $uptime, $load);
## PING APACHE
if($apache) {
$apache_status = 'Online';
} else {
$apache_status = 'Offline';
}
## PING MYSQL
if($mysql) {
$mysql_status = 'Online';
} else {
$mysql_status = 'Offline';
}
## OUTPUT
$status = 'Server Name: up '.$load[1][0].' days - Apache: '.$apache_status.' / MySQL: '.$mysql_status.' - Load: '.$load[2][0].', '.$load[3][0].', '.$load[4][0].'.';
## TWEET STATUS
$twitter = 'http://www.twitter.com/statuses/update.xml';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $twitter);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
curl_setopt($curl, CURLOPT_USERPWD, "twitter-username:twitter-password");
$result = curl_exec($curl);
$resultArray = curl_getinfo($curl);
curl_close($curl);
?>
Sadly, this version doesnt use OAuth or the new Out-Of-Band Authentification method (which is what i think i need to change it to for when they no longer allow basic auth after 30th June 2010).
All you need to do is register a new account on twitter, fill in your account name and password and then setup a cronjob to hit it however often you like. Not too often though, as twitter now filters tweets that are similar, I have mine spaced 10 minutes apart every two hours :)
Trixx: up 105 days - Apache: Online / MySQL: Online - Load: 0.04, 0.03, 0.00. #eckostatusless than a minute ago via API
BuiltByEcko Servers
EckoServers
Websites that i visit atleast once per day.
Posted on Fri 14th May 2010 · Web · 2 Comments
We all have our daily reads such as TechCrunch & Mashable but I'm more interested in those not-so-mainstream blogs that people visit each day - which are sometimes the best place to learn amazing things. Heres mine :]
1) TechCrunch // Tech news
2) GoodPHPTutorials // PHP tutorials
3) David Walsh // PHP, MooTools & jQuery tutorials
4) 9 Lessons // PHP & mainly jQuery tutorials
5) Nettuts // All manner of tutorials & walkthroughs
6) Forrst // Designer & Developers share network thingy
7) Gravity // Discussion forums, but like never before
8) Noupe // Tutorials
9) 9GAG // Everyday lol's
10) Reddit.com/r/php // PHP things :]
Those are mine, please share yours :)