1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

Merge pull request #988 from shtrom/file_length_

[file_lenght_] Various fixes
This commit is contained in:
Lars Kruse 2019-06-28 11:40:25 +02:00 committed by GitHub
commit 33270dd198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,20 +36,20 @@ SPDX-License-Identifier: GPL-2.0-only
# needs shellcheck -x /usr/share/munin/plugins/plugin.sh # needs shellcheck -x /usr/share/munin/plugins/plugin.sh
# shellcheck source=/usr/share/munin/plugins/plugin.sh # shellcheck source=/usr/share/munin/plugins/plugin.sh
. "$MUNIN_LIBDIR/plugins/plugin.sh" . "${MUNIN_LIBDIR}/plugins/plugin.sh"
NAME=$(echo "$0" | sed 's/.*_//') 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}
# we want globbing to happen here # we want globbing to happen here
# shellcheck disable=SC2116 disable=SC2086 # shellcheck disable=SC2116 disable=SC2086
FILES=$(echo $FILES) FILES=$(echo ${FILES})
TYPE=${type:-GAUGE} TYPE=${type:-GAUGE}
if [ "$1" = "config" ] ; then if [ "${1}" = "config" ] ; then
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [ "${logarithmic}" = "1" ]; then if [ "${logarithmic}" = "1" ]; then
graph_args="-o" graph_args="-o"
@ -60,24 +60,32 @@ if [ "$1" = "config" ] ; then
graph_title ${TITLE} graph_title ${TITLE}
graph_args ${graph_args} --base 1000 graph_args ${graph_args} --base 1000
graph_category ${CATEGORY} graph_category ${CATEGORY}
graph_info This graph shows the length of ${FILES}
graph_vlabel length (lines)
EOF EOF
if [ "${TYPE}" = "GAUGE" ]; then
echo "graph_info This graph shows the length of ${FILES}"
echo "graph_vlabel length (lines)"
else
echo "graph_info This graph shows the addition of new lines in ${FILES}"
# ${graph_period} is not a shell variable
# shellcheck disable=SC2016
echo 'graph_vlabel new lines per ${graph_period}'
fi
for F in $FILES; do for F in ${FILES}; do
MF=$(clean_fieldname "$F") MF=$(clean_fieldname "${F}")
BF=$(basename "$F") BF=$(basename "${F}")
echo "$MF.label ${BF}" echo "${MF}.label ${BF}"
echo "$MF.type ${TYPE}" echo "${MF}.type ${TYPE}"
echo "${MF}.min 0"
done done
else else
HAS_GNU_STAT=$(stat --help | grep GNU) HAS_GNU_STAT=$(stat --help 2>&1| grep GNU)
for F in $FILES; do for F in ${FILES}; do
MF=$(echo "$F" | sed 's/[-\/\.]/_/g') MF=$(echo "${F}" | sed 's/[-\/\.]/_/g')
echo "$MF.value $(wc -l < "$F")" echo "${MF}.value $(wc -l < "${F}")"
if [ -n "${HAS_GNU_STAT}" ]; then if [ -n "${HAS_GNU_STAT}" ]; then
echo "$MF.extinfo $(stat --printf="%sB\n" "$F")" echo "${MF}.extinfo $(stat --printf="%sB\n" "${F}")"
fi fi
done done
fi fi