/usr/bin/graphdefang.pl is in graphdefang 2.83-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | #!/usr/bin/perl -w
#
# GraphDefang -- a set of tools to create graphs of your mimedefang
# spam and virus logs.
#
# Written by: John Kirkland
# jpk@bl.org
#
# Copyright (c) 2002-2003, John Kirkland
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#=============================================================================
use strict;
use vars qw($SHAREDIR $OUTPUT_DIR $SUMMARYDB $QUIET $NODB $DATAFILE @DATAFILES @GRAPHS %TZ);
# Argument parsing
use Getopt::Long;
use Pod::Usage;
$QUIET = 0; # No output
$NODB = 0; # Don't use SummaryDB, just produce charts from logfile
my $trim = 0; # Trim database
my $nomax = 0; # Ignore max date/time
my $help = 0; # Show help?
my $man = 0; # Show bigger help?
my $file; # Log file to parse (optional)
GetOptions( 'quiet' => \$QUIET,
'nodb' => \$NODB,
'trim' => \$trim,
'nomax' => \$nomax,
'help|?' => \$help,
'man' => \$man,
'file=s' => \$file ) or pod2usage(2);;
pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2) if $man;
# Get the directory from where graphdefang.pl is running
use File::Basename ();
#($MYDIR) = (File::Basename::dirname($0) =~ /(.*)/);
$SHAREDIR="/usr/share/graphdefang";
# Get graph configurations
#require("$MYDIR/graphdefang-config");
require("/etc/graphdefang/graphdefang-config");
# Require the graphdefang library file
#require ("$MYDIR/graphdefanglib.pl");
require ("/usr/share/graphdefang/graphdefanglib.pl");
#
# Path to summary database
#
#$SUMMARYDB = "$MYDIR/SummaryDB.db";
+$SUMMARYDB = "/var/cache/graphdefang/SummaryDB.db";
# Do we do a database trim?
if ($trim) {
print STDERR "Beginning SummaryDB Trim\n" if (!$QUIET);
trim_database();
print STDERR "Completed SummaryDB Trim\n" if (!$QUIET);
exit;
}
# Did the user specify a file on the command line?
$DATAFILE = $file if (defined($file));
my %DataSummary;
if ($DATAFILE) {
print STDERR "Processing data file: $DATAFILE\n" if (!$QUIET);
# Open DATAFILE and Summarize It
%DataSummary = read_and_summarize_data($DATAFILE, $nomax)
or die "No valid mimedefang logs in $DATAFILE";
} elsif (@DATAFILES) {
foreach my $datafile (@DATAFILES) {
print STDERR "Processing data file: $datafile\n" if (!$QUIET);
%DataSummary = read_and_summarize_data($datafile, $nomax)
or die "No valid mimedefang logs in $datafile";
}
} else {
# No DATAFILE or DATAFILES specified!
die "No DATAFILES specified on the command line or in your config file";
}
print STDERR "Processing graphs\n" if (!$QUIET);
# Draw graphs
foreach my $settings (@GRAPHS) {
graph(\%{$settings}, \%DataSummary);
}
__END__
=head1 NAME
Application for generating graphs from mimedefang log files.
=head1 SYNOPSIS
graphdefang.pl [options]
Options:
--help brief help message
--man full documentation
--quiet quiet output
--nodb do not update SummaryDB
--trim trim the SummaryDB
--nomax ignore the max date/time in SummaryDB
--file optional log file to parse
If called with no options, graphdefang.pl will parse the
logfile as defined by the $DATAFILE variable.
=head1 OPTIONS
=over 8
=item B<--help>
Print a brief help message and exits.
=item B<--man>
Prints the manual page and exits.
=item B<--quiet>
Do not produce status output from mimedefang.pl.
=item B<--nodb>
Do not use nor update the SummaryDB, just parse the file and draw graphs from it.
=item B<--trim>
Trim the SummaryDB to cut out old data. It trims out:
1. hourly data older than 1.25x$NUM_HOURS_SUMMARY hours
2. daily data older than 1.25x$NUM_DAYS_SUMMARY days
3. all but top 25 sender, recipient, value1, value2, subject values
for all dates prior to the current hour, day, and month..
=item B<--nomax>
Ignore the max date/time in the SummaryDB; add all lines from the parsed
file to the database.
=item B<--file>
Optional log file to parse. If this option is not set, graphdefang
will use the $DATAFILE variable.
=back
=head1 DESCRIPTION
B<graphdefang.pl> will read a file that contains syslog messages from
mimedefang, update its internal summary database, and produce graphs
as requested by the user.
=cut
|