Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 300010 Details for
Bug 406201
3.10: Commandline utilities and cron jobs
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
command line utility mail_log.pl to mail log4perl logging
cronjob_mail_log (text/plain), 2.92 KB, created by
Noura El hawary
on 2008-04-02 04:32:45 UTC
(
hide
)
Description:
command line utility mail_log.pl to mail log4perl logging
Filename:
MIME Type:
Creator:
Noura El hawary
Created:
2008-04-02 04:32:45 UTC
Size:
2.92 KB
patch
obsolete
>Index: mail_log.pl >=================================================================== >RCS file: mail_log.pl >diff -N mail_log.pl >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ mail_log.pl 2 Apr 2008 04:29:04 -0000 >@@ -0,0 +1,106 @@ >+#!/usr/bin/perl >+ >+use lib '.'; >+use strict; >+use warnings; >+ >+use MIME::QuotedPrint; >+use MIME::Base64; >+use Mail::Sendmail 0.75; # doesn't work with v. 0.74! >+use File::Basename; >+use Bugzilla::Config; # for Param method >+use Log::Log4perl; >+use Bugzilla; >+ >+main(@ARGV) if not caller(); >+ >+sub main { >+ my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) >+ = localtime(time); >+ my $current_date = sprintf( >+ "%.4d/%.2d/%.2d %.2d:%.2d:%.2d", >+ $year + 1900, >+ $mon + 1, $mday, $hour, $min, $sec >+ ); >+ >+ my %mail = ( >+ from => 'bugzilla@redhat.com', >+ to => Bugzilla->params->{maintainer}, >+ subject => "[$current_date] Bugzilla Log File", >+ smtp => 'localhost', >+ ); >+ >+ my $boundary = "====" . time() . "===="; >+ $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; >+ >+ my $message = encode_qp("Bugzilla Log File"); >+ >+ # Get the log file name from Log4perl config file >+ my $log_file = Bugzilla->log_filename; >+ >+ # Exit if file does not exist >+ return if !-e $log_file; >+ >+ # Gzip the current log file and rename to logfile.gz >+ my $tmp_file = $log_file . ".gz"; >+ system("/bin/gzip -f $log_file") == 0 >+ or die "Error executing gzip -f $log_file"; >+ >+ open( F, $tmp_file ) or die "Cannot read $tmp_file: $!\n"; >+ binmode F; >+ undef $/; >+ $mail{body} = encode_base64(<F>); >+ close F; >+ >+ # Need just filename for email filename >+ my $email_file = basename( $tmp_file, [".gz"] ); >+ >+ $boundary = '--' . $boundary; >+ $mail{body} = <<END_OF_BODY; >+$boundary >+Content-Type: text/plain; charset="iso-8859-1" >+Content-Transfer-Encoding: quoted-printable >+ >+$message >+$boundary >+Content-Type: application/octet-stream; name="$email_file" >+Content-Transfer-Encoding: base64 >+Content-Disposition: attachment; filename="$email_file" >+ >+$mail{body} >+$boundary-- >+END_OF_BODY >+ >+ # Send the email >+ sendmail(%mail) || die "Error: $Mail::Sendmail::error\n"; >+ >+ # Removed the compressed file >+ unlink($tmp_file) || die "Error: could not remove $tmp_file: $!\n"; >+} >+ >+1; >+__END__ >+ >+=head1 NAME >+ >+mail_log.pl - Gzip's the Log4Perl log file and emails to bugzilla maintainer >+ >+=head1 SYNOPSIS >+ >+ cd /path/to/bugzilla && perl mail_log.pl >+ >+ # cron example >+ MAILTO="bugzilla-owner@redhat.com" >+ # run 13 minutes past midnight every day >+ 0 13 * * * cd <your-bugzilla-directory>; ./mail_log.pl >+ >+=head1 DESCRIPTION >+ >+The script gzips the current log file and then emails it to >+the current Bugzilla maintainer. The script then removes the log file. >+ >+=head1 ENVIRONMENT >+ >+Needs to be in the root directory of the Bugzilla installation in order >+to load the perl libs. >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
dkl
: review-
Actions:
View
|
Diff
Attachments on
bug 406201
:
300010
|
302304
|
302305
|
302344