[PHP] SLN - Server Load Notifier v1.0 - Opensource

Status
Not open for further replies.

l0calh0st

Active Member
4,052
2010
713
0
Hello, I've coded this small script to keep and eye out of my server :)

SLN - Server Load Notifier v1.0 - Coded by l0calh0st!
This script will notify your whenever your server load gets higher then $overmax value. Please ensure you have the following cronjob running:
"php /home/YOUR_USER_NAME/public_html/sln.php> /dev/null"
Without the quotes "", also don't forget to change YOUR_USER_NAME to the (cpanel) account username. 5 minutes interval should be fine.

PHP:
<?php
/*
SLN - Server Load Notifier v1.0 - Coded by l0calh0st!
This script will notify your whenever your server load gets higher then $overmax value. Please ensure you have the following cronjob running:
"php /home/YOUR_USER_NAME/public_html/sln.php> /dev/null"
Without the quotes "", also don't forget to change YOUR_USER_NAME to the (cpanel) account username.
*/

// Edit the configurations below:
$overmax = "5"; // Maximum server load to notify. If the server load gets higher then this value, you will get mail :P
$email = "your@email.com"; // Server admin email, this script will email to the following email.

// DO NOT EDIT BELOW - Get current server load without exec. Most webhosts have this option disable for security reasons.
$load=file_get_contents("/proc/loadavg");
$load=explode(' ',$load);
$loadnow=$load[0];

// Detect if the server load get higher then your value.
if ($loadnow >= $overmax ) {
// Ooh noes! server load got higher! Start spammin'
$sub = "SLN Overload Detected!";
$mess = "Hello,\n\nOverload has been detected by SLN scripts.\n\nThe load was: $loadnow";
mail($email, $sub, $mess);
}
else
{
// die...
}

?>

Again don't forget the cronjob!
"php /home/YOUR_USER_NAME/public_html/sln.php> /dev/null" without quotes. Doesn't matter which interval, 5minutes is okay.​
 
10 comments
Status
Not open for further replies.
Back
Top