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

[hostdenied] Reverse order of series so new entries are on top

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
Olivier Mehani 2019-10-23 14:51:11 +11:00 committed by Lars Kruse
parent 6a47ad0aed
commit f8801b87a0
3 changed files with 19 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View file

@ -44,33 +44,34 @@
# ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------
DENY="/etc/hosts.deny" DENY="/etc/hosts.deny"
NAME="$(basename $0)" # component of naming temporary files NAME="$(basename "$0")" # component of naming temporary files
STATEFILE="$MUNIN_PLUGSTATE/$NAME.state" STATEFILE="$MUNIN_PLUGSTATE/$NAME.state"
COLOUR=(FF0000 DA0024 B60048 91006D 6D0091 4800B6 2400DA 0000FF) # hot to cold colours COLOUR=(FF0000 DA0024 B60048 91006D 6D0091 4800B6 2400DA 0000FF) # hot to cold colours
# ------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------
run_autoconf() { run_autoconf() {
RUN="no" RUN="no (denyhosts not found)"
which grep denyhosts basename > /dev/null && RUN="yes" # only run when grep and denyhost are present command -v denyhosts > /dev/null && RUN="yes" # only run when denyhosts is present
echo "$RUN" echo "$RUN"
} }
run_config() { run_config() {
cat << EOF cat << EOF
graph_title Hosts denied sshd access graph_title Hosts denied sshd access
graph_info Hosts denied sshd access in $DENY graph_info Hosts denied sshd access in $DENY
graph_args --base 1000 -l 0 graph_args --base 1000 -l 0
graph_vlabel Hosts denied graph_vlabel Hosts denied
graph_category security graph_category security
age0.label added last 24h
age0.draw AREA
age0.colour ${COLOUR[0]}
EOF EOF
for AGE in {1..7}; do for AGE in {7..0}; do
cat << EOF if [ "${AGE}" = 0 ]; then
age${AGE}.label older than $((AGE*24))h echo "age${AGE}.label added last 24h"
age${AGE}.draw STACK else
echo "age${AGE}.label older than $((AGE*24))h"
fi
cat << EOF
age${AGE}.draw AREASTACK
age${AGE}.colour ${COLOUR[$AGE]} age${AGE}.colour ${COLOUR[$AGE]}
EOF EOF
done done
@ -81,17 +82,17 @@ run_fetch() {
TOTAL=0 TOTAL=0
NOW=$(date +%s) NOW=$(date +%s)
sed -n 's/^\# DenyHosts: //;s/ | .*//gp' $DENY | # strip all but date sed -n 's/^\# DenyHosts: //;s/ | .*//gp' $DENY | # strip all but date
while read DATE; do while read -r DATE; do
echo $(((NOW - $(date -d "$DATE" +%s))/86400)) # calculate rule age echo $(((NOW - $(date -d "$DATE" +%s))/86400)) # calculate rule age
done > $STATEFILE # rather than going through temp file, the age could be done > "$STATEFILE" # rather than going through temp file, the age could be
for AGE in {0..6} ; do # used to increment an array element with that index. for AGE in {6..0} ; do # used to increment an array element with that index.
COUNT="$(grep -c "^$AGE$" $STATEFILE)" # That'd save grepping for counting from temp file. COUNT="$(grep -c "^$AGE$" "$STATEFILE")" # That'd save grepping for counting from temp file.
echo "age${AGE}.value $COUNT" # produce values for all but oldest echo "age${AGE}.value $COUNT" # produce values for all but oldest
((TOTAL+=COUNT)) ((TOTAL+=COUNT))
done done
echo "age7.value $(($(grep -c . $STATEFILE)-TOTAL))" # all non-printed are older echo "age7.value $(($(grep -c . "$STATEFILE")-TOTAL))" # all non-printed are older
rm $STATEFILE rm "$STATEFILE"
} }
run_${1:-"fetch"} run_"${1:-fetch}"
exit 0 exit 0

View file

@ -417,7 +417,6 @@ plugins/spamassasin/sa-learn
plugins/sphinx/sphinx_documents plugins/sphinx/sphinx_documents
plugins/squid/squid_efficiency plugins/squid/squid_efficiency
plugins/squid/squid_times plugins/squid/squid_times
plugins/ssh/hostdenied
plugins/ssh/openssh-denyhosts plugins/ssh/openssh-denyhosts
plugins/ssh/sshd_log plugins/ssh/sshd_log
plugins/streaming/packetship_ plugins/streaming/packetship_