Перейти к содержанию

Описание.

Поддерживаемое оборудование

  • RB-260GS
  • CSS106-5G-1S
  • CSS106-1G-4P-1S
  • CSS326-24G-2S+

Команды

protocol <имя_протокола>

Выбрать протокол для дальнейшего взаимодействия с устройством.

Параметры:
<имя_протокола> - протокол, который бдует использоваться для взаимодействия с узлом.

Пример.

$host="192.0.2.3"
$user="admin"
$passwd=""
$port="80"

class device.Mikrotik.swos
protocol http
http "http://"+$user+":"+$passwd+"@"+$host+":"+$port
authtype HTTPDigetsAuth

$sysinfo=sysinfo()

Функции

config_hr(<конфигурация_устройства>,<модель_устройства>)

Преобразовывает исходные конфигурационные данные в человекочитаемый вид.

Параметры:
<конфигурация_устройства> - конфигурация во внутреннем формате устройства.
<модель_устройства> - модель устройства.

Возвращаемое значение:
Конфигурация в формате, приемлемом для человеческого восприятия.

Пример.

$host="192.2.0.3"
$user="admin"
$passwd=""
$port="80"

class device.Mikrotik.swos
protocol http
http "http://"+$user+":"+$passwd+"@"+$host+":"+$port
authtype HTTPDigetsAuth

$sysinfo=sysinfo()
$sysinfosz=size($sysinfo)

print ("Данные узла:\n")
for $i=0, $i<$sysinfosz, $i=$i+2
    print ("%-16s: %s\n",$sysinfo[$i],$sysinfo[$i+1])
endfor

$boardname=$sysinfo %? "BoardName"

$cfg=configraw_get()

print ("\nКонфигурация:\n%s",config_hr($cfg,$boardname))

Результат:

Данные узла:
ip              : 192.2.0.3
MAC             : 4c:5e:0c:f5:0c:10
SerialNumber    : 6071045F3F09
Uptime          : 90604202
Identity        : MikroTik
Version         : 1.17
BoardName       : RB260GS
Voltage         : 0.0
Temperature     : 0

Конфигурация:
username admin password ""
hostname "MikroTik"
watchdog enable
discovery enable
vlan 78 ivl disable Port1 leave-as-is Port4 strip
vlan 2 ivl disable Port1 leave-as-is Port2 strip
vlan 3106 ivl disable Port1 leave-as-is Port5 strip
ip-address 192.2.0.3
allow-from-ip 0.0.0.0/0
allow-from-ports Port1,Port2,Port3,Port4,Port5,SFP
allow-from-vlan 0
static host address 00:00:00:00:00:01 ports Port1,Port2,Port3,Port4,Port5,SFP vlan 99 drop enable mirror enable
interface Port1
 description "Port1"
 state enable
 speed-duplex auto
 flowcontrol off
 vlan ingress mode strict
 vlan ingress receive any
 vlan ingress default id 1
 vlan ingress force id off
 vlan egress header leave
 forward-to Port2,Port3,Port4,Port5,SFP
 port-lock off
 lock-on-first off
 mirror ingress off
 mirror egress off
 bandwidth egress 0
interface Port2
 description "Port2"
 state enable
 speed-duplex auto
 flowcontrol off
 vlan ingress mode strict
 vlan ingress receive untagged
 vlan ingress default id 2
 vlan ingress force id off
 vlan egress header strip
 forward-to Port1,Port3,Port4,Port5,SFP
 port-lock off
 lock-on-first off
 mirror ingress off
 mirror egress off
 bandwidth egress 0
interface Port3
 description "Port3"
 state enable
 speed-duplex auto
 flowcontrol off
 vlan ingress mode strict
 vlan ingress receive untagged
 vlan ingress default id 1
 vlan ingress force id off
 vlan egress header strip
 forward-to Port1,Port2,Port4,Port5,SFP
 port-lock off
 lock-on-first off
 mirror ingress off
 mirror egress off
 bandwidth egress 0
interface Port4
 description "Port4"
 state enable
 speed-duplex auto
 flowcontrol off
 vlan ingress mode strict
 vlan ingress receive untagged
 vlan ingress default id 78
 vlan ingress force id off
 vlan egress header strip
 forward-to Port1,Port2,Port3,Port5,SFP
 port-lock off
 lock-on-first off
 mirror ingress off
 mirror egress off
 bandwidth egress 0
interface Port5
 description "Port5"
 state enable
 speed-duplex auto
 flowcontrol off
 vlan ingress mode strict
 vlan ingress receive untagged
 vlan ingress default id 3106
 vlan ingress force id off
 vlan egress header strip
 forward-to Port1,Port2,Port3,Port4,SFP
 port-lock off
 lock-on-first off
 mirror ingress off
 mirror egress off
 bandwidth egress 0
interface SFP
 description "SFP"
 state enable
 autonegotiation enable
 vlan ingress mode optional
 vlan ingress receive any
 vlan ingress default id 1
 vlan ingress force id off
 vlan egress header leave
 forward-to Port1,Port2,Port3,Port4,Port5
 port-lock off
 lock-on-first off
 mirror ingress off
 mirror egress off
 bandwidth egress 0
snmp-server disable
snmp-server community "public"
snmp-server contact ""
snmp-server location ""
mirror destination Port1

configraw_get()

Получить конфигурацию во внутреннем формате устройства.

Параметры:
Нет.

Возвращаемое значение:
Строка, содержащая конфигурационную информацию.

Пример.

$host="192.0.2.3"
$user="admin"
$passwd=""
$port="80"

class device.Mikrotik.swos
protocol http
http "http://"+$user+":"+$passwd+"@"+$host+":"+$port
authtype HTTPDigetsAuth

$cfg=configraw_get()
print ("Config:\n%s\n",$cfg)

Результат:

Config:
link.b:{en:0x1f,an:0x1f,spdc:[0x0,0x00,0x00,0x00,0x00,0x00],dpxc:0x1f,fct:0x0,fp1:0x3e,fp2:0x3d,fp3:0x3b,fp4:0x37,fp5:0x2f,fp6:0x1f,lck:0x0,lckf:0x0,imr:0x0,omr:0x0,mrto:0x1,vlan:[0x3,0x03,0x03,0x03,0x03,0x01],vlnh:[0x0,0x01,0x01,0x01,0x01,0x00],vlni:[0x0,0x02,0x02,0x02,0x02,0x00],dvid:[0x1,0x0002,0x0001,0x004e,0x0c22,0x0001],fvid:0x0,ir:[0x0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000],or:[0x0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000],srt:[0x0,0x00,0x00,0x00,0x00,0x00],suni:0x0,poe:[0x0,0x00,0x00,0x00,0x00,0x00],prio:[0x0,0x00,0x00,0x00,0x00,0x00],nm0:'506f727431',nm1:'506f727432',nm2:'506f727433',nm3:'506f727434',nm4:'506f727435'},sfp.b:{en:0x1,an:0x1,nm5:'534650'},snmp.b:{en:0x0,com:'7075626c6963',ci:'',loc:''},acl.b:[],vlan.b:[{vid:0x4e,prt:[0x0,0x03,0x03,0x01,0x03,0x03],ivl:0x0},{vid:0x2,prt:[0x0,0x01,0x03,0x03,0x03,0x03],ivl:0x0},{vid:0xc22,prt:[0x0,0x03,0x03,0x03,0x01,0x03],ivl:0x0}],host.b:[{adr:'000000000001',prt:0x3f,drp:0x1,mir:0x1,sts:0x0,vid:0x63}],sys.b:{ip:0x30200c0,id:'4d696b726f54696b',wdt:0x1,dsc:0x1,alla:0x0,allm:0x0,allp:0x3f,avln:0x0,lcbl:0x0},.pwd.b:{pwd:''}

sysinfo()

Получить системные данные узла.

Параметры:
Нет.

Возвращаемое значение:
Список имен полей и их значений.

Пример.

$host="192.0.2.3"
$user="admin"
$passwd=""
$port="80"

class device.Mikrotik.swos
protocol http
http "http://"+$user+":"+$passwd+"@"+$host+":"+$port
authtype HTTPDigetsAuth

$sysinfo=sysinfo()
$sysinfosz=size($sysinfo)

print ("Данные устройства %s (модель %s):\n",$host,$sysinfo %? "BoardName")
for $i=0, $i<$sysinfosz, $i=$i+2
    print ("%-16s: %s\n",$sysinfo[$i],$sysinfo[$i+1])
endfor

Результат:

Данные устройства 192.0.2.3 (модель RB260GS):
ip              : 192.0.2.3
MAC             : 4c:5e:0c:f5:0c:10
SerialNumber    : 6071045F3F09
Uptime          : 89647548
Identity        : MikroTik
Version         : 1.17
BoardName       : RB260GS
Voltage         : 0.0
Temperature     : 0

К началу