From b43ec018dcc0a90eb8815094370ef2fdb93263bf Mon Sep 17 00:00:00 2001 From: Younes Ichiche Date: Sun, 28 Nov 2021 09:16:55 +0100 Subject: [PATCH] use printf and pass variable to awk --- plugins/router/mikrotik_system | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/router/mikrotik_system b/plugins/router/mikrotik_system index fa00afd3..766170ec 100755 --- a/plugins/router/mikrotik_system +++ b/plugins/router/mikrotik_system @@ -320,9 +320,9 @@ function get_memory_label { get_mem_total get_mem_free while read -r line; do - echo "$line" | awk '/free-memory:/{ - print "multigraph memory_graph_""'"$name"'"; - print "graph_title memory " "'"$name"'"; + echo "$line" | awk -v name=$name '/free-memory:/{ + printf "multigraph memory_graph_%s\n", name; + printf "graph_title memory %s\n", name; print "graph_vlabel MiB"; print "graph_category mikrotik"; print "graph_args -l 0"; @@ -331,8 +331,8 @@ function get_memory_label { print "free_memory.label free memory"; print "graph_info Total, Used & free RAM."; gsub(/MiB/,"",$2); - print "used_memory.critical " $2*0.9; - print "used_memory.warning " $2*0.7 }' + printf "used_memory.critical %.0f\n", $2*0.9; + printf "used_memory.warning %.0f\n", $2*0.7 }' done <<< "$data" } function get_memory_value {