1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| #!/usr/pkg/bin/perl
#
# Plugin to monitor a vsftpd server running on the machine
#
#
# Requirements:
# - Needs access to the log file of the ftp server
#
# Tip: To see if it's already set up correctly, just run this plugin
# with the parameter "autoconf". If you get a "yes", everything should
# work like a charm already.
#
# Parameters supported:
#
# config
# autoconf
#
# Configurable variables
#
# logfile - Override default log file
#
# $Log$
# Revision 0.0.0.1 2006/07/14 19:20 gorgonite
my $logfile = exists $ENV{'logfile'} ? $ENV{'logfile'} : "/var/log/vsftpd.log";
my $ret = undef;
open(my $logs, '<', $logfile) or $ret = "access to the file $logfile";
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
if ($ret)
{
print "no ($ret)\n";
exit 1;
}
print "yes\n";
exit 0;
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
{
print "graph_title Very Secure FTP server\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel requests\n";
print "graph_category other\n";
print "connections.label connections\n";
print "connections.type DERIVE\n";
print "connections.min 0\n";
print "login_successes.label successful_logins\n";
print "login_successes.type DERIVE\n";
print "login_successes.min 0\n";
print "login_failures.label failed_logins\n";
#print "login_failures.type DERIVE\n";
print "login_failures.min 0\n";
print "upload_successes.label successful_uploads\n";
#print "upload_successes.type DERIVE\n";
print "upload_successes.min 0\n";
print "upload_failures.label failed_uploads\n";
#print "upload_failures.type DERIVE\n";
print "upload_failures.min 0\n";
print "download_successes.label successful_downloads\n";
print "download_successes.type DERIVE\n";
print "download_successes.min 0\n";
print "download_failures.label failed_uploads\n";
print "download_failures.type DERIVE\n";
print "download_failures.min 0\n";
print "deletion_successes.label successful_deletions\n";
print "deletion_successes.type DERIVE\n";
print "deletion_successes.min 0\n";
print "deletion_failures.label failed_deletions\n";
print "deletion_failures.type DERIVE\n";
print "deletion_failures.min 0\n";
exit 0;
} else {
my ($nbConnect, $nbOKLogin, $nbFailLogin) = (0,0,0);
my ($nbOKUpload, $nbFailUpload, $nbOKDownload, $FailDownload) = (0,0,0,0);
my ($nbOKDelete, $nbFailDelete) = (0,0);
while (my $line = <$logs>) {
$nbConnect++ if ($line =~ "CONNECT");
$nbOKLogin++ if ($line =~ "OK LOGIN");
$nbFailLogin++ if ($line =~ "FAIL LOGIN");
$nbOKUpload++ if ($line =~ "OK UPLOAD");
$nbFailUpload++ if ($line =~ "FAIL UPLOAD");
$nbOKDownload++ if ($line =~ "OK DOWNLOAD");
$nbFailDownload++ if ($line =~ "FAIL DOWNLOAD");
$nbOKDelete++ if ($line =~ "OK DELETE");
$nbFailDelete++ if ($line =~ "FAIL DELETE");
}
print "connections.value $nbConnect\n";
print "login_successes.value $nbOKLogin\n";
print "login_failures.value $nbFailLogin\n";
print "upload_successes.value $nbOKUpload\n";
print "upload_failures.value $nbFailUpload\n";
print "download_successes.value $nbOKDownload\n";
print "download_failures.value $nbFailDownload\n";
print "deletion_successes.value $nbOKDelete\n";
print "deletion_failures.value $nbFailDelete\n";
}
close($logs);
# vim:syntax=perl |
Partager