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

    MSIMPerf.h:  Headers for an Extensible Performance Object

    Copyright Microsoft Corporation 1998, All Rights Reserved.

    Author:  Peter Beebee, peterbee@microsoft.com

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

#ifndef __MSIMPERF_H
#define __MSIMPERF_H

#include "httputils.h"

// This string is service name (under HKLM\CurrentControlSet\Services ) which uses this DLL.
#define EVENTLOG_NAME _T("MSExchangeIM")

// 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_INSTANT_MESSAGING_PERFORMANCE_DATA"
#define PERF_SHARED_MEMORY_MUTEX PERF_SHARED_MEMORY_FILE L"_MUTEX"

// The instance name is the virtual server name, so length is limited by the maximum URL length
#define PERF_MAXLEN_INSTANCE_NAME MAXLEN_HOSTPORT

// 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       23

#define COUNTER_InboundSUBSCRIBE         4
#define COUNTER_InboundUNSUBSCRIBE       6
#define COUNTER_InboundSUBSCRIPTIONS     8
#define COUNTER_InboundPROPFIND         10
#define COUNTER_InboundPROPPATCH        12
#define COUNTER_InboundACL              14
#define COUNTER_InboundOPTIONS          16
#define COUNTER_InboundNOTIFY           18
#define COUNTER_InboundRequests         20
#define COUNTER_InboundRequestsTotal    22

#define COUNTER_OutboundNOTIFY          24
#define COUNTER_OutboundRequests        26
#define COUNTER_OutboundRequestsTotal   28

#define COUNTER_CurrentUsersOnline      30
#define COUNTER_CurrentSubscriptions    32

#define COUNTER_RedirectedRequests      34
#define COUNTER_RedirectedRequestsTotal 36
#define COUNTER_ForwardedRequests       38
#define COUNTER_ForwardedRequestsTotal  40
#define COUNTER_FailedRequests          42
#define COUNTER_FailedRequestsTotal     44
#define COUNTER_FailedResponses         46
#define COUNTER_FailedResponsesTotal    48

#define NUM_COUNTERS_TOTAL_ONLY     10

#define COUNTER_InboundResponseBytes    50

#define COUNTER_OutboundRequestBytes    52

#define COUNTER_CurrentConnections      54
#define COUNTER_CurrentInboundRequests  56
#define COUNTER_CurrentOutboundRequests 58
#define COUNTER_CurrentThreadPoolSize   60
#define COUNTER_CurrentThreadPoolIdle   62

#define COUNTER_RejectedRequests        64
#define COUNTER_RejectedRequestsTotal   66
#define COUNTER_OpenedConnections       68

// Sample Counters

// MSExchangeIM Counters

#define COUNTERS_INSTANCE                                                                      \
           COUNTER_MACRO(InboundSUBSCRIBE,        ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundUNSUBSCRIBE,      ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundSUBSCRIPTIONS,    ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundPROPFIND,         ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundPROPPATCH,        ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundACL,              ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundOPTIONS,          ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(InboundNOTIFY,           ULONG,     PERF_COUNTER_COUNTER,         0); \
    PARENT_COUNTER_MACRO(InboundRequests,         ULONG,     PERF_COUNTER_COUNTER,        -1); \
           COUNTER_MACRO(InboundRequestsTotal,    ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \
                                                                                               \
           COUNTER_MACRO(OutboundNOTIFY,          ULONG,     PERF_COUNTER_COUNTER,         0); \
    PARENT_COUNTER_MACRO(OutboundRequests,        ULONG,     PERF_COUNTER_COUNTER,        -1); \
           COUNTER_MACRO(OutboundRequestsTotal,   ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \
                                                                                               \
           COUNTER_MACRO(CurrentUsersOnline,      ULONG,     PERF_COUNTER_RAWCOUNT,       -2); \
           COUNTER_MACRO(CurrentSubscriptions,    ULONG,     PERF_COUNTER_RAWCOUNT,       -3); \
                                                                                               \
    PARENT_COUNTER_MACRO(RedirectedRequests,      ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(RedirectedRequestsTotal, ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \
    PARENT_COUNTER_MACRO(ForwardedRequests,       ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(ForwardedRequestsTotal,  ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \
    PARENT_COUNTER_MACRO(FailedRequests,          ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(FailedRequestsTotal,     ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \
    PARENT_COUNTER_MACRO(FailedResponses,         ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(FailedResponsesTotal,    ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \

#define COUNTERS_TOTAL_ONLY                                                                    \
           COUNTER_MACRO(InboundResponseBytes,    ULONGLONG, PERF_COUNTER_BULK_COUNT,     -3); \
                                                                                               \
           COUNTER_MACRO(OutboundRequestBytes,    ULONGLONG, PERF_COUNTER_BULK_COUNT,     -3); \
                                                                                               \
           COUNTER_MACRO(CurrentConnections,      ULONG,     PERF_COUNTER_RAWCOUNT,        0); \
           COUNTER_MACRO(CurrentInboundRequests,  ULONG,     PERF_COUNTER_RAWCOUNT,        0); \
           COUNTER_MACRO(CurrentOutboundRequests, ULONG,     PERF_COUNTER_RAWCOUNT,        0); \
           COUNTER_MACRO(CurrentThreadPoolSize,   ULONG,     PERF_COUNTER_RAWCOUNT,        0); \
           COUNTER_MACRO(CurrentThreadPoolIdle,   ULONG,     PERF_COUNTER_RAWCOUNT,        0); \
                                                                                               \
    PARENT_COUNTER_MACRO(RejectedRequests,        ULONG,     PERF_COUNTER_COUNTER,         0); \
           COUNTER_MACRO(RejectedRequestsTotal,   ULONGLONG, PERF_COUNTER_LARGE_RAWCOUNT, -3); \
           COUNTER_MACRO(OpenedConnections,       ULONG,     PERF_COUNTER_COUNTER,         0); \

////////////////////////////////////////////////////////////////////////////////

#endif // __MSIMPERF_H
