Analiza Sendmail logova – SendmailAnalyzer

Treba mi satna analiza mail poruka (koliko ih prođe na sat kroz server), i to ne može da mi pruži MailScanner (na žalost), pa sad eksperimentišem sa SendmailAnalyzer-om (link).

Linkovi sa uputstvom za instalaciju : link1

Instalacija na CentOS 6U4 :
Koji su svi potrebni Perl moduli :
MIME::Base64; Ova prva dva su u jednom fajlu…
MIME::QuotedPrint
GD Ovi se mogu instalirati korišćenjem yum naredbe
GD::Graph
GD::TextUtil
GD::Graph::bars3d
Pojedinačni Perl moduli se posle spuštanja i razvijanja instaliraju komandama :
# perl Makefile.PL
# make
# make test
# make install
Najjednostavnije je prvo korišćenjem YUM komande instalirati perl-GD (i da GD mora da se napiše velikim slovima), gd i gd-devel, i onda sve ostalo instalirati jednom komandom :
# perl -MCPAN -e ‘install GD::Graph::bars3d’
Paziti ovo ume da traaajjjeee, i da jedno 4 puta pita da li ZAISTA hoćete da instalirate….

Posle ovoga ide sama instalacija SendmailAnalyzer-a :
Gde ga naći : link.
# tar xzf sendmailanalyzer-x.x.tar.gz
# cd sendmailanalyzer-x.x/
# perl Makefile.PL
# make && make install

Posle instalacije :

1. Start SendmailAnalyzer daemon with:
# /usr/local/sendmailanalyzer/sendmailanalyzer -f
# /usr/local/sendmailanalyzer/sa_cache
Cache generation took: 2 wallclock secs ( 1.69 usr + 0.02 sys = 1.71 CPU)

Ako se ovde javi greška :
# /usr/local/sendmailanalyzer/sa_cache
Can’t locate CGI.pm in @INC …..
Treba uraditi sledeće :
# find / -name CGI.pm -print
Ako nije instaliran, treba ga instalirati :
# perl -e shell -MCPAN
cpan[1]> install CGI
…..
Ovde (/usr/local/sendmailanalyzer/) je i lokacija gde se sve instalira (kada idemo default)

2. U fajl /etc/httpd/conf/httpd.conf na kraj ubaciti sledeće :
Alias /sareport /usr/local/sendmailanalyzer/www

Options ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex sa_report.cgi
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from vaša-interna-mreža
# Allow from ::1
# Allow from .example.com

3. # service httpd restart

3a. Promena vlasništva i prava nad startup skriptama :
# cd /lokacija-gde-ste-razvili-program/sendmailanalyzer-xxx/start_scripts
# chown root:root *
# chmod 755 *
Tako da to sada izgleda ovako :
-rwxr-xr-x 1 root root 720 Jul 3 14:42 rc.sendmailanalyzer
-rwxr-xr-x 1 root root 1643 Jul 3 14:42 README
-rwxr-xr-x 1 root root 1143 Jul 3 14:42 sendmailanalyzer
-rwxr-xr-x 1 root root 283 Jul 3 14:42 sendmailanalyzer.service

3b. A da bi se pokretalo kao servis, i da se podigne pri podizanju servera :
# cp -p /lokacija-gde-ste-razvili-program/sendmailanalyzer-xxx/start_scripts/sendmailanalyzer /etc/init.d/sendmailanalyzer
# chkconfig –add sendmailanalyzer
# chkconfig sendmailanalyzer on
# service sendmailanalyzer restart

4. Setup a cronjob to run sa_cache and restart SendmailAnalyzer daemon after maillog logrotate as follow:
# SendmailAnalyzer log reporting daily cache (ovo ako vam ne treba real-time)
0 1 * * * /usr/local/sendmailanalyzer/sa_cache > /dev/null 2>&1
# On huge MTA you may want to have five minutes caching (ako vam treba real time, kasni 5min)
#*/5 * * * * /usr/local/sendmailanalyzer/sa_cache -a > /dev/null 2>&1
*/10 * * * * /usr/local/sendmailanalyzer/sa_cache > /dev/null 2>&1

5. Add an entry in /etc/logrotate.d/syslog to restart SendmailAnalyzer when maillog is rotated or create a cron job. For example:
/var/log/cron
/var/log/debug
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
/var/log/syslog
{
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2>/dev/null` 2>/dev/null || true
/PATH_TO/rc.sendmailanalyzer restart >/dev/null 2>&1 || true
# or /etc/rc.d/init.d/sendmailanalyzer restart >/dev/null 2>&1 || true
endscript
}
6. Pristupiti prvoj strani na lokaciji : http://IP-adresa-servera/sareport/

This entry was posted in Linux and tagged , . Bookmark the permalink.

Comments are closed.