I'm glad to see that we're thinking along the same lines. I'm pretty good with bash. Not as good with perl, but I think I can read it well enough to translate what you're doing into bash. I'll have a look at it when I get a chance. It would help me out a bit if you could give me a couple examples of what the script needs to do (from the user standpoint). I'm guessing that shortening the output is all that qmlog might need to do.
FWIW, there is a tai64nlocal program included in the daemontools-toaster package that converts the time to a readable format. I'll have to see what you're doing to shorten things, but I'm guessing that sed or cut might fit the bill (no pun intended). Thanks! Bill Kwok wrote: > There are a few Perl modules which I use in the program. You may run > the following to make sure you've got all of them: > > #perl -MCPAN -e shell > cpan> install Getopt::Std > cpan> install Time::TAI64 > cpan> install Time::HiRes > cpan> install File::Tail > cpan> install Cwd > cpan> exit > > I select perl to develop the program only because my knowledge about > bash is not good enough to develop what I want, especially about how to > convert the tai64n string to the format I want and how to shorten the > output message. It will be great if we can perform all these features > by using bash script. At least people don't need to install any > additional perl modules in order to use it. :) > > Best regards, > Bill > > > On 11/22/06, *Bill Kwok* <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > The module can be installed by: > > # perl -MCPAN -e 'install File::Tail' > > Actually, you may add other required modules by the same way. > > Best regards, > Bill > > On 11/22/06, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>* < > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: > > The module was successfully installed but I still get the same > error but > this time is line 7 of the script as opposed to the previous error > occurring at line 5. > > Can't locate File/Tail.pm in @INC > BEGIN failed--compilation aborted at ./qt-showlog line 7. > > > > > Hi, > > > > You may install the required Perl module by the following command: > > > > # *perl -MCPAN -e 'install Time::TAI64'* > > > > > > Best regards, > > Bill > > > > On 11/22/06, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> < > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: > >> > >> Bill, > >> > >> I am getting errors when I run your script. I may be missing some > >> modules > >> (I think) bunt don't know how to install them. > >> > >> [EMAIL PROTECTED] ~]# ./qt-showlog -t -s pop3-ssl -i LOGOUT -f > '%y%b%d %H:%M' > >> Can't locate Time/TAI64.pm in @INC (@INC contains: > >> /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi > >> /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi > >> /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi > >> /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi > >> /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi > >> /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi > >> /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 > >> /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 > >> /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 > >> /usr/lib/perl5/site_perl > >> /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi > >> /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi > >> /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi > >> /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi > >> /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi > >> /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi > >> /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 > >> /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 > >> /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 > >> /usr/lib/perl5/vendor_perl > /usr/lib/perl5/5.8.8/i386-linux-thread-multi > >> /usr/lib/perl5/5.8.8 .) at ./qt-showlog line 5. > >> BEGIN failed--compilation aborted at ./qt-showlog line 5. > >> [ [EMAIL PROTECTED] ~]# > >> > >> > >> > >> > >> > Hi all, > >> > > >> > From time to time, we need to read qmail's log files. Since > the time > >> > stamp > >> > returned by tai64nlocal is "too precise" (lengthy), for me, > I've > >> written > >> a > >> > Perl script so that the log file can be displayed in a > customized time > >> > stamp. It also includes few more options: > >> > > >> > # qt-showlog -h > >> > Display qmail log in custom time format > >> > Usage: /root/scripts/qt-showlog [Options] [file name]... > >> > -d <directory> Specify directory location. Default: > >> > /var/log/qmail > >> > -e <Text> Display lines without <Text> > >> > -f <date format> SpecIfy date format to be used. > Default: %b%d > >> > %H:%M:%S > >> > -h Show this message > >> > -i <Text> Display lines with <Text> > >> > -s <Service> Select <Service> log, such as > pop3-ssl and > >> send. > >> > Default: send > >> > -t Display log which is continously > appended to > >> > (similar to tail -f) > >> > [filename] File to be displayed. Default: All > files > >> started > >> > with ' and 'current' > >> > > >> > If -t is selected, only 'current' will be displayed > >> > > >> > For example, the following command shows only the lines > which includes > >> > 'LOGOUT' in the newly appended records of > >> > the /var/log/qmail/pop3-ssl/current file with a yymmmdd > HH:MM time > >> stamp: > >> > > >> > #qt-showlog -t -s pop3-ssl -i LOGOUT -f '%y%b%d %H:%M' > >> > 06Nov16 11:31 INFO: LOGOUT, user=adams, ip=[1.2.3.4 > <http://1.2.3.4/>], top=0, retr=0, > >> > rcvd=24, sent=2614, time=0 > >> > 06Nov16 11:31 INFO: LOGOUT, user=sylvia, ip=[ 1.2.3.4 > <http://1.2.3.4/>], top=0, retr=0, > >> > rcvd=12, sent=39, time=0 > >> > 06Nov16 11:31 INFO: LOGOUT, user=adrian, ip=[4.3.2.1 > <http://4.3.2.1/>], top=0, retr=0, > >> > rcvd=12, sent=39, time=1 > >> > 06Nov16 11:31 INFO: LOGOUT, user=anita, ip=[1.3.5.7 > <http://1.3.5.7/>], top=0, > >> retr=25181, > >> > rcvd=40, sent=25923, time=0 > >> > > >> > > >> > > >> > To further reduce the length of the output, you may want to > edit the > >> > following lines of regex in the script. In my example here, > I replace > >> all > >> > " > >> > mydomain.com <http://mydomain.com/>" with "MD" and etc. > >> > > >> > # comment out the following if you want to show full content > >> > my @items= ( > >> > [ qr/mydomain.com/, "MD" ], > >> > [ > >> > qr/User_and_password_not_set,_continuing_without_authentication./, > >> > "w/o auth" ], > >> > [ qr(Remote_host_said:_250[^/]+), > 'Remote_host_said:_250' ], > >> > ); > >> > > >> > I hope you like it. Please feel free to comment. > >> > > >> > Best regards, > >> > Bill > >> > > --------------------------------------------------------------------- > > >> > QmailToaster hosted by: VR Hosted < http://www.vr.org > <http://www.vr.org/>> > >> > > --------------------------------------------------------------------- -- -Eric 'shubes' --------------------------------------------------------------------- QmailToaster hosted by: VR Hosted <http://www.vr.org> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
