-#ifdef SQUID_SNMP
-#ifndef CACHE_SNMP_H
-#define CACHE_SNMP_H
+#ifndef SQUID_CACHE_SNMP_H
+#define SQUID_CACHE_SNMP_H
-#if SIZEOF_LONG == 8
-#define snint int
-#else
-#define snint long
+#if SQUID_SNMP
+
+typedef int64_t snint;
+
+#ifndef MIN
+#define MIN(a,b) (a<b?a:b)
#endif
#include "snmp.h"
-#include "snmp_impl.h"
-#include "asn1.h"
#include "snmp_api.h"
-#include "snmp_client.h"
-#include "snmp_vars.h"
-#include "snmp_oidlist.h"
-#include "mib.h"
-
-/* mib stuff here */
-
-#ifndef CURRENT_MIB_VERSION
-#define CURRENT_MIB_VERSION "-- v 1.13 1998/03/22 kostas@nlanr.net"
-#endif
+#include "snmp_impl.h"
/* MIB definitions
- * We start from the SQUIDMIB as the root of the subtree
+ * SQUID-MIB
+ * .iso.org.dod.internet.private.enterprises.nlanr.squid
+ * 1 3 6 1 4 1 3495 1
*
- * we are under : iso.org.dod.internet.experimental.nsfnet.squid
- * 1 3 6 1 3 25 17
+ * PROXY-MIB
+ * .iso.org.dod.internet.experimental.nsfnet.proxy
+ * 1 3 6 1 3 25 17
*/
-#define SQUIDMIB 1, 3, 6, 1, 3, 25, 17 /* length is 7 */
-#define LEN_SQUIDMIB 7
-
-#define SYSMIB 1, 3, 6, 1, 2, 1, 1 /* basic system vars */
-#define LEN_SYSMIB 7
+#define SQUIDMIB 1, 3, 6, 1, 4, 1, 3495, 1
+#define LEN_SQUIDMIB 8
+#define INSTANCE 0
+#define TIME_INDEX 1, 5, 60
+#define TIME_INDEX_LEN 3
/* basic groups under .squid */
-#define SQ_SYS SQUIDMIB, 1 /* length is 8 */
+#define SQ_SYS SQUIDMIB, 1 /* cacheSystem group { squid 1 } */
#define LEN_SQ_SYS LEN_SQUIDMIB+1
-#define SQ_CONF SQUIDMIB, 2
+#define SQ_CONF SQUIDMIB, 2 /* cacheConfig group { squid 2 } */
#define LEN_SQ_CONF LEN_SQUIDMIB+1
-#define SQ_PRF SQUIDMIB, 3
+#define SQ_PRF SQUIDMIB, 3 /* cachePerformance group { squid 3 } */
#define LEN_SQ_PRF LEN_SQUIDMIB+1
-#define SQ_NET SQUIDMIB, 4
+#define SQ_NET SQUIDMIB, 4 /* cacheNetwork group { squid 4 } */
#define LEN_SQ_NET LEN_SQUIDMIB+1
-#define SQ_MESH SQUIDMIB, 5
+#define SQ_MESH SQUIDMIB, 5 /* cacheMesh group { squid 5 } */
#define LEN_SQ_MESH LEN_SQUIDMIB+1
-#define SQ_ACC SQUIDMIB, 6
-#define LEN_SQ_ACC LEN_SQUIDMIB+1
-
-enum { /* basic system mib info group */
-SYSMIB_START,
-VERSION_DESCR,
-VERSION_ID,
-UPTIME,
-SYSCONTACT,
-SYSYSNAME,
-SYSLOCATION,
-SYSSERVICES,
-SYSORLASTCHANGE,
-SYSMIB_END
-};
-
-/* cacheSystem group */
+/**
+ * cacheSystem group { squid 1 }
+ */
enum {
- SYS_START,
- SYSVMSIZ,
- SYSSTOR,
- SYSCONNTBL,
- SYSFDTBL,
+ SYS_START = 0,
+ SYSVMSIZ = 1, /**< cacheSysVMsize */
+ SYSSTOR = 2, /**< cacheSysStorage */
+ SYS_UPTIME = 3, /**< cacheUptime */
SYS_END
};
-/* cacheConfig group */
+#define LEN_SYS LEN_SQ_SYS + 1
+#define LEN_SYS_INST LEN_SQ_SYS + 2
+/**
+ * cacheConfig group { squid 2 }
+ */
enum {
- CONF_START,
- CONF_ADMIN,
- CONF_VERSION,
- CONF_VERSION_ID,
- CONF_UPTIME,
- CONF_LOG_FAC,
- CONF_STORAGE,
+ CONF_START = 0,
+ CONF_ADMIN = 1, /**< cacheAdmin */
+ CONF_VERSION = 2, /**< cacheSoftware */
+ CONF_VERSION_ID = 3, /**< cacheVersionId */
+ CONF_LOG_FAC = 4, /**< cacheLoggingFacility */
+ CONF_STORAGE = 5, /**< cacheStorageConfig group */
+ CONF_UNIQNAME = 6, /**< cacheUniqName */
CONF_END
};
+#define LEN_CONF LEN_SQ_CONF + 1
+#define LEN_CONF_INST LEN_SQ_CONF + 2
+
+/**
+ * cacheStorageConfig group { cacheConfig 5 }
+ */
enum {
- CONF_ST_START,
- CONF_ST_MMAXSZ,
- CONF_ST_MHIWM,
- CONF_ST_MLOWM,
- CONF_ST_SWMAXSZ,
- CONF_ST_SWHIWM,
- CONF_ST_SWLOWM,
+ CONF_ST_START = 0,
+ CONF_ST_MMAXSZ = 1, /* cacheMemMaxSize */
+ CONF_ST_SWMAXSZ = 2, /* cacheSwapMaxSize */
+ CONF_ST_SWHIWM = 3, /* cacheSwapHighWM */
+ CONF_ST_SWLOWM = 4, /* cacheSwapLowWM */
CONF_ST_END
};
-/* cacheMesh group */
-
-enum {
- MESH_START,
- MESH_PTBL,
- MESH_CTBL,
- MESH_END
-};
+#define LEN_CONF_ST LEN_CONF + 1
+#define LEN_CONF_ST_INST LEN_CONF + 2
-enum { /* cachePeerTable */
- MESH_PTBL_START,
- MESH_PTBL_NAME,
- MESH_PTBL_IP,
- MESH_PTBL_HTTP,
- MESH_PTBL_ICP,
- MESH_PTBL_TYPE,
- MESH_PTBL_STATE,
- MESH_PTBL_SENT,
- MESH_PTBL_PACKED,
- MESH_PTBL_FETCHES,
- MESH_PTBL_RTT,
- MESH_PTBL_IGN,
- MESH_PTBL_KEEPAL_S,
- MESH_PTBL_KEEPAL_R,
- MESH_PTBL_END
-};
+/*
+ * Cache Performance Group {squid 3}
+ */
-enum { /* cacheClientTable */
- MESH_CTBL_START,
- MESH_CTBL_ADDR,
- MESH_CTBL_HTREQ,
- MESH_CTBL_HTBYTES,
- MESH_CTBL_HTHITS,
- MESH_CTBL_HTHITBYTES,
- MESH_CTBL_ICPREQ,
- MESH_CTBL_ICPBYTES,
- MESH_CTBL_ICPHITS,
- MESH_CTBL_ICPHITBYTES,
- MESH_CTBL_END
+enum {
+ PERF_START = 0,
+ PERF_SYS = 1, /* cacheSysPerf */
+ PERF_PROTO = 2, /* cacheProtoStats */
+ PERF_END
};
-/* cacheNetwork group */
-
+/* cacheSysPerf */
enum {
- NETDB_START,
- NETDB_NET,
- NETDB_PING_S,
- NETDB_PING_R,
- NETDB_HOPS,
- NETDB_RTT,
- NETDB_PINGTIME,
- NETDB_LASTUSE,
- NETDB_END
+ PERF_SYS_START = 0,
+ PERF_SYS_PF = 1, /* cacheSysPageFaults */
+ PERF_SYS_NUMR = 2, /* cacheSysNumReads */
+ PERF_SYS_MEMUSAGE = 3, /* cacheMemUsage */
+ PERF_SYS_CPUTIME = 4, /* cacheCpuTime */
+ PERF_SYS_CPUUSAGE = 5, /* cacheCpuUsage */
+ PERF_SYS_MAXRESSZ = 6, /* cacheMaxResSize */
+ PERF_SYS_NUMOBJCNT = 7, /* cacheNumObjCount */
+ PERF_SYS_CURLRUEXP = 8, /* cacheCurrentLRUExpiration */
+ PERF_SYS_CURUNLREQ = 9, /* cacheCurrentUnlinkRequests */
+ PERF_SYS_CURUNUSED_FD = 10, /* cacheCurrentUnusedFDescrCnt */
+ PERF_SYS_CURRESERVED_FD = 11, /* cacheCurrentResFileDescrCnt */
+ PERF_SYS_CURUSED_FD = 12, /* cacheCurrentFileDescrCnt */
+ PERF_SYS_CURMAX_FD = 13, /* cacheCurrentFileDescrMax */
+ PERF_SYS_END
};
+/* cacheProtoStats */
enum {
- NET_IPC_START,
- NET_IPC_ID,
- NET_IPC_NAME,
- NET_IPC_IP,
- NET_IPC_STATE,
- NET_IPC_END
+ PERF_PROTOSTAT_START,
+ PERF_PROTOSTAT_AGGR = 1, /* cacheProtoAggregateStats */
+ PERF_PROTOSTAT_MEDIAN = 2, /* cacheMedianSvcTable */
+ PERF_PROTOSTAT_END
};
+/* cacheProtoAggregateStats */
enum {
- NET_DNS_START,
- NET_DNS_IPCACHE,
- NET_DNS_FQDNCACHE,
- NET_DNS_END
+ PERF_PROTOSTAT_AGGR_START = 0,
+ PERF_PROTOSTAT_AGGR_HTTP_REQ = 1, /* cacheProtoClientHttpRequests */
+ PERF_PROTOSTAT_AGGR_HTTP_HITS = 2, /* cacheHttpHits */
+ PERF_PROTOSTAT_AGGR_HTTP_ERRORS = 3, /* cacheHttpErrors */
+ PERF_PROTOSTAT_AGGR_HTTP_KBYTES_IN = 4, /* cacheHttpInKb */
+ PERF_PROTOSTAT_AGGR_HTTP_KBYTES_OUT = 5, /* cacheHttpOutKb */
+ PERF_PROTOSTAT_AGGR_ICP_S = 6, /* cacheIcpPktsSent */
+ PERF_PROTOSTAT_AGGR_ICP_R = 7, /* cacheIcpPktsRecv */
+ PERF_PROTOSTAT_AGGR_ICP_SKB = 8, /* cacheIcpKbSent */
+ PERF_PROTOSTAT_AGGR_ICP_RKB = 9, /* cacheIcpKbRecv */
+ PERF_PROTOSTAT_AGGR_REQ = 10, /* cacheServerRequests */
+ PERF_PROTOSTAT_AGGR_ERRORS = 11, /* cacheServerErrors */
+ PERF_PROTOSTAT_AGGR_KBYTES_IN = 12, /* cacheServerInKb */
+ PERF_PROTOSTAT_AGGR_KBYTES_OUT = 13, /* cacheServerOutKb */
+ PERF_PROTOSTAT_AGGR_CURSWAP = 14, /* cacheCurrentSwapSize */
+ PERF_PROTOSTAT_AGGR_CLIENTS = 15, /* cacheClients */
+ PERF_PROTOSTAT_AGGR_END
};
-
+/* cacheMedianSvcEntry */
enum {
- NET_FQDN_START,
- NET_FQDN_ID,
- NET_FQDN_NAME,
- NET_FQDN_IP,
- NET_FQDN_LASTREF,
- NET_FQDN_EXPIRES,
- NET_FQDN_STATE,
- NET_FQDN_END
+ PERF_MEDIAN_START = 0,
+ PERF_MEDIAN_TIME = 1, /* cacheMedianTime */
+ PERF_MEDIAN_HTTP_ALL = 2, /* cacheHttpAllSvcTime */
+ PERF_MEDIAN_HTTP_MISS = 3, /* cacheHttpMissSvcTime */
+ PERF_MEDIAN_HTTP_NM = 4, /* cacheHttpNmSvcTime */
+ PERF_MEDIAN_HTTP_HIT = 5, /* cacheHttpHitSvcTime */
+ PERF_MEDIAN_ICP_QUERY = 6, /* cacheIcpQuerySvcTime */
+ PERF_MEDIAN_ICP_REPLY = 7, /* cacheIcpReplySvcTime */
+ PERF_MEDIAN_DNS = 8, /* cacheDnsSvcTime */
+ PERF_MEDIAN_RHR = 9, /* cacheRequestHitRatio */
+ PERF_MEDIAN_BHR = 10, /* cacheRequestByteRatio */
+ PERF_MEDIAN_HTTP_NH = 11, /* cacheHttpNhSvcTime */
+ PERF_MEDIAN_END
};
+/*
+ * cacheNetwork group { squid 4 }
+ */
enum {
- NET_START,
- NET_NETDBTBL,
- NET_DNS,
- NET_NETSTAT,
+ NET_START = 0,
+ NET_IP_CACHE = 1, /* cacheIpCache */
+ NET_FQDN_CACHE = 2, /* cacheFqdnCache */
+ NET_DNS_CACHE = 3, /* cacheDns */
NET_END
};
+/* cacheIpCache */
enum {
- NETSTAT_START,
- NETSTAT_TCPCONNS,
- NETSTAT_UDPCONNS,
- NETSTAT_INTHRPUT,
- NETSTAT_OUTHRPUT
-};
-
-enum {
- PERF_START,
- PERF_SYS,
- PERF_PROTO,
- PERF_PEER,
- PERF_END
+ IP_START = 0,
+ IP_ENT = 1, /* cacheIpEntrie */
+ IP_REQ = 2, /* cacheIpRequests */
+ IP_HITS = 3, /* acheIpHits */
+ IP_PENDHIT = 4, /* cacheIpPendingHits */
+ IP_NEGHIT = 5, /* cacheIpNegativeHit */
+ IP_MISS = 6, /* cacheIpMisses */
+ IP_GHBN = 7, /* cacheBlockingGetHostByName */
+ IP_LOC = 8, /* cacheAttemptReleaseLckEntries */
+ IP_END
};
+/* cacheFqdnCache */
enum {
- PERF_SYS_START,
- PERF_SYS_PF,
- PERF_SYS_NUMR,
- PERF_SYS_DEFR,
- PERF_SYS_MEMUSAGE,
- PERF_SYS_CPUUSAGE,
- PERF_SYS_MAXRESSZ,
- PERF_SYS_NUMOBJCNT,
- PERF_SYS_CURLRUEXP,
- PERF_SYS_CURUNLREQ,
- PERF_SYS_CURUNUSED_FD,
- PERF_SYS_CURRESERVED_FD,
- PERF_SYS_END
+ FQDN_START = 0,
+ FQDN_ENT = 1, /* cacheFqdnEntries */
+ FQDN_REQ = 2, /* cacheFqdnRequests */
+ FQDN_HITS = 3, /* cacheFqdnHits */
+ FQDN_PENDHIT = 4, /* cacheFqdnPendingHits */
+ FQDN_NEGHIT = 5, /* cacheFqdnNegativeHits */
+ FQDN_MISS = 6, /* cacheFqdnMisses */
+ FQDN_GHBN = 7, /* cacheBlockingGetHostByAddr */
+ FQDN_END
};
+/* cacheDNS */
enum {
- PERF_PROTOSTAT_START,
- PERF_PROTOSTAT_AGGR,
- PERF_PROTOSTAT_MEDIAN,
- PERF_PROTOSTAT_END
+ DNS_START = 0,
+ DNS_REQ = 1, /* cacheDnsRequests */
+ DNS_REP = 2, /* cacheDnsReplies */
+ DNS_SERVERS = 3, /* cacheDnsNumberServers */
+ DNS_END
};
-enum {
- PERF_PROTOSTAT_AGGR_START,
- PERF_PROTOSTAT_AGGR_HTTP_REQ,
- PERF_PROTOSTAT_AGGR_HTTP_HITS,
- PERF_PROTOSTAT_AGGR_HTTP_ERRORS,
- PERF_PROTOSTAT_AGGR_HTTP_KBYTES_IN,
- PERF_PROTOSTAT_AGGR_HTTP_KBYTES_OUT,
- PERF_PROTOSTAT_AGGR_ICP_S,
- PERF_PROTOSTAT_AGGR_ICP_R,
- PERF_PROTOSTAT_AGGR_ICP_SKB,
- PERF_PROTOSTAT_AGGR_ICP_RKB,
- PERF_PROTOSTAT_AGGR_REQ,
- PERF_PROTOSTAT_AGGR_ERRORS,
- PERF_PROTOSTAT_AGGR_KBYTES_IN,
- PERF_PROTOSTAT_AGGR_KBYTES_OUT,
- PERF_PROTOSTAT_AGGR_CURSWAP,
- PERF_PROTOSTAT_AGGR_END
-};
+/*
+ * cacheMesh group { squid 5 }
+ */
enum {
- PERF_MEDIAN_START,
- PERF_MEDIAN_TIME,
- PERF_MEDIAN_HTTP_ALL,
- PERF_MEDIAN_HTTP_MISS,
- PERF_MEDIAN_HTTP_NM,
- PERF_MEDIAN_HTTP_HIT,
- PERF_MEDIAN_ICP_QUERY,
- PERF_MEDIAN_ICP_REPLY,
- PERF_MEDIAN_DNS,
- PERF_MEDIAN_END
+ MESH_START = 0,
+ MESH_PTBL = 1, /* cachePeerTable */
+ MESH_CTBL = 2, /* cacheClientTable */
+ MESH_END
};
+/* CachePeerTableEntry (version 3) */
enum {
- SYS_FD_START,
- SYS_FD_NUMBER,
- SYS_FD_NREAD,
- SYS_FD_NWRITE,
- SYS_FD_NAME,
- SYS_FD_END
+ MESH_PTBL_START = 0,
+ MESH_PTBL_INDEX = 1, /* cachePeerIndex */
+ MESH_PTBL_NAME = 2, /* cachePeerName */
+ MESH_PTBL_ADDR_TYPE = 3, /* cachePeerAddressType */
+ MESH_PTBL_ADDR = 4, /* cachePeerAddress */
+ MESH_PTBL_HTTP = 5, /* cachePortHttp */
+ MESH_PTBL_ICP = 6, /* cachePeerPortIcp */
+ MESH_PTBL_TYPE = 7, /* cachePeerType */
+ MESH_PTBL_STATE = 8, /* cachePeerStat */
+ MESH_PTBL_SENT = 9, /* cachePeerPingsSent */
+ MESH_PTBL_PACKED = 10, /* cachePeerPingsAcked */
+ MESH_PTBL_FETCHES = 11, /* cachePeerFetches */
+ MESH_PTBL_RTT = 12, /* cachePeerRtt */
+ MESH_PTBL_IGN = 13, /* cachePeerIgnored */
+ MESH_PTBL_KEEPAL_S = 14, /* cachePeerKeepAlSent */
+ MESH_PTBL_KEEPAL_R = 15, /* cachePeerKeepAlRecv */
+ MESH_PTBL_END
};
+/* cacheClientEntry */
enum {
- SYS_CONN_START,
- SYS_CONN_FDNUM,
- SYS_CONN_READ,
- SYS_CONN_WRITE,
- SYS_CONN_ADDR,
- SYS_CONN_NAME,
- SYS_CONN_PORT,
- SYS_CONN_END
-};
-
-/* First, we have a huge array of MIBs this agent knows about */
-
-struct MIBListEntry {
- oid Name[9]; /* Change as appropriate */
- snint NameLen;
- oid_GetFn *GetFn;
- oid_GetNextFn *GetNextFn;
+ MESH_CTBL_START = 0,
+ MESH_CTBL_ADDR_TYPE = 1, /* cacheClientAddressType */
+ MESH_CTBL_ADDR = 2, /* cacheClientAddress */
+ MESH_CTBL_HTREQ = 3, /* cacheClientHttpRequests */
+ MESH_CTBL_HTBYTES = 4, /* cacheClientHttpKb */
+ MESH_CTBL_HTHITS = 5, /* cacheClientHttpHits */
+ MESH_CTBL_HTHITBYTES = 6, /* cacheClientHTTPHitKb */
+ MESH_CTBL_ICPREQ = 7, /* cacheClientIcpRequests */
+ MESH_CTBL_ICPBYTES = 8, /* cacheClientIcpKb */
+ MESH_CTBL_ICPHITS = 9, /* cacheClientIcpHits */
+ MESH_CTBL_ICPHITBYTES = 10, /* cacheClientIcpHitKb */
+ MESH_CTBL_END
};
-variable_list *snmp_basicFn(variable_list *, snint *);
-variable_list *snmp_meshPtblFn(variable_list *, snint *);
-variable_list *snmp_meshCtblFn(variable_list *, snint *);
-variable_list *snmp_confFn(variable_list *, snint *);
-variable_list *snmp_sysFn(variable_list *, snint *);
-variable_list *snmp_prfSysFn(variable_list *, snint *);
-variable_list *snmp_prfProtoFn(variable_list *, snint *);
-variable_list *snmp_prfPeerFn(variable_list *, snint *);
-variable_list *snmp_netdbFn(variable_list *, snint *);
-variable_list *snmp_dnsFn(variable_list *, snint *);
-variable_list *snmp_ipcacheFn(variable_list *, snint *);
-variable_list *snmp_fqdncacheFn(variable_list *, snint *);
+#endif /* SQUID_SNMP */
-#endif
-#endif
+#endif /* SQUID_CACHE_SNMP_H */