/*==================================================================*\

    MSChtPrf.h:  Headers for an Extensible Performance Object

    Copyright Microsoft Corporation 1998, All Rights Reserved.

    Author:  Peter Beebee, peterbee@microsoft.com
    Modified:scottbri (Adapted for Chat)

\*==================================================================*/

#ifndef __MSCHTPRF_H
#define __MSCHTPRF_H

// This string is service name (under HKLM\CurrentControlSet\Services ) which uses this DLL.
#define EVENTLOG_NAME _T("MSExchangeChat")
// This unique name is used for the shared memory containing the performance data.
#define PERF_SHARED_MEMORY_SIZE (1024 * 1024)  // Allow this much space in the page file.
#define PERF_SHARED_MEMORY_FILE L"Global\\" L"MS_EXCHANGE_CHAT_SERVER_PERFORMANCE_DATA"
#define PERF_SHARED_MEMORY_MUTEX PERF_SHARED_MEMORY_FILE L"_MUTEX"
// This value includes the terminating NULL
#define PERF_MAXLEN_INSTANCE_NAME 255

////////////////////////////////////////////////////////////////////////////////
//                           ///////////////////////////////////////////////////
// $$ADD COUNTERS HERE START ///////////////////////////////////////////////////
//                           ///////////////////////////////////////////////////

// These are offsets (from the "base" value that lodctr.exe installs in the 
// "First Counter" and "First Help" registry values under your service's 
// "Performance" key) for counter/object name and help strings.  In the string 
// database in the registry.  Counter name strings are stored at even offsets 
// and help strings are stored at odd offsets, so counter/object offsets 
// increment by 2.
//
// For each counter, add a macro for the index of your counter, increment the 
// appropriate count, and insert a line in either the COUNTERS_INSTANCE macro 
// or the COUNTERS_TOTAL_ONLY macro to declare your counter.  The arguments
// to yhe COUNTER_MACRO macro are the counter name, ctype, type, and scale.
//
// A parent counter is the same as a regular counter, except that when it is 
// incremented, the following counter is also incremented.  This is most 
// useful for incrementing total and rate counters simultaneously.
//
// NOTE: Do not put anything else in this header file --
//       it is shipped with the *.ini, and perfmon dll binary.

#define NUM_OBJECTS                  2
#define OBJECT_Total                     0
#define OBJECT_Instance                  2

#define NUM_COUNTERS_INSTANCE                   30
#define COUNTER_ANONYMOUS_CLIENTS                         4
#define COUNTER_AUTHENTICATED_CLIENTS                     6
#define COUNTER_AUTHENTICATION_FAILURES                   8
#define COUNTER_CHANNEL_CREATES                          10
#define COUNTER_CHANNEL_CREATES_PERSEC                   12
#define COUNTER_CHANNEL_DELETES                          14
#define COUNTER_CHANNEL_DELETES_PERSEC                   16
#define COUNTER_CHANNEL_JOINS                            18
#define COUNTER_CHANNEL_JOINS_PERSEC                     20
#define COUNTER_CHANNEL_PARTS                            22
#define COUNTER_CHANNEL_PARTS_PERSEC                     24
#define COUNTER_CHANNELS                                 26
#define COUNTER_CLIENT_BYTES_QUEUED                      28
#define COUNTER_CLIENT_BYTES_RECEIVED                    30
#define COUNTER_CLIENT_BYTES_RECEIVED_PERSEC             32
#define COUNTER_CLIENT_BYTES_SENT                        34
#define COUNTER_CLIENT_BYTES_SENT_PERSEC                 36
#define COUNTER_CLIENT_CONNECTS                          38
#define COUNTER_CLIENT_CONNECTS_PERSEC                   40
#define COUNTER_CLIENT_DISCONNECTS                       42
#define COUNTER_CLIENT_DISCONNECTS_PERSEC                44
#define COUNTER_CLIENT_MESSAGES_RCV_PERSEC               46
#define COUNTER_CLIENT_MESSAGES_SENT_PERSEC              48
#define COUNTER_CLIENT_OPERATOR_KILLED                   50
#define COUNTER_CLIENT_TIME_REL_DIS                      52
#define COUNTER_CLIENTS                                  54
#define COUNTER_CONNECTION_ATTEMPTS                      56
#define COUNTER_NICK_COLLISIONS                          58
#define COUNTER_UNKNOWN_CLIENTS                          60
#define COUNTER_CHANNEL_MEMBERS                          62

// Per physical server counters
#define NUM_COUNTERS_TOTAL_ONLY                 7
#define COUNTER_ACTIVE_DNS_LOOKUP_THREADS               64
#define COUNTER_CLIENT_CONNECTIONS                      66
#define COUNTER_DNS_LOOKUP_FAILURES                     68
#define COUNTER_SERVER_OPS_QUEUED                       70
#define COUNTER_SERVER_OPS_QUEUED_PERSECOND             72
#define COUNTER_WORKER_THREADS_ACTIVE                   74
#define COUNTER_WORKER_THREADS_IDLE                     76

// Comment out the following line to remove performance counting from the Chat Server.
//
#define CHATPERF_ENABLED 1
#ifdef CHATPERF_ENABLED

// MSExchangeIM Counters
//#define MY_PERF_COUNTER_RAWCOUNT 0x00010000
//#define MY_PERF_COUNTER_COUNTER  0x10410400

#define COUNTERS_INSTANCE                                                                         \
           COUNTER_MACRO(ANONYMOUS_CLIENTS,            ULONG, PERF_COUNTER_RAWCOUNT, -3);    \
           COUNTER_MACRO(AUTHENTICATED_CLIENTS,        ULONG, PERF_COUNTER_RAWCOUNT, -3);    \
           COUNTER_MACRO(AUTHENTICATION_FAILURES,      ULONG, PERF_COUNTER_RAWCOUNT, -4);    \
    PARENT_COUNTER_MACRO(CHANNEL_CREATES,              ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CHANNEL_CREATES_PERSEC,       ULONG, PERF_COUNTER_COUNTER, -2);    \
    PARENT_COUNTER_MACRO(CHANNEL_DELETES,              ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CHANNEL_DELETES_PERSEC,       ULONG, PERF_COUNTER_COUNTER, -2);    \
    PARENT_COUNTER_MACRO(CHANNEL_JOINS,                ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CHANNEL_JOINS_PERSEC,         ULONG, PERF_COUNTER_COUNTER, -2);    \
    PARENT_COUNTER_MACRO(CHANNEL_PARTS,                ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CHANNEL_PARTS_PERSEC,         ULONG, PERF_COUNTER_COUNTER, -2);    \
           COUNTER_MACRO(CHANNELS,                     ULONG, PERF_COUNTER_RAWCOUNT, -3);    \
           COUNTER_MACRO(CLIENT_BYTES_QUEUED,          ULONG, PERF_COUNTER_RAWCOUNT, -6);    \
    PARENT_COUNTER_MACRO(CLIENT_BYTES_RECEIVED,        ULONG, PERF_COUNTER_RAWCOUNT, -6);    \
           COUNTER_MACRO(CLIENT_BYTES_RECEIVED_PERSEC, ULONG, PERF_COUNTER_COUNTER, -3);    \
    PARENT_COUNTER_MACRO(CLIENT_BYTES_SENT,            ULONG, PERF_COUNTER_RAWCOUNT, -6);    \
           COUNTER_MACRO(CLIENT_BYTES_SENT_PERSEC,     ULONG, PERF_COUNTER_COUNTER, -3);    \
    PARENT_COUNTER_MACRO(CLIENT_CONNECTS,              ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CLIENT_CONNECTS_PERSEC,       ULONG, PERF_COUNTER_COUNTER, -3);    \
    PARENT_COUNTER_MACRO(CLIENT_DISCONNECTS,           ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CLIENT_DISCONNECTS_PERSEC,    ULONG, PERF_COUNTER_COUNTER, -3);    \
           COUNTER_MACRO(CLIENT_MESSAGES_RCV_PERSEC,   ULONG, PERF_COUNTER_COUNTER, -3);    \
           COUNTER_MACRO(CLIENT_MESSAGES_SENT_PERSEC,  ULONG, PERF_COUNTER_COUNTER, -3);    \
           COUNTER_MACRO(CLIENT_OPERATOR_KILLED,       ULONG, PERF_COUNTER_RAWCOUNT, -3);    \
           COUNTER_MACRO(CLIENT_TIME_REL_DIS,          ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(CLIENTS,                      ULONG, PERF_COUNTER_COUNTER, -3);    \
           COUNTER_MACRO(CONNECTION_ATTEMPTS,          ULONG, PERF_COUNTER_RAWCOUNT, -5);    \
           COUNTER_MACRO(NICK_COLLISIONS,              ULONG, PERF_COUNTER_RAWCOUNT, -3);    \
           COUNTER_MACRO(UNKNOWN_CLIENTS,              ULONG, PERF_COUNTER_RAWCOUNT, -2);    \
           COUNTER_MACRO(CHANNEL_MEMBERS,              ULONG, PERF_COUNTER_RAWCOUNT, -2);    \
           
           
#define COUNTERS_TOTAL_ONLY                                                                       \
           COUNTER_MACRO(ACTIVE_DNS_LOOKUP_THREADS,   ULONG, PERF_COUNTER_RAWCOUNT, 0);    \
           COUNTER_MACRO(CLIENT_CONNECTIONS,          ULONG, PERF_COUNTER_RAWCOUNT, 0);    \
           COUNTER_MACRO(DNS_LOOKUP_FAILURES,         ULONG, PERF_COUNTER_RAWCOUNT, -1);    \
    PARENT_COUNTER_MACRO(SERVER_OPS_QUEUED,           ULONG, PERF_COUNTER_RAWCOUNT, -3);    \
           COUNTER_MACRO(SERVER_OPS_QUEUED_PERSECOND, ULONG, PERF_COUNTER_COUNTER, -2);    \
           COUNTER_MACRO(WORKER_THREADS_ACTIVE,       ULONG, PERF_COUNTER_RAWCOUNT, 0);    \
           COUNTER_MACRO(WORKER_THREADS_IDLE,         ULONG, PERF_COUNTER_RAWCOUNT, 0);    \


#endif // CHATPERF_ENABLED

#endif // __MSCHTPRF_H
