Upload graph images to FTP

Hi guys,

I know that there is an old script to create the graphs and upload them to a folder called /graphs.

# 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])
   }
}

# 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])
      }
   }
}

My question is since Mikrotik came with the tool /fetch if there is a way that we can upload the files from to the graphs folder to an FTP server?

Thanks
Mihail

what this script does?

@nichky,

The script above is creating daily, weekly and monthly graph utilisation for all the active interface and places those images in a folder called graphs and later on if you access the web page http://IP_OF_MIKROTIK_ROUTER/graphs/ will show you the generated graphs.

My question is if someone did a script that is uploading this images to an FTP server and if is willing to share with us how he did it.

Thanks
Mihail

I would like the same and will look at the script with some friends,
IF we can find the time in the next few weeks…

# Backup graphing data

:local graphaddress "IP_ADDRESS_FTP_SERVER"
:local user "USER"
:local password "PASSWORD*"
:local graphport 21
:local graphimages "daily.gif, weekly.gif, monthly.gif, yearly.gif"

# Internal processing...
:local graphpath

# Main graphs page
:set graphpath ("graphs/iface/wan-2-ether2/")               *** I pick up only one path as a test ***

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

The script is uploading a file but comes with 0 bit as a size ( ref. attached image ) and after that it hangs. I guess is an issue with the rights on that system folder.

Any guess guys what might go wrong ?

Thanks
Mihail
2018-01-17_18-36-19.jpg