Squid has a built-in SNMP agent that you can query with various SNMP client tools. It allows you to collect a few basic statistics from Squid. Unfortunately, the Squid MIB has not evolved much since its initial implementation. Many of the parameters that you'd like to monitor aren't available through the SNMP MIB. Perhaps this will be rectified in a future version.
To enable SNMP in Squid, use the enable-snmp option when running ./configure and recompile if necessary. Squid uses UDP port 3401 for SNMP by default. You can use a different port by setting the snmp_port directive.
Use the snmp_access access list and snmp_community ACL type to define an access policy for the SNMP agent. For example:
acl Snmppublic snmp_community public acl Adminhost src 192.168.1.1 snmp_access allow Adminhost Snmppublic
In this case, Squid accepts SNMP requests from 192.168.1.1 with the community name set to public.
The NET-SNMP package (http://net-snmp.sourceforge.net/) provides a good implementation of the snmpwalk and snmpget command-line tools for Unix. The former walks through an SNMP MIB tree, displaying every value, while the latter prints the value for a single MIB object.
After installing NET-SNMP, copy the Squid MIB file to the directory where the utilities can find it. By default, this is the /usr/local/share/snmp/mibs directory:
# cp squid-2.5.STABLE4/src/mib.txt /usr/local/share/snmp/mibs/SQUID-MIB.txt # chmod 644 /usr/local/share/snmp/mibs/SQUID-MIB.txt
You should then be able to use the snmpget command. Note that Squid is an SNMPv1 agent:
% snmpget -v 1 -c public -m SQUID-MIB localhost:3401 cacheDnsSvcTime.5 SQUID-MIB::cacheDnsSvcTime.5 = INTEGER: 44
If you want to see the entire Squid MIB tree, use snmpwalk. The -Cc option tells snmpwalk to ignore nonincreasing OIDs:
% snmpwalk -v 1 -c public -m SQUID-MIB -Cc localhost:3401 squid | less
If you can't get the Squid MIB installed so that snmpwalk sees it, you can use the numeric OID value instead:
% snmpwalk -v 1 -c public -m SQUID-MIB -Cc localhost:3401 .1.3.6.1.4.1.3495.1 | less
In this section, I provide a brief description for each OID in the Squid MIB, which lives in the global MIB tree under iso.org.dod.internet.private.enterprises.nlanr.squid, or .1.3.6.1.4.1.3495.1. The full MIB names, such as cachePerf.cacheProtoStats.cacheMedianSvcTable.cacheMedianSvcEntry.cacheHttpMissSvcTime.60, take up too much space on the page. Instead, I'll just use the last nonnumeric component of the OID name, which is unique.
The amount of memory (in kilobytes) currently used to store in-memory objects. For example:
SQUID-MIB::cacheSysVMsize = INTEGER: 10224
The amount of disk space (in kilobytes) currently used to store on-disk objects. For example:
SQUID-MIB::cacheSysStorage = INTEGER: 19347723
The amount of time (number of seconds) since Squid was started.
SQUID-MIB::cacheUptime = Timeticks: (33239630) 3 days, 20:19:56.30
The email address, or name, of the cache administrator. For example:
SQUID-MIB::cacheAdmin = STRING: wessels@bo2.us.ircache.net
The name of the application. For example:
SQUID-MIB::cacheSoftware = STRING: squid
The application's version identification. For example:
SQUID-MIB::cacheVersionId = STRING: "2.5.STABLE4"
The current debugging levels, from the debug_options directive. For example:
SQUID-MIB::cacheLoggingFacility = STRING: ALL,1
The value of the cache_mem directive, in megabytes. For example:
SQUID-MIB::cacheMemMaxSize = INTEGER: 10
The total amount of disk storage, in megabytes, taken from the sum of all cache_dir lines. For example:
SQUID-MIB::cacheSwapMaxSize = INTEGER: 21000
The high watermark percentage for disk storage, taken from the cache_swap_high directive. For example:
SQUID-MIB::cacheSwapHighWM = INTEGER: 95
The low watermark percentage for disk storage, taken from the cache_swap_low directive. For example:
SQUID-MIB::cacheSwapLowWM = INTEGER: 90
The number of page faults for the Squid process since it was started. (See "Page faults with physical i/o" in Section 14.2.1.24.) For example:
SQUID-MIB::cacheSysPageFaults = Counter32: 9
The number of times this process called read( ) on HTTP sockets connected to origin servers and neighbor caches. For example:
SQUID-MIB::cacheSysNumReads = Counter32: 15941979
The amount of memory allocated by the memory pooling routines. Not the same as the total memory used by Squid. (See "Total accounted" in Section 14.2.1.24.) For example:
SQUID-MIB::cacheMemUsage = INTEGER: 143709
The amount of CPU time, in seconds, accumulated by the Squid process. For example:
SQUID-MIB::cacheCpuTime = INTEGER: 79313
The mean CPU utilization, as a percentage, since Squid was started. Unfortunately, since this value is an integer, any graphs that you make will be "quantized." For example:
SQUID-MIB::cacheCpuUsage = INTEGER: 23
The maximum resident set size, in kilobytes, for the Squid process. (See "Maximum Resident Size" in Section 14.2.1.24.) For example:
SQUID-MIB::cacheMaxResSize = INTEGER: 219128
The total number of objects currently in the cache. For example:
SQUID-MIB::cacheNumObjCount = Counter32: 1717181
Current versions of Squid don't have a global LRU expiration age value, so this is always reported as zero. For example:
SQUID-MIB::cacheCurrentLRUExpiration = Timeticks: (0) 0:00:00.00
The number of files given to the external unlinkd process for removal. Note that Squid doesn't use unlinkd with the diskd and aufs storage schemes. For example:
SQUID-MIB::cacheCurrentUnlinkRequests = Counter32: 0
The current number of available (unused) file descriptors. For example:
SQUID-MIB::cacheCurrentUnusedFDescrCnt = Gauge32: 7253
The number of reserved file descriptors. (See "Reserved number of file descriptors" in Section 14.2.1.24.) For example:
SQUID-MIB::cacheCurrentResFileDescrCnt = Gauge32: 100
The total number of HTTP requests received from cache clients. For example:
SQUID-MIB::cacheProtoClientHttpRequests = Counter32: 7277019
The number of client requests that were cache hits. For example:
SQUID-MIB::cacheHttpHits = Counter32: 2526484
The number of client requests that resulted in an error. For example:
SQUID-MIB::cacheHttpErrors = Counter32: 0
The amount of network traffic, in kilobytes, read from cache clients. For example:
SQUID-MIB::cacheHttpInKb = Counter32: 4231883
The amount of network traffic, in kilobytes, written to cache clients. For example:
SQUID-MIB::cacheHttpOutKb = Counter32: 56894945
The number of ICP messages (both queries and replies) sent to neighbors. For example:
SQUID-MIB::cacheIcpPktsSent = Counter32: 5296120
The number of ICP messages (both queries and replies) received from neighbors. For example:
SQUID-MIB::cacheIcpPktsRecv = Counter32: 5271238
The amount of network traffic, in kilobytes, used for ICP messages sent to neighbors, not including UDP and IP headers. For example:
SQUID-MIB::cacheIcpKbSent = Counter32: 428112
The amount of network traffic, in kilobytes, used for ICP messages received from neighbors, not including UDP and IP headers. For example:
SQUID-MIB::cacheIcpKbRecv = Counter32: 447762
The number of requests forwarded to origin servers and neighbor caches. For example:
SQUID-MIB::cacheServerRequests = INTEGER: 5338305
The number of errors received from origin servers and neighbor caches. Currently unimplemented and always reported as zero. For example:
SQUID-MIB::cacheServerErrors = INTEGER: 0
The amount of network traffic, in kilobytes, read from origin servers and neighbor caches. For example:
SQUID-MIB::cacheServerInKb = Counter32: 49196559
The amount of network traffic, in kilobytes, written to origin servers and neighbor caches. For example:
SQUID-MIB::cacheServerOutKb = Counter32: 3404717
The amount of disk space, in kilobytes, currently in use by Squid. Compare to cacheSysStorage. For example:
SQUID-MIB::cacheCurrentSwapSize = Counter32: 19347723
The number of clients that sent HTTP requests to Squid since it was started. For example:
SQUID-MIB::cacheClients = Counter32: 498
These OIDs report the time intervals, in minutes, over which median values are computed for subsequent OIDs. The value is the same as the last number of the OID. For example:
SQUID-MIB::cacheMedianTime.1 = INTEGER: 1
The 1-, 5-, and 60-minute median service time values, in milliseconds, for all client HTTP requests. For example:
SQUID-MIB::cacheHttpAllSvcTime.1 = INTEGER: 78
The 1-, 5-, and 60-minute median service time values for cache misses. For example:
SQUID-MIB::cacheHttpMissSvcTime.1 = INTEGER: 114 SQUID-MIB::cacheHttpMissSvcTime.5 = INTEGER: 87 SQUID-MIB::cacheHttpMissSvcTime.60 = INTEGER: 74
The 1-, 5-, and 60-minute median service time values for requests logged as TCP_IMS_HIT. (See "Not-Modified Replies" in Section 14.2.1.24.) For example:
SQUID-MIB::cacheHttpNmSvcTime.1 = INTEGER: 12 SQUID-MIB::cacheHttpNmSvcTime.5 = INTEGER: 34 SQUID-MIB::cacheHttpNmSvcTime.60 = INTEGER: 32
The 1-, 5-, and 60-minute median service time values for cache hits, logged as TCP_HIT. For example:
SQUID-MIB::cacheHttpHitSvcTime.1 = INTEGER: 45 SQUID-MIB::cacheHttpHitSvcTime.5 = INTEGER: 45 SQUID-MIB::cacheHttpHitSvcTime.60 = INTEGER: 40
The 1-, 5-, and 60-minute service time values for ICP queries sent by Squid (the time elapsed between sending your query and receiving a neighbor's reply). For example:
SQUID-MIB::cacheIcpQuerySvcTime.1 = INTEGER: 0 SQUID-MIB::cacheIcpQuerySvcTime.5 = INTEGER: 0 SQUID-MIB::cacheIcpQuerySvcTime.60 = INTEGER: 3563
The 1-, 5-, and 60-minute median service time values for ICP queries received by Squid. In current implementations, these are always zero because processing occurs faster than the process clock is updated. For example:
SQUID-MIB::cacheIcpReplySvcTime.1 = INTEGER: 0 SQUID-MIB::cacheIcpReplySvcTime.5 = INTEGER: 0 SQUID-MIB::cacheIcpReplySvcTime.60 = INTEGER: 0
The 1-, 5-, and 60-minute median service time values for Squid's DNS queries. For example:
SQUID-MIB::cacheDnsSvcTime.1 = INTEGER: 40 SQUID-MIB::cacheDnsSvcTime.5 = INTEGER: 42 SQUID-MIB::cacheDnsSvcTime.60 = INTEGER: 42
Squid's cache hit ratio (percentage) over the last 1, 5, and 60 minutes. For example:
SQUID-MIB::cacheRequestHitRatio.1 = INTEGER: 16 SQUID-MIB::cacheRequestHitRatio.5 = INTEGER: 18 SQUID-MIB::cacheRequestHitRatio.60 = INTEGER: 22
Squid's byte hit ratio (percentage) over the last 1, 5, and 60 minutes. For example:
SQUID-MIB::cacheRequestByteRatio.1 = INTEGER: 73 SQUID-MIB::cacheRequestByteRatio.5 = INTEGER: 43 SQUID-MIB::cacheRequestByteRatio.60 = INTEGER: 34
The number of entries in Squid's IP (name-to-address) cache. For example:
SQUID-MIB::cacheIpEntries = Gauge32: 10033
The number of requests received by Squid's IP cache. For example:
SQUID-MIB::cacheIpRequests = Counter32: 8195627
The number of lookups that were hits in the IP cache. For example:
SQUID-MIB::cacheIpHits = Counter32: 6040658
If the ratio of hits to requests is less than 60-75%, you may want to increase the size of your IP cache.
Always zero in the current implementation. For example:
SQUID-MIB::cacheIpPendingHits = Gauge32: 0
Older versions of Squid had the notion of IP cache hits for outstanding queries.
The number of lookups that were negative hits in the IP cache. Certain failed queries may be negatively cached for an amount of time determined by the negative_dns_ttl directive. For example:
SQUID-MIB::cacheIpNegativeHits = Counter32: 49433
The number of IP cache misses. For example:
SQUID-MIB::cacheIpMisses = Counter32: 1807438
Always zero in the current implementation. For example:
SQUID-MIB::cacheBlockingGetHostByName = Counter32: 0
Older versions occasionally called the gethostbyname( ) function if the IP cache couldn't provide an answer.
Always zero in the current implementation. Older versions would, in some cases, want to release locked IP cache entries. For example:
SQUID-MIB::cacheAttemptReleaseLckEntries = Counter32: 0
The number of entries in the FQDN (address-to-name) cache. For example:
SQUID-MIB::cacheFqdnEntries = Gauge32: 1
The number of requests to the FQDN cache. For example:
SQUID-MIB::cacheFqdnRequests = Counter32: 0
The number of FQDN cache requests satisfied as hits. For example:
SQUID-MIB::cacheFqdnHits = Counter32: 0
Always zero in the current implementation. For example:
SQUID-MIB::cacheFqdnPendingHits = Gauge32: 0
The number of FQDN requests satisfied as negative cache hits. For example:
SQUID-MIB::cacheFqdnNegativeHits = Counter32: 0
The number of FQDN cache misses. For example:
SQUID-MIB::cacheFqdnMisses = Counter32: 0
Always zero in the current implementation. For example:
SQUID-MIB::cacheBlockingGetHostByAddr = Counter32: 0
The number of DNS queries made by Squid. This counter is reset each time you reconfigure the running Squid process. For example:
SQUID-MIB::cacheDnsRequests = Counter32: 3262
The number of DNS replies received by Squid. This counter is reset each time you reconfigure the running Squid process. For example:
SQUID-MIB::cacheDnsReplies = Counter32: 2440
When using internal DNS (the default), this OID reports the number of nameservers that Squid knows about. For external DNS, it reports the number of (running) dnsserver helper processes. For example:
SQUID-MIB::cacheDnsNumberServers = Counter32: 2
This, and the next group of OIDs, come from the list of neighbor caches. (See Section 14.2.1.50.) These OIDs are indexed by the IPv4 address of the peer. This particular OID returns the neighbor cache's hostname. For example:
SQUID-MIB::cachePeerName.192.203.230.19 = STRING: sv.us.ircache.net
This is the IP address of the peer, which, of course, you already know from the OID itself. For example:
SQUID-MIB::cachePeerAddr.192.203.230.19 = IpAddress: 192.203.230.19
This is the neighbor cache's HTTP port number. For example:
SQUID-MIB::cachePeerPortHttp.192.203.230.19 = INTEGER: 3128
This is the neighbor cache's ICP or HTCP port number. For example:
SQUID-MIB::cachePeerPortIcp.192.203.230.19 = INTEGER: 3130
The type of the neighbor: 1 for sibling, 2 for parent, and 3 for multicast. For example:
SQUID-MIB::cachePeerType.192.203.230.19 = INTEGER: 1
The state of the peer: 1 for up, 0 for down. (See Section 10.3.2.) For example:
SQUID-MIB::cachePeerState.192.203.230.19 = INTEGER: 1
The number of ICP/HTCP queries sent to the neighbor. For example:
SQUID-MIB::cachePeerPingsSent.192.203.230.19 = Counter32: 924
The number of ICP/HTCP queries received from the neighbor. For example:
SQUID-MIB::cachePeerPingsAcked.192.203.230.19 = Counter32: 901
The number of HTTP requests sent to the neighbor. (See the discussion about FETCHES in Section 14.2.1.50.) For example:
SQUID-MIB::cachePeerFetches.192.203.230.19 = Counter32: 34
The average round-trip time for ICP/HTCP queries to this peer. For example:
SQUID-MIB::cachePeerRtt.192.203.230.19 = INTEGER: 26
The number of ICP/HTCP replies that Squid ignored. (See the discussion about IGNORED in Section 14.2.1.50.) For example:
SQUID-MIB::cachePeerIgnored.192.203.230.19 = Counter32: 201
The number of HTTP requests sent to the neighbor with a request to keep the connection open. For example:
SQUID-MIB::cachePeerKeepAlSent.192.203.230.19 = Counter32: 34
The number of HTTP replies received from the neighbor with a request to keep the connection open. For example:
SQUID-MIB::cachePeerKeepAlRecv.192.203.230.19 = Counter32: 34
The cacheClientAddr OIDs come from the same database as the Cache Client List (see Section 14.2.1.46). This particular OID's value is the IPv4 address, just like the last four octets of the OID itself. For example:
SQUID-MIB::cacheClientAddr.206.168.0.9 = IpAddress: 206.168.0.9
The number of HTTP requests received from this client. For example:
SQUID-MIB::cacheClientHttpRequests.206.168.0.9 = Counter32: 108281
The amount of traffic, in kilobytes, sent to this client. For example:
SQUID-MIB::cacheClientHttpKb.206.168.0.9 = Counter32: 921447
The number of cache hits sent to this client. For example:
SQUID-MIB::cacheClientHttpHits.206.168.0.9 = Counter32: 32365
The amount of traffic, in kilobytes, sent to this client for cache hits. For example:
SQUID-MIB::cacheClientHTTPHitKb.206.168.0.9 = Counter32: 141638
The number of ICP (but not HTCP ) queries received from this client. For example:
SQUID-MIB::cacheClientIcpRequests.206.168.0.9 = Counter32: 79120
The amount of traffic, in kilobytes, received from this client in ICP queries. For example:
SQUID-MIB::cacheClientIcpKb.206.168.0.9 = Counter32: 5986
The number of ICP_HIT replies sent to this client. For example:
SQUID-MIB::cacheClientIcpHits.206.168.0.9 = Counter32: 21897
The amount of traffic, in kilobytes, sent to this client for ICP_HIT messages. A somewhat silly measurement because ICP_HIT and ICP_MISS messages have the same size. However, old versions of Squid used the now-obsolete ICP_HIT_OBJ opcode, which included the object content. For example:
SQUID-MIB::cacheClientIcpHitKb.206.168.0.9 = Counter32: 1679