~wibblymat/ubuntu/oneiric/sagan/ftbfs-jam

« back to all changes in this revision

Viewing changes to src/sagan-stats.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2011-03-17 15:18:58 UTC
  • Revision ID: james.westby@ubuntu.com-20110317151858-iqvfx0hsxlamxp6b
Tags: upstream-0.1.9~svn129
ImportĀ upstreamĀ versionĀ 0.1.9~svn129

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
** Copyright (C) 2009-2011 Softwink, Inc. 
 
3
** Copyright (C) 2009-2011 Champ Clark III <champ@softwink.com>
 
4
**
 
5
** This program is free software; you can redistribute it and/or modify
 
6
** it under the terms of the GNU General Public License Version 2 as
 
7
** published by the Free Software Foundation.  You may not use, modify or
 
8
** distribute this program under any other version of the GNU General
 
9
** Public License.
 
10
**
 
11
** This program is distributed in the hope that it will be useful,
 
12
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
** GNU General Public License for more details.
 
15
**
 
16
** You should have received a copy of the GNU General Public License
 
17
** along with this program; if not, write to the Free Software
 
18
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
*/
 
20
 
 
21
/* sagan-stats.c 
 
22
 *
 
23
 * Simply dumps statistics of Sagan to the user or via sagan.log
 
24
 *
 
25
 */
 
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include "config.h"             /* From autoconf */
 
29
#endif
 
30
 
 
31
#include <stdio.h>
 
32
#include <string.h>
 
33
#include <unistd.h>
 
34
#include <stdint.h>
 
35
#include <inttypes.h>
 
36
 
 
37
#include "sagan.h"
 
38
 
 
39
struct _SaganConfig *config;
 
40
struct _SaganCounters *counters;
 
41
 
 
42
void sagan_statistics() { 
 
43
 
 
44
sbool flag=0;
 
45
 
 
46
        if ((isatty(1))) {
 
47
 
 
48
                    sagan_log(0, "--------------------------------------------------------------------------");
 
49
                    sagan_log(0, "Total number of events processed: %" PRIu64 "", counters->sagantotal);
 
50
                    sagan_log(0, "Total number of events thresholded: %" PRIu64 " (%.3f%%)", counters->threshold_total, CalcPct( counters->threshold_total, counters->sagantotal) );
 
51
                    sagan_log(0, "Total number of signatures matched: %" PRIu64 " (%.3f%%)",  counters->saganfound, CalcPct( counters->saganfound, counters->sagantotal ) );
 
52
                    sagan_log(0, "Total events dropped: %" PRIu64 " (%.3f%%)", counters->sagandrop, CalcPct(counters->sagandrop, counters->sagantotal) );
 
53
                    sagan_log(0, "--------------------------------------------------------------------------");
 
54
 
 
55
                    if ( config->sagan_ext_flag ) { 
 
56
                       sagan_log(0, "Max external threads: %" PRIu64 " of %" PRIu64 " (%.3f%%) | External events dropped: %" PRIu64 "", counters->threadmaxextc,  config->max_external_threads, CalcPct( counters->threadmaxextc, config->max_external_threads), counters->saganexternaldrop);
 
57
                       flag=1;
 
58
                       }
 
59
 
 
60
#if defined(HAVE_LIBMYSQLCLIENT_R) || defined(HAVE_LIBPQ)
 
61
                    
 
62
                    if ( config->dbtype ) { 
 
63
                       sagan_log(0, "Max Snort database threads: %" PRIu64 " of %" PRIu64 " (%.3f%%) | Snort DB drops: %" PRIu64 "", counters->threadmaxdbc, config->maxdb_threads, CalcPct( counters->threadmaxdbc, config->maxdb_threads), counters->sagansnortdrop);
 
64
                       flag=1;
 
65
                       }
 
66
 
 
67
                    if ( config->logzilla_dbtype ) { 
 
68
                       sagan_log(0, "Max Logzilla threads: %" PRIu64 " of %" PRIu64 " (%.3f%%) | Logzilla events dropped: %" PRIu64 "", counters->threadmaxlogzillac, config->max_logzilla_threads, CalcPct( counters->threadmaxlogzillac, config->max_logzilla_threads), counters->saganlogzilladrop);
 
69
                       flag=1;
 
70
                       }
 
71
#endif
 
72
 
 
73
#ifdef HAVE_LIBESMTP
 
74
                    if ( config->sagan_esmtp_flag ) {
 
75
                       sagan_log(0, "Max SMTP threads reached: %" PRIu64 " of %" PRIu64 " (%.3f%%) | SMTP events dropped: %" PRIu64 "", counters->threadmaxemailc, config->max_email_threads, CalcPct( counters->threadmaxemailc, config->max_email_threads), counters->saganesmtpdrop);
 
76
                       flag=1;
 
77
                       }
 
78
#endif
 
79
 
 
80
#ifdef HAVE_LIBPRELUDE
 
81
                   if ( config->sagan_prelude_flag ) { 
 
82
                      sagan_log(0, "Max Prelude threads reached: %" PRIu64 " of %" PRIu64 " (%.3f%%) | Prelude events dropped: %" PRIu64 "", counters->threadmaxpreludec, config->max_prelude_threads, CalcPct( counters->threadmaxpreludec, config->max_prelude_threads), counters->saganpreludedrop);
 
83
                      flag=1;
 
84
                      }
 
85
#endif
 
86
 
 
87
if ( flag == 1) sagan_log(0, "--------------------------------------------------------------------------");
 
88
        
 
89
        }
 
90
}