Verschiebe in Root

This commit is contained in:
no
2024-11-28 13:36:01 +01:00
parent a99479e4c6
commit fca6e5ba93
8 changed files with 0 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
function check_network_traffic() {
total_inbound=0
total_outbound=0
for ((i=1; i<=$MEASUREMENT_COUNT; i++)); do
usage=$(ifstat -i $INTERFACE $INTERVAL 1 | tail -n 1)
if [[ -z "$usage" ]]; then
log_error "No output from ifstat on measurement $i."
exit 2
fi
inbound=$(echo $usage | awk '{print $1}')
outbound=$(echo $usage | awk '{print $2}')
total_inbound=$(echo "$total_inbound + $inbound" | bc)
total_outbound=$(echo "$total_outbound + $outbound" | bc)
done
avg_inbound=$(echo "scale=2; $total_inbound / $MEASUREMENT_COUNT" | bc)
avg_outbound=$(echo "scale=2; $total_outbound / $MEASUREMENT_COUNT" | bc)
if (( $(echo "$avg_inbound < $THRESHOLD_INBOUND" | bc -l) )) || (( $(echo "$avg_outbound < $THRESHOLD_OUTBOUND" | bc -l) )); then
log_critical "Network traffic below thresholds. Avg In: $avg_inbound KB/s, Avg Out: $avg_outbound KB/s."
restart_service
else
log_info "Network traffic is above thresholds. Avg In: $avg_inbound KB/s, Avg Out: $avg_outbound KB/s."
fi
}