Sep 20

I gotthis problem on the cpanel, my analog stats ( your cpanel -> logs -> analog stats ) it only updated every once a month, according to my cpanel whm it should be updated every 24 hours (Main >> Server Configuration >> Statistics Software Configuration), i also see this warning there :

The server is having trouble keeping up with your statistics processing schedule. You should increase the time between statistic generation, or upgrade the server. If you have recently decreased the time between statistic generation, you may wish to wait that amount of time to see if the server will catch up before changing back.

Okay it seem that my cpanel server are having problem updating the statistic for all of my account. Okay i tried to update the stat one by one

# /scripts/runstatsonce
This script requires cPanel 6.4.2 Build 11+
==> WARNING: The configured processor count does not match the
==> actual processor count (2)! Running log analysis programs
==> on this system may cause excessive load! You should set “extracpus”
==> to “0” in /var/cpanel/cpanel.config if this is not ok.
==> cPanel Log Daemon version 22.2
==> Shared RRDTOOL support enabled
==> Starting cpbandwd (bandwidth monitoring for IMAP/POP)
cpbandwd is already running.
==> Ignoring lastrun files and running all stats now
==> cpanellogd will exit after stats have run

Okay it seem that my cpanel version are outdated, my cpanel version is :

WHM 11.1.0 cPanel 11.4.19-R14379
SUSE 9.0 i686 – WHM X v3.1.0

Okay i need to udpate the server manually, you can update it using this command

/scripts/upcp

It takes me 3 hours to update it , but it is updated atlast šŸ™‚ to version

cPanel 11.24.5-S38506 – WHM 11.24.2 – X 3.9
SUSE 9.0 i686 standard on vh2

and

The server currently is able to keep up with your statistics processing schedule.
cpanel1

And the analog stat are updated now šŸ™‚

cpanel2

Sep 17

url referer : –Ā http://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam

After sometimes it occur to me that me how to get log of mail that was sent from formmail on my web because i always wonderring who sent the email is it spam or not, then i found this artickelĀ http://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam šŸ™‚

Okay let’s start the installation

1. Installing the Log Ā script

Create new fileĀ /usr/local/bin/phpsendmail

vi /usr/local/bin/phpsendmail

Then paste this

#!/usr/bin/php

<?php

$sendmail_bin = ‘/usr/sbin/sendmail.postfix’; // i use postfix and postfix sendmail bin was located onĀ /usr/sbin/sendmail.postfix , it depend on your mail system

$logfile = ‘/var/log/mail.form’;

//* Get the email content

$logline = ”;

while ($line = fgets(STDIN)) {

if(stristr($line,’to:’) || stristr($line,’from:’)) $logline .= trim($line).’ ‘;

$mail .= $line;

}

//* compose the sendmail command

$command = ‘echo “‘.$mail.'” | ‘.$sendmail_bin.’ -t’;

for ($i = 1; $i < $_SERVER[‘argc’]; $i++) {

$command .= $_SERVER[‘argv’][$i].’ ‘;

}

//* rotate log if it gets too big

if(is_file($logfile) && filesize($logfile) > 10000000) {

if(is_file($logfile.’.old’)) unlink($logfile.’.old’);

exec(‘cp -pf ‘.$logfile.’ ‘.$logfile.’.old’);

exec(‘cat /dev/null > ‘.$logfile);

}

//* Write the log

system(‘echo “‘.date(“Y-m-d H:i:s”).’ ‘.$_ENV[‘PWD’].’ ‘.$logline.'” >> ‘.$logfile);

//* Execute the command

return shell_exec($command);

?>

Now make the script executable…

chmod +x /usr/local/bin/phpsendmail

… and create the logfile and make it writable:

touch /var/log/mail.form
chmod 777 /var/log/mail.form

2. Modifying the main.cf

Again it depend on your mail system , on my ssystem i use postfix to send the email from my formmail, in other system usually the email send from sendmail or from the php itself in that case you need to edit php.ini. In my system i need to modify postfix main.cf

go to your main.cf on /etc/postfix/main.cf and changes this

viĀ /etc/postfix/main.cf

sendmail_path = /usr/local/bin/phpsendmail

then relaod your postfix

# /etc/init.d/postfix reload

3 Test the setup

To test this setup, create a new php file with the nameĀ mailtest.php in one of your websites with the content:

<?php
mail('yourname@yourdomain.com','This is a test message subject','This is a test message body');
echo 'Mail sent.'; 
?>
to see the log  you can use
# tail /var/log/mail.form -f
2009-09-17 15:49:30 /home/test/public_html To: test@yahoo.com From: test <test@yahoo.com> 
2009-09-17 16:12:01 /home/test/public_html To: test2@bi.edu From: test <test2@bi.edu>