1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
--- amavis-stats.orig Sat Mar 27 23:25:27 2004
+++ amavis-stats Mon Jul 10 22:55:19 2006
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/perl -w
#
# amavis-stats -- generate rrds from amavis log output
#
@@ -28,6 +28,7 @@
# ########################################################################
use strict;
use warnings;
+use diagnostics;
use Getopt::Std;
use Time::localtime;
use Time::Local;
@@ -83,8 +84,8 @@
$version = "0.1.12"; # this value is auto-updated by packing system
$pkg = "amavis-stats";
$locale = "C";
-$lockfile = "/var/lock/$pkg";
-$statedir = "/var/lib/$pkg";
+$lockfile = "/var/tmp/$pkg";
+$statedir = "/usr/local/www/$pkg";
$statefile = "$statedir/$pkg.state"; # last read position of the logfile
$namesfile = "$statedir/$pkg.names"; # stores the virus name to id mappings
$countfile = "$statedir/$pkg.count"; # per virus totals
@@ -212,7 +213,7 @@
sub semlock {
open (LOCKF, ">$lockfile") or do_exit(1, "Could not open $lockfile: $!");
unless (flock(LOCKF, LOCK_EX | LOCK_NB)) {
- err("warning: Could not lock $lockfile: $!");
+ print_err("warning: Could not lock $lockfile: $!");
sleep 2;
unless (flock(LOCKF, LOCK_EX | LOCK_NB)) {
do_exit(1, "Could not lock $lockfile: $!");
@@ -680,8 +681,8 @@
if (defined($rotlogfile)) {
parseFile ($rotlogfile, $spos, (stat $rotlogfile)[7]);
} else {
- err("Could not open rotated logfile.");
- err(" Tried extentions .0, .1, .01, -$today, -$yesterday");
+ print_err("Could not open rotated logfile.");
+ print_err(" Tried extentions .0, .1, .01, -$today, -$yesterday");
do_exit(1);
}
}
@@ -707,7 +708,7 @@
my $err = RRDs::error;
if ($err) {
- err("createRRD: $err");
+ print_err("createRRD: $err");
return -1;
}
@@ -736,7 +737,7 @@
$last = RRDs::last($rrdfile);
$err = RRDs::error;
if ($err) {
- err("updateRRD: $err");
+ print_err("updateRRD: $err");
return -1;
}
@@ -750,8 +751,8 @@
$err = RRDs::error;
if ($err) {
- err("updateRRD: $err");
- err("Attempted to update $rrdfile at $epoch count $count");
+ print_err("updateRRD: $err");
+ print_err("Attempted to update $rrdfile at $epoch count $count");
return -1;
}
}
@@ -769,7 +770,8 @@
print "$me: @_\n" if ($verbose);
}
-sub err {
+sub print_err
+{
print STDERR "$me: error: @_\n";
}
|