My question is: How to send output from a script to syslog?
Example:
I would like a script to show the dynamic nat and send that to my external syslog server.
Code: Select all
/ip firewall nat print dynamic
/ip firewall nat print dynamic
try this:My question is: How to send output from a script to syslog?
Example:
I would like a script to show the dynamic nat and send that to my external syslog server.Code: Select all/ip firewall nat print dynamic
:log info message=[/ip firewall nat print dynamic as-value ]
script,info MikroTik: orrent (TCP);dst-address=92.220.197.134;dst-port=28816;in-interface=ether1-Wan;protocol=tcp;to-addresses=10.10.10.32;to-ports=28816;.id=*1a9c;action=dst-nat;chain=dstnat;comment=upnp 10.10.10.32: uTorrent (UDP);dst-address=92.220.197.134;dst-port=28816;in-
script,info MikroTik: .id=*1a57;action=dst-nat;chain=dstnat;comment=upnp 10.10.10.32: Teredo;dst-address=92.220.197.134;dst-port=49290;in-interface=ether1-Wan;protocol=udp;to-addresses=10.10.10.32;to-ports=49290;.id=*1a9b;action=dst-nat;chain=dstnat;comment=upnp 10.10.10.32: uT
/ip firewall nat print dynamic
Flags: X - disabled, I - invalid, D - dynamic
0 D ;;; upnp 10.10.10.32: Teredo
chain=dstnat action=dst-nat to-addresses=10.10.10.32 to-ports=49290 protocol=udp
dst-address=92.220.197.134 in-interface=ether1-Wan dst-port=49290
1 D ;;; upnp 10.10.10.32: uTorrent (TCP)
chain=dstnat action=dst-nat to-addresses=10.10.10.32 to-ports=28816 protocol=tcp
dst-address=92.220.197.134 in-interface=ether1-Wan dst-port=28816
2 D ;;; upnp 10.10.10.32: uTorrent (UDP)
chain=dstnat action=dst-nat to-addresses=10.10.10.32 to-ports=28816 protocol=udp
dst-address=92.220.197.134 in-interface=ether1-Wan dst-port=28816
:foreach logline in=[/ip firewall nat find dynamic=yes] do={:log info message="$[/ip firewall nat print as-value from=$logline]"}
script,info MikroTik: .nextid=*ffffffff;action=dst-nat;chain=dstnat;comment=upnp 10.10.10.32: uTorrent (UDP);dst-address=92.220.197.134;dst-port=28816;in-interface=ether1-Wan;protocol=udp;to-addresses=10.10.10.32;to-ports=28816
script,info MikroTik: .nextid=*1b04;action=dst-nat;chain=dstnat;comment=upnp 10.10.10.32: uTorrent (TCP);dst-address=92.220.197.134;dst-port=28816;in-interface=ether1-Wan;protocol=tcp;to-addresses=10.10.10.32;to-ports=28816
script,info MikroTik: .nextid=*1b03;action=dst-nat;chain=dstnat;comment=upnp 10.10.10.32: Teredo;dst-address=92.220.197.134;dst-port=49290;in-interface=ether1-Wan;protocol=udp;to-addresses=10.10.10.32;to-ports=49290
/ip accounting snapshot print
:foreach logline in=[/ip accounting snapshot print] do={:log info message="$[/ip accounting snapshot print as-value from=$logline]"}
foreach logline in=[/ip accounting snapshot find dynamic=yes] do={:log info message="$[/ip accounting snapshot print as-value from=$logline]"}
foreach logline in=[/ip accounting snapshot find] do={:log info message="$[/ip accounting snapshot print as-value from=$logline]"}
# SRC-ADDRESS DST-ADDRESS PACKETS BYTES SRC-USER DST-USER
0 193.212.207.247 10.10.10.32 41 47011
1 37.247.52.130 10.10.10.32 31 32623
2 10.10.10.32 193.212.207.247 33 3077
3 31.13.72.8 10.10.10.128 4 349
script,info MikroTik: .id=*56;bytes=291;dst-address=10.10.10.80;packets=6;src-address=109.74.9.62
script,info MikroTik: .id=*55;bytes=612;dst-address=10.10.10.128;packets=7;src-address=31.13.72.38
script,info MikroTik: .id=*54;bytes=99891;dst-address=31.13.72.49;packets=706;src-address=10.10.10.241
script,info MikroTik: .id=*53;bytes=285;dst-address=31.13.72.32;packets=5;src-address=10.10.10.128
script,info MikroTik: .id=*52;bytes=1131;dst-address=10.10.10.128;packets=9;src-address=162.125.18.133
script,info MikroTik: .id=*51;bytes=1077;dst-address=10.10.10.50;packets=14;src-address=125.209.235.182
foreach logline in=[/ip accounting snapshot find] do={:log info message="$[/ip accounting snapshot print as-value from=$logline]"}
foreach logline in=[/ip accounting snapshot find] do={:log info message="test $[/ip accounting snapshot print as-value from=$logline]"}
foreach logline in=[/ip accounting snapshot find] do={:log info message="test"."$[/ip accounting snapshot print as-value from=$logline]"}
: local line
:foreach logline in=[/ip accounting snapshot find] do={
:set line ("test")
:set line ($line . "$[/ip accounting snapshot print as-value from=$logline]")
:log info message="$line"}