Scripts p2

Скачать как pdf или txt
Скачать как pdf или txt
Вы находитесь на странице: 1из 18

.


: /system script job


name(-; ) -
owner() -
source( ; ) -

[admin@MikroTik] system script> job print


# SCRIPT OWNER STARTED
0 DelayeD admin dec/27/2003 11:17:33

[admin@MikroTik] system script>

[admin@MikroTik] system script> job remove 0


[admin@MikroTik] system script> job print

[admin@MikroTik] system script>


: /system script edit

RouterOS
.

Delete -

Ctrl+h, bakspase -

Tab -

Ctrl+b,LeftArrow

Ctrl+f, RightArrow -

Ctrl+n, DownArrow -

Ctrl+p, UpArrow -

Ctrl+a, Home -

Ctrl+e, End -

Ctrl+y -

Ctrl+k -

Ctrl+u - 8

Ctrl+o -

Ctrl+x -


edit() - name -

backspace, delete Ctrl+k


.
(Ctrl+y ),
. .
VT102 (
"vt102", "linux", "xterm", "rxvt"
VT102). backspace delete
.

.
"hello"
"kuku".

: system
: Level1
: system sheduler
:
:


interval(; 0)- ,
interval ,
, .
name() -
run-count( ; ) - ,
.
start-date() -
start-time() -

run-count .
(),
.
.
move.

,
.

[admin@MikroTik] system script> add name=log-test source=:log message=test


[admin@MikroTik] system script> print
0 name="log-test" source=":log messgae=test" owner=admin run -count=0
[admin@MikroTik] system script> .. scheduler
[admin@MikroTik] system scheduler> add name=run -1h interval=1h
on-event=log-test
[admin@MikroTik] system scheduler> print

Flags: X - disabled
# NAME ON-EVENT START-DATE START-TIME INTERVAL RUN-COUNT
0 run-1h log-test mar/30/2004 06:11:35 1h 0
[admin@MikroTik] system scheduler>


"Cust0". 9
64 Kb/s 5 128 Kb/s.
, .

[admin@MikroTik] queue simple> add name=Cust0 interface=ether1


... dst-address=192.168.0.0/24 limit -at=64000
[admin@MikroTik] queue simple> print
Flags: X - disabled, I - invalid
0 name="Cust0" target-address=0.0.0.0/0 dst-address=192.168.0.0/24

interface=ether1 limit-at=64000 queue=default priority=8 bounded=yes

[admin@MikroTik] queue simple> /system script


[admin@MikroTik] system script> add name=start_limit source={/queue simple set
... Cust0 limit-at=64000}
[admin@MikroTik] system script> add name=stop_limit source={/queue simple set
... Cust0 limit-at=128000}
[admin@MikroTik] system script> print
0 name="start_limit" source="/queue simple set Cust0 limit -at=64000"
owner=admin run-count=0

1 name="stop_limit" source="/queue simple set Cust0 limit -at=128000"


owner=admin run-count=0

[admin@MikroTik] system script> .. scheduler


[admin@MikroTik] system scheduler> add interval=24h name="set -64k"
... start-time=9:00:00 on-event=start_limit
[admin@MikroTik] system scheduler> add interval=24h name="set -128k"
... start-time=17:00:00 on-event=stop_limit
[admin@MikroTik] system scheduler> print
Flags: X - disabled
# NAME ON-EVENT START-DATE START-TIME INTERVAL RUN-COUNT
0 set-64k start... oct/30/2008 09:00:00 1d 0
1 set-128k stop_... oct/30/2008 17:00:00 1d 0
[admin@MikroTik] system scheduler>


e-mail.

[admin@MikroTik] system script> add name=e -backup source={/system backup


{... save name=email; /tool e -mail send to="[email protected]" subject=([/system
{... identity get name] . " Backup") file=email.backup}
[admin@MikroTik] system script> print
0 name="e-backup" source="/system backup save name=ema... owner=admin<br /><br /> runcount=0<br /><br /> <br /><br />[admin@MikroTik] system script> .. scheduler<br /><br
/>[admin@MikroTik] system scheduler> add interval=7d name="email -backup"
... on-event=e-backup
[admin@MikroTik] system scheduler> print
Flags: X - disabled
# NAME ON-EVENT START-DATE START-TIME INTERVAL RUN-COUNT
0 email-... e-backup oct/30/2008 15:19:28 7d 1
[admin@MikroTik] system scheduler>

e -mail, e -mail SMTP


FROM: .

[admin@MikroTik] tool e -mail> set server=159.148.147.198 [email protected]


[admin@MikroTik] tool e -mail> print
server: 159.148.147.198
from: [email protected]
[admin@MikroTik] tool e -mail>

'x' .

[admin@MikroTik] system script> add name=enable -x source={/system scheduler


{... enable x}
[admin@MikroTik] system script> add name=disable -x source={/system scheduler
{... disable x}
[admin@MikroTik] system script> add name=log -x source={:log message=x}
[admin@MikroTik] system script> .. scheduler
[admin@MikroTik] system scheduler> add name=x -up start-time=00:00:00
... interval=24h on-event=enable-x
[admin@MikroTik] system scheduler> add name=x -down start-time=12:00:00
... interval=24h on-event=disable-x
[admin@MikroTik] system scheduler> add name=x start -time=00:00:00 interval=1h
... on-event=log-x
[admin@MikroTik] system scheduler> print
Flags: X - disabled
# NAME ON-EVENT START-DATE START-TIME INTERVAL RUN-COUNT
0 x-up enable-x oct/30/2008 00:00:00 1d 0
1 x-down disab... oct/30/2008 12:00:00 1d 0
2 x log-x oct/30/2008 00:00:00 1h 0
[admin@MikroTik] system scheduler>

: advanced-tools

: Level1
: /tool netwatch
: none
:

.
ICMP .
IP , .

.


down-script() -
unknown up down
host(IP ; : 0.0.0.0) - IP .
interval(; 1s) - ICMP .
,
.
since( : ) - ,
.
status( : up | down| unknown) - .

up - ()

down - ( )

unknown -

/

timeout(; : 1s) - .
, (down)
up-script() -
unknown down up

gw_1 gw_2

:

[admin@MikroTik] system script> add name=gw_1 source={/ip route set


{... [/ip route find dst 0.0.0.0] gateway 10.0.0.1}
[admin@MikroTik] system script> add name=gw_2 source={/ip route set
{.. [/ip route find dst 0.0.0.0] gateway 10.0.0.217}
[admin@MikroTik] system script> /tool netwatch
[admin@MikroTik] tool netwatch> add host=10.0.0.217 interval=10s timeout=998ms
... up-script=gw_2 down-script=gw_1
[admin@MikroTik] tool netwatch> print
Flags: X - disabled
# HOST TIMEOUT INTERVAL STATUS
0 10.0.0.217 997ms 10s up
[admin@MikroTik] tool netwatch> print detail
Flags: X - disabled
0 host=10.0.0.217 timeout=997ms interval=10s since=feb/27/2003 14:01:03
status=up up-script=gw_2 down-script=gw_1

[admin@MikroTik] tool netwatch>

,
.
, ,
.
? . "gw_2"
up
:

[admin@MikroTik] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.217

/ip route find dst 0.0.0.0 dstaddress 0.0.0.0. .


/ip route set
10.0.0.217
"gw_1" down.
.

[admin@MikroTik] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.1

10.0.0.217 .
, e -mail
10.0.0.25 .

[admin@MikroTik] system script> add name=e -down source={/tool e-mail send


{... from="[email protected]" server="159.148.147.198" body="Router down"
{... subject="Router at second floor is down" to="[email protected]"}
[admin@MikroTik] syste m script> add name=e-up source={/tool e-mail send
{... from="[email protected]" server="159.148.147.198" body="Router up"
{.. subject="Router at second floor is up" to="[email protected]"}
[admin@MikroTik] system script>
[admin@MikroTik] system script> /tool n etwatch

[admin@MikroTik] system netwatch> add host=10.0.0.215 timeout=999ms


... interval=20s up-script=e-up down-script=e-down
[admin@MikroTik] tool netwatch> print detail
Flags: X - disabled
0 host=10.0.0.215 timeout=998ms interval=20s since=feb/2 7/2003 14:15:36
status=up up-script=e-up down-script=e-down

[admin@MikroTik] tool netwatch>

: advanced-tools
: Level1
: /tool-traffic monitor
C :
:


.
(
),
,
.

C
interface() -

name() -
on-event() - . /system script
threshold(; :0) -
traffic( | ; : transmitted()) -

transmitted -

received -

triger( | | ; : ) -

above - ,

always - above below

below - ,

ether2,
15kbs ether1 12kbs
ether1.

[admin@MikroTik] system script> add name=eth -up source={/interface enable ether2}


[admin@MikroTik] system script> add name=eth -down source={/interface disable
{... ether2}
[admin@MikroTik] system script> /tool traffic -monitor

[admin@MikroTik] tool traffic -monitor> add name=turn_on interface=ether1


... on-event=eth-up threshold=15000 trigger=above traffic=received
[admin@MikroTik] tool traffic -monitor> add name=turn_off interface=ether1
... on-event=eth-down threshold=12000 trigger=below traffic=received
[admin@MikroTik] tool traffic -monitor> print
Flags: X - disabled, I - invalid
# NAME INTERFACE TRAFFIC TRIGGER THRESHOLD ON -EVENT
0 turn_on ether1 received above 15000 eth -up
1 turn_off ether1 received below 12000 eth -down
[admin@MikroTik] tool traffic -monitor>

Sigwatch( )
: advanced-tools
: Level1
: /tools sigwatch
:
:

Sigwatch


count( : ) - .

log( | ; no) - -of-sigwatch-item:

[ high | low] System-info sigwatch
name() - sigwatch
on-condition(on | off | change; : on) -

on - high

off - low

- .
,

port() -
script() -
signal(dtr | rts | cts | dcd | ri | dsr; : rts) - (
)

dtr - ( 4)

rts - ( 7)

cts - ( 8)

dcd - ( 1)

ri - ( 9)

dsr - ( 6)

state( ; ) -

/system script
.

sigwatch
serial1 cts .

[[email protected]] tool sigwatch> pr


Flags: X - disabled
# NAME PORT SIGNAL ON -CONDITION LOG
0 test serial1 cts change no
[admin@MikroTik] tool sigwatch>

print detail interval=1s,


. state
on, off.

[admin@MikroTik] tool sigwatch> print detail


Flags: X - disabled

0 name="test" port=serial1 signal=cts on -condition=change log=no script=""


count=1 state=on

[admin@MikroTik] tool sigwatch> print detail


Flags: X - disabled
0 name="test" port=serial1 signal=cts on -condition=change log=no script=""
count=1 state=on

[admin@MikroTik] tool sigwatch> print detail


Flags: X - disabled
0 name="test" port=serial1 signal=cts on -condition=change log=no script=""
count=2 state=off

[admin@MikroTik] tool sigw atch> print detail


Flags: X - disabled
0 name="test" port=serial1 signal=cts on -condition=change log=no script=""
count=2 state=off

[admin@MikroTik] tool sigwatch>

port
.

[admin@MikroTik] port> print stats


0 name="serial0" line-state=dtr,rts

1 name="serial1" line-state=dtr,rts
[admin@MikroTik] port>

[admin@MikroTik] port> print stats


0 name="serial0" line-state=dtr,rts

1 name="serial1" line-state=dtr,rts,cts
[admin@MikroTik] port>


dtr,rts cts
oncondition
off

[[email protected]] tool sigwat ch> pr detail


Flags: X - disabled
0 name="cts_rest" port=serial1 signal=cts on -condition=off log=no
script=/system shutdown count=0 state=on
[[email protected]] tool sigwatch>

:
.
. .
.

Вам также может понравиться