diff --git a/traffic-peak-monitor.sh b/traffic-peak-monitor.sh index 1d336f2..a8337a8 100755 --- a/traffic-peak-monitor.sh +++ b/traffic-peak-monitor.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # # traffic-peak-monitor.sh # ------------------------ @@ -147,7 +147,19 @@ run_worker() { # Log-Datei schreiben. Wichtig: das muss VOR einer moeglichen # Tages-Rotation passieren, da dieser Eintrag noch zu CUR_DAY # gehoert (z.B. der Eintrag "23:00-00:00" gehoert noch zum alten Tag). - echo "${HOUR_START}-${HOUR_END} peak_rx=${MAX_RX_KBIT}kbit/s (${RX_PCT}%) peak_tx=${MAX_TX_KBIT}kbit/s (${TX_PCT}%)" >> "$log_file" + # + # Feste Feldbreiten fuer eine sauber ausgerichtete Ausgabe: + # %7d -> kbit/s-Wert, rechtsbuendig, 7 Stellen breit. + # 7 Stellen reichen bis 9.999.999 kbit/s (= 9999 Mbit/s), + # deckt also auch 1000-Mbit/s-Leitungen (max. 1.000.000 + # kbit/s = 7-stellig) komfortabel ab. + # %5.1f -> Prozentwert, rechtsbuendig, 1 Nachkommastelle, + # 5 Stellen breit (deckt bis "100.0" ab). + # Durch die feste Breite des peak_rx-Blocks beginnt "peak_tx=" + # in jeder Zeile automatisch an derselben Spalte (linksbuendig), + # unabhaengig davon wie gross die einzelnen Zahlen sind. + printf '%s peak_rx=%7dkbit/s (%5.1f%%) peak_tx=%7dkbit/s (%5.1f%%)\n' \ + "${HOUR_START}-${HOUR_END}" "$MAX_RX_KBIT" "$RX_PCT" "$MAX_TX_KBIT" "$TX_PCT" >> "$log_file" MAX_RX=0 MAX_TX=0