mem und free als func
This commit is contained in:
parent
bd8640d788
commit
77f6359621
1 changed files with 15 additions and 8 deletions
|
@ -68,6 +68,18 @@ function get_data {
|
|||
# hole daten per ssh
|
||||
data=$(sshpass -p $ssh_password ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $ssh_user@$ssh_host -q ':delay 6s; /system health print; /system resource print; /system resource cpu print; /system identity print')
|
||||
}
|
||||
function get_mem_total {
|
||||
mem_total=$(
|
||||
while read -r line; do
|
||||
echo $line | awk '/total-memory:/{ gsub(/MiB/,"",$2); print $2 }' | tr -dc '[0-9.]'
|
||||
done <<< "$data")
|
||||
}
|
||||
function get_mem_free {
|
||||
mem_free=$(
|
||||
while read -r line; do
|
||||
echo $line | awk '/free-memory:/{ gsub(/MiB/,"",$2); print $2 }' | tr -dc '[0-9.]'
|
||||
done <<< "$data")
|
||||
}
|
||||
|
||||
function get_voltage_label {
|
||||
while read -r line; do # für jede zeile in... ; siehe "done"
|
||||
|
@ -265,6 +277,8 @@ function get_cpu_value {
|
|||
}
|
||||
|
||||
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"'";
|
||||
|
@ -297,14 +311,7 @@ function get_memory_value {
|
|||
done <<< "$data"
|
||||
# berechne used-memory
|
||||
# gesamt + frei = benutzt
|
||||
mem_total=$(
|
||||
while read -r line; do
|
||||
echo $line | awk '/total-memory:/{ gsub(/MiB/,"",$2); print $2 }' | tr -dc '[0-9.]'
|
||||
done <<< "$data")
|
||||
mem_free=$(
|
||||
while read -r line; do
|
||||
echo $line | awk '/free-memory:/{ gsub(/MiB/,"",$2); print $2 }' | tr -dc '[0-9.]'
|
||||
done <<< "$data")
|
||||
|
||||
echo used_memory.value $(echo $mem_total-$mem_free| bc)
|
||||
# prufe noch ob war gesetzt
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue