From 9c17efc39bd84b6242e4c21c4020a1a175458472 Mon Sep 17 00:00:00 2001 From: Michael Grote <38253905+quotengrote@users.noreply.github.com> Date: Sun, 24 Apr 2022 20:15:57 +0200 Subject: [PATCH] Fix mikrotik_system - temp + voltage (#1307) * Fix awk search-term for ROS7* Value could be named "temperature" or "cpu-temperature". Tested with RB5009, hex, CRS309, CRS305. Search value without :. Check different values in different ROS-Versions. Tested with RB5009, hex, CRS309, CRS305. --- plugins/router/mikrotik_system | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/router/mikrotik_system b/plugins/router/mikrotik_system index 2c753d7b..2a09032b 100755 --- a/plugins/router/mikrotik_system +++ b/plugins/router/mikrotik_system @@ -127,7 +127,7 @@ function get_voltage_label { # if found # print line # external/bash-variables with "'""'" - echo "$line" | awk '/voltage:/{ + echo "$line" | awk '/voltage/{ print "multigraph voltage_graph_""'"$name"'"; print "graph_title voltage " "'"$name"'"; print "graph_vlabel volt"; @@ -139,21 +139,29 @@ function get_voltage_label { done <<< "$data" # der variable data } function get_voltage_value { + get_ros_version while read -r line; do # like the label functions # print title if dirtyconfig is not set # because the call does not come in "config" if [ "$MUNIN_CAP_DIRTYCONFIG" = "0" ] || [ -z "$MUNIN_CAP_DIRTYCONFIG" ]; then - echo "$line" | awk '/voltage:/{ + echo "$line" | awk '/voltage/{ print "multigraph voltage_graph_""'"$name"'"; }' fi - # remove with gsub the char % in argument $2 - # print $2 - echo "$line" | awk '/voltage:/{ - gsub(/V/,"",$2); - print "voltage.value " $2 - }' + if [ "$ros_version" == "6" ]; then + # remove with gsub the char % in argument $2 + # print $2 + echo "$line" | awk '/voltage/{ + gsub(/V/,"",$2); + print "voltage.value " $2 + }' + fi + if [ "$ros_version" == "7" ]; then + echo "$line" | awk '/voltage/{ + print "voltage.value " $3 + }' + fi done <<< "$data" } @@ -267,7 +275,7 @@ function get_temperature_value { }' fi if [ "$ros_version" == "7" ]; then - echo "$line" | awk '/cpu-temperature/{ + echo "$line" | awk '/temperature/{ print "temperature.value " $3 }' fi