mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
More housekeeping.
This commit is contained in:
parent
038c3ce96b
commit
e5ce74926d
43 changed files with 0 additions and 0 deletions
80
plugins/ftp/pure-ftpd-bw
Executable file
80
plugins/ftp/pure-ftpd-bw
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#
|
||||
# pure-ftpd-bw plugin
|
||||
# show the bandwidth used by pure-ftpd, counts the bytes sent and received
|
||||
# made by Dju
|
||||
# v1.2
|
||||
#
|
||||
# commands needed: logtail - grep
|
||||
#
|
||||
#
|
||||
# Configuration:
|
||||
# Maybe need to add folowing lines to plugins config file
|
||||
# (e.g. /etc/munin/plugin-conf.d/pure-ftpd) to run pure-ftpwho
|
||||
# as user with apropirate privilegs then restart munin-node.
|
||||
#
|
||||
# [pure-ftpd-bw]
|
||||
# user root
|
||||
#
|
||||
#
|
||||
# Parameters
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and installation scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
LOGFILE=/var/log/pure-ftpd/transfer.log
|
||||
LOGTAIL=$(which logtail)
|
||||
OFFSET_FILE=/var/lib/munin/plugin-state/pure-ftpd-bw.offset
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f $LOGFILE ]; then
|
||||
if [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (logtail not found)"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "no (logfile $LOGFILE does not exist)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Pure Ftpd Bandwidth'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel Datas sent / received'
|
||||
echo 'graph_category pure-ftpd'
|
||||
echo 'dl.label Bytes downloaded'
|
||||
echo 'ul.label Bytes uploaded'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TMP1=`mktemp`
|
||||
if [ -f $TMP1 ]; then
|
||||
$LOGTAIL -o $OFFSET_FILE -f $LOGFILE | grep 'GET \|PUT ' > $TMP1
|
||||
dls=$(awk '/GET / {print $9}' $TMP1)
|
||||
dl=0
|
||||
for d in $dls; do dl=$(expr $dl + $d); done
|
||||
echo "dl.value ${dl}"
|
||||
uls=$(awk '/PUT / {print $9}' $TMP1)
|
||||
ul=0
|
||||
for u in $uls; do ul=$(expr $ul + $u); done
|
||||
echo "ul.value ${ul}"
|
||||
rm $TMP1
|
||||
else
|
||||
echo "cant write temp file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
83
plugins/ftp/pure-ftpd-logs
Executable file
83
plugins/ftp/pure-ftpd-logs
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
#
|
||||
# pure-ftpd plugin
|
||||
# show what the users did on your ftp server
|
||||
# made by Dju
|
||||
#
|
||||
# commands needed: logtail - grep
|
||||
#
|
||||
#
|
||||
# Parameters
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and installation scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
|
||||
LOGFILE=/var/log/syslog
|
||||
LOGTAIL=$(which logtail)
|
||||
OFFSET_FILE=/var/lib/munin/plugin-state/pure-ftpd-conns.offset
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f $LOGFILE ]; then
|
||||
if [ ! -z "$LOGTAIL" -a -f $LOGTAIL -a -x $LOGTAIL ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (logtail not found)"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "no (logfile ${LOGFILE} does not exist)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Pure Ftpd Logs'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel Connections number'
|
||||
echo 'graph_category pure-ftp'
|
||||
echo 'nc.label new connection'
|
||||
echo 'al.label anonymous logged'
|
||||
echo 'ul.label auth user logged'
|
||||
echo 'af.label auth failed'
|
||||
echo 'to.label timeout'
|
||||
echo 'dl.label download'
|
||||
echo 'upl.label upload'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TMP1=`mktemp`
|
||||
$LOGTAIL -o $OFFSET_FILE $LOGFILE | grep ' pure-ftpd: ' > $TMP1
|
||||
|
||||
echo -en "nc.value "
|
||||
grep '\[INFO\] New connection from ' $TMP1 | wc -l
|
||||
|
||||
echo -en "al.value "
|
||||
grep '\[INFO\] Anonymous user logged in' $TMP1 | wc -l
|
||||
|
||||
echo -en "ul.value "
|
||||
grep '\[INFO\] .*is now logged in' $TMP1 | wc -l
|
||||
|
||||
echo -en "to.value "
|
||||
grep ' Timeout ' $TMP1 | wc -l
|
||||
|
||||
echo -en "af.value "
|
||||
grep '\[WARNING\] Authentication failed' $TMP1 | wc -l
|
||||
|
||||
echo -en "dl.value "
|
||||
grep '\[NOTICE\].* downloaded ' $TMP1 | wc -l
|
||||
|
||||
echo -en "upl.value "
|
||||
grep '\[NOTICE\].* uploaded ' $TMP1 | wc -l
|
||||
|
||||
rm $TMP1
|
||||
|
123
plugins/ftp/pureftpd_traffic
Executable file
123
plugins/ftp/pureftpd_traffic
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use HTTP::Date;
|
||||
use Date::Manip;
|
||||
|
||||
$logfile="/var/log/pure-ftpd/transfer.log";
|
||||
$ts="/tmp/munin_pureftpd_traffic_plugin_ts";
|
||||
|
||||
if ($ARGV[0] eq "test") {
|
||||
$handle = open LOG,"<$logfile";
|
||||
if(!$handle) {
|
||||
print "Can't open logfile!\n";
|
||||
exit -1;
|
||||
}
|
||||
$handle = open TS,"<$ts";
|
||||
if(!$handle) {
|
||||
print "Can't open lockfile!\n";
|
||||
exit -1;
|
||||
}
|
||||
print "OK\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($ARGV[0] eq "config") {
|
||||
$out.="graph_title pureftpd traffic
|
||||
graph_category PureFTPd
|
||||
graph_info This graph shows pureftpd traffic.
|
||||
graph_vlabel Bytes
|
||||
get.label Get
|
||||
get.type COUNTER
|
||||
get.draw LINE1
|
||||
get.colour ff0000
|
||||
put.label Put
|
||||
put.type COUNTER
|
||||
put.draw LINE1
|
||||
put.colour 00ff00
|
||||
mti.label MTI
|
||||
mti.type COUNTER
|
||||
mti.draw LINE1
|
||||
mti.colour 0000ff
|
||||
dsm.label DSM
|
||||
dsm.type COUNTER
|
||||
dsm.draw LINE1
|
||||
dsm.colour 009999
|
||||
";
|
||||
print $out;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (!(-e $logfile)) {
|
||||
die "No transfer.log available!";
|
||||
}
|
||||
if (!(-e $ts)) {
|
||||
open LOG, "<$logfile" or print "Can't open logfile!\n";
|
||||
my $last_line;
|
||||
while(<LOG>) {
|
||||
$last_line = $_ if eof;
|
||||
}
|
||||
close LOG;
|
||||
@em = split(/ /,$last_line);
|
||||
$curr_ts = "$em[3] $em[4]";
|
||||
$curr_ts =~ s/\[//g;
|
||||
$curr_ts =~ s/\]//g;
|
||||
|
||||
open TS, ">$ts";
|
||||
print TS $curr_ts;
|
||||
close TS;
|
||||
$last_ts=$curr_ts;
|
||||
} else {
|
||||
open TS, "<$ts";
|
||||
@l=<TS>;
|
||||
close TS;
|
||||
$last_ts=$l[0];
|
||||
}
|
||||
|
||||
my $get=0,
|
||||
$put=0,
|
||||
$mti=0,
|
||||
$dsm=0;
|
||||
|
||||
open LOG, "<$logfile";
|
||||
@log=<LOG>;
|
||||
foreach $row (@log) {
|
||||
@parts=split(/ /,$row);
|
||||
$curr_ts = "$parts[3] $parts[4]";
|
||||
$curr_ts =~ s/\[//g;
|
||||
$curr_ts =~ s/\]//g;
|
||||
|
||||
if ( Date_Cmp($curr_ts,$last_ts) > 0 ) {
|
||||
if ( $parts[5]=~ /GET/ ) {
|
||||
$get+=int($parts[8]);
|
||||
if ($parts[2] eq "mti") {
|
||||
$mti+=int($parts[8]);
|
||||
}
|
||||
if ($parts[2] eq "dsm") {
|
||||
$dsm+=int($parts[8]);
|
||||
}
|
||||
}
|
||||
if ( $parts[5]=~ /PUT/ ) {
|
||||
$put-=int($parts[8]);
|
||||
if ($parts[2] eq "mti") {
|
||||
$mti-=int($parts[8]);
|
||||
}
|
||||
if ($parts[2] eq "dsm") {
|
||||
$dsm-=int($parts[8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open TS, ">$ts";
|
||||
print TS $curr_ts;
|
||||
close TS;
|
||||
close LOG;
|
||||
$out="get.value $get
|
||||
put.value $put
|
||||
mti.value $mti
|
||||
dsm.value $dsm
|
||||
";
|
||||
print $out;
|
||||
exit (0);
|
||||
|
||||
__END__
|
Loading…
Add table
Add a link
Reference in a new issue