This file is indexed.

/usr/include/sipwitch/stats.h is in libsipwitch-dev 1.6.1-2build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright (C) 2009-2010 David Sugar, Tycho Softworks.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Basic server call statistics.
 * This provides the interface for managing server call statistics, which are
 * kept in shared memory.
 * @file sipwitch/stats.h
 */

#ifndef _SIPWITCH_STATS_H_
#define _SIPWITCH_STATS_H_

#ifndef _UCOMMON_LINKED_H_
#include <ucommon/linked.h>
#endif

#ifndef _UCOMMON_THREAD_H_
#include <ucommon/thread.h>
#endif

#ifndef _UCOMMON_STRING_H_
#include <ucommon/string.h>
#endif

#ifndef _SIPWITCH_NAMESPACE_H_
#include <sipwitch/namespace.h>
#endif

NAMESPACE_SIPWITCH
using namespace UCOMMON_NAMESPACE;

#define STAT_MAP    "sipwitch.stats"

/**
 * A stat element of call traffic.  Stats may cover a specific element for
 * a current time period, and total stats for the life of the server.  This
 * is used to determine server utilization, to determine peak times such as
 * may be needed for acd traffic analysis, and to categorize the kind of
 * traffic we are processing through the server.  There is a "system" stat
 * node for ALL server call traffic, as well as nodes for collecting stats
 * on all extensions, on all service entries, etc.
 * @author David Sugar <dyfet@gnutelephony.org>
 */
class __EXPORT stats
{
public:
    char id[12];

    typedef enum {INCOMING = 0, OUTGOING = 1} stat_t;

    /**
     * We have stats for both incoming and outgoing traffic of various kinds.
     */
    struct
    {
        unsigned long total, period, pperiod;
        unsigned short current, peak, min, max, pmin, pmax;
    } data[2];

    time_t lastcall;
    unsigned short limit;

    /**
     * Assign a call to inbound or outbound statistic for this stat node.
     * Increments count.
     * @param elenent (in or out) to assign to.
     */
    void assign(stat_t element);

    /**
     * Release a call from inbound or outbound stastic for this stat node.
     * This is commonly related to call drop and decrements count.
     * @param element (in or out) to release from.
     */
    void release(stat_t element);

    /**
     * Total number of active calls in the server at the moment.
     * @return total active calls.
     */
    unsigned active(void) const;

    /**
     * Write out statistics to a file for the current period.  The stats
     * are also reset for the new period.  The period is also the sync
     * period of the sync event, and is set with the service::period method.
     * @param file to write to or NULL for none.
     */
    static void period(FILE *file = NULL);

    /**
     * Create stats in shared memory pool.  Creates several default statistic
     * nodes for groups of calls, and returns the "system" stat node for the
     * total server.
     */
    static stats *create(void);

    /**
     * Request a stat node from the memory pool by id.  If the node does not
     * exist, it is created.
     * @return node from shared memory or NULL if out of nodes.
     */
    static stats *request(const char *id);

    /**
     * Server allocate x number of stat nodes at startup.
     * @param number of stat nodes to allocate.
     */
    static void allocate(unsigned count);

    /**
     * Release stat nodes shared memory segment.
     */
    static void release(void);
};

END_NAMESPACE

#endif