Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / squid / squid_times @ 176b5512

Historique | Voir | Annoter | Télécharger (2,31 ko)

1
#!/bin/sh
2
#
3
# Copyright (C) 2008 Olivier DELHOMME. All rights reserved.
4
# License GPL V2 or higher
5
#
6
# Abstract
7
# munin plugin that logs the cache mean services times 
8
# Requires netcat (here nc)
9
#
10
# Authors
11
#  . Olivier Delhomme <olivierdelhomme at gmail dot com>
12
#
13
#%# family=auto
14
#%# capabilities=autoconf
15

    
16
host=${squidhost:-localhost}
17
port=${squidport:-3128}
18

    
19
if [ "$1" = "autoconf" ]; then
20
	SQUID_STATS=`printf "GET cache_object://$host/info HTTP/1.0\n\n" | netcat $host $port`
21
	if [ -n "${SQUID_STATS}" ]; then
22
		echo yes 
23
		exit 0
24
	else
25
		echo "no (HTTP GET failed)"
26
		exit 1
27
	fi
28
fi
29

    
30
if [ "$1" = "config" ]; then
31
	echo 'graph_title Squid Median Services Times'
32
	echo 'graph_info This graph shows the proxy median services response times.'
33
	echo 'graph_category squid'
34
	echo 'graph_args --lower-limit 0'
35
	echo 'graph_vlabel median reponse times (s)'
36

    
37
	echo 'mean_http.label Http'
38
	echo 'mean_cmis.label Cache misses'	
39
	echo 'mean_chits.label Cache hits'
40
	echo 'mean_nhits.label Near hits'
41
	echo 'mean_nmr.label Not-modified replies'
42
	echo 'mean_dnsl.label Dns lookups'
43
	echo 'mean_icpq.label Icp queries'
44

    
45
	exit 0
46
fi 
47

    
48
SQUID_TIME=$(printf "GET cache_object://$host/info HTTP/1.0\n\n" | nc $host $port)
49

    
50
SQUID_TIME_HTTP=$(echo "$SQUID_TIME" | grep "HTTP Requests (All)" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
51
SQUID_TIME_CACHE_MISSES=$(echo "$SQUID_TIME" | grep "Cache Misses" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
52
SQUID_TIME_CACHE_HITS=$(echo "$SQUID_TIME" | grep "Cache Hits" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
53
SQUID_TIME_NEAR_HITS=$(echo "$SQUID_TIME" | grep "Near Hits" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
54
SQUID_TIME_NM_REPLIES=$(echo "$SQUID_TIME" | grep "Not-Modified Replies" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
55
SQUID_TIME_DNS_LOOKUPS=$(echo "$SQUID_TIME" | grep "DNS Lookups" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
56
SQUID_TIME_ICP_QUERIES=$(echo "$SQUID_TIME" | grep "ICP Queries" | cut -d':' -f2 | sed -e "s/^\ *//" | cut -d' ' -f1)
57

    
58
echo "mean_http.value $SQUID_TIME_HTTP"
59
echo "mean_cmis.value $SQUID_TIME_CACHE_MISSES"
60
echo "mean_chits.value $SQUID_TIME_CACHE_HITS" 
61
echo "mean_nhits.value $SQUID_TIME_NEAR_HITS"
62
echo "mean_nmr.value $SQUID_TIME_NM_REPLIES"
63
echo "mean_dnsl.value $SQUID_TIME_DNS_LOOKUPS"
64
echo "mean_icpq.value $SQUID_TIME_ICP_QUERIES"
65