From: Michael Gale <michael.gale@utilitran.com>
To: Marek Dohojda <mdohojda@cisco.com>, netfilter@lists.netfilter.org
Subject: Re: bandwidth monitoring
Date: Thu, 06 Jan 2005 14:24:15 -0700 [thread overview]
Message-ID: <41DDAC7F.5050004@utilitran.com> (raw)
In-Reply-To: <41DDA135.5000205@cisco.com>
No problem ...
I just checked and actually I am using two scripts.
The first script:
--snip-- runntop -- executed by cron.
#!/bin/bash
/usr/bin/curl -k -s -s --digest -u ntopUP:ntopUP
https://mis.utilitran.com/uploadscripts/ntopget.php > /dev/null
if [ "$?" == "0" ]; then
echo "File loaded" >> /dev/null
else
~/email "Error with NTOP update" netops@utilitran.com < /dev/null
fi
sleep 5
/usr/bin/curl --basic -u admin:ntopadmin
http://ntop.utilitran.com:3000/ntop/resetStats.html
if [ "$?" == "0" ]; then
echo "File loaded" >> /dev/null
else
~/email "Error with NTOP reset" netops@utilitran.com < /dev/null
fi
--snip--
The first script makes a http request to a php web page that display no
data. Then once that is successful it makes a http connections to ntop
and resets the stats.
The second script ... that the first script calls, uses curl to make a
http connection to the ntop server, download the stats and store them in
a database. The scripts are kind of messy ... really my first attempt.
You may notice that data_total is not being used .. that is because I am
working on storing the total amounts somewhere .. but that is not done.
The second script:
--snip-- ntopget.php -- executed by http request
<?php
//
// The PHP curl module supports the received page to be returned in a
variable
// if told.
//
$dat=date('m:d:y-U');
$startphp="<?php\n";
$endphp="?>";
echo 'Preparing to download file<BR>';
$fp = fopen('/home/mis/htdocs/datafiles/ntop/data/' . $dat, 'w');
fwrite($fp,$startphp,strlen($startphp));
fclose($fp);
$fp = fopen('/home/mis/htdocs/datafiles/ntop/data/' . $dat, 'a');
$ch =
curl_init("http://ntop.utilitran.com:3000/ntop/dumpData.html?language=php&view=long");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$fp = fopen('/home/mis/htdocs/datafiles/ntop/data/' . $dat, 'a');
fwrite($fp,$endphp,strlen($endphp));
fclose($fp);
echo 'Done downloading file<BR>';
include '/home/mis/htdocs/datafiles/ntop/data/' . $dat;
// Start of using array
$db = mysql_connect("127.0.0.1", "ntop", "ntop") or
die("Error ... check with network team");
mysql_select_db("ntop",$db);
foreach ($ntopHash as $key => $value) {
$addme = strpos($key,"192.168.7");
$data = array();
if ( $addme !== FALSE )
{
array_push($data,$key);
array_push($data,$ntopHash[$key]['hostResolvedName']);
array_push($data,$dat);
array_push($data,$ntopHash[$key]['ethAddressString']);
array_push($data,$ntopHash[$key]['firstSeen']);
array_push($data,$ntopHash[$key]['lastSeen']);
array_push($data,$ntopHash[$key]['averageRcvdThpt']);
array_push($data,$ntopHash[$key]['averageSentThpt']);
array_push($data,$ntopHash[$key]['averageTThpt']);
array_push($data,$ntopHash[$key]['icmpSent']);
array_push($data,$ntopHash[$key]['icmpRcvd']);
array_push($data,$ntopHash[$key]['IP']['FTP']['sendLoc']);
array_push($data,$ntopHash[$key]['IP']['FTP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['FTP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['FTP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['HTTP']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['HTTP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['HTTP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['HTTP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['DIFFHTTP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['RDP']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['RDP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['RDP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['RDP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['DNS']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['DNS']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['DNS']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['DNS']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['Mail']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['Mail']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['Mail']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['Mail']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['DHCP-BOOTP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['SNMP']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['SNMP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['SNMP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['SNMP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['NNTP']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['NNTP']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['NNTP']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['NNTP']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['SSH']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['SSH']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['SSH']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['SSH']['rcvdFromRem']);
array_push($data,$ntopHash[$key]['IP']['Messenger']['sentLoc']);
array_push($data,$ntopHash[$key]['IP']['Messenger']['rcvdLoc']);
array_push($data,$ntopHash[$key]['IP']['Messenger']['sentRem']);
array_push($data,$ntopHash[$key]['IP']['Messenger']['rcvdFromRem']);
foreach ( $data as $key => $value ) {
$data_table = $data_table . '\'' . $value . '\',';
}
for ($i=0;$i<6;$i++) {
$data_total = $data_total . '\'' . $data_table[$i] . '\',';
}
$data_table = substr($data_table,0,(strlen($data_table)-1));
$data_total = substr($data_total,0,(strlen($data_total)-1));
// Here we upload the data into the daily table
$sql = "INSERT INTO ntop_daily VALUES ($data_table)";
$result = mysql_query($sql) or die("Error ..... check
with network team " . mysql_error());
if ( $result === FALSE )
{
exec('/home/mis/email "NTOP Nightly Update FAILED" "The
NTOP nightly update failed" \&/> /dev/null');
}
}
unset($data_table);
unset($data_total);
unset($data);
unset($result);
}
mysql_close($db);
?>
--snip--
Marek Dohojda wrote:
> Can I see that script?
>
>
>
>
>
> ---
> 01001101011000010111001001100101011010110010000001000100010011110110100001101111011010100110010001100001
>
>
> Michael Gale wrote:
>
>> Hello,
>>
>> To run NTOP permanitly you just have to clear the stats nightly. I
>> have a php script that makes a HTTP connection, downloads the stats
>> from NTOP and saves them in a mysql database. It then makes another
>> connection and tells NTOP to reset the stats.
>>
>> That keeps the memory and CPU usage low ... so you could run it
>> continuously.
>>
>> Michael.
>>
>>
>> patrick.leduc@novipro.com wrote:
>>
>>> Hello
>>>
>>> Does somebody know a program for monitoring bandwidth by ip? I have
>>> one internet interface and I must monitor many ips adresses on this
>>> interface. I tried Ipac-ng and, I worked a lot to do this config but
>>> it seems not working this way.
>>>
>>> thanx
>>>
>>
--
Michael Gale
Lan Administrator
Utilitran Corp.
I make better friends with those who think for them selves
next prev parent reply other threads:[~2005-01-06 21:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-06 16:28 bandwidth monitoring patrick.leduc
2005-01-06 17:09 ` J. Nerius
2005-01-06 17:42 ` Les Mikesell
2005-01-06 17:56 ` J. Nerius
2005-01-06 20:09 ` Michael Gale
2005-01-06 20:19 ` J. Nerius
2005-01-06 21:28 ` Michael Gale
2005-01-06 21:54 ` J. Nerius
2005-01-06 23:30 ` Michael Gale
[not found] ` <41DDA135.5000205@cisco.com>
2005-01-06 21:24 ` Michael Gale [this message]
2005-01-07 1:54 ` Mark E. Donaldson
2005-01-10 13:45 ` Fabiano Reis
2005-01-26 18:33 ` Ranjeet Shetye
2005-01-26 20:00 ` Jose Maria Lopez
2005-01-28 5:21 ` monitoring Alireza Yazdani
2005-01-28 12:23 ` monitoring Radien Radien
-- strict thread matches above, loose matches on Subject: below --
2012-10-29 0:44 Bandwidth monitoring David H. Lynch Jr.
2012-10-29 11:46 ` Christian Lamparter
2012-10-28 15:37 David H. Lynch Jr.
2012-10-28 20:59 ` Christian Lamparter
2012-10-23 18:58 David H. Lynch Jr.
2012-10-24 6:35 ` Christian Lamparter
2012-10-21 19:58 David H. Lynch Jr.
2012-10-22 10:43 ` Christian Lamparter
2005-01-07 5:48 bandwidth monitoring Patrich Björklund
2005-01-06 20:28 Daniel Chemko
2005-01-06 19:04 Daniel Chemko
2005-01-06 19:39 ` Les Mikesell
[not found] <04a901c36e18$ad2d6650$2a0110ac@SAMHP>
2003-08-31 1:03 ` Bandwidth Monitoring Arnt Karlsen
2003-09-01 7:33 ` Ray Leach
2003-09-04 6:34 ` Dharmendra.T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41DDAC7F.5050004@utilitran.com \
--to=michael.gale@utilitran.com \
--cc=mdohojda@cisco.com \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.