2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

[file_length_] Cleanup and shellcheck

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
Olivier Mehani 2016-10-29 17:43:40 +11:00
parent 0d27db73ea
commit 6d4da015de

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
: << =cut : << =cut
@ -18,25 +18,35 @@ Useful for things such as lists (white, black, user, ...).
=head1 AUTHOR =head1 AUTHOR
Olivier Mehani (based on disk/log_sizes) Olivier Mehani <shtrom+munin@ssji.net> (based on disk/log_sizes)
=head1 LICENSE =head1 LICENSE
GPLv2 GPLv2
=head1 MAGIC MARKERS
#%# family=manual
=cut =cut
#NAME=`echo $0 | sed 's/.*_//'` # needs shellcheck -x /usr/share/munin/plugins/plugin.sh
NAME=${0#*_} # shellcheck source=/usr/share/munin/plugins/plugin.sh
. "$MUNIN_LIBDIR/plugins/plugin.sh"
NAME=$(echo "$0" | sed 's/.*_//')
TITLE=${title:-File lengths for $NAME} TITLE=${title:-File lengths for $NAME}
CATEGORY=${category:-system} CATEGORY=${category:-system}
FILES=${files:-/var/log/messages} FILES=${files:-/var/log/messages}
FILES=$(echo $(ls $FILES)) # we want globbing to happen here
# shellcheck disable=SC2116 disable=SC2086
FILES=$(echo $FILES)
if [ "$1" = "config" ] ; then if [ "$1" = "config" ] ; then
if [ ${logarithmic} = 1 ]; then # shellcheck disable=SC2154
if [ "${logarithmic}" = "1" ]; then
graph_args="-o" graph_args="-o"
else else
graph_args="-l 0" graph_args="-l 0"
@ -50,16 +60,15 @@ graph_vlabel length (lines)
EOF EOF
for F in $FILES; do for F in $FILES; do
MF=`echo $F | sed 's/[-\/\.]/_/g'` MF=$(clean_fieldname "$F")
echo "$MF.label ${F##*/}" BF=$(basename "$F")
echo "$MF.label ${BF}"
done done
else else
for F in $FILES; do for F in $FILES; do
MF=`echo $F | sed 's/[-\/\.]/_/g'` MF=$(echo "$F" | sed 's/[-\/\.]/_/g')
echo -n "$MF.value " echo "$MF.value $(wc -l < "$F")"
cat $F | wc -l echo "$MF.extinfo $(stat --printf="%sB\n" "$F")"
echo -n "$MF.extinfo "
stat --printf="%sB\n" $F
done done
fi fi