~ubuntu-branches/ubuntu/oneiric/clamfs/oneiric

« back to all changes in this revision

Viewing changes to src/stats.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2009-02-21 14:01:39 UTC
  • mfrom: (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090221140139-l2f2ig2qndwp79pv
Tags: 1.0.0-1
* New upstream version
* debian/control:
  - removed dependency on libpoco5-dev
  - s/An user-space/user-space/ in Description: field

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!\file stats.cxx
 
2
 
 
3
   \brief Statistics (fs, av, cache, etc.) routines
 
4
 
 
5
   $Id: stats.cxx,v 1.4 2008-11-23 16:04:24 burghardt Exp $
 
6
 
 
7
*//*
 
8
 
 
9
   ClamFS - An user-space anti-virus protected file system
 
10
   Copyright (C) 2008 Krzysztof Burghardt.
 
11
 
 
12
   This program is free software; you can redistribute it and/or modify
 
13
   it under the terms of the GNU General Public License as published by
 
14
   the Free Software Foundation; either version 2 of the License, or
 
15
   (at your option) any later version.
 
16
 
 
17
   This program is distributed in the hope that it will be useful,
 
18
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
   GNU General Public License for more details.
 
21
 
 
22
   You should have received a copy of the GNU General Public License
 
23
   along with this program; if not, write to the Free Software
 
24
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
25
*/
 
26
 
 
27
#include "stats.hxx"
 
28
 
 
29
namespace clamfs {
 
30
 
 
31
Stats::Stats(time_t dumpEvery) {
 
32
    earlyCacheHit = 0;
 
33
    earlyCacheMiss = 0;
 
34
    lateCacheHit = 0;
 
35
    lateCacheMiss = 0;
 
36
 
 
37
    whitelistHit = 0;
 
38
    blacklistHit = 0;
 
39
 
 
40
    tooBigFile = 0;
 
41
 
 
42
    openCalled = 0;
 
43
    openAllowed = 0;
 
44
    openDenied = 0;
 
45
 
 
46
    scanFailed = 0;
 
47
 
 
48
    lastdump = time(NULL);
 
49
    every = dumpEvery;
 
50
}
 
51
 
 
52
Stats::~Stats() {
 
53
}
 
54
 
 
55
void Stats::dumpToLog() {
 
56
    rLog(Info, "--- begin of statistics ---");
 
57
    rLog(Info, "Early cache hit: %llu", earlyCacheHit);
 
58
    rLog(Info, "Early cache miss: %llu", earlyCacheMiss);
 
59
    rLog(Info, "Late cache hit: %llu", lateCacheHit);
 
60
    rLog(Info, "Late cache miss: %llu", lateCacheMiss);
 
61
    rLog(Info, "Whitelist hit: %llu", whitelistHit);
 
62
    rLog(Info, "Blacklist hit: %llu", blacklistHit);
 
63
    rLog(Info, "Files bigger than maximal-size: %llu", tooBigFile);
 
64
    rLog(Info, "open() function called %llu times (allowed: %llu, denied: %llu)",
 
65
            openCalled, openAllowed, openDenied);
 
66
    rLog(Info, "Scan failed %llu times", scanFailed);
 
67
    rLog(Info, "--- end of statistics ---");
 
68
}
 
69
 
 
70
void Stats::periodicDumpToLog() {
 
71
    if (!every)
 
72
        return;
 
73
 
 
74
    time_t current = time(NULL);
 
75
    if ((current - lastdump) > every) {
 
76
        dumpToLog();
 
77
        lastdump = current;
 
78
    }
 
79
}
 
80
 
 
81
} /* namespace clamfs */
 
82
 
 
83
/* EoF */