AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.142.42.94
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/munin/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /usr/share/munin/plugins/mailscanner
#!/usr/bin/perl -w
# -*- perl -*-

=head1 NAME

mailscanner - Plugin to show statistics for e-mails passing through a
MailScanner filter

=head1 CONFIGURATION

The following environment variables are used by this plugin:

=over 4

=item logfile

The file where MailScanner logs its action (Default:
/var/log/mail.log)

=item logtail

The location of the logtail command (Default: /usr/sbin/logtail)

=item offsetfile

The location of the offset file (Default:
/tmp/munin-mailscanner.offset)

=back

=head1 USAGE

Requires the logtail command somewhere in path

=head1 MAGIC MARKERS

 #%# family=contrib
 #%# capabilities=

=cut

use strict;

my $logfile = '/var/log/mail.log';
my $logtail = '/usr/sbin/logtail';
my $offsetfile = "$ENV{MUNIN_PLUGSTATE}/munin-mailscanner.offset";
my ($clean, $viruses, $spams, $others, $total) = (0, 0, 0, 0, 0);
my $cmd = (defined($ARGV[0])) ? $ARGV[0] : '';

(defined($ENV{'logfile'})) and $logfile = $ENV{'logfile'};
(defined($ENV{'logtail'})) and $logtail = $ENV{'logtail'};
(defined($ENV{'offsetfile'})) and $offsetfile = $ENV{'offsetfile'};

if ($cmd eq 'config') {
	print("graph_title MailScanner statistics\n");
	print("graph_args --lower-limit 0\n");
	print("graph_vlabel messages\n");
	print("clean.label clean\n");
	print("clean.type GAUGE\n");
	print("clean.draw LINE2\n");
	print("viruses.label viruses\n");
	print("viruses.type GAUGE\n");
	print("viruses.draw LINE2\n");
	print("spams.label spams\n");
	print("spams.type GAUGE\n");
	print("spams.draw LINE2\n");
	print("others.label others\n");
	print("others.type GAUGE\n");
	print("others.draw LINE2\n");
	print("total.label total\n");
	print("total.type GAUGE\n");
	print("total.draw LINE2\n");

	exit(0);
}

my @lines = split(/\n/, qx($logtail -f $logfile -o $offsetfile));

# sometimes the logtail syntax is:
#my @lines = split(/\n/, qx($logtail $logfile $offsetfile));

foreach (@lines) {
    if (s/.*New Batch: Scanning ([0-9]+) messages.*/$1/) {
	$total += $_;
	next;
    }
    if (s/.*Virus Scanning: Found ([0-9]+) viruses.*/$1/g) {
	$viruses += $_;
	next;
    }
    if (s/.*Spam Checks: Found ([0-9]+) spam.*/$1/g) {
	$spams += $_;
	next;
    }
    if (s/.*Other Checks: Found ([0-9]+) problems.*/$1/g) {
	$others += $_;
	next;
    }
}

$clean = $total - ($viruses + $spams + $others);

print("clean.value $clean\n");
print("viruses.value $viruses\n");
print("spams.value $spams\n");
print("others.value $others\n");
print("total.value $total\n");

exit(0);

Anon7 - 2022
AnonSec Team