[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cobalt-users] BUG CORRECTION !!! SECOND EDITION
- Subject: [cobalt-users] BUG CORRECTION !!! SECOND EDITION
- From: Marco Baurdoux <linux@xxxxxxxxxxxxx>
- Date: Wed Oct 17 10:28:57 2001
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
Sorry folks, this sounds like microsoft,
but the previous bug correction I sent for my script is even worse then my
first go at it.
So here is the final release of it, it does a bit more parsing so it should
work fine this time. If it doesn't...... you guys can pay me some vacantion
because it will mean that I definitely need them :-))
<?
/************************************************************************
* *
* Infomaniak Network SA *
* Traffic overload announcer *
* Marco Baurdoux *
* linux@xxxxxxxxxxxxx *
* 16.10.1977 *
* *
************************************************************************/
/************************************************************************
Main Configuration
************************************************************************/
$quota = "20"; //Put it in Gigabytes, ie 20 means 20 GB
$mail_address = "linux@xxxxxxxxxxxxx"; //Pretty straight forward
/************************************************************************
!!! DO NOT EDIT BELOW THIS LINE !!!
************************************************************************/
//Now lets convert the quota into bytes.
$limit = ($quota * 1000 * 1024);
//Now let us run throuh the websites that are hosted on my raq
//All I do is make a array out the webalizer.hist file and fetch
//the 5 entry from it, that correponds to the "kbytes" entry, because
//that's what I wanted to check.
$body = "Infomaniak Network SA\n";
$body .= "Traffic overload announcer\n";
$body .= "Written by : Marco Baurdoux\n";
$body .= "linux@xxxxxxxxxxxxx\n\n";
$body .= "********************************************\n";
$body .= "The transfer limit has been set to $quota GB\n";
$body .= "********************************************\n\n";
$body .= "Website\tLast month\tCurrent month\n\n";
if($handle = opendir("/home/sites"))
{
$dot = readdir($handle);
$dotdot = readdir($handle);
while($entry = readdir($handle))
{
if(is_link("/home/sites/$entry"))
{
//bande($entry);
if($webalizer =
@file("/home/sites/$entry/stats/webalizer.hist"))
{
$this_month = date("n");
$previous_month = $this_month -1;
for($r=0;$r<=count($webalizer);$r++)
{
if($line = explode(" ", $webalizer[$r]))
{
if($line[0] == $this_month)
{
$line0 = $line[5];
}
elseif($line[0] == $previous_month)
{
$line1 = $line[5];
}
}
}
if($line0 > $limit || $line1 > $limit)
{
$body .= $entry;
$body .= "\t";
$body .= $line1;
$body .= "\t";
$body .= $line0;
$body .= "\n";
}
}
}
}
if(mail($mail_address, "Sites overload for $SERVER_NAME", $body))
{
print "Youpi";
}
else
{
print "Merde";
}
}
?>
Enjoy !!!
=======================================================================
Marco Baurdoux
Unix Administrator
Infomaniak Network SA
Avenue de la Praille 26
1227 Carouge
Switzerland
Tel: +41 (0)22 820 35 41
Fax: +41 (0)22 820 35 46
http://web.infomaniak.ch
Linux/Unix is very user friendly,
it's just very picky about who its friends are !!!
=======================================================================