NOC:ctwug updated

From CTWUG Wiki
Jump to: navigation, search

Purpose

My guess is that this script tells the NOC system that the RB making the request is alive and well.

It probably stores the identity, serialnumber and remote address with a timestamp in a database.

This script is scheduled to run every hour.

Dependencies

Script

:local fid [/system identity get name]
:local fserial [/system routerboard get serial-number]
:local ffile "ctwug_version.rsc"       
:local fpath ("web/api/update?id=".$fid."&serial=".$fserial."&update=1")
:local fpath2 $fpath
:local fpath ""
:for i from=0 to=( [:len $fpath2] - 1) do={
  :local fchar [:pick $fpath2 $i]
  :if ( $fchar = " ") do={
    :set fchar "%20"
  }
  :set fpath ($fpath.$fchar)
}
       
/tool fetch host=noc.ctwug.za.net address=noc.ctwug.za.net src-path=$fpath dst-path=$ffile mode=http
:delay 1
:log info [/file get $ffile contents]