We want to monitor our users traffic (http, ftp , email) usage. We want to get figures about how many mb or gb a specific users uses... What 's the best easiest way to do this? Perhaps a bash script or command or tool ??? Who can point me in the good direction...
http://awstats.sourceforge.net/ with it you can monitor ftp,http,mail just sort out how your log files are wrtiten
I know that awstats shows these statistics. But I want to gather some of these statistics for check how many traffic a client uses. So i can mail them a warning if they approach their max traffic usage or i can show their total usage in a small personel cpanel. Something like their quota but then for their traffic usage.
For me the was it simple to write a little php script that checks thing and notify the custumers. but i don't know if you have php experiance if so i'll give you some scripts if not i cant help you anymore with this then.
I know my why around in PHP I'm a web developper. But i don't know how or where to get the traffic counting data and how to monitor it? How does it get monitored? So if you like, you may send me the scripts, i will have a look at them. Thnx 4 the help so far already ColdDoT
I'm rebulding plesk only then in php only, with some cool featers (home made) so i had to make a awstats parser (it can be done trough regulair expresions) but with a parser is it a lot easyer. PHP: <? //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Sections~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //GENERAL # see below //MISC # Misc ID" => "Pages" => "Hits" => "Bandwidth //TIME # Hour" => "Pages" => "Hits" => "Bandwidth" => "Not viewed Pages" => "Not viewed Hits" => "Not viewed Bandwidth //VISITOR # Host" => "Pages" => "Hits" => "Bandwidth" => "Last visit date" => "[Start date of last visit]" => "[Last page of last visit] //DAY # Date" => "Pages" => "Hits" => "Bandwidth" => "Visits //DOMAIN # Domain" => "Pages" => "Hits" => "Bandwidth //ROBOT # Robot ID" => "Hits" => "Bandwidth" => "Last visit" => "Hits on robots.txt //SESSION # Session range" => "Number of visits //SIDER # URL" => "Pages" => "Bandwidth" => "Entry" => "Exit //FILETYPES # Files type" => "Hits" => "Bandwidth" => "Bandwidth without compression" => "Bandwidth after compression //OS # OS ID" => "Hits //BROWSER # Browser ID" => "Hits //UNKNOWNREFERER # Unknown referer OS" => "Last visit date //UNKNOWNREFERERBROWSER # Unknown referer Browser" => "Last visit date //ORIGIN # Origin" => "Pages" => "Hits //PAGEREFS # External page referers" => "Pages" => "Hits //ERRORS # Errors" => "Hits" => "Bandwidth //SIDER_404 # URL with 404 errors" => "Hits" => "Last URL referer //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Sections~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GENERAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// # LastLine = Date of last record processed" => "Last record line number in last log" => "Last record offset in last log" => "Last record signature value # FirstTime = Date of first visit for history file # LastTime = Date of last visit for history file # LastUpdate = Date of last update" => "Nb of parsed records" => "Nb of parsed old records" => "Nb of parsed new records" => "Nb of parsed corrupted- Nb of parsed dropped # TotalVisits = Number of visits # TotalUnique = Number of unique visitors # MonthHostsKnown = Number of hosts known # MonthHostsUnKnown = Number of hosts unknown //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GENERAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// //USER CONFIG $awstat_path = "/var/lib/awstats"; $config_domain = "www.colddot.nl"; //NAME CHANGERS $os_array = array( "winxp" => "Windows XP", "winxbox" => "Xbox", "winnt" => "Windows NT", "winme" => "Windows ME", "winlong" => "Windows Longhorn", "wince" => "Windows CE", "win" => "Windows", "win2003" => "Windows 2003", "win2000" => "Windows 2000", "win98" => "Windows 98", "win95" => "Windows 95", "win16" => "Windows 16", "webtv" => "Web TV", "sunos" => "Sun OS", "psp" => "Playstation portable", "openbsd" => "Open BSD", "netbsd" => "Net BSD", "macosx" => "Mac OS X", "macintosh" => "Mac Intosh", "linuxubuntu" => "Ubuntu", "linuxsuse" => "SuSe", "linuxredhat" => "Red Hat", "linuxmandr" => "Mandrake", "linuxfedora" => "Fedora", "linuxdebian" => "Debian", "linuxcentos" => "Centos", "kfreebsd" => "kFree BSD", "freebsd" => "Free BSD", "bsdopenbsd" => "BSD Open BSD", "bsdnetbsd" => "BSD Net BSD", "bsdfreebsd" => "BSD Free BSD" ); $bot_array = array( "googlebot" => "http://www.google.com/bot.html", "msnbot" => "http://search.msn.com/msnbot.htm", "slurp" => "http://help.yahoo.com/help/us/ysearch/slurp/", "girafabot" => "http://www.girafa.com/", "msiecrawler" => "http://msdn.microsoft.com/workshop/delivery/offline/linkrel.asp", "mj12bot" => "http://majestic12.co.uk/bot.php", "jeeves" => "http://sp.ask.com/docs/about/tech_crawling.html", ); $error_array = array( "0" => "Onvolledig/Niet gedefinieerd", "201" => "Angemaakt", "202" => "Geaccepteerd", "204" => "Geen inhoud", "206" => "Gedeeltelijke inhoud", "301" => "Permanent verplaatst", "302" => "Verwijzen", "304" => "Niet veranderd", "400" => "Verkeerd syntax", "401" => "Niet geautoriseerd", "402" => "Niet in gebruik", "403" => "Verboden", "404" => "Bestand niet gevonden", "405" => "Methode niet toegestaan", "406" => "Niet acceptabel", "407" => "Proxy-autorisatie vereist", "408" => "Timeout voor dit verzoek", "500" => "Interne Server Fout", "501" => "Niet geimplemeteerd", "502" => "Server Overbelast", "503" => "Gateway Timeout", ); //SCRIPT CONFIG if(isset($_GET["config"])){ $config_domain = $_GET["config"]; $config_link = "?config=www.".$_GET["config"]; } //READ CONFIG $awstats_text = file_get_contents($awstat_path."/awstats".date("mY").".".$config_domain.".txt"); //FUNCTIONS function os($name){ global $os_array; $array = array_flip($os_array); if(in_array($name,$array)){ return $os_array[$name]; }else{ return ucfirst($name); } } function file_size($size,$wat = true) { $bytes = array("B", "KB", "MB", "GB", "TB", "PB"); $i = 0; while ($size >= 1024) { $size = $size/1024; $i++; } if ($i > 1) { if($wat == true){$extra = " ".$bytes[$i];}else{$extra = NULL;} return round($size,2).$extra; } else { if($wat == true){$extra = " ".$bytes[$i];}else{$extra = NULL;} return round($size,0).$extra; } } function bot($name){ global $bot_array; $array = array_flip($bot_array); if(in_array($name,$array)){ return "<a href=\"".$bot_array[$name]."\">".ucfirst($name)."</a>"; }else{ return ucfirst($name); } } function read_section($section) { global $awstats_text; if (preg_match('/\nBEGIN_'.$section.' \d+\n(.*)\nEND_'.$section.'\n/s', $awstats_text, $match)) { foreach (explode("\n", $match[1]) as $row) $lines[] = split(' ', trim($row)); } return $lines; } if (!function_exists('is_even')) { function is_even($getal){ $iNum = ($getal / 2); $aNum = explode('.', $iNum); if($aNum[1] == 5){ return FALSE; }else{ return TRUE; } } } function procent($hits,$tot_hits){ $deel = $hits / $tot_hits; return round($deel * 100,1); } ?> I think if you been a webdeveloper you know your way around with this pice of code good luck with it (if you don't suceed post here then i will make it) Greets ColdDoT
It studied it and it's do-able We are also building our own plesk a-like cpanel but not that advanced. Just to do our basics on our basic linux system. What method do you use for executing the commands in PHP? Sudo method? SSH2? or other?
But the default php functions exec() and system() are too limited for let's say making accounts... plus another minor is that al the commands are executed as APACHE user and not as a system user. That's why installed the SSH2 module for PHP, this makes it possible to login as a system user with a specific user through PHP. it's something like an ssh client through php.