clamav stats perl script help
First of all I'm not perl smart nor am I knowledgable in scripting. I downloaded a perl script for generating clamav stats, the author had not updated it in several years and told me to go ahead and do with it what I could. Through some outside help I got the script to semi-work, however, I get the below errors:
Use of uninitialized value in substitution (s///) at /usr/local/bin/clamstats.pl line 105. Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106. Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106. Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106. Use of uninitialized value in concatenation (.) or string at /usr/local/bin/clamstats.pl line 106. Use of uninitialized value in split at /usr/local/bin/clamstats.pl line 108. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 115. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 116. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 117. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 118. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 120. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 122. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 122. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 124. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 124. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 125. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 125. Use of uninitialized value in hash element at /usr/local/bin/clamstats.pl line 49. Use of uninitialized value in sprintf at /usr/local/bin/clamstats.pl line 49. Use of uninitialized value in sprintf at /usr/local/bin/clamstats.pl line 49. Argument "" isn't numeric in sprintf at /usr/local/bin/clamstats.pl line 317. Use of uninitialized value in sprintf at /usr/local/bin/clamstats.pl line 53. I see that I can't post attachments. The script is 3.1kb gzip'd, if someone would like to look at the whole script, please let me know. Thanks Chris |
Posting a few lines of your "/usr/local/bin/clamstats.pl", say from lines 105 - 126, and from lines 49 - 55, might be a good alternative ;-)
|
Quote:
$date = "$dow $month $day $time $year"; $startdate = $date if (!defined $startdate); ($hour, $min, $sec) = split(":", $time); $date =~ s/\d+:\d+:\d+\s//; $date =~ s/^\w+\s//; $date =~ s/\s\d+$//; $stats{date}{$date}++; $stats{hour}{$hour}++; $stats{month}{$month}++; $stats{year}{$year}++; $stats{virus}{$virus}++; $stats{count}++; $stats{type}{$ext}++; $hourmax = $stats{hour}->{$hour} if ($stats{hour}->{$hour} > $hourmax); $datemax = $stats{date}->{$date} if ($stats{date}->{$date} > $datemax); $monthmax = $stats{month}->{$month} if ($stats{month}->{$month} > $monthmax); $yearmax = $stats{year}->{$year} if ($stats{year}->{$year} > $yearmax); } Lines 49 - 55: return(sprintf "%-2.2d%-2.2d", $months{$month}, $day); } sub build_key_mon { return(sprintf "%-2.2d", $months{$_}); } and line 317 $TXT .= sprintf("%2d: %6s %s\n", $hr, $stats{hour}->{$hr}, "." x int($hourraw/$hourscale)) if $text; Thanks for any help Chris |
quote:
Use of uninitialized value in substitution (s///) at /usr/local/bin/clamstats.pl line 105. There's no substitution in your example code; I think you need to go back at least one line. If the lines are co-dependent, prob means you are substituting an uninit value and then trying to use it in the first line you've shown us ie effectively a string cooncat. Notice how you get the same complaint 4 times for line 106, which has 4 string subst/concats in it. |
Here are lines 96 - 126, possibly this will help:
if (/^\w{3}\s\w{3}\s{1,2}\d{1,2}\s(\d+:){2}\d{2}\s\d{4}\s->\sstream:\s[\w\.\d-]+\sFOUND$/) { $dow = $1; $month = $2; $day = $3; $time = $4; $year = $5; my $id = $6; my $ext = $7; my $virus = $8; $day =~ s/^(\d)$/0$1/; $date = "$dow $month $day $time $year"; $startdate = $date if (!defined $startdate); ($hour, $min, $sec) = split(":", $time); $date =~ s/\d+:\d+:\d+\s//; $date =~ s/^\w+\s//; $date =~ s/\s\d+$//; $stats{date}{$date}++; $stats{hour}{$hour}++; $stats{month}{$month}++; $stats{year}{$year}++; $stats{virus}{$virus}++; $stats{count}++; $stats{type}{$ext}++; $hourmax = $stats{hour}->{$hour} if ($stats{hour}->{$hour} > $hourmax); $datemax = $stats{date}->{$date} if ($stats{date}->{$date} > $datemax); $monthmax = $stats{month}->{$month} if ($stats{month}->{$month} > $monthmax); $yearmax = $stats{year}->{$year} if ($stats{year}->{$year} > $yearmax); } Here is the output of running clamstats.pl > cstatsoutput.txt: ClamAV Statistics cpollock -------------------------------------------------------- clamd last started Sat May 20 16:07:28 2006 -------------------------------------------------------- Statistics since Last Database Update Tue May 30 16:11:24 2006 -------------------------------------------------------- Total viruses detected 92 Total Database Signatures 57,032 -------------------------------------------------------- 5 FreshClam errors, last on Thu May 25 14:36:34 2006: Mirrors are not fully synchronized. Please try again later. 1 Virus Types Detected ------------------------------------------ 92 100.00% 1 File Extensions Used -------------------------- 92 100.00% By Date ( . = 1 viruses ) -------------------------- 06: : 2 .. 44: : 2 .. 57: : 1 . 15: : 3 ... 21: : 2 .. 14: : 1 . 04: : 4 .... 09: : 1 . 28: : 1 . 22: : 4 .... 10: : 1 . 55: : 4 .... 36: : 1 . 40: : 4 .... 35: : 1 . 37: : 3 ... 27: : 4 .... 05: : 2 .. 24: : 2 .. 12: : 1 . 11: : 1 . 07: : 1 . 31: : 1 . 32: : 1 . 51: : 1 . 20: : 2 .. 54: : 1 . 58: : 1 . 13: : 2 .. 52: : 3 ... 33: : 2 .. 03: : 2 .. 17: : 2 .. 39: : 3 ... 42: : 1 . 50: : 1 . 00: : 2 .. 08: : 1 . 59: : 2 .. 23: : 2 .. 43: : 1 . 02: : 2 .. 19: : 2 .. 56: : 1 . 46: : 1 . 45: : 3 ... 48: : 4 .... 25: : 2 .. By Hour ( . = 1 viruses ) -------------------------- 0: 92 ............................................................................................ By Month ( . = 3 viruses ) ------------------------- : 92 .............................. By Year ( . = 4 viruses ) -------------------------- : 92 ....................... It partially looks correct, however, the date fields are all wrong. If run from the command line, the errors in my first post are shown, if ran outputting to a txt file they are not. Again, I know absolutely nothing about perl scripts. |
To capture all the output, treat it like a shell script ie capture stdout & stderr like this
yourscript >script.log 2>&1 Basically, the if() statement there is trying to parse a date string of some sort, but it's doing it wrong, hence the rest of the errors. Are you sure you can't post the script as a script.txt attachment? |
I see nothing to click that would allow me to upload the script, however I've posted it here:
http://www.easy-sharing.com/473251/clamstats.pl.html Thanks for any help |
Anybody able to get that script contents? All I get is the link, which pts to itself.
|
Quote:
http://w05.easy-sharing.com/473251/D...K/clamstats.pl File size: 12Kb. Downloaded: 0 times I clicked on it and it worked fine. The link is underlined and in brown text. |
Consider e-mailing the clamstat author directly...
Hi -
I looked at your "clamstat.pl" script, and I don't see anything obviously wrong. HOWEVER ... I also see that the purpose of the script is to monitor Clam Antivirus logs. My script won't even start, because I don't have Clam installed, so the script isn't finding a Clam logs directory: Quote:
SUGGESTION: Why not contact the original author of Clamstat.pl directly? His blog (and an e-mail link) are here: http://weblog.infoworld.com/venezia/ |
I did back on 22 May when I couldn't get it to run right. His reply was:
I haven't updated that code in forever, so it's entirely possible > that this is a parsing error caused by a new log format or something > similar. If/when I have time I'll update the code. Alternatively, it > should be relatively simple to modify it to your needs... > > -Paul I know next to nothing about scripts, I've made several small bash scripts to do simple things but thats the extent of my expertise. |
Would posting a few lines of a clamd log here help?
|
Hi -
I definitely sympathize with you ... but no way can I volunteer to debug somebody else's 400 line Perl script. Feel free to post a few lines (or even e-mail me directly). If I can help, I'd be happy to. Otherwise - maybe you could make Mr. Venezia feel guilty enough to update his script (which is still posted on his current site). Sorry I can't be of more help .. PSM |
That link hates me; when I left click I get the same web page again or right click i get the link text.
|
Hmm, it works ok for me, did you click on the link underneath the ad for 100% Real Tones?
|
All times are GMT -5. The time now is 01:07 AM. |