Skip to content

Commit

Permalink
Strip all non-ASCII characters from hddtemp output
Browse files Browse the repository at this point in the history
  • Loading branch information
einarjh committed Jun 8, 2017
1 parent 3903f43 commit 8119489
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion agent-local/hddtemp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if [ "${hddtemp}" != "" ]; then
else
output=`${hddtemp} -w -q ${disks} 2>/dev/null`
fi
content=`echo "$output" | awk -F": " 'BEGIN{ ORS="" }{ print "|"$1"|"$2"|"$3"|";} ' | sed 's/[° ]C|/|C|/g' | sed 's/[° ]F|/|F|/g'`
content=`echo "$output" | awk -F": " 'BEGIN{ ORS="" }{ print "|"$1"|"$2"|"$3"|";} ' | sed 's/[° ]C|/|C|/g' | sed 's/[° ]F|/|F|/g' | tr -cd '\12\14\40-\176'`
if [ "${content}" != "" ]; then
echo '<<<hddtemp>>>'
echo ${content}
Expand Down

1 comment on commit 8119489

@einarjh
Copy link
Owner Author

@einarjh einarjh commented on 8119489 Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works around garbage output from the hddtemp utility by stripping away everything but CR, LF and all characters from octal 40 to 176 (up until DEL). Fixes librenms/librenms#6800.

Please sign in to comment.