Thursday, November 20, 2008

Monitoring SSL certificate expiration date

OK, last night I had the embarrassment of by my boss discovering that I did not renew the SSL certificate of a web site we run before the expiration date. But, more than the embarrassment, I felt stupid for not setting up a way to monitor the SSL certificates of our web sites and having a facility that would hammer me as the certificate expiration day get closer.

After bit of research, I found that I could have run openssl command below via a cron from anywhere in my network and monitor it:

openssl s_client -connect hostname:443 < /dev/null 2>&1 | openssl x509 -noout -enddate


Oh, well.

Wednesday, June 11, 2008

Not so familair log entries from sendmail

For a sysadmin or an application support person, log files are the key input to all they do. Mastering the skill of understanding what each log entry in a log file means or trying to tell you, is something that separate a super admin from a Joe Schmoe admin.

Some applications provide logs in a meaningful uniform format, while others just spits out strings to logs. From my experience, most open-source applications running on Unix flavors which uses syslog facility are excellent in this regard. On the other hand Most windows applications that logs via event log facility are pathetic. Output from tomcat on web servers are just plain funny, they don't even have a time stamp.

OK, back to the title of this post. I made some changes to a sendmail instance running on one of my boxes. The goal was to
  1. Stop processing the queue if the load average on the box rises above, say 20.
  2. Delay the incoming messages if the load average rises above, say 30.
sendmail is rich in this regard. I could use '-OQueueLA=20' to prevent the queue processors from processing the queue if/when the load grows above 20. I can use '-ODelayLA=30' on my sendmail listeners to delay in incoming volume by inserting a one second sleep when the load rises above 25. This is all good stuff. But I have to show my boss that these changes are actually working. Few lines from sendmail log will be the best. A bit of digging uncovered the gem I was looking for.

When the load average rise past 20, sendmail stops processing the queue and logs:

runqueue: Aborting queue run: load average too high

When load average rise past 30, sendmail delays incoming e-mails and logs:

delaying connections on daemon : load average=32 >= 30

Additionally, I think , if the load average goes above during an SMTP session, sendmail delay the commands of the session and logs:

delaying=EHLO, load average=32 >= 30
delaying=MAIL, load average=32 >= 30
delaying=DATA, load average=32 >= 30


Sweet!

Wednesday, March 26, 2008

Perl one liners

Perl one liners is a pretty cool thing.. OK for some one who is not familiar with awk or sed ?

Whatever, I believed Perl one liner is what I need is for a simple task at hand. I have a log file where the fields are separated by spaces. I wanted to extract a field from the file.

I started by skimming through http://search.cpan.org/dist/perl/pod/perlrun.pod. I figured out the options I needed are:

-a : turns on autosplit mode when used with a -n or -p. An implicit split command to the @F array is done as the first thing inside the implicit while loop produced by the -n or -p.

-n: causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed -n or awk:
  LINE:
while (<>) {
... # your program goes here
}
Note that the lines are not printed by default.
-e: may be used to enter one line of program. If -e is given, Perl will not look for a filename in the argument list. Multiple -e commands may be given to build up a multi-line script. Make sure to use semicolons where you would in a normal program.

And there were a ton of examples of the Perl one-liners on the above URL too.. so my Perl one liner came up as below:

perl -ane 'print $F[20], $F[23], "\n" if defined $F[20];' logfile.log