Page 1 of 1

How to Add [apache] variable in connectiontracking Email

Posted: 02 Mar 2013, 15:05
by maxgdias
Actually the connectiontracking.txt file reports this information:

From: root
To: root
Subject: lfd on [hostname]: [ip] blocked with too many connections

Time: [time]
IP: [ip]
Connections: [ipcount]
Blocked: [temp]

Connections:
[iptext]
--------------


I like receive in this SAME email this other variables:

Time: [time]
1 Min Load Avg: [loadavg1]
5 Min Load Avg: [loadavg5]
15 Min Load Avg: [loadavg15]
Running/Total Processes: [totprocs]
--------------
[apache]
--------------




How can i do this?
I try insert this lines in connectiontracking.txt but the variables dont work...

Can You help me?

SOLVED: How to Add [apache] variable in connectiontracking E

Posted: 03 Mar 2013, 22:57
by maxgdias
SOLVED

in files "lfd dot pl", line 2792:

flock (THISLOCK, LOCK_EX | LOCK_NB) or &childcleanup("*Lock Error* [$lockstr] still active - section skipped");

##### Add Max
my @proclist;
eval {
local $SIG{__DIE__} = undef;
local $SIG{'ALRM'} = sub {die};
alarm(15);
my ($childin, $childout);
my $cmdpid = open3($childin, $childout, $childout, "$config{PS} axuf");
@proclist = <$childout>;
waitpid ($cmdpid, 0);
alarm(0);
};
alarm(0);
if ($@) {push @proclist, "Unable to obtain process output within 15 seconds - Timed out"}

my @vmstat;
eval {
local $SIG{__DIE__} = undef;
local $SIG{'ALRM'} = sub {die};
alarm(10);
my ($childin, $childout);
my $cmdpid = open3($childin, $childout, $childout, "$config{VMSTAT}");
@vmstat = <$childout>;
waitpid ($cmdpid, 0);
alarm(0);
};
alarm(0);
if ($@) {push @vmstat, "Unable to obtain vmstat output within 10 seconds - Timed out"}

my $url = $config{PT_APACHESTATUS};
my ($status, $apache) = &urlget($url);
if ($status) {$apache = "Unable to retrieve Apache Server Status [$url] - $apache"}

#### FIM Max



my @connections;



--------------------

In Email variables:

my $boundary = "csf".time;
my @message;
foreach my $line (@alert) {
$line =~ s/\[ip\]/$tip/ig;
$line =~ s/\[ipcount\]/$ipcnt{$ip}/ig;
$line =~ s/\[iptext\]/$iptext{$ip}/ig;
$line =~ s/\[temp\]/$block/ig;


$line =~ s/\[processlist\]/@proclist/ig;
$line =~ s/\[vmstat\]/@vmstat/ig;
$line =~ s/\[apache\]/$apache/ig;
$line =~ s/\[boundary\]/$boundary/ig;

push @message, $line;