Local-check problem with agent-output, breaks line

Hello everybody,

I have problems with a local check. As soon as I have a “comma” or a “dot” in the status text of the output, he makes a new line at this dot …

Here is the script, the output of the script and the output from the agent:

Script:

find /backup/RSYNC-BACKUP/. -maxdepth 0 | while read line; do

name=$(echo “$line” | awk -F “^/backup/RSYNC-BACKUP/” ‘{print $2}’)
percent=$(df -h | grep $line | awk ‘{print $5}’ | grep -o ‘[0-9,]+’)
used=$(df -h | grep $line | awk ‘{print $3}’ | grep -o ‘[0-9,]+’)
size=$(df -h | grep $line | awk ‘{print $2}’ | grep -o ‘[0-9,]+’)

if [ “$percent” -ge “90” 2>/dev/null ]; then
status=2
statustext=“$percent% used (”$used"GB of “$size"GB)”
elif [ “$percent” -ge “80” 2>/dev/null ]; then
status=1
statustext=“$percent% used (”$used"GB of “$size"GB)”
elif [ “$percent” -lt “80” 2>/dev/null ]; then
status=0
statustext=“$percent% used (”$used"GB of “$size"GB)”
else
status=2
statustext=“Fehler beim auslesen von $line”
fi

echo “$status SPACE:$name used=$used $statustext” | sed ‘s/,/./g’

done

Output Script:

0 SPACE:**** used=12 13% used (12GB of 98GB)
0 SPACE:**** used=52 22% used (52GB of 246GB)
0 SPACE:**** used=20 43% used (20GB of 49GB)
0 SPACE:**** used=18 19% used (18GB of 98GB)
0 SPACE:**** used=925 2% used (925GB of 49GB)
0 SPACE:**** used=33 15% used (33GB of 246GB)
2 SPACE:**** used= Fehler beim auslesen von /backup/RSYNC-BACKUP/****
0 SPACE:**** used=30 13% used (30GB of 246GB)
0 SPACE:**** used=562 2% used (562GB of 49GB)
0 SPACE:**** used=6.6 15% used (6.6GB of 49GB)
0 SPACE:**** used=7.0 15% used (7.0GB of 49GB)
0 SPACE:**** used=20 42% used (20GB of 49GB)
0 SPACE:**** used=48 21% used (48GB of 246GB)
0 SPACE:**** used=8.8 10% used (8.8GB of 98GB)
0 SPACE:**** used=54 24% used (54GB of 246GB)
0 SPACE:**** used=39 17% used (39GB of 246GB)
0 SPACE:**** used=151 65% used (151GB of 246GB)

Output from Agent:

cached(1582102357,43200) 0 SPACE:**** used=12 13% used (12GB of 98GB)
cached(1582102357,43200) 0 SPACE:**** used=52 22% used (52GB of 246GB)
cached(1582102357,43200) 0 SPACE:**** used=20 43% used (20GB of 49GB)
cached(1582102357,43200) 0 SPACE:**** used=18 19% used (18GB of 98GB)
cached(1582102357,43200) 0 SPACE:**** used=925 2% used (925GB of 49GB)
cached(1582102357,43200) 0 SPACE:**** used=33 15% used (33GB of 246GB)
cached(1582102357,43200) 2 SPACE:**** used= Fehler beim auslesen von /backup/RSYNC-BACKUP/****
cached(1582102357,43200) 0 SPACE:**** used=30 13% used (30GB of 246GB)
cached(1582102357,43200) 0 SPACE:**** used=562 2% used (562GB of 49GB)
cached(1582102357,43200) 0 SPACE:**** used=6
cached(1582102357,43200) 6 15% used (6
cached(1582102357,43200) 6GB of 49GB)
cached(1582102357,43200) 0 SPACE:**** used=7
cached(1582102357,43200) 0 15% used (7
cached(1582102357,43200) 0GB of 49GB)
cached(1582102357,43200) 0 SPACE:**** used=20 42% used (20GB of 49GB)
cached(1582102357,43200) 0 SPACE:**** used=48 21% used (48GB of 246GB)
cached(1582102357,43200) 0 SPACE:**** used=8
cached(1582102357,43200) 8 10% used (8
cached(1582102357,43200) 8GB of 98GB)
cached(1582102357,43200) 0 SPACE:**** used=54 24% used (54GB of 246GB)
cached(1582102357,43200) 0 SPACE:**** used=39 17% used (39GB of 246GB)
cached(1582102357,43200) 0 SPACE:**** used=151 65% used (151GB of 246GB)

Maybe someone has an idea how I could solve this?

Best regards

Niko

Hi,
I tried it with your output and checkmk works fine (1.6.0p8 CEE). Looks like your shell interprete .0 as new line.
Regards, Christian

Maybe try to replace sed 's/,/./g' with tr ',' '.' . Sometimes “sed” is weird…

Many thanks for your help. As so often happens after a while :smile:

The “grep -o ‘[0-9,]+’” in the variable “used” was responsible for the strange schaver. With the following script there are no problems;)

find /backup/RSYNC-BACKUP/. -maxdepth 0 | while read line; do

name=$(echo “$line” | awk -F “^/backup/RSYNC-BACKUP/” ‘{print $2}’)
percent=$(df -h | grep $line | awk ‘{print $5}’ | grep -o ‘[0-9,]+’)
used=$(df -h | grep $line | awk ‘{print $3}’)
size=$(df -h | grep $line | awk ‘{print $2}’)

if [ “$percent” -ge “90” 2>/dev/null ]; then
status=2
statustext=“$percent% used (”$used" of “$size”)"
elif [ “$percent” -ge “80” 2>/dev/null ]; then
status=1
statustext=“$percent% used (”$used" of “$size”)"
elif [ “$percent” -lt “80” 2>/dev/null ]; then
status=0
statustext=“$percent% used (”$used" of “$size”)"
else
status=2
statustext=“Fehler beim auslesen von $line”
fi

echo “$status SPACE:$name used=$used $statustext”

done