Mailing List Archive

Total bytes per IP for accounting on ntopng
Hi,

I'd like to collect of clients downloaded data per IP every day so I'll
integrate it for home made quota management per IP.

How can I get the data of total bytes from an API or cli from ntopng?

thanks.

--
*Umut Arus*

Information Technology
Sabanc? University
Re: Total bytes per IP for accounting on ntopng [ In reply to ]
Hi,

Currently ntopng does not export such daily information via an API. Feel
free to open a feature request on github https://github.com/ntop/ntopng
for an API request.

As an alternative, if you have MySQL support enabled (see -F option),
you could perform manual MySQL aggregations from the database.

Another alternative is to read data from the RRD files which ntopng
creates every 5 minute for local hosts (see -m option for defining local
networks). In this case, you could read the statistics of the host
192.168.1.1 with the command "rrdtool fetch
/var/tmp/ntopng/0/rrd/192/168/1/1/bytes.rrd AVERAGE -s now-1d". The
first column of the output contains the downloaded host traffic, while
the second the uploaded traffic.

This approach has the following implications:

- data is actually an average of the host traffic in 5 minutes, not the
actual traffic

- data is not aggregated, you will need to sum up the rows values to get
the total

- you will need to multiply the row value by 300, since values are derivates

See https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html for more details.

Regards,
Emanuele


On 05/07/2017 01:21 PM, Umut Arus wrote:
> Hi,
>
> I'd like to collect of clients downloaded data per IP every day so
> I'll integrate it for home made quota management per IP.
>
> How can I get the data of total bytes from an API or cli from ntopng?
>
> thanks.
>
> --
> *Umut Arus*
> *
> *
> Information Technology
> Sabanc? University
>
>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop
Re: Total bytes per IP for accounting on ntopng [ In reply to ]
Hello Emanuele,

Thanks for your reply I have tried to store mysql data. But I have
collected huge amount of 250.000 rows with about 10.000 clients in only
five minutes. In this case, it wouldn't be practical.

If you can help about summarize the data inside "redis" of ntopng it'll be
better...

thanks.



On Mon, May 8, 2017 at 4:04 PM, Emanuele Faranda <faranda@ntop.org> wrote:

> Hi,
>
> Currently ntopng does not export such daily information via an API. Feel
> free to open a feature request on github https://github.com/ntop/ntopng
> for an API request.
>
> As an alternative, if you have MySQL support enabled (see -F option), you
> could perform manual MySQL aggregations from the database.
>
> Another alternative is to read data from the RRD files which ntopng
> creates every 5 minute for local hosts (see -m option for defining local
> networks). In this case, you could read the statistics of the host
> 192.168.1.1 with the command "rrdtool fetch /var/tmp/ntopng/0/rrd/192/168/1/1/bytes.rrd
> AVERAGE -s now-1d". The first column of the output contains the downloaded
> host traffic, while the second the uploaded traffic.
>
> This approach has the following implications:
>
> - data is actually an average of the host traffic in 5 minutes, not the
> actual traffic
>
> - data is not aggregated, you will need to sum up the rows values to get
> the total
>
> - you will need to multiply the row value by 300, since values are
> derivates
>
> See https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html for more details.
>
> Regards,
> Emanuele
>
>
> On 05/07/2017 01:21 PM, Umut Arus wrote:
>
> Hi,
>
> I'd like to collect of clients downloaded data per IP every day so I'll
> integrate it for home made quota management per IP.
>
> How can I get the data of total bytes from an API or cli from ntopng?
>
> thanks.
>
> --
> *Umut Arus*
>
> Information Technology
> Sabanc? University
>
>
>
>
> _______________________________________________
> Ntop mailing listNtop@listgateway.unipi.ithttp://listgateway.unipi.it/mailman/listinfo/ntop
>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop
>



--
*Umut Arus*
System Specialist
Information Technology
Sabanc? University

Phone: +90216 483 9172
Re: Total bytes per IP for accounting on ntopng [ In reply to ]
Hi Umut,

The proper way to do this would be via an API to ntopng, but we are in
the process of releasing the next stable version so new features must wait.

What you can do right now is quering ntopng for an host stats like this:

curl --cookie "user=admin; password=your_password"
"http://127.0.0.1:3000/lua/do_export_data.lua?ifid=0&ip=192.168.1.1"

It will return a JSON with "rcvd.bytes" but it does not reset daily.

An alternative is to setup a global alert threshold on traffic for your
local hosts, so that after the threshold is crossed by any local host,
an alert is generated and stored to the "closed_alerts" table of the
SQLite database "/var/tmp/ntopng/0/alerts/alerts_v5.db". You can setup
this from any local host details page, through the icon with the
esclamation mark. You can then filter that database to see if the host
has exceeded the quota and take an action.

This is very complex for a really simple task, but again please wait we
complete the next release and then we will expose an api for this.

Emanuele


On 05/08/2017 08:52 PM, Umut Arus wrote:
> Hello Emanuele,
>
> Thanks for your reply I have tried to store mysql data. But I have
> collected huge amount of 250.000 rows with about 10.000 clients in
> only five minutes. In this case, it wouldn't be practical.
>
> If you can help about summarize the data inside "redis" of ntopng
> it'll be better...
>
> thanks.
>
>
>
> On Mon, May 8, 2017 at 4:04 PM, Emanuele Faranda <faranda@ntop.org
> <mailto:faranda@ntop.org>> wrote:
>
> Hi,
>
> Currently ntopng does not export such daily information via an
> API. Feel free to open a feature request on github
> https://github.com/ntop/ntopng for an API request.
>
> As an alternative, if you have MySQL support enabled (see -F
> option), you could perform manual MySQL aggregations from the
> database.
>
> Another alternative is to read data from the RRD files which
> ntopng creates every 5 minute for local hosts (see -m option for
> defining local networks). In this case, you could read the
> statistics of the host 192.168.1.1 with the command "rrdtool fetch
> /var/tmp/ntopng/0/rrd/192/168/1/1/bytes.rrd AVERAGE -s now-1d".
> The first column of the output contains the downloaded host
> traffic, while the second the uploaded traffic.
>
> This approach has the following implications:
>
> - data is actually an average of the host traffic in 5 minutes,
> not the actual traffic
>
> - data is not aggregated, you will need to sum up the rows values
> to get the total
>
> - you will need to multiply the row value by 300, since values are
> derivates
>
> See https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html
> <https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html> for more details.
>
> Regards,
> Emanuele
>
>
> On 05/07/2017 01:21 PM, Umut Arus wrote:
>> Hi,
>>
>> I'd like to collect of clients downloaded data per IP every day
>> so I'll integrate it for home made quota management per IP.
>>
>> How can I get the data of total bytes from an API or cli from ntopng?
>>
>> thanks.
>>
>> --
>> *Umut Arus*
>> *
>> *
>> Information Technology
>> Sabanc? University
>>
>>
>>
>>
>> _______________________________________________
>> Ntop mailing list
>> Ntop@listgateway.unipi.it <mailto:Ntop@listgateway.unipi.it>
>> http://listgateway.unipi.it/mailman/listinfo/ntop
>> <http://listgateway.unipi.it/mailman/listinfo/ntop>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it <mailto:Ntop@listgateway.unipi.it>
> http://listgateway.unipi.it/mailman/listinfo/ntop
> <http://listgateway.unipi.it/mailman/listinfo/ntop>
>
>
>
>
> --
> *Umut Arus*
> System Specialist
> Information Technology
> Sabanc? University
> Phone: +90216 483 9172
>
>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop
Re: Total bytes per IP for accounting on ntopng [ In reply to ]
Hi,

I'm trying to get "all IP's data". It works on browser successfully but not
works by curl.

Have you any hint why it is?

http://10.10.10.10:3000/lua/do_export_data.lua?csrf=59390245f24646cdaa24287733f15d74&hostIP=&hostVlan=

curl --cookie "user=admin; password=xxxxx" "
http://10.10.10.10:3000/lua/export_data.lua?ifid=0&ip="

thanks.


On Tue, May 9, 2017 at 12:24 PM, Emanuele Faranda <faranda@ntop.org> wrote:

> Hi Umut,
>
> The proper way to do this would be via an API to ntopng, but we are in the
> process of releasing the next stable version so new features must wait.
>
> What you can do right now is quering ntopng for an host stats like this:
>
> curl --cookie "user=admin; password=your_password"
> "http://127.0.0.1:3000/lua/do_export_data.lua?ifid=0&ip=192.168.1.1"
> <http://127.0.0.1:3000/lua/do_export_data.lua?ifid=0&ip=192.168.1.1>
>
> It will return a JSON with "rcvd.bytes" but it does not reset daily.
>
> An alternative is to setup a global alert threshold on traffic for your
> local hosts, so that after the threshold is crossed by any local host, an
> alert is generated and stored to the "closed_alerts" table of the SQLite
> database "/var/tmp/ntopng/0/alerts/alerts_v5.db". You can setup this from
> any local host details page, through the icon with the esclamation mark.
> You can then filter that database to see if the host has exceeded the quota
> and take an action.
>
> This is very complex for a really simple task, but again please wait we
> complete the next release and then we will expose an api for this.
>
> Emanuele
>
> On 05/08/2017 08:52 PM, Umut Arus wrote:
>
> Hello Emanuele,
>
> Thanks for your reply I have tried to store mysql data. But I have
> collected huge amount of 250.000 rows with about 10.000 clients in only
> five minutes. In this case, it wouldn't be practical.
>
> If you can help about summarize the data inside "redis" of ntopng it'll be
> better...
>
> thanks.
>
>
>
> On Mon, May 8, 2017 at 4:04 PM, Emanuele Faranda <faranda@ntop.org> wrote:
>
>> Hi,
>>
>> Currently ntopng does not export such daily information via an API. Feel
>> free to open a feature request on github https://github.com/ntop/ntopng
>> for an API request.
>>
>> As an alternative, if you have MySQL support enabled (see -F option), you
>> could perform manual MySQL aggregations from the database.
>>
>> Another alternative is to read data from the RRD files which ntopng
>> creates every 5 minute for local hosts (see -m option for defining local
>> networks). In this case, you could read the statistics of the host
>> 192.168.1.1 with the command "rrdtool fetch /var/tmp/ntopng/0/rrd/192/168/1/1/bytes.rrd
>> AVERAGE -s now-1d". The first column of the output contains the downloaded
>> host traffic, while the second the uploaded traffic.
>>
>> This approach has the following implications:
>>
>> - data is actually an average of the host traffic in 5 minutes, not the
>> actual traffic
>>
>> - data is not aggregated, you will need to sum up the rows values to get
>> the total
>>
>> - you will need to multiply the row value by 300, since values are
>> derivates
>>
>> See https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html for more details.
>>
>> Regards,
>> Emanuele
>>
>>
>> On 05/07/2017 01:21 PM, Umut Arus wrote:
>>
>> Hi,
>>
>> I'd like to collect of clients downloaded data per IP every day so I'll
>> integrate it for home made quota management per IP.
>>
>> How can I get the data of total bytes from an API or cli from ntopng?
>>
>> thanks.
>>
>> --
>> *Umut Arus*
>>
>> Information Technology
>> Sabanc? University
>>
>>
>>
>>
>> _______________________________________________
>> Ntop mailing listNtop@listgateway.unipi.ithttp://listgateway.unipi.it/mailman/listinfo/ntop
>>
>>
>>
>> _______________________________________________
>> Ntop mailing list
>> Ntop@listgateway.unipi.it
>> http://listgateway.unipi.it/mailman/listinfo/ntop
>>
>
>
>
> --
> *Umut Arus*
> System Specialist
> Information Technology
> Sabanc? University
>
> Phone: +90216 483 9172 <+90%20216%20483%2091%2072>
>
>
>
>
> _______________________________________________
> Ntop mailing listNtop@listgateway.unipi.ithttp://listgateway.unipi.it/mailman/listinfo/ntop
>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop
>



--
*Umut Arus*
System Specialist
Information Technology
Sabanc? University

Phone: +90216 483 9172
Re: Total bytes per IP for accounting on ntopng [ In reply to ]
Hi,

You will need to update to the latest version as I've fixed it just a
few days ago.

Regards,
Emanuele


On 05/17/2017 01:25 PM, Umut Arus wrote:
> Hi,
>
> I'm trying to get "all IP's data". It works on browser successfully
> but not works by curl.
>
> Have you any hint why it is?
>
> http://10.10.10.10:3000/lua/do_export_data.lua?csrf=59390245f24646cdaa24287733f15d74&hostIP=&hostVlan=
>
> curl --cookie "user=admin; password=xxxxx"
> "http://10.10.10.10:3000/lua/export_data.lua?ifid=0&ip="
>
> thanks.
>
>
> On Tue, May 9, 2017 at 12:24 PM, Emanuele Faranda <faranda@ntop.org
> <mailto:faranda@ntop.org>> wrote:
>
> Hi Umut,
>
> The proper way to do this would be via an API to ntopng, but we
> are in the process of releasing the next stable version so new
> features must wait.
>
> What you can do right now is quering ntopng for an host stats like
> this:
>
> curl --cookie "user=admin; password=your_password"
> "http://127.0.0.1:3000/lua/do_export_data.lua?ifid=0&ip=192.168.1.1"
> <http://127.0.0.1:3000/lua/do_export_data.lua?ifid=0&ip=192.168.1.1>
>
> It will return a JSON with "rcvd.bytes" but it does not reset daily.
>
> An alternative is to setup a global alert threshold on traffic for
> your local hosts, so that after the threshold is crossed by any
> local host, an alert is generated and stored to the
> "closed_alerts" table of the SQLite database
> "/var/tmp/ntopng/0/alerts/alerts_v5.db". You can setup this from
> any local host details page, through the icon with the esclamation
> mark. You can then filter that database to see if the host has
> exceeded the quota and take an action.
>
> This is very complex for a really simple task, but again please
> wait we complete the next release and then we will expose an api
> for this.
>
> Emanuele
>
>
> On 05/08/2017 08:52 PM, Umut Arus wrote:
>> Hello Emanuele,
>>
>> Thanks for your reply I have tried to store mysql data. But I
>> have collected huge amount of 250.000 rows with about 10.000
>> clients in only five minutes. In this case, it wouldn't be practical.
>>
>> If you can help about summarize the data inside "redis" of ntopng
>> it'll be better...
>>
>> thanks.
>>
>>
>>
>> On Mon, May 8, 2017 at 4:04 PM, Emanuele Faranda
>> <faranda@ntop.org <mailto:faranda@ntop.org>> wrote:
>>
>> Hi,
>>
>> Currently ntopng does not export such daily information via
>> an API. Feel free to open a feature request on github
>> https://github.com/ntop/ntopng for an API request.
>>
>> As an alternative, if you have MySQL support enabled (see -F
>> option), you could perform manual MySQL aggregations from the
>> database.
>>
>> Another alternative is to read data from the RRD files which
>> ntopng creates every 5 minute for local hosts (see -m option
>> for defining local networks). In this case, you could read
>> the statistics of the host 192.168.1.1 with the command
>> "rrdtool fetch /var/tmp/ntopng/0/rrd/192/168/1/1/bytes.rrd
>> AVERAGE -s now-1d". The first column of the output contains
>> the downloaded host traffic, while the second the uploaded
>> traffic.
>>
>> This approach has the following implications:
>>
>> - data is actually an average of the host traffic in 5
>> minutes, not the actual traffic
>>
>> - data is not aggregated, you will need to sum up the rows
>> values to get the total
>>
>> - you will need to multiply the row value by 300, since
>> values are derivates
>>
>> See https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html
>> <https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html> for more
>> details.
>>
>> Regards,
>> Emanuele
>>
>>
>> On 05/07/2017 01:21 PM, Umut Arus wrote:
>>> Hi,
>>>
>>> I'd like to collect of clients downloaded data per IP every
>>> day so I'll integrate it for home made quota management per IP.
>>>
>>> How can I get the data of total bytes from an API or cli
>>> from ntopng?
>>>
>>> thanks.
>>>
>>> --
>>> *Umut Arus*
>>> *
>>> *
>>> Information Technology
>>> Sabanc? University
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Ntop mailing list
>>> Ntop@listgateway.unipi.it <mailto:Ntop@listgateway.unipi.it>
>>> http://listgateway.unipi.it/mailman/listinfo/ntop
>>> <http://listgateway.unipi.it/mailman/listinfo/ntop>
>>
>>
>> _______________________________________________
>> Ntop mailing list
>> Ntop@listgateway.unipi.it <mailto:Ntop@listgateway.unipi.it>
>> http://listgateway.unipi.it/mailman/listinfo/ntop
>> <http://listgateway.unipi.it/mailman/listinfo/ntop>
>>
>>
>>
>>
>> --
>> *Umut Arus*
>> System Specialist
>> Information Technology
>> Sabanc? University
>> Phone: +90216 483 9172 <tel:+90%20216%20483%2091%2072>
>>
>>
>>
>>
>> _______________________________________________
>> Ntop mailing list
>> Ntop@listgateway.unipi.it <mailto:Ntop@listgateway.unipi.it>
>> http://listgateway.unipi.it/mailman/listinfo/ntop
>> <http://listgateway.unipi.it/mailman/listinfo/ntop>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it <mailto:Ntop@listgateway.unipi.it>
> http://listgateway.unipi.it/mailman/listinfo/ntop
> <http://listgateway.unipi.it/mailman/listinfo/ntop>
>
>
>
>
> --
> *Umut Arus*
> System Specialist
> Information Technology
> Sabanc? University
> Phone: +90216 483 9172
>
>
>
>
> _______________________________________________
> Ntop mailing list
> Ntop@listgateway.unipi.it
> http://listgateway.unipi.it/mailman/listinfo/ntop