The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I need to email daily exim stats to a customer. How?

Discussion in 'E-mail Discussions' started by dianaward, Mar 15, 2005.

  1. dianaward

    dianaward Well-Known Member

    Joined:
    Dec 9, 2002
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Twitter:
    I have one server that is used by just one customer with one website. He is not interested in managing the server, I do that for him, but he wants the mail stats sent to him. I don't want to give him root access. Is there a way I can have the server automatically email an exim stats report like the WHM Mail Delivery Stats daily?
     
  2. asmar

    asmar Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    16
    You can make webalizer stats to be public under domain.com/stats for example and add a daily cron job to copy and email the file (I think it's just a html file).

    Hope that helps
     
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    I'm not so sure that you can do that easily for the exim stats. Those exim stats are created from the MySQL database eximstats which you could certainly query using your language of preference to generate your own statistics.
     
  4. bhd

    bhd Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    149
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    JNB ZA
    cPanel Access Level:
    Root Administrator
    If it's in a text file and you know where it is on the server you can set up a 24 hour cron to call a simple mail script to grab the file and send it out every 24 hours. Something like this should do it (just make sure to chmod it to 755):

    Code:
    #!/usr/bin/perl
    use strict;
    #-------------------------------------------------------------------------------
    #                            CHANGE TO SUITE
    #-------------------------------------------------------------------------------
    my $sendmail = "/usr/sbin/sendmail";          # Path to sendmail
    my $to       = 'me@mydomain.com';             # Your email address
    my $file     = 'path-to-text-file-to-send';   # the text file you want to send
    my $from     = 'root@server.com';             # Email form
    #-------------------------------------------------------------------------------
    open F, $file;
    my $body = join '', <F>;
    close F;
    
    open  MAIL, "|$sendmail -t -f \"$from\"" or die "Can't start mail program";
    print MAIL "To: $to\n";
    print MAIL "From: $from\n";
    print MAIL "Log file on ". localtime(time) . "\n\n";
    print MAIL $body;
    print MAIL"\n\n";
    close (MAIL);
    
     
  5. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Unfortunately it isn't. As I said, the data is stored in a MySQL database and the stats are generated on the fly.
     
  6. __arjun__

    __arjun__ Guest

    You can use the following to generate stats


    Code:
    eximstats -nr -html /var/log/exim_mainlog > stats.html
    [/CODE[
    
    That would generate email stats for the whole server.
    You can then send stats.html as an email to your client.
     
  7. WinterRG

    WinterRG Member

    Joined:
    Oct 21, 2004
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    I know this thread is a little old, but........

    a slight modification to the above perl script and it works just fine....


    Code:
    #!/usr/bin/perl
    use strict;
    #-------------------------------------------------------------------------------
    #                            CHANGE TO SUITE
    #-------------------------------------------------------------------------------
    my $sendmail = "/usr/sbin/sendmail";               # Path to sendmail
    my $to       = 'email@address.tld';                     # Your email address
    my $file     = '/tmp/eximstats.log';                    # the text file you want to send
    my $from     = 'system email address';              # Email form
    #-------------------------------------------------------------------------------
    
    [B]system ("eximstats -txt=/tmp/eximstats.log -ne -nr -t10 /var/log/exim_mainlog");
    [/B]
    open F, $file;
    my $body = join '', <F>;
    close F;
    
    open  MAIL, "|$sendmail -t -f \"$from\"" or die "Can't start mail program";
    print MAIL "To: $to\n";
    print MAIL "From: $from\n";
    print MAIL "Log file on ". localtime(time) . "\n\n";
    print MAIL $body;
    print MAIL"\n\n";
    close (MAIL);
    
    [B]system ("rm -f /tmp/eximstats.log");[/B]
    
    As mentioned before, set this up on a cron job, that runs prior to any logrotate and your set, my options in the eximstats are restricted, I didn't want to have huge emails being sent (up in the high MB) and only really wanted to monitor for abuse, spamming etc. In your case you may wish to remove some of the restrictions to provide your customer with additional data.

    Hope this helps

    Russ
     
  8. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    My apologies to bump this old thread once again, but can this be done for a single domain on the shared hosting server ? Can stats be generated for one domain ?

    Any assistance would be wonderful.
     
Loading...

Share This Page