Advertisement

09.19.2007 at 01:23AM PDT, ID: 22838045
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Help with searching through the event log

Asked by WillHudson in Perl Programming Language

Tags: , ,

Hiya folks.

Basically i've written a script to check the event log on our print server (every print job is logged for auditing/cost centres purposes). At the moment, it will search the event log from the oldest log to the newest, with any print event is recorded.  I've  tried changing the way the script works, so that now a start date and end date can be specified (if for example they wanted a monthly report) but the problem i've found is that it is still searching from the beginning of the log, which will take an increasingly longer amount of time as the event log grows and if i only want (for example) the last 2 days logs it will take the same amount of time as if i wanted the entire log! So my question is, can i make it so the search starts from a start date?

Below is the section that i know needs changing, luckily i comment most of my code so i remember what it does! I believe i need to change "while ( $x < $recs)" ?

 $handle=Win32::EventLog->new("System", $server)
        or die "Can't open Application EventLog\n";
 $handle->GetNumber($recs) # Get the number of records in the log
        or die "Can't get number of EventLog records\n";
 $handle->GetOldest($base) # Get the number of the oldest record
        or die "Can't get number of oldest EventLog record\n";

 my @printerlogs;
 my %printerdata;
 my %printtotal; # Total number of pages for each printer
 my $grandtotal = 0;  # The total number of pages printed
 my $x;
   
 while ( $x < $recs) {
        $handle->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,
                                  $base+$x,
                                  $hashRef)
                or die "Can't read EventLog entry #$x\n";
        my @date = localtime( $hashRef->{TimeGenerated} );
          my $LogDate = sprintf("%04d%02d%02d", ($date[5]+1900, ($date[4])+1, $date[3] ));
            # Logdate is the date of the event, in YYYYMMDD format
            my ($day, $month, $year) = split /[-\/]/, $startdate;
                $convstartdate = sprintf("%04d%02d%02d", $year, $month, $day);
            # Converts the startdate to YYYYMMDD for comparison compatibility
            my ($day, $month, $year) = split /[-\/]/, $enddate;
            $convenddate = sprintf("%04d%02d%02d", $year, $month, $day);
            # Converts the enddate to YYYYMMDD for comparison compatibility
            if (($hashRef->{EventID} == 1073741834) && ($LogDate >= $convstartdate) && ($LogDate <= $convenddate)) {  # 1073741834 = Event ID of a Print job
                     Win32::EventLog::GetMessageText($hashRef);
                      push @printerlogs, $hashRef->{Message};
            }
  $x++;
 } # Reads the event log, and if the Event ID is matched then read the message

Any help would be appreciated.Start Free Trial
[+][-]09.19.2007 at 04:45AM PDT, ID: 19919737

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: 1073741834, event, eventlog
Sign Up Now!
Solution Provided By: mjcoyne
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09.19.2007 at 07:01AM PDT, ID: 19920667

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2007 at 07:11AM PDT, ID: 19920765

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628