MPK has asked for the wisdom of the Perl Monks concerning the following question:

Respected Monks, I have a Log file with delimited values of date, time, userid, status of login(Success or failure). I need to get the count of successful & unsuccessful login for each user. For this can I write a perl script that sorts the delimited file & get the values & check them? Could you guide me with the script to do so? Thanks in advance MPK
  • Comment on Identify count of successful & unsuccessful Login - Script to monitor Log files

Replies are listed 'Best First'.
Re: Identify count of successful & unsuccessful Login - Script to monitor Log files
by psini (Deacon) on May 29, 2008 at 14:47 UTC

    You should read the file, line by line, parse the lines (with a regex? It depends on the format of the file; if it is a CSV file you could use Text::CSV) verify the status and increment the counter. The counter coud be a HoA: an hash whit userid as key and containing the reference to a two element array (i.e. $counter->{$userid}->[0] success, ...->[1] failure)

    Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

Re: Identify count of successful & unsuccessful Login - Script to monitor Log files
by MidLifeXis (Monsignor) on May 29, 2008 at 15:14 UTC