Community discussions

MikroTik App
 
smartynet
just joined
Topic Author
Posts: 12
Joined: Fri May 26, 2006 11:24 am

simple queue - save statistic

Thu Aug 10, 2006 11:47 am

Please allow roterOS to save statistic of simple queues into HDD. I always lost this data after reboot. I use this for counting user data and FUP. Is here any possibility to do this?
 
User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6695
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

Thu Aug 10, 2006 12:06 pm

If you are talking about graphing, you have to specify store-on-disk=yes.
Use correct clock setings (setup NTP client).

P.S. I think such question should be asked in 'General Networking' section.
 
smartynet
just joined
Topic Author
Posts: 12
Joined: Fri May 26, 2006 11:24 am

Thu Aug 10, 2006 4:05 pm

I am not talking about graphing. I am talking about transmitted data via queue (variable total-bytes). I am using this in my script for limiting user speed after transmitting given amount of data. Everything works fine, but after reset this variable is 0 so I want to store this variable on HDD or I need this variable to be stored on HDD by routerOS. I don't want to use external PC for storing this variable. Is here any possibility how to do this.

http://forum.mikrotik.com/viewtopic.php ... ight=queue
 
User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6695
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

Thu Aug 10, 2006 4:19 pm

I guess, it's not possible to store particular value on HDD, and data will be erased after reboot, shutdown, etc.
I think 'graphing' is more informative way to monitor queues (External SNMP server can be used as well).
 
smartynet
just joined
Topic Author
Posts: 12
Joined: Fri May 26, 2006 11:24 am

Thu Aug 10, 2006 5:17 pm

And is it possible to read from graphing amount of transmitted data per month in a script?
 
User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6695
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

Thu Aug 10, 2006 5:19 pm

Simple graphs provides information about 'Daily', 'Weekly', 'Monthly', 'Yearly' usage, and provides information like this,
http://demo2.mt.lv/graphs/iface/wlan1/
 
smartynet
just joined
Topic Author
Posts: 12
Joined: Fri May 26, 2006 11:24 am

Thu Aug 10, 2006 5:43 pm

I know this, but is it possible to read the exact number of bytes via script?
 
smartynet
just joined
Topic Author
Posts: 12
Joined: Fri May 26, 2006 11:24 am

Fri Aug 11, 2006 10:38 am

Does anybody has any idea?
 
xxmusaxx
just joined
Posts: 10
Joined: Tue Jul 26, 2011 10:05 am

Re: simple queue - save statistic

Tue Jul 26, 2011 10:07 am

So did you find any solution for saving this data?
 
xxmusaxx
just joined
Posts: 10
Joined: Tue Jul 26, 2011 10:05 am

Re: simple queue - save statistic

Tue Jul 26, 2011 11:52 am

or anyone else? how to save this data?
 
User avatar
sergejs
MikroTik Support
MikroTik Support
Posts: 6695
Joined: Thu Mar 31, 2005 3:33 pm
Location: Riga, Latvia
Contact:

Re: simple queue - save statistic

Tue Jul 26, 2011 1:30 pm

Command to get detailed information about queue statistic,
/queue simple print stats
1 D rate=0/35080 total-rate=0 packet-rate=0/10 total-packet-rate=0
queued-bytes=0/0 total-queued-bytes=0 queued-packets=0/0
total-queued-packets=0 bytes=11737/33719917 total-bytes=0
packets=97/40651 total-packets=0 dropped=0/0 total-dropped=0 lends=97/581
total-lends=0 borrows=0/40070 total-borrows=0
 
xxmusaxx
just joined
Posts: 10
Joined: Tue Jul 26, 2011 10:05 am

Re: simple queue - save statistic

Wed Sep 21, 2011 10:49 pm

Yes, but these statistics are deleted after reboot. But how to save these statistics so it stays there even if router is rebooted?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: simple queue - save statistic

Wed Sep 21, 2011 11:02 pm

Query the router via SNMP. There's OIDs for all the queues.
 
xxmusaxx
just joined
Posts: 10
Joined: Tue Jul 26, 2011 10:05 am

Re: simple queue - save statistic

Wed Sep 21, 2011 11:19 pm

Can you be litle more precise about it? Thanks!
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: simple queue - save statistic

Wed Sep 21, 2011 11:25 pm

About what? What OIDs are? What SNMP is? Those questions would probably be better suited to a general Google search. SNMP is a common protocol used to monitor network equipment and collect information from it. OIDs are the addresses of data points a system provides. You can use SNMP via the NMS of your choice to monitor simple queues in RouterOS on an external server, and store data on the external data permanently.
 
xxmusaxx
just joined
Posts: 10
Joined: Tue Jul 26, 2011 10:05 am

Re: simple queue - save statistic

Thu Sep 22, 2011 12:00 am

That is ok, thanks for info. But all that are just alternative options. I asked why isn't possible to store this on disk? So it will stay there even after reboot. I don't need server or any other mashine to monitor traffic.. I share connection with 3 other friends, and need to know that simple stats. But I guess that it isn't so simple.
 
dbs
just joined
Posts: 5
Joined: Sun Jul 10, 2011 1:01 am
Contact:

Re: simple queue - save statistic

Thu Sep 22, 2011 12:08 am

Please allow roterOS to save statistic of simple queues into HDD. I always lost this data after reboot. I use this for counting user data and FUP. Is here any possibility to do this?
We've looked into what you describe extensively and decided to build the DBS solution as described in the signature below.

If you insist in building this yourself you would need to gather and store the data off of the router and save in a "round robin database" a.k.a. "rrdtool" somewhere else. The trick is detecting data rates that are impossible and then ignoring those samples, as it would appear when a register rolls over or by having a counter being reset to zero. One great example of this is provided by the open source program called Cacti (http://www.cacti.net/), where the data is collected through SNMP and saved and graphed using RrdTool.

Once you have the data off the router, then your script would need to retrieve this data, and make adjustments as needed. No simple task.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: simple queue - save statistic

Thu Sep 22, 2011 12:44 am

That is ok, thanks for info. But all that are just alternative options. I asked why isn't possible to store this on disk? So it will stay there even after reboot. I don't need server or any other mashine to monitor traffic.. I share connection with 3 other friends, and need to know that simple stats. But I guess that it isn't so simple.
It really isn't.

Most RouterBOARDs have NAND storage. That limits the number of write cycles. How often do you update the stats on disk? They change all the time, so that's an awful lot of write cycles, until the internal storage breaks.
 
DarielHG89
just joined
Posts: 3
Joined: Sun Dec 09, 2018 3:08 pm

Re: simple queue - save statistic

Thu Sep 22, 2022 4:20 am

Store statistics info in a remote server.
In this example i just post the name and bytes.
Script:
{
	/queue simple
	:local queueList [find]
	:foreach q in=$queueList do={
		:local qName [get $q name]
		:local qTarget [get $q target]
		:local qBytes [get $q bytes]
		:local qStatus [get $q disabled]
		:if (!$qStatus) do={
			:local logmessage ("{\"name\":\"" . $qName . "\",\"bytes\":\"" . $qBytes . "\"}")
			:put ($logmessage)
			/tool fetch http-method=post http-header-field="Content-Type: application/json" http-data=$logmessage url="http://192.168.100.17/queue.php"
		}
	}
}
queue.php:
<?php
  function isValidJSON($str) {
     json_decode($str);
     return json_last_error() == JSON_ERROR_NONE;
  }
  $json = file_get_contents('php://input');
  if (strlen($json) > 0 && isValidJSON($json)){
    $data = json_decode($json);
	date_default_timezone_set("America/New_York");
	$njsond = ["LastC"=>date("d-m-Y h:i:sa"),"bytesUD"=>$data->bytes];
	echo file_put_contents("Queue-" . $data->name . ".json",json_encode($njsond));
  }
?>
Last edited by DarielHG89 on Thu Sep 22, 2022 4:29 am, edited 2 times in total.

Who is online

Users browsing this forum: Ahrefs [Bot], iustin, marcelofares, pajapatak, rjuho, seriquiti and 68 guests