after long time looking over forums and testing I have finally found solution how to monitor my APC UPSs which are connected to MikroTik servers by serial/usb cable.
Since there is not possible to use standard SNMP OID (mikrotiks snmp currently do not include values from UPS) you need to use The Dude functions and create own functions/probes.
For that I have used ros_command() function which is possible to use to send command and get an answer from RouterOS server. Please note that you need configure your The Dude to connect to server which monitoring your UPS - so you need to tape an username/password to device configuration. Also be sure that your UPS is named "ups1" (in other way, you need to rename that in fallowing functions).
After that you can use fallowing functions:
ups_status() (returns 1 if UPS is online, 0 if is offline)
Code: Select all
if (string_substring(ros_command("/system ups monitor ups1 once"),string_find(ros_command("/system ups monitor ups1 once"),"on-line")+9,3), "1", "0")
Code: Select all
round(
string_substring(ros_command("/system ups monitor ups1 once"),
string_find(
ros_command("/system ups monitor ups1 once"),"battery-charge")+16,
3)
)
Code: Select all
round(
string_substring(ros_command("/system ups monitor ups1 once"),
string_find(
ros_command("/system ups monitor ups1 once"),"temperature")+13,
2)
)
ups_available()
Code: Select all
if (string_size(ros_command("/system ups monitor ups1 once")) > 40, "1", "0")
ups_info()
Code: Select all
concatenate(
if(ups_available() > 0, concatenate("ups: ", round(ups_battery_charge()), "% "), ""),
if(ups_available() > 0, concatenate("temp: ", round(ups_temperature()), "C "), "")
)
device_performance() (modification of original function - will add UPS info when is an ups present)
Code: Select all
concatenate(
if(
string_size(cpu_mem_disk()) > 0,
concatenate(cpu_mem_disk(), "
"),
""
)
,
if(
string_size(ups_info()) > 0,
concatenate(ups_info(), "
"),
""
)
)
ups status - Probe
type: Function
Agent: Default
Available: ups_available()
Errror: if(ups_status(), "", "Off-line")
Value: ups_battery_charge()
Unit: %
Rate: none
That is all of my examples. Until RouterOS will give us full SNMP OID UPS status, can be this usefull.
All of this is just an example. Be sure that you make an backup of your The Dude configuration. Also I am pretty sure that my solution is not just only working one - but works.
Any suggestions to improve welcome!
Regards
Pelish