Community discussions

MikroTik App
 
erny
just joined
Topic Author
Posts: 21
Joined: Fri Mar 11, 2005 2:59 pm
Location: near Riga, Latvia

Extract graphs from backup

Thu Feb 11, 2010 9:41 am

I have an issue, that I have to extract graphing data from backup datet september. Problem is that I have changed hw, so I could restore this backup only on some other router, which would result graphing data reset just after bootup.
Is there any way to extract these graph data directly from backup without loosing graphing information?
 
duvi
Frequent Visitor
Frequent Visitor
Posts: 70
Joined: Fri Jun 05, 2009 12:32 pm
Contact:

Re: Extract graphs from backup

Thu Feb 11, 2010 10:13 am

I also wish to know if there is a way to move the graphing data to another router. It would be really helpful, if I need to change the hardware (e.g. for better performance), but don't want to lose the graphs.
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Fri Feb 12, 2010 5:57 am

Mikrotik license and other data is tied to the hard drive. If you transfer that hard drive to another computer, you can boot your existing RouterOS install and all the graphing data should stay intact, as only hardware would change, software (RouterOS and data) would stay the same.

The only way to backup configuration is through a system backup or export, none of which allow graphing data to be saved.
System backup: /system backup save name=<filename>
Export: /export file=<filename>
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8394
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Extract graphs from backup

Fri Feb 12, 2010 4:22 pm

unfortunately, you cannot transfer ethernet/wlan graphs. they appear as new interfaces, so history begins from zero for them =( but all vlans, queues, resources graphs are moved correctly
Russian-speaking forum: https://forum.mikrotik.by/. Welcome!

For every complex problem, there is a solution that is simple, neat, and wrong.

MikroTik. Your life. Your routing.
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Sat Feb 13, 2010 1:51 am

Another option might be: before you move the hard drive, you could pull the image right from RouterOS's web interface and store it as backup. You can store the image locally on the RouterOS using the fetch tool.

Here is a script to backup all graph data (including the main graphs page) on RouterOS:
# Backup graph data

:local graphaddress "127.0.0.1"
:local graphport 80
:local graphimages "daily.gif, monthly.gif, yearly.gif"

# Internal processing...
:local graphpath

# Main graphs page
:set graphpath ("graphs/")
/tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath) dst-path=($graphpath . "index.html")

# Resource graphs
:foreach g in=[:toarray "cpu,ram,hdd"] do={
   :set graphpath ("graphs/" . [:tostr $g] . "/")

   /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath) dst-path=($graphpath . "index.html")

   :foreach i in=[:toarray $graphimages] do={
      /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
   }
}

# Queue graphs
# Only simple queues are available (both enabled and disabled)
:foreach g in=[/queue simple find] do={
   :set graphpath ("graphs/queue/" . [/queue simple get $g name] . "/")

   /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath) dst-path=($graphpath . "index.html")

   :foreach i in=[:toarray $graphimages] do={
      /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
   }
}

# Interface graphs
# Only running interfaces are available
:foreach g in=[/interface find] do={
   :if ([/interface get $g running] = [:tobool true]) do={
      :set graphpath ("graphs/iface/" . [/interface get $g name] . "/")

      /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath) dst-path=($graphpath . "index.html")

      :foreach i in=[:toarray $graphimages] do={
         /tool fetch address=127.0.0.1 port=8000 mode=http \
	src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
      }
   }
}
I just ran this on my setup, and it works well. I'm thinking of running it on schedule maybe once a week for records keeping. Also, as the graph's gif images are accessible, you could show customers their usage via email -- just a thought.

Anyway, hope this helps.
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Thu Mar 11, 2010 2:00 am

UPDATE: Added weekly.gif capture for weekly graphs. It was missing from the original release.

Also, I updated the Wiki entry:
http://wiki.mikrotik.com/wiki/Backup_graphing_data
 
sw0rdf1sh
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Sun Nov 28, 2010 6:16 pm

Re: Extract graphs from backup

Thu Dec 02, 2010 10:03 pm

What about netwatch.
http://wiki.mikrotik.com/wiki/Netwatch_on_web

Can someone knowing scripting writes
netwatch script like the one above but
/tool fetch mode=ftp

this time
and a php getting the images (gifs) stored to a cmod777 location in a website?
Just a thought.I don't know if this can be done.
 
ojeysky
Frequent Visitor
Frequent Visitor
Posts: 68
Joined: Tue Mar 10, 2009 2:04 pm

Re: Extract graphs from backup

Thu Feb 17, 2011 11:26 am

UPDATE: Added weekly.gif capture for weekly graphs. It was missing from the original release.

Also, I updated the Wiki entry:
http://wiki.mikrotik.com/wiki/Backup_graphing_data
Hello thanks for this script. However the interface graph seems not to be running properly, it only creates the index.html file and stops at that. It does not create the other image files.
Can you help correct it?
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Sat Feb 19, 2011 12:23 am

What error message do you get when running it from the terminal?
/system script run <script name>
Also what version of RouterOS are you using?

Basically, that script just pulls the graph images for reference. It can be good if you experience network problems where using external applications may not be viable (ex. snmp, traffic flow, etc...). The images are then stored on the same router, so even if the router looses network connectivity, you're graphs will still be saved locally to the router itself.
Doug
 
ojeysky
Frequent Visitor
Frequent Visitor
Posts: 68
Joined: Tue Mar 10, 2009 2:04 pm

Re: Extract graphs from backup

Sat Feb 19, 2011 1:19 am

Yes i ran the script(run v4.16), the fetching for cpu,ram and hdd went well however that of interface did not complete(stops at LAN html while i still have other interfaces) as shown in the output of file print bellow:
65 graphs directory feb/19/2011 00:15:42
66 trafic.txt .txt file 306 feb/18/2011 22:30:27
67 graphs/index.html .html file 1127 feb/19/2011 00:15:25
68 graphs/cpu directory feb/19/2011 00:15:30
69 graphs/cpu/index.html .html file 2856 feb/19/2011 00:15:26
70 graphs/cpu/daily.gif .gif file 10334 feb/19/2011 00:15:27
71 graphs/cpu/weekly.gif .gif file 9414 feb/19/2011 00:15:28
72 graphs/cpu/monthly.gif .gif file 9855 feb/19/2011 00:15:29
73 graphs/cpu/yearly.gif .gif file 8347 feb/19/2011 00:15:30
74 graphs/ram directory feb/19/2011 00:15:36
75 graphs/ram/index.html .html file 3066 feb/19/2011 00:15:31
76 graphs/ram/daily.gif .gif file 9839 feb/19/2011 00:15:33
77 graphs/ram/weekly.gif .gif file 8103 feb/19/2011 00:15:34
78 graphs/ram/monthly.gif .gif file 7961 feb/19/2011 00:15:35
79 graphs/ram/yearly.gif .gif file 8620 feb/19/2011 00:15:36
80 graphs/hdd directory feb/19/2011 00:15:41
81 graphs/hdd/index.html .html file 3060 feb/19/2011 00:15:37
82 graphs/hdd/daily.gif .gif file 9742 feb/19/2011 00:15:38
83 graphs/hdd/weekly.gif .gif file 7860 feb/19/2011 00:15:39
84 graphs/hdd/monthly.gif .gif file 7484 feb/19/2011 00:15:40
85 graphs/hdd/yearly.gif .gif file 8448 feb/19/2011 00:15:41
86 graphs/iface directory feb/19/2011 00:15:42
87 graphs/iface/LAN directory feb/19/2011 00:15:42
88 graphs/iface/LAN/index.html .html file 5160 feb/19/2011 00:15:42
Here is also the log
00:15:25 info fetch: file "graphs/index.html" created
00:15:26 info fetch: file "graphs/cpu/index.html" created
00:15:27 info fetch: file "graphs/cpu/daily.gif" created
00:15:28 info fetch: file "graphs/cpu/weekly.gif" created
00:15:29 info fetch: file "graphs/cpu/monthly.gif" created
00:15:30 hotspot,debug Abuja: dynamic host 10.2.16.226 removed: idle timeout
00:15:30 info fetch: file "graphs/cpu/yearly.gif" created
00:15:31 info fetch: file "graphs/ram/index.html" created
00:15:33 info fetch: file "graphs/ram/daily.gif" created
00:15:34 info fetch: file "graphs/ram/weekly.gif" created
00:15:35 info fetch: file "graphs/ram/monthly.gif" created
00:15:36 info fetch: file "graphs/ram/yearly.gif" created
00:15:37 info fetch: file "graphs/hdd/index.html" created
00:15:38 info fetch: file "graphs/hdd/daily.gif" created
00:15:39 info fetch: file "graphs/hdd/weekly.gif" created
00:15:40 info fetch: file "graphs/hdd/monthly.gif" created
00:15:41 info fetch: file "graphs/hdd/yearly.gif" created
00:15:42 info fetch: file "graphs/iface/LAN/index.html" created
Here is the script i ran (note that i did not require the queue graph so i removed it)
# Backup graphing data

:local graphaddress "127.0.0.1"
:local graphport 80
:local graphimages "daily.gif, weekly.gif, monthly.gif, yearly.gif"

# Internal processing...
:local graphpath

# Main graphs page
:set graphpath ("graphs/")
/tool fetch address=$graphaddress port=$graphport mode=http \
src-path=($graphpath) dst-path=($graphpath . "index.html")


# Resource graphs
:foreach g in=[:toarray "cpu,ram,hdd"] do={
:set graphpath ("graphs/" . [:tostr $g] . "/")

/tool fetch address=$graphaddress port=$graphport mode=http \
src-path=($graphpath) dst-path=($graphpath . "index.html")

:foreach i in=[:toarray $graphimages] do={
/tool fetch address=$graphaddress port=$graphport mode=http \
src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
}
}
# Interface graphs
# Only running interfaces are available
:foreach g in=[/interface find] do={
:if ([/interface get $g running] = [:tobool true]) do={
:set graphpath ("graphs/iface/" . [/interface get $g name] . "/")
/tool fetch address=$graphaddress port=$graphport mode=http \
src-path=($graphpath) dst-path=($graphpath . "index.html")
:foreach i in=[:toarray $graphimages] do={
/tool fetch address=127.0.0.1 port=8000 mode=http \
src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
}
}
}
Thanks for helping out
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Mon Feb 21, 2011 11:03 pm

It looks like there's some hard-coded address and port specified in the interface section.
Here is an updated version.
Let me know if this works for you, and if so, I will update the Wiki with any needed updates.
# Backup graphing data

:local graphaddress "127.0.0.1"
:local graphport 80
:local graphimages "daily.gif, weekly.gif, monthly.gif, yearly.gif"

# Internal processing...
:local graphpath

# Main graphs page
:set graphpath ("graphs/")
/tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath) dst-path=($graphpath . "index.html")


# Resource graphs
:foreach g in=[:toarray "cpu,ram,hdd"] do={
   :set graphpath ("graphs/" . [:tostr $g] . "/")

   /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath) dst-path=($graphpath . "index.html")

   :foreach i in=[:toarray $graphimages] do={
      /tool fetch address=$graphaddress port=$graphport mode=http \
	src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
   }
}
# Interface graphs
# Only running interfaces are available
:foreach g in=[/interface find] do={
   :if ([/interface get $g running] = [:tobool true]) do={
      :set graphpath ("graphs/iface/" . [/interface get $g name] . "/")
      /tool fetch address=$graphaddress port=$graphport mode=http \
         src-path=($graphpath) dst-path=($graphpath . "index.html")
      :foreach i in=[:toarray $graphimages] do={
          /tool fetch address=$graphaddress port=$graphport mode=http \
              src-path=($graphpath . [:tostr $i]) dst-path=($graphpath . [:tostr $i])
      }
   }
}
EDIT: Changed from quote -> code tags for easier readability.
Doug
 
ojeysky
Frequent Visitor
Frequent Visitor
Posts: 68
Joined: Tue Mar 10, 2009 2:04 pm

Re: Extract graphs from backup

Mon Feb 21, 2011 11:36 pm

This worked perfectly! :D Thanks.
NB
Does anyone know how i could email a directory in the mikrotik>files? I am looking at emailing the folder graph to my email daily?
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Wed Feb 23, 2011 3:34 am

Does anyone know how i could email a directory in the mikrotik>files? I am looking at emailing the folder graph to my email daily?
AFAIK, you can only send 1 file attachment through email on RouterOS, and there is no way to convert the folder/files to a zip, or single file.
To send a single graph image, you could simply attach the single .gif image via email attachment.
Doug
 
ojeysky
Frequent Visitor
Frequent Visitor
Posts: 68
Joined: Tue Mar 10, 2009 2:04 pm

Re: Extract graphs from backup

Wed Feb 23, 2011 5:39 am

Yeah i am aware of the single file attachment. I was thinking there is a work around to zip/tar a directory and send. Sending the directory gives a more detailed view of the graph just as if i were checking directly via web-box, cos it also goes with the index.html files...sending all one by one could be untidy....maybe its a feature mikrotik guys want to consider:?:
Thanks anyway
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: Extract graphs from backup

Thu Feb 24, 2011 3:05 am

Actually, I would like to have gzip command exposed to RouterOS. This way I could compress the .backup files to same a lot of space in case router doesn't have so much drive space. The compression is really really good, as most of the backup is the same data.

Something I've noticed with Mikrotik: One solution will work only part way, but there's always limitations in some way. So you have to always "hack" together a full solution. I really kind of wish at least, very least we had a linux term available. They could still use their console, but maybe a command called "/system bash" or something to load the back-end terminal. Many tasks seem simple (and really are simple), but often require quite a workaround in RouterOS.
Doug

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot], Majestic-12 [Bot], nithinkumar2000 and 134 guests