Compare commits

...

5 Commits

Author SHA1 Message Date
Steve Schnepp 3b6ef20dc1
Merge pull request #17 from daald/improve-df
Improve df
2023-12-14 14:33:37 +01:00
Daniel Alder c2b8d7315d Fix previous change. The key for config and values was the mountpoint
I accidently changed this to dev. This also works but breaks existing history
2023-12-14 13:26:47 +01:00
Daniel Alder f55b83fdbd Improve df
Before, there were 1+n calls of df where n is the number of output values. I introduced some script magic to use the values from the
first call. Motivation was, there was a very complex sed call which failed to process some of my df output lines. The new code is much
safer.

Actually, the original problem obviously was that the sed regex didn't cover capital letters which I had in my mountpoints.
2023-12-13 14:58:34 +01:00
Lars Kruse a2f1745477 plugin ntpdate: tolerate multiple NTP servers (e.g. in a pool)
Previously multiple "server" lines were consumed, but the output of the
awk filter lacked the line ending.  Thus the last numeric value of the
previous "server" line was concatenated with the first numeric value of
the following "server" line.  Thus multiple dots occurred in a single
numeric value and parsing just failed.

Thanks, glyndon!

Closes: #16
2022-05-04 14:55:41 +02:00
Kim B. Heino 74927fc6e7
ntpdate: fix typo on graph title 2021-08-22 19:37:40 +03:00
2 changed files with 9 additions and 11 deletions

View File

@ -4,21 +4,19 @@ graph_args --upper-limit 100 -l 0
graph_vlabel %
graph_category disk
graph_info This graph shows disk usage on the machine."
for PART in $(df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g')
df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | while read dev type blocks used avail pct mp
do
PINFO=$(df -P "$PART" | tail -1);
PNAME=$(clean_fieldname "$(echo "$PINFO" | cut -d " " -f 1)")
echo "$PNAME.label $PART"
echo "$PNAME.info $PNAME -> $PART"
PNAME=$(clean_fieldname "$mp")
echo "$PNAME.label $mp"
echo "$PNAME.info $dev -> $mp"
echo "$PNAME.warning 92"
echo "$PNAME.critical 98"
done
}
fetch_df() {
for PART in $(df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | sed '/\/[a-z0-9]*$/!d;s/.* \([a-z0-9\/]\{1,\}\)$/\1/g')
df -PT | grep '^/' | grep -vwE "$DF_IGNORE_FILESYSTEM_REGEX" | while read dev type blocks used avail pct mp
do
PINFO=$(df -P "$PART" | tail -1);
PNAME=$(clean_fieldname "$(echo "$PINFO" | cut -d " " -f 1)")
echo "$PNAME.value" "$(echo "$PINFO" | sed -e 's/\%//g' -e 's/ */ /g' | cut -d " " -f 5)"
PNAME=$(clean_fieldname "$mp")
echo "$PNAME.value" "${pct%\%}"
done
}

View File

@ -1,5 +1,5 @@
config_ntpdate() {
echo "graph_title NTP offset and dealy to peer $NTP_PEER"
echo "graph_title NTP offset and delay to peer $NTP_PEER"
echo "graph_args --base 1000 --vertical-label msec"
echo "graph_category time"
echo "offset.label Offset"
@ -11,7 +11,7 @@ fetch_ntpdate() {
OFFSET=0
DELAY=0
if [ -n "$NTP_PEER" ] && [ -x "$NTPDATE" ]; then
DATA=$("$NTPDATE" -q "$NTP_PEER" | awk '/^server.*offset/{gsub(/,/,""); printf "%s %s", ($6*1000), ($8*1000);}')
DATA=$("$NTPDATE" -q "$NTP_PEER" | awk '/^server.*offset/{gsub(/,/,""); printf "%s %s", ($6*1000), ($8*1000); exit;}')
OFFSET=$(echo "$DATA" | cut -d " " -f 1)
DELAY=$(echo "$DATA" | cut -d " " -f 2)
fi