Community discussions

 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 1310
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

"/system resources" do miss "find", bug?

Sun Jul 22, 2018 10:27 am

I am trying to get memory usage from the my MikrtoTik 750Gv3 without using SNMP.

To get other information like snapshot information I do use this line:
foreach logline in=[/ip accounting snapshot find] do={:log info message="$[/ip accounting snapshot print as-value from=$logline]"}
find command is the clue here. It will split the output so it sends each line as a separate line.
But for
/system resources the find is missing.
You have the usual print, but not find
/system resource>

.. -- go up to system
cpu --
export -- Print or save an export script that can be used to restore configuration
get -- Gets value of item's property
irq -- Interrupt Request usage information
monitor -- Monitor CPU and memory usage
pci -- List of all PCI devices
print -- Print values of item properties
usb -- List of all USB devices
If I go to cpu, find is there:
/system resource cpu>

.. -- go up to resource
find -- Find items by value
get -- Gets value of item's property
print -- Print values of item properties
Any tips on how to get the /system resources out as line by line?
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 1310
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: "/system resources" do miss "find", bug?

Sun Jul 22, 2018 10:36 am

Why does this work:
log info message=[/ip firewall nat print dynamic as-value]
but not this?
log info message=[/system resource print dynamic as-value]
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
dasiu
Trainer
Trainer
Posts: 232
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

Re: "/system resources" do miss "find", bug?

Mon Jul 23, 2018 3:09 am

Hi,

1. Don't use "print as-value" if you don't need it. Learn how to use find and get.
2. Your example doesn't work, because there is no "dynamic" entry in system resources. Without "dynamic" it should work:
log info message=[/system resource print as-value]
3. Please, look at this:
log info message=[/system resource get free-memory]
And generally - when you do /system resource get <TAB> - you'll see the values you can just obtain. Then you can do it in smart way, for example:
:local freemem [/system resource get free-memory];
:local totmem [/system resource get total-memory];
:log info message="Free memory: $freemem bytes out of $totmem bytes";
Or maybe:
:local freemem ([/system resource get free-memory]/1000000);
:local totmem ([/system resource get total-memory]/1000000);
:log info message="Free memory: $freemem MB out of $totmem MB";
 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 1310
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: "/system resources" do miss "find", bug?

Mon Jul 23, 2018 9:36 am

Thanks allot.
I do see I have lot to learn about scripting :)

Here is what I use now:
:local freemem ([/system resource get free-memory]/1000000);
:local totmem ([/system resource get total-memory]/1000000);
:local freehddspace ([/system resource get free-hdd-space]/1000000);
:local totalhddspace ([/system resource get total-hdd-space]/1000000);
:local cpuload ([/system resource get cpu-load]);
:local up ([/system resource get uptime]);
:log info message="free-memory=$freemem MB total_memory=$totmem MB free-hdd-space=$freehddspace MB total-hdd-space=$totalhddspace MB cpu_load=$cpuload uptime=$up";
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: Google [Bot] and 14 guests