Adding devices to the free MikroTik Dude program is straight forward enough and how to configure Dude for a basic setup will not be covered here as that is already well documented elsewhere.
What I will examine today is Dude labels. The stock information provided on a device’s label is configured under ‘Settings / Map / Label’ field. It will likely only contain the following default data fields which are configured to be displayed on every device icon:
These values are predefined and are obvious from their names. E.g. [Device.Name] will display the name of the device as stored in the device settings by double clicking the device and looking in the Name field.
Adding new Functions allows us to provide more additional data extracted from a device. Normally this would be in the form of SNMP data, as in this example which will display the Total Power consumed on a Netonix Switch.
oid("iso.org.dod.internet.private.enterprises.netonixSwitch.totalPowerConsumption.0")
Having defined that function, one can then add that to the label appearance as follows (where ‘Netonix_TotalPower_Collector’ is the name of the Function):
[Device.Name] [Device.FirstAddress] Netonix Total Power = [Netonix_TotalPower_Collector()]W [TimeAndDate]
Note how I have also inserted in some extra descriptive text (“Netonix Total Power = ” and the trailing “W”) onto the label appearance settings. Also note that all functions must have a () set of brackets after their name.
As this function obtains only data values we can also re-use this Function in a probe which allows it to be graphed and alert us if it falls outside set parameters.
By setting “Netonix Total Power = [Netonix_TotalPower_Collector()]” to be displayed on every label, it will also be display “Netonix Total Power = W” on devices that are not a Netonix switch! We can fix this by adding a second function (called Netonix_Total_Power) that takes this data obtaining function and adds text only if the SNMP OID is present.
if(string_size(Netonix_TotalPower_Collector()),concatenate(“Netonix Total Power = “,Netonix_TotalPower_Collector(),”W
“),””)
Note that after the W on the end of the first line, it is immediately followed by a new line. The final “” in the equation means display a blank if the SNMP OID is not found. Therefore if the SNMP OID is found, the function will display the preceding text, the value, then a new line, but only if it is a Netonix Switch, but on all other devices it will display nothing at all. The label appearance can then be changed to :
[Device.Name] [Device.FirstAddress] [Netonix_Total_Power()][TimeAndDate]
Note that there is no ‘New Line’ between [Netonix_Total_Power()] and [TimeAndDate] as that will be inserted in by the function (if actioned). Adding new lines between these types of functions where the new line is auto-inserted (and therefore only being there if needed) stops the Dude displaying the data values with extra Carriage Returns and making the labels vertically spaced out more than required.