2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/squid/squid_times

66 lines
2.3 KiB
Plaintext
Raw Normal View History

2008-06-12 09:11:18 +02:00
#!/bin/sh
#
# Copyright (C) 2008 Olivier DELHOMME. All rights reserved.
# License GPL V2 or higher
#
# Abstract
# munin plugin that logs the cache mean services times
# Requires netcat (here nc)
#
# Authors
# . Olivier Delhomme <olivierdelhomme at gmail dot com>
#
#%# family=auto
#%# capabilities=autoconf
2014-09-29 15:48:05 +02:00
host=${squidhost:-localhost}
port=${squidport:-3128}
2008-06-12 09:11:18 +02:00
if [ "$1" = "autoconf" ]; then
2014-09-29 15:48:05 +02:00
SQUID_STATS=`printf "GET cache_object://$host/info HTTP/1.0\n\n" | netcat $host $port`
2008-06-12 09:11:18 +02:00
if [ -n "${SQUID_STATS}" ]; then
echo yes
exit 0
else
echo "no (HTTP GET failed)"
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title Squid Median Services Times'
echo 'graph_info This graph shows the proxy median services response times.'
echo 'graph_category webserver'
2008-06-12 09:11:18 +02:00
echo 'graph_args --lower-limit 0'
echo 'graph_vlabel median response times (s)'
2008-06-12 09:11:18 +02:00
echo 'mean_http.label Http'
echo 'mean_cmis.label Cache misses'
echo 'mean_chits.label Cache hits'
echo 'mean_nhits.label Near hits'
echo 'mean_nmr.label Not-modified replies'
echo 'mean_dnsl.label Dns lookups'
echo 'mean_icpq.label Icp queries'
exit 0
fi
2014-09-29 15:48:05 +02:00
SQUID_TIME=$(printf "GET cache_object://$host/info HTTP/1.0\n\n" | nc $host $port)
2008-06-12 09:11:18 +02:00
SQUID_TIME_HTTP=$(echo "$SQUID_TIME" | grep "HTTP Requests (All)" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
SQUID_TIME_CACHE_MISSES=$(echo "$SQUID_TIME" | grep "Cache Misses" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
SQUID_TIME_CACHE_HITS=$(echo "$SQUID_TIME" | grep "Cache Hits" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
SQUID_TIME_NEAR_HITS=$(echo "$SQUID_TIME" | grep "Near Hits" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
SQUID_TIME_NM_REPLIES=$(echo "$SQUID_TIME" | grep "Not-Modified Replies" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
SQUID_TIME_DNS_LOOKUPS=$(echo "$SQUID_TIME" | grep "DNS Lookups" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
SQUID_TIME_ICP_QUERIES=$(echo "$SQUID_TIME" | grep "ICP Queries" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
echo "mean_http.value $SQUID_TIME_HTTP"
echo "mean_cmis.value $SQUID_TIME_CACHE_MISSES"
echo "mean_chits.value $SQUID_TIME_CACHE_HITS"
echo "mean_nhits.value $SQUID_TIME_NEAR_HITS"
echo "mean_nmr.value $SQUID_TIME_NM_REPLIES"
echo "mean_dnsl.value $SQUID_TIME_DNS_LOOKUPS"
2014-09-29 15:48:05 +02:00
echo "mean_icpq.value $SQUID_TIME_ICP_QUERIES"