From: wessels <> Date: Tue, 2 Dec 1997 05:45:44 +0000 (+0000) Subject: SNMP changes to get snmpwalk working X-Git-Tag: SQUID_3_0_PRE1~4437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a97cfa48d9c10f3b983d04060c984d1c07f081e0;p=thirdparty%2Fsquid.git SNMP changes to get snmpwalk working --- diff --git a/include/snmp.h b/include/snmp.h index aead0a9955..e50aef0a76 100644 --- a/include/snmp.h +++ b/include/snmp.h @@ -120,7 +120,7 @@ typedef struct _conf_if_list { } conf_if_list; extern conf_if_list *if_list; - +extern void init_mib(const char *); extern int read_objid(char *input, oid * output, int *out_len); extern void snmp_add_null_var(struct snmp_pdu *, oid *, int); extern void sprint_objid(char *buf, oid * id, int idlen); diff --git a/include/snmp_util.h b/include/snmp_util.h index cc35744ced..399fa87d23 100644 --- a/include/snmp_util.h +++ b/include/snmp_util.h @@ -61,7 +61,7 @@ Util_file_read (char *file, int offset, char *data, int dataSz); * ** Write data into file */ int -Util_file_write (char *file, int offset, char *data, int dataSz)) +Util_file_write (char *file, int offset, char *data, int dataSz); /* ---------------------------------------------------------------------- */ @@ -69,13 +69,4 @@ Util_file_write (char *file, int offset, char *data, int dataSz)) - - - - - - - - - #endif diff --git a/snmplib/Makefile.in b/snmplib/Makefile.in index d333fe9481..166225a54a 100644 --- a/snmplib/Makefile.in +++ b/snmplib/Makefile.in @@ -43,6 +43,8 @@ $(ALIB): ${OBJS} mib.o: mib.c $(CC) $(CFLAGS) $(MIBDEFS) -c mib.c +distclean: celan + -rm -f Makefile clean: rm -f core *.o ${TARG} shared/*.o *.a *.so* diff --git a/snmplib/mib.c b/snmplib/mib.c index d1a1aa2b42..dccedd517b 100644 --- a/snmplib/mib.c +++ b/snmplib/mib.c @@ -593,6 +593,8 @@ void init_mib(const char *file) { char *prefix; + if (Mib!=NULL) + return; Mib = 0; if (file) diff --git a/src/Makefile.in b/src/Makefile.in index 79f9c87b69..1d706a4f4f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.102 1997/11/23 06:47:18 wessels Exp $ +# $Id: Makefile.in,v 1.103 1997/12/01 22:45:47 wessels Exp $ # # Uncomment and customize the following to suit your needs: # @@ -18,9 +18,9 @@ STORE_KEY_SHA = # -DSTORE_KEY_SHA=1 USE_ASYNC_IO = # -DUSE_ASYNC_IO=1 # define all three for SNMP support -#SQUID_SNMP = -DSQUID_SNMP=1 -#SQUID_MIB = mib.txt -#SQUID_SNMP_LIBS = -L../snmplib -lsnmp +SQUID_SNMP = -DSQUID_SNMP=1 +SQUID_MIB = mib.txt +SQUID_SNMP_LIBS = -L../snmplib -lsnmp DEFINES = $(HOST_OPT) \ $(ICMP_OPT) $(DELAY_HACK) $(USERAGENT_OPT) \ @@ -40,7 +40,6 @@ srcdir = @srcdir@ VPATH = @srcdir@ DEFAULT_CONFIG_FILE = $(sysconfdir)/squid.conf -DEFAULT_SNMP_CONF = $(sysconfdir)/snmp.conf DEFAULT_MIME_TABLE = $(sysconfdir)/mime.conf DEFAULT_DNSSERVER = $(libexecdir)/dnsserver DEFAULT_CACHE_LOG = $(localstatedir)/logs/cache.log @@ -52,7 +51,7 @@ DEFAULT_PINGER = $(libexecdir)/pinger DEFAULT_UNLINKD = $(libexecdir)/unlinkd DEFAULT_ICON_DIR = $(sysconfdir)/icons DEFAULT_ERROR_DIR = $(sysconfdir)/errors -DEFAULT_MIB_PATH = $(sysconfdir)/squidmib.txt +DEFAULT_MIB_PATH = $(sysconfdir)/mib.txt CC = @CC@ MAKEDEPEND = @MAKEDEPEND@ @@ -206,7 +205,6 @@ cf.data: cf.data.pre Makefile s%@DEFAULT_STORE_LOG@%$(DEFAULT_STORE_LOG)%g;\ s%@DEFAULT_PID_FILE@%$(DEFAULT_PID_FILE)%g;\ s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g;\ - s%@DEFAULT_SNMP_CONF@%$(DEFAULT_SNMP_CONF)%g;\ s%@DEFAULT_ICON_DIR@%$(DEFAULT_ICON_DIR)%g;\ s%@DEFAULT_MIB_PATH@%$(DEFAULT_MIB_PATH)%g;\ s%@DEFAULT_ERROR_DIR@%$(DEFAULT_ERROR_DIR)%g" < cf.data.pre >$@ @@ -288,13 +286,6 @@ install: all install-mkdirs echo "$(INSTALL_FILE) squid.conf $(sysconfdir)"; \ $(INSTALL_FILE) squid.conf $(sysconfdir); \ fi - $(INSTALL_FILE) snmp.conf $(sysconfdir)/snmp.conf.default - @if test -f $(sysconfdir)/snmp.conf ; then \ - echo "$@ will not overwrite existing $(sysconfdir)/snmp.conf" ; \ - else \ - echo "$(INSTALL_FILE) snmp.conf $(sysconfdir)"; \ - $(INSTALL_FILE) snmp.conf $(sysconfdir); \ - fi $(INSTALL_FILE) mime.conf $(sysconfdir)/mime.conf.default @if test -f $(sysconfdir)/mime.conf ; then \ diff --git a/src/access_log.cc b/src/access_log.cc index 0f13e30c84..30184e799b 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1,6 +1,6 @@ /* - * $Id: access_log.cc,v 1.12 1997/11/30 02:26:41 wessels Exp $ + * $Id: access_log.cc,v 1.13 1997/12/01 22:45:48 wessels Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -53,6 +53,7 @@ const char *log_tags[] = "UDP_DENIED", "UDP_INVALID", "UDP_MISS_NOFETCH", + "LOG_METER_EXPIRES", "LOG_TYPE_MAX" }; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index dbad86fbcd..1eef7606e6 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,5 +1,5 @@ /* - * $Id: cache_cf.cc,v 1.234 1997/11/23 06:48:39 wessels Exp $ + * $Id: cache_cf.cc,v 1.235 1997/12/01 22:45:49 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -29,6 +29,8 @@ */ #include "squid.h" +#include "snmp.h" +#include "snmp_config.h" static const char *const T_SECOND_STR = "second"; static const char *const T_MINUTE_STR = "minute"; @@ -52,6 +54,7 @@ static void self_destruct(void); static void wordlistAdd(wordlist **, const char *); static void configDoConfigure(void); +static void parse_snmp_conf(snmpconf **); static void parse_refreshpattern(refresh_t **); static int parseTimeUnits(const char *unit); static void parseTimeLine(time_t * tptr, const char *units); @@ -64,6 +67,13 @@ static void parseBytesLine(size_t * bptr, const char *units); static size_t parseBytesUnits(const char *unit); static void free_all(void); static void requirePathnameExists(const char *name, const char *path); +/* +extern int create_view ( char **); +extern int create_user ( char **); +extern int create_community (char **); +extern void tokenize ( char *, char **, int ); +*/ +extern struct tree *Mib; static void self_destruct(void) @@ -351,6 +361,35 @@ dump_acl(StoreEntry * entry, const char *name, acl * acl) storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); } +static void +parse_snmp_conf(snmpconf **s) +{ + static char buff[256]; + static char *tokens[10], *p; + if (Mib==NULL) + { + if (Config.Snmp.mibPath) + init_mib(Config.Snmp.mibPath) ; + else + fatal("snmp_mib_path should be defined before any snmp_agent_conf\n"); + } + p=strtok(NULL, null_string); + strcpy(buff,p); + tokenize(buff, tokens, 10 ); + + if ( !strcmp("view", tokens[0]) ) { + if (create_view(tokens) < 0 ) + debug(49,5)("snmp: parse_snmpconf(): error\n"); + } else if ( !strcmp("user", tokens[0])) { + if (create_user(tokens) < 0 ) + debug(49,5)("snmp: parse_snmpconf(): error\n"); + } else if ( !strcmp("community", tokens[0] )) { + if ( create_community(tokens) < 0 ) + debug(49,5)("snmp: parse_snmpconf(): error\n"); + } else + debug(49,5)("snmp: unknown directive %s\n",tokens[0]); +} + static void parse_acl(acl ** acl) { @@ -874,6 +913,12 @@ parse_onoff(int *var) #define dump_eol dump_string #define free_eol free_string +static void +dump_snmp_conf(StoreEntry *entry, const char *name, snmpconf *head) +{ + storeAppendPrintf(entry, "%s -- UNIMPLEMENTED\n", name); +} + static void dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) { @@ -935,6 +980,17 @@ parse_refreshpattern(refresh_t ** head) safe_free(pattern); } +static void +free_snmp_conf(snmpconf **head) +{ + snmpconf *t; + while (( t= *head ) != NULL ) { + *head=t->next; + safe_free(t->line); + safe_free(t); + } +} + static void free_refreshpattern(refresh_t ** head) { diff --git a/src/cf.data.pre b/src/cf.data.pre index 827175242f..e8f3eb6489 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1925,6 +1925,59 @@ DOC_START maximum_single_addr_tries 3 DOC_END +NAME: snmp_port +TYPE: ushort +LOC: Config.Port.snmp +DEFAULT: 3401 +DOC_START + Port for snmp. <=0 to disable. +DOC_END + +NAME: snmp_config_file +TYPE: string +LOC: Config.Snmp.configFile +DEFAULT: @DEFAULT_SNMP_CONF@ +DOC_START + External snmp configuration file, CMU-snmpd style. +DOC_END + +NAME: snmp_do_queueing +TYPE: onoff +LOC: Config.Snmp.do_queueing +DEFAULT: on +DOC_START + If disabled, snmp packets will not be queued but delivered + immediately. This could be performant when you want to monitor + a cache in trouble, but this could also bring squid to block. +DOC_END + +NAME: forward_snmpd_port +TYPE: ushort +LOC: Config.Snmp.localPort +DEFAULT: 0 +DOC_START + This configures whether we should be forwarding SNMP requests + to another snmpd. The reason for putting this piece of functionality + into squid was to enable access to the system's installed + snmpd with minimal changes. + This option is turned off by default, check with your /etc/services + for your system's snmp port (usually 161). + We do not use getservbyname() to allow you to set squid into port 161 + and your system's snmpd to another port by changing /etc/services. + + WARNING: Because of squid acting as a proxy snmpd for system + you have to do security checks on THIS snmpd for all objects. + Check your snmp_config_file +DOC_END + +NAME: snmp_mib_path +TYPE: string +LOC: Config.Snmp.mibPath +DEFAULT: @DEFAULT_MIB_PATH@ +DOC_START + The location of squid's mib. +DOC_END + NAME: snmp_port TYPE: ushort LOC: Config.Port.snmp @@ -1968,13 +2021,43 @@ DOC_START snmp_config_file DOC_END -NAME: snmp_mib_path +NAME: trap_sink TYPE: string -LOC: Config.Snmp.mibPath -DEFAULT: @DEFAULT_MIB_PATH@ +LOC: Config.Snmp.trap_sink +DEFAULT: 127.0.0.1 DOC_START - The location of squid's mib. + Hostname or ip address of trap sink for snmp DOC_END +NAME: snmp_trap_community +TYPE: string +LOC: Config.Snmp.trap_community +DEFAULT: public +DOC_START + Community name for traps +DOC_END + +NAME: snmp_enable_authen_traps +TYPE: onoff +LOC: Config.Snmp.conf_authtraps +DEFAULT: off +DOC_START + Enable SNMP authenticated traps +DOC_END + +NAME: snmp_agent_conf +TYPE: snmp_conf +LOC: Config.Snmp.snmpconf +DEFAULT: none +DOC_START + Define snmp views, users and communities + Example: + snmp_agent_conf view all .1.3.6 included + snmp_agent_conf view squid .1.3.6 included + snmp_agent_conf user squid - all all public + snmp_agent_conf user all all all all squid + snmp_agent_conf community public squid squid + snmp_agent_conf community readwrite all all +DOC_END EOF diff --git a/src/cf_gen.cc b/src/cf_gen.cc index faeef18e26..5549121ae7 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -1,5 +1,5 @@ /* - * $Id: cf_gen.cc,v 1.15 1997/11/05 05:29:19 wessels Exp $ + * $Id: cf_gen.cc,v 1.16 1997/12/01 22:45:50 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Max Okumoto @@ -48,6 +48,8 @@ #include #include #include +#include "snmp.h" +#include "snmp_config.h" #define MAX_LINE 1024 /* longest configuration line */ #define _PATH_PARSER "cf_parser.c" diff --git a/src/enums.h b/src/enums.h index b4df7669a0..a13d1d7828 100644 --- a/src/enums.h +++ b/src/enums.h @@ -20,6 +20,7 @@ typedef enum { LOG_UDP_DENIED, LOG_UDP_INVALID, LOG_UDP_MISS_NOFETCH, + LOG_METER_EXPIRES, LOG_TYPE_MAX } log_type; @@ -362,3 +363,9 @@ typedef enum { ACCESS_ALLOWED, ACCESS_REQ_PROXY_AUTH } allow_t; + +enum { +SNMP_C_VIEW, +SNMP_C_USER, +SNMP_C_COMMUNITY +}; diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 75cf0c20f8..a8499e28c6 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.69 1997/11/28 08:19:56 wessels Exp $ + * $Id: fqdncache.cc,v 1.70 1997/12/01 22:45:51 wessels Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -140,8 +140,8 @@ static void fqdncache_dnsHandleRead(int, void *); static fqdncache_entry *fqdncache_parsebuffer(const char *buf, dnsserver_t *); static int fqdncache_purgelru(void); static void fqdncache_release(fqdncache_entry *); -static fqdncache_entry *fqdncache_GetFirst(void); -static fqdncache_entry *fqdncache_GetNext(void); + fqdncache_entry *fqdncache_GetFirst(void); + fqdncache_entry *fqdncache_GetNext(void); static fqdncache_entry *fqdncache_create(const char *name); static void fqdncache_add_to_hash(fqdncache_entry *); static void fqdncache_call_pending(fqdncache_entry *); @@ -240,13 +240,13 @@ fqdncache_get(const char *name) return f; } -static fqdncache_entry * + fqdncache_entry * fqdncache_GetFirst(void) { return (fqdncache_entry *) hash_first(fqdn_table); } -static fqdncache_entry * + fqdncache_entry * fqdncache_GetNext(void) { return (fqdncache_entry *) hash_next(fqdn_table); diff --git a/src/ipcache.cc b/src/ipcache.cc index 44c309d66d..e850bc3f7c 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.146 1997/11/28 08:20:29 wessels Exp $ + * $Id: ipcache.cc,v 1.147 1997/12/01 22:45:52 wessels Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -130,7 +130,7 @@ static struct { int release_locked; } IpcacheStats; -static dlink_list lru_list; + dlink_list lru_list; static int ipcache_testname(void); #if OLD_CODE diff --git a/src/mib.txt b/src/mib.txt index eb7276be54..6f5da2fa44 100644 --- a/src/mib.txt +++ b/src/mib.txt @@ -1,8 +1,20 @@ -- File: SQUID.MIB -- kostas@nlanr.net -- Created : 11/ 2/97 kostas@nlanr.net --- Last Update: 11/18/97 kostas@nlanr.net +-- Last Update: 12/1/97 kostas@nlanr.net +SQUID-MIB DEFINITIONS ::= BEGIN + IMPORTS + TimeTicks, + Counter FROM RFC1155-SMI + DisplayString FROM RFC1158-MIB + mib-2 FROM RFC1213-MIB + OBJECT-TYPE FROM RFC-1212 + TRAP-TYPE FROM RFC-1215; + +-- +-- definitions included for standalone agent/managers +-- mgmt OBJECT IDENTIFIER ::= { iso org(3) dod(6) internet(1) 2 } mib OBJECT IDENTIFIER ::= { mgmt 1 } @@ -11,24 +23,18 @@ experimental OBJECT IDENTIFIER ::= { internet 3 } private OBJECT IDENTIFIER ::= { internet 4 } enterprises OBJECT IDENTIFIER ::= { private 1 } nsfnet OBJECT IDENTIFIER ::= { experimental 25 } +squid OBJECT IDENTIFIER ::= { nsfnet 17 } - --- SQUID-MIB DEFINITIONS ::= BEGIN --- IMPORTS --- TimeTicks, --- Counter FROM RFC1155-SMI --- DisplayString FROM RFC1158-MIB --- mib-2 FROM RFC1213-MIB --- OBJECT-TYPE FROM RFC-1212 --- TRAP-TYPE FROM RFC-1215; - squid OBJECT IDENTIFIER ::= { nsfnet 17 } - +-- +-- Major MIB groups +-- cacheSystem OBJECT IDENTIFIER ::= { squid 1 } cacheConfig OBJECT IDENTIFIER ::= { squid 2 } cachePerf OBJECT IDENTIFIER ::= { squid 3 } - cacheAccounting OBJECT IDENTIFIER ::= { squid 4 } + cacheAccounting OBJECT IDENTIFIER ::= { squid 6 } cacheSecurity OBJECT IDENTIFIER ::= { squid 5 } - cacheNetwork OBJECT IDENTIFIER ::= { squid 6 } + cacheNetwork OBJECT IDENTIFIER ::= { squid 4 } + -- -- cacheSystem group @@ -59,7 +65,7 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } -- -- config group -- --- Contains configuration information including peers, acls etc. +-- Contains configuration information including peers etc. cacheAdmin OBJECT-TYPE @@ -129,7 +135,7 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } ::= { cacheStorageConfig 6 } cacheWaisRelayHost OBJECT-TYPE - SYNTAX OCTET STRING + SYNTAX DisplayString ACCESS read-only STATUS mandatory DESCRIPTION @@ -146,7 +152,6 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } cacheTimeoutValues OBJECT IDENTIFIER ::= { cacheConfig 6 } - cacheReadTimeout OBJECT-TYPE SYNTAX Integer ACCESS read-only @@ -174,7 +179,7 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } cacheLoggingLevel OBJECT-TYPE - SYNTAX Integer + SYNTAX DisplayString ACCESS read-write STATUS mandatory DESCRIPTION @@ -213,51 +218,59 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } cachePeerState INTEGER } + cachePeerId OBJECT-TYPE + SYNTAX Integer + ACCESS read-only + STATUS current + ::= { cachePeerEntry 1 } cachePeerName OBJECT-TYPE SYNTAX DisplayString ACCESS read-only STATUS current - ::= { cachePeerEntry 1 } + ::= { cachePeerEntry 2 } cachePeerIP OBJECT-TYPE SYNTAX IpAddress ACCESS read-only STATUS current - ::= { cachePeerEntry 2 } - - cachePeerPortHttp OBJECT-TYPE - SYNTAX INTEGER - ACCESS read-only - STATUS current ::= { cachePeerEntry 3 } - cachePeerPortIcp OBJECT-TYPE + cachePeerPortHttp OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS current ::= { cachePeerEntry 4 } - cachePeerType OBJECT-TYPE + cachePeerPortIcp OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS current ::= { cachePeerEntry 5 } +-- cachePeerType OBJECT-TYPE +-- SYNTAX INTEGER +-- ACCESS read-only +-- STATUS current +-- ::= { cachePeerEntry 6 } + cachePeerState OBJECT-TYPE SYNTAX INTEGER ACCESS read-only STATUS current - ::= { cachePeerEntry 6 } + ::= { cachePeerEntry 7 } cachePeerType OBJECT-TYPE SYNTAX INTEGER { - parent(1), sibling(2), multicast(3), none(4) + parent(1), + sibling(2), + multicast(3), + none(4) } MAX-ACCESS not-accessible STATUS current DESCRIPTION " Peer Type " - ::= { cachePeerEntry 4 } + ::= { cachePeerEntry 6 } -- -- cacheNetwork group @@ -340,7 +353,7 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } -- IP cache info - IPcacheTable OBJECT-TYPE + ipCacheTable OBJECT-TYPE SYNTAX SEQUENCE OF iPcacheEntry ACCESS read-only STATUS current @@ -355,10 +368,11 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } STATUS current DESCRIPTION " An entry in cachePeerTable " - INDEX { IPcacheEntryIP } - ::= { IPcacheTable 1 } + INDEX { IPcacheEntryId } + ::= { ipCacheTable 1 } IPcacheEntry ::= SEQUENCE { + IPcacheEntryId Integer, IPcacheEntryName OCTET STRING, IPcacheEntryIP IpAddress, IPcacheEntryState INTEGER, @@ -373,27 +387,33 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } " State of IP cache entry " ::= { iPcacheEntry 3 } + IPcacheEntryId OBJECT-TYPE + SYNTAX Integer + ACCESS read-only + STATUS current + ::= { iPcacheEntry 1 } + IPcacheEntryName OBJECT-TYPE SYNTAX OCTET STRING ACCESS read-only STATUS current - ::= { iPcacheEntry 1 } + ::= { iPcacheEntry 2 } IPcacheEntryIP OBJECT-TYPE SYNTAX IpAddress ACCESS read-only STATUS current - ::= { iPcacheEntry 2 } + ::= { iPcacheEntry 3 } IPcacheEntryState OBJECT-TYPE SYNTAX Integer ACCESS read-only STATUS current - ::= { iPcacheEntry 3 } + ::= { iPcacheEntry 4 } -- fqdn cache info - FQDNcacheTable OBJECT-TYPE + fQDNcacheTable OBJECT-TYPE SYNTAX SEQUENCE OF fQDNcacheEntry ACCESS read-only STATUS current @@ -408,10 +428,11 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } STATUS current DESCRIPTION " An entry in cachePeerTable " - INDEX { FQDNcacheEntryName } - ::= { IPcacheTable 1 } + INDEX { FQDNcacheEntryId } + ::= { fQDNcacheTable 1 } FQDNcacheEntry ::= SEQUENCE { + FQDNcacheEntryId Integer, FQDNcacheEntryName OCTET STRING, FQDNcacheEntryIP IpAddress, FQDNcacheEntryLastRef TimeTicks, @@ -419,35 +440,41 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } FQDNcacheEntryState INTEGER } + FQDNcacheEntryId OBJECT-TYPE + SYNTAX Integer + ACCESS read-only + STATUS current + ::= { fQDNcacheEntry 1 } + FQDNcacheEntryName OBJECT-TYPE SYNTAX OCTET STRING ACCESS read-only STATUS current - ::= { fQDNcacheEntry 1 } + ::= { fQDNcacheEntry 2 } FQDNcacheEntryIP OBJECT-TYPE SYNTAX IpAddress ACCESS read-only STATUS current - ::= { fQDNcacheEntry 2 } + ::= { fQDNcacheEntry 3 } FQDNcacheEntryLastRef OBJECT-TYPE SYNTAX TimeTicks ACCESS read-only STATUS current - ::= { fQDNcacheEntry 3} + ::= { fQDNcacheEntry 4} FQDNcacheEntryExpires OBJECT-TYPE SYNTAX TimeTicks ACCESS read-only STATUS current - ::= { fQDNcacheEntry 4} + ::= { fQDNcacheEntry 5} FQDNcacheEntryState OBJECT-TYPE SYNTAX Integer ACCESS read-only STATUS current - ::= { fQDNcacheEntry 5} + ::= { fQDNcacheEntry 6} @@ -458,7 +485,7 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } STATUS current DESCRIPTION " state of FQDN cache entry " - ::= { fQDNcacheEntry 3 } + ::= { fQDNcacheEntry 7 } cacheTCPconnections OBJECT-TYPE @@ -485,13 +512,13 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } " Throughput of incoming traffic in 5 min intervals " ::= { cacheNetwork 6 } --- cacheOutThroughput OBJECT-TYPE ----- SYNTAX Integer32 - -- ACCESS read-only - -- STATUS current - -- DESCRIPTION --- "Throughput of outgoing traffic in 5 min intevals" --- ::= { cacheNetwork 7 } + cacheOutThroughput OBJECT-TYPE + SYNTAX Integer32 + ACCESS read-only + STATUS current + DESCRIPTION + " Throughput of outgoing traffic in 5 min intevals" + ::= { cacheNetwork 7 } -- -- performance group { squid 3 } @@ -637,12 +664,42 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } ::= { cacheSysPerf 7 } cacheNumObjCount OBJECT-TYPE - SYNTAX Counter32 MAX-ACCESS read-only + SYNTAX Counter32 + MAX-ACCESS read-only STATUS current DESCRIPTION " Number of objects " ::= { cacheSysPerf 8 } + cacheCurrentMemSize OBJECT-TYPE + SYNTAX Counter32 + ACCESS read-only + STATUS mandatory + ::= { cacheSysPerf 9 } + + cacheCurrentLRUExpiration OBJECT-TYPE + SYNTAX TimeTicks + ACCESS read-only + STATUS mandatory + ::= { cacheSysPerf 10 } + + cacheCurrentUnlinkRequests OBJECT-TYPE + SYNTAX Counter32 + ACCESS read-only + STATUS mandatory + ::= { cacheSysPerf 11 } + + cacheCurrentUnusedFileDescrCount OBJECT-TYPE + SYNTAX Gauge32 + ACCESS read-only + STATUS mandatory + ::= { cacheSysPerf 12 } + + cacheCurrentReservedFileDescrCount OBJECT-TYPE + SYNTAX Gauge32 + ACCESS read-only + STATUS mandatory + ::= { cacheSysPerf 13 } -- -- cacheProtoStats @@ -733,6 +790,34 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } STATUS mandatory ::= { cacheProtoStatEntry 9 } + + cacheProtoAggregateStats OBJECT IDENTIFIER ::= { cacheProtoStats 2 } + + cacheClientHttpRequests OBJECT-TYPE + SYNTAX Counter32 + ACCESS read-only + STATUS mandatory + ::= { cacheProtoAggregateStats 1 } + + cacheICPpktsSent OBJECT-TYPE + SYNTAX Counter32 + ACCESS read-only + STATUS mandatory + ::= { cacheProtoAggregateStats 2 } + + cacheICPpktsRecv OBJECT-TYPE + SYNTAX Counter32 + ACCESS read-only + STATUS mandatory + ::= { cacheProtoAggregateStats 3 } + + cacheCurrentSwapSize OBJECT-TYPE + SYNTAX Counter32 + ACCESS read-only + STATUS mandatory + ::= { cacheProtoAggregateStats 4 } + + -- -- cachePeerStats @@ -745,7 +830,7 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } DESCRIPTION " Table containing aggregate statistics per supported protocol " - ::= { cacheProtoStats 2 } + ::= { cachePeerStats 1 } cachePeerStatEntry OBJECT-TYPE SYNTAX CachePeerStatEntry @@ -863,4 +948,4 @@ nsfnet OBJECT IDENTIFIER ::= { experimental 25 } cacheProtoAclMask IpAddress cacheProtoAclType INTEGER } - +END diff --git a/src/net_db.cc b/src/net_db.cc index f33e47d458..b9247e57fa 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.51 1997/11/05 05:29:32 wessels Exp $ + * $Id: net_db.cc,v 1.52 1997/12/01 22:45:53 wessels Exp $ * * DEBUG: section 37 Network Measurement Database * AUTHOR: Duane Wessels @@ -31,15 +31,13 @@ #include "squid.h" -#if USE_ICMP -static hash_table *addr_table = NULL; +#if USE_ICMP +hash_table *addr_table = NULL; static hash_table *host_table = NULL; static struct in_addr networkFromInaddr(struct in_addr a); static void netdbRelease(netdbEntry * n); -static netdbEntry *netdbGetFirst(hash_table * table); -static netdbEntry *netdbGetNext(hash_table * table); static void netdbHashInsert(netdbEntry * n, struct in_addr addr); static void netdbHashDelete(const char *key); static void netdbHashLink(netdbEntry * n, const char *hostname); @@ -115,13 +113,13 @@ netdbLookupHost(const char *key) return hptr ? (netdbEntry *) hptr->item : NULL; } -static netdbEntry * +netdbEntry * netdbGetFirst(hash_table * table) { return (netdbEntry *) hash_first(table); } -static netdbEntry * +netdbEntry * netdbGetNext(hash_table * table) { return (netdbEntry *) hash_next(table); diff --git a/src/protos.h b/src/protos.h index 6efeb431d1..0337010438 100644 --- a/src/protos.h +++ b/src/protos.h @@ -328,6 +328,8 @@ extern void netdbFreeMemory(void); extern int netdbHostHops(const char *host); extern int netdbHostRtt(const char *host); extern void netdbUpdatePeer(request_t *, peer * e, int rtt, int hops); +extern netdbEntry *netdbGetFirst(hash_table * table); +extern netdbEntry *netdbGetNext(hash_table * table); extern void objcachePasswdAdd(cachemgr_passwd **, char *, wordlist *); extern void objcachePasswdDestroy(cachemgr_passwd ** a); @@ -432,6 +434,7 @@ extern int storePendingNClients(const StoreEntry *); extern int storeWriteCleanLogs(int reopen); extern HASHCMP urlcmp; extern EVH storeMaintainSwapSpace; + extern void storeExpireNow(StoreEntry *); extern void storeReleaseRequest(StoreEntry *); extern void storeRotateLog(void); diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index 2f38bd96f7..21e01547b5 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -44,12 +44,6 @@ int create_identical(); int parse_var_op_list(); void setVariable(); -#if kinetics -char version_descr[]; -oid version_id[]; -int version_id_len; -#endif - struct pbuf *definitelyGetBuf(); int get_community(); @@ -191,16 +185,19 @@ long *ireqid; create_report( session, out_sn_data, out_length, -ret, reqid ); return 1; } else { + debug(49,5)("snmp_agent_parse: asn_parse failed\n"); return 0; } } else if( ret > 0 ) { increment_stat( ret ); + debug(49,5)("snmp_agent_parse: authorization failed>0 "); return 0; } } else if( version == SNMP_VERSION_1 ) { if( (ret = get_community( sid )) != 0 ) { increment_stat(ret); + debug(49,5)("snmp_agent_parse: get_community failed\n"); return 0; } session->version = SNMP_VERSION_1; @@ -233,8 +230,12 @@ long *ireqid; if( msgtype == GETBULK_REQ_MSG ) { if( session->version == SNMP_VERSION_1 ) + { + debug(49,5)("snmp_agent_parse: getbulk but version 1\n"); return 0; + } } else if (msgtype != GET_REQ_MSG && msgtype != GETNEXT_REQ_MSG && msgtype != SET_REQ_MSG ) { + debug(49,5)("snmp_agent_parse: unknown request type\n"); return 0; } sn_data = asn_parse_int(sn_data, &length, &type, &reqid, sizeof(reqid)); @@ -346,6 +347,7 @@ long *ireqid; *out_length = packet_end - out_auth; return 1; } + debug(49,5)("snmp_agent_parse: problem in ERR_NOERROR\n"); return 0; } else { parse_var_op_list(sn_data, length, out_sn_data, *out_length, @@ -405,8 +407,10 @@ long *ireqid; *out_length = packet_end - out_auth; return 1; } + debug(49,5)("snmp_agent_parse: create_identical failed\n"); return 0; default: + debug(49,5)("snmp_agent_parse: hey, something's wrong\n"); return 0; } @@ -488,6 +492,7 @@ parse_var_op_list(sn_data, length, out_sn_data, out_length, index, msgtype, acti if (sn_data == NULL) return PARSE_ERROR; /* now attempt to retrieve the variable on the local entity */ + debug(49,5)("snmp:before getStatPtr...\n"); statP = getStatPtr(var_name, &var_name_len, &statType, &statLen, &acl, exact, &write_method, session->version, &noSuchObject, msgtype==SET_REQ_MSG ? session->writeView : session->readView ); @@ -630,7 +635,7 @@ create_identical(snmp_in, snmp_out, snmp_length, errstat, errindex) int length, headerLength; u_char *headerPtr, *reqidPtr, *errstatPtr, *errindexPtr, *varListPtr; - bcopy((char *)snmp_in, (char *)snmp_out, snmp_length); + memcpy((char *)snmp_out, (char *)snmp_in, snmp_length); length = snmp_length; headerPtr = snmp_auth_parse(snmp_out, &length, sid, &sidlen, (long *)&dummy); sid[sidlen] = 0; @@ -774,8 +779,9 @@ int get_community(sessionid) u_char *sessionid; { communityEntry *cp; - - for( cp = communities; cp; cp = cp->next ) { + debug(49,5)("get_community: %s on %d\n",sessionid, getpid()); + for( cp = Config.Snmp.communities; cp; cp = cp->next ) { + debug(49,5)("get_community: %s\n", cp->name); if (!strcmp(cp->name, (char *)sessionid)) break; } diff --git a/src/squid.h b/src/squid.h index befc48984a..73ba559f3c 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.137 1997/11/30 02:52:09 wessels Exp $ + * $Id: squid.h,v 1.138 1997/12/01 22:45:57 wessels Exp $ * * AUTHOR: Duane Wessels * @@ -264,6 +264,10 @@ #define storeKeyHashCmp urlcmp #define storeKeyHashHash hash4 #endif +#ifdef SQUID_SNMP +#include "snmp.h" +#include "snmp_config.h" +#endif /* Needed for poll() on Linux at least */ #if HAVE_POLL diff --git a/src/stat.cc b/src/stat.cc index 8962bb35b9..51ba62ad41 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.176 1997/11/28 08:11:58 wessels Exp $ + * $Id: stat.cc,v 1.177 1997/12/01 22:45:57 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -115,7 +115,7 @@ static void proto_count(cacheinfo *, protocol_t, log_type); static void proto_newobject(cacheinfo *, protocol_t, int, int); static void proto_purgeobject(cacheinfo *, protocol_t, int); static void proto_touchobject(cacheinfo *, protocol_t, int); -static int memoryAccounted(void); + int memoryAccounted(void); static void statAvgTick(void *notused); #ifdef XMALLOC_STATISTICS @@ -496,7 +496,7 @@ statFiledescriptors(StoreEntry * sentry) storeAppendPrintf(sentry, close_bracket); } -static int + int memoryAccounted(void) { return (int) diff --git a/src/structs.h b/src/structs.h index 5c6779d021..09384ef1c1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -34,6 +34,12 @@ struct _acl_deny_info_list { struct _acl_deny_info_list *next; }; +struct _snmpconf { + char *line; + int type; + struct _snmpconf *next; +}; + struct _acl { char name[ACL_NAME_SZ]; squid_acl type; @@ -131,8 +137,15 @@ struct _SquidConfig { char *configFile; char *agentInfo; char *mibPath; + char *trap_community; + char *trap_sink; u_short localPort; int do_queueing; + int conf_authtraps; + struct _snmpconf *snmpconf; + viewEntry *views; + usecEntry *users; + communityEntry *communities; } Snmp; struct { char *log; @@ -612,7 +625,7 @@ struct _net_db_peer { struct _netdbEntry { char *key; - struct _net_db *next; + struct _netdbEntry *next; char network[16]; int pings_sent; int pings_recv; diff --git a/src/tools.cc b/src/tools.cc index 236335583f..b126a100a4 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.131 1997/11/28 08:12:02 wessels Exp $ + * $Id: tools.cc,v 1.132 1997/12/01 22:45:59 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -178,9 +178,9 @@ dumpMallocStats(void) #if HAVE_MSTATS && HAVE_GNUMALLOC_H struct mstats ms = mstats(); fprintf(debug_log, "\ttotal space in arena: %6d KB\n", - ms.bytes_total >> 10); + (int) (ms.bytes_total >> 10)); fprintf(debug_log, "\tTotal free: %6d KB %d%%\n", - ms.bytes_free >> 10, + (int) (ms.bytes_free >> 10), percent(ms.bytes_free, ms.bytes_total)); #elif HAVE_MALLINFO struct mallinfo mp; diff --git a/src/typedefs.h b/src/typedefs.h index 787b73d673..5ba339f662 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -14,6 +14,7 @@ typedef struct _acl_time_data acl_time_data; typedef struct _acl_name_list acl_name_list; typedef struct _acl_deny_info_list acl_deny_info_list; typedef struct _acl acl; +typedef struct _snmpconf snmpconf; typedef struct _acl_list acl_list; typedef struct _acl_access acl_access; typedef struct _aclCheck_t aclCheck_t; @@ -104,8 +105,8 @@ typedef void SIGHDLR(int sig); /* 32 bit integer compatability hack */ #if SIZEOF_INT == 4 -typedef int num32; -typedef unsigned int u_num32; +/*typedef int num32; +typedef unsigned int u_num32;*/ #elif SIZEOF_LONG == 4 typedef long num32; typedef unsigned long u_num32;