reihenfolge

This commit is contained in:
Michael Grote 2021-09-21 15:50:23 +02:00
parent 68ee4016e1
commit 544ab69714

View file

@ -20,7 +20,6 @@
# TODO:
# - [ ] normal cpu mit rein
# - [ ] limits für cpu
# - [ ] alles als func
# - [ ] doku
# - [ ] free-hdd-space: 4760.0KiB
# - [ ] total-hdd-space: 16.3MiB
@ -36,108 +35,6 @@ c=0 # zähler; wird für verschiedene Schleifen benötigt
# Funktionen
function get_voltage_label {
while read -r line; do # für jede zeile in... ; siehe "done"
# gebe die zeile aus
# suche mit awk nach "voltage:"
# wenn gefunden:
# gebe jede zeile per print text aus
# externe/bash-variablen mit "'"<var>"'"
echo $line | awk '/voltage:/{
print "multigraph voltage_graph_""'"$name"'";
print "graph_title voltage " "'"$name"'";
print "graph_vlabel volt";
print "graph_category mikrotik";
print "graph_args -l 0";
print "voltage.label voltage"
}'
done <<< "$data" # der variable data
}
function get_bad_blocks_label {
while read -r line; do
echo $line | awk '/bad-blocks:/{
print "multigraph bad_blocks_graph_""'"$name"'";
print "graph_title bad blocks " "'"$name"'";
print "graph_vlabel %";
print "graph_category mikrotik";
print "graph_args -l 0 --upper-limit 100";
print "bad_blocks.label bad_blocks";
print "bad_blocks.warning 2";
print "bad_blocks.critical 25"
}'
done <<< "$data"
}
function get_write_sect_total_label {
while read -r line; do
echo $line | awk '/write-sect-total:/{
print "multigraph write_sect_total_graph_""'"$name"'";
print "graph_title Total sector writes " "'"$name"'";
print "graph_vlabel count";
print "graph_category mikrotik";
print "graph_args -l 0";
print "write_sect_total.label write_sect_total"
}'
done <<< "$data"
}
function get_write_sect_since_reboot_label {
while read -r line; do
echo $line | awk '/write-sect-since-reboot:/{
print "multigraph write_sect_since_reboot_graph_""'"$name"'";
print "graph_title Sector writes since reboot " "'"$name"'";
print "graph_vlabel count";
print "graph_category mikrotik";
print "graph_args -l 0";
print "write_sect_since_reboot.label write_sect_since_reboot"
}'
done <<< "$data"
}
function get_cpu_load_label {
while read -r line; do
echo $line | awk '/cpu-load:/{
print "multigraph cpu_load_graph_""'"$name"'";
print "graph_title cpu load " "'"$name"'";
print "graph_vlabel %";
print "graph_category mikrotik";
print "graph_args -l 0 --upper-limit 100";
print "cpu_load.label cpu_load";
print "cpu_load.warning 75";
print "cpu_load.critical 90";
print "cpu_load.draw AREA"
}'
done <<< "$data"
}
function get_temperature_label {
while read -r line; do
echo $line | awk '/temperature:/{
print "multigraph temperature_graph_""'"$name"'";
print "graph_title temperature " "'"$name"'";
print "graph_vlabel °C";
print "graph_category mikrotik";
print "graph_args -l 0";
print "temperature.label cpu temperature";
print "temperature.warning 75";
print "temperature.critical 90"
}'
done <<< "$data"
}
function get_cpu_detail_label {
echo multigraph cpu_load_detail_$name
echo graph_title cpu load $name
echo graph_vlabel %
echo graph_category mikrotik
echo graph_args -l 0 --upper-limit 100
while [ "$c" -lt "$anzahl_cpu" ]; do
while read -r line; do
echo $line | grep cpu$c | awk '{
print "cpu"'"$c"'"_load.label " "load " "cpu" "'"$c"'"
print "cpu"'"$c"'"_irq.label " "irq " "cpu" "'"$c"'"
print "cpu"'"$c"'"_disk.label " "disk " "cpu" "'"$c"'"
}'
done <<< "$data"
c=$(( $c + 1 ))
done
}
function get_name {
while read -r line; do
if echo $line | grep 'name:' > /dev/null; then
@ -158,6 +55,24 @@ function check_sshpass {
exit 1
fi
}
function get_voltage_label {
while read -r line; do # für jede zeile in... ; siehe "done"
# gebe die zeile aus
# suche mit awk nach "voltage:"
# wenn gefunden:
# gebe jede zeile per print text aus
# externe/bash-variablen mit "'"<var>"'"
echo $line | awk '/voltage:/{
print "multigraph voltage_graph_""'"$name"'";
print "graph_title voltage " "'"$name"'";
print "graph_vlabel volt";
print "graph_category mikrotik";
print "graph_args -l 0";
print "voltage.label voltage"
}'
done <<< "$data" # der variable data
}
function get_voltage_value {
while read -r line; do
# funktion wie bei den "label"-funktionen
@ -172,6 +87,21 @@ function get_voltage_value {
}'
done <<< "$data"
}
function get_bad_blocks_label {
while read -r line; do
echo $line | awk '/bad-blocks:/{
print "multigraph bad_blocks_graph_""'"$name"'";
print "graph_title bad blocks " "'"$name"'";
print "graph_vlabel %";
print "graph_category mikrotik";
print "graph_args -l 0 --upper-limit 100";
print "bad_blocks.label bad_blocks";
print "bad_blocks.warning 2";
print "bad_blocks.critical 25"
}'
done <<< "$data"
}
function get_bad_blocks_value {
while read -r line; do
echo $line | awk '/bad-blocks:/{
@ -181,6 +111,19 @@ function get_bad_blocks_value {
}'
done <<< "$data"
}
function get_write_sect_total_label {
while read -r line; do
echo $line | awk '/write-sect-total:/{
print "multigraph write_sect_total_graph_""'"$name"'";
print "graph_title Total sector writes " "'"$name"'";
print "graph_vlabel count";
print "graph_category mikrotik";
print "graph_args -l 0";
print "write_sect_total.label write_sect_total"
}'
done <<< "$data"
}
function get_write_sect_total_value {
while read -r line; do
echo $line | awk '/write-sect-total:/{
@ -189,6 +132,19 @@ function get_write_sect_total_value {
}'
done <<< "$data"
}
function get_write_sect_since_reboot_label {
while read -r line; do
echo $line | awk '/write-sect-since-reboot:/{
print "multigraph write_sect_since_reboot_graph_""'"$name"'";
print "graph_title Sector writes since reboot " "'"$name"'";
print "graph_vlabel count";
print "graph_category mikrotik";
print "graph_args -l 0";
print "write_sect_since_reboot.label write_sect_since_reboot"
}'
done <<< "$data"
}
function get_write_sect_since_reboot_value {
while read -r line; do
echo $line | awk '/write-sect-since-reboot:/{
@ -197,6 +153,23 @@ function get_write_sect_since_reboot_value {
}'
done <<< "$data"
}
function get_cpu_load_label {
while read -r line; do
echo $line | awk '/cpu-load:/{
print "multigraph cpu_load_graph_""'"$name"'";
print "graph_title cpu load " "'"$name"'";
print "graph_vlabel %";
print "graph_category mikrotik";
print "graph_args -l 0 --upper-limit 100";
print "cpu_load.label cpu_load";
print "cpu_load.warning 75";
print "cpu_load.critical 90";
print "cpu_load.draw AREA"
}'
done <<< "$data"
}
function get_cpu_load_value {
while read -r line; do
echo $line | awk '/cpu-load:/{
@ -206,6 +179,21 @@ function get_cpu_load_value {
}'
done <<< "$data"
}
function get_temperature_label {
while read -r line; do
echo $line | awk '/temperature:/{
print "multigraph temperature_graph_""'"$name"'";
print "graph_title temperature " "'"$name"'";
print "graph_vlabel °C";
print "graph_category mikrotik";
print "graph_args -l 0";
print "temperature.label cpu temperature";
print "temperature.warning 75";
print "temperature.critical 90"
}'
done <<< "$data"
}
function get_temperature_value {
while read -r line; do
echo $line | awk '/temperature:/{
@ -215,6 +203,24 @@ function get_temperature_value {
}'
done <<< "$data"
}
function get_cpu_detail_label {
echo multigraph cpu_load_detail_$name
echo graph_title cpu load $name
echo graph_vlabel %
echo graph_category mikrotik
echo graph_args -l 0 --upper-limit 100
while [ "$c" -lt "$anzahl_cpu" ]; do
while read -r line; do
echo $line | grep cpu$c | awk '{
print "cpu"'"$c"'"_load.label " "load " "cpu" "'"$c"'"
print "cpu"'"$c"'"_irq.label " "irq " "cpu" "'"$c"'"
print "cpu"'"$c"'"_disk.label " "disk " "cpu" "'"$c"'"
}'
done <<< "$data"
c=$(( $c + 1 ))
done
}
function get_cpu_detail_value {
echo multigraph cpu_load_detail_$name
c=0