Repository
Munin (contrib)
Last change
2020-03-26
Graph Categories
Family
manual
Capabilities
Keywords
Language
Bash
Authors

s9y

Name

s9y - Plugin to monitor the daily Spam entries for the Blog Serendipity http://s9y.org

Configuration

The user running this plugin needs read access to the mysql Database will need to add this:

[s9y]
user root

The following configuration parameters are used by this plugin

[s9y]
 env.database
 env.extrafile  path/to/extrafile e.g. /etc/mysql/debian.cnf
 env.warning    Warning Count of Spam
 env.critical   Critical Count of Spam
 env.resettype  one of monthly weekly daily number (must be greater than env.critical)
                (currently only monthly is supported)

Default Configuration

[s9y]
 env.database  null
 env.extrafile null
 env.warning   15000
 env.critical  20000
 env.resettype monthly

Authors

Bernd Dau visit my Blog: http://zockertown.de/s9y/

License

GPL3.0

Version

Version # $Rev: 7 $

Bugs

The resetting is done only when the minute is 00 and the hour is 00 if the script is running to late because of heavy load or when other plungins are running too long, the emptiness of the table is not guaranteed

This plugin is in heavy development expect all but functionality

Magic Markers

#%# family=manual
#%# capabilities=autoconf
#!/bin/bash
# $Id: s9y 7 2010-02-24 22:15:37Z root $
# $Rev: 7 $
# $Author: root $
# $Date: 2010-02-24 23:15:37 +0100 (Mi, 24. Feb 2010) $
#
#
: <<EOF

=head1 NAME

s9y - Plugin to monitor the daily Spam entries for the Blog Serendipity
http://s9y.org

=head1 CONFIGURATION

The user running this plugin needs read access to the
mysql Database will need to add this:

 [s9y]
 user root


The following configuration parameters are used by this plugin

 [s9y]
  env.database
  env.extrafile  path/to/extrafile e.g. /etc/mysql/debian.cnf
  env.warning    Warning Count of Spam
  env.critical   Critical Count of Spam
  env.resettype  one of monthly weekly daily number (must be greater than env.critical)
                 (currently only monthly is supported)

=head2 DEFAULT CONFIGURATION

 [s9y]
  env.database  null
  env.extrafile null
  env.warning   15000
  env.critical  20000
  env.resettype monthly

=head1 AUTHORS

Bernd Dau
visit my Blog: http://zockertown.de/s9y/

=head1 LICENSE

GPL3.0

=head1 VERSION

Version # $Rev: 7 $

=head1 BUGS

The resetting is done only when the minute is 00 and the hour is 00
if the script is running to late because of heavy load or when other
plungins are running too long, the emptiness of the table is not guaranteed

This plugin is in heavy development
expect all but functionality


=head1 MAGIC MARKERS

 #%# family=manual
 #%# capabilities=autoconf

=cut

EOF

. $MUNIN_LIBDIR/plugins/plugin.sh
#echo "ENV=`env`">/tmp/s9y-env.txt

if [ "$1" = "autoconf" ]; then
	echo no
        echo "Set the needed Variables in munin-node"
	exit 0
fi
	SPAM=`mysql --defaults-extra-file=$extrafile -D $database -B --skip-column-names -e "select count(*) from  serendipity_spamblocklog;"`

if [ "$1" = "config" ]; then

	echo 'graph_title Spam Entries in Serendipity'
	echo 'graph_args --base 1000 --lower-limit 0'
	echo 'graph_vlabel Entries'
	echo 'graph_category other'
	echo 'graph_total Total'
        echo 'graph_info counts the moderated and rejected Comment Entries in Serendipity which where classified as Spam'
        echo 'spam.label SPAM'
        echo "resettype $resettype"
        echo "spam.value $SPAM"

	exit 0
fi

#### resettype?
if [ -n $resettype ]
then
  if [ "$resettype" = "monthly" ]
    then
       day=`date '+%d'`
       if [ $day -eq 1 && "`date '+%H%M'`" -eq 0 ]
       then
         mysql --defaults-extra-file=$extrafile -D $database -B --skip-column-names -e "delete from  serendipity_spamblocklog where 1=1;"
       fi
   fi
fi

echo "spam.value $SPAM"