Projet

Général

Profil

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

root / plugins / nscd / nscd_ @ 17f78427

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

1
#!/usr/bin/env bash
2

    
3
# nscd (name server caching daemon) statistics
4
#
5
# Tested with nscd 2.13 on Debian 7.8
6
#
7
# This plugin is capable to show:
8
# - per-database (passwd, group, hosts, services):
9
#     - Suggested size
10
#     - Cache hit rate
11
#     - Number of currently cached values
12
#     - Number of max cached values
13
#
14
# Required permissions:
15
# - root permissions to run "nscd -g"
16
#
17
# OS: *NIX
18
#
19
# Author: Oliver Ladner <waste@lugh.ch>
20
#
21
# Configuration:
22
# - set env.nscd_cfg to nscd.conf path if necessary
23
# - Configure to run as root in /etc/munin/plugin-conf.d/munin-node
24
#   [nscd_*]
25
#    user root
26
#
27
# Notes:
28
#
29
# A low cache hit rate in combination with a shared cache configuration is
30
# normal, as clients can search the cache directly without asking the nscd
31
# daemon first. See http://goo.gl/dkwzDH
32

    
33
#%# family=auto
34
#%# capabilities=autoconf suggest
35

    
36
source $MUNIN_LIBDIR/plugins/plugin.sh
37
NSCD_CFG=${nscd_cfg:-/etc/nscd.conf}
38
AUTOCONF_CHECK=$(nscd -g | grep -ic 'yes.*cache is enabled')
39
SUGGEST_CHECK=$(nscd -g | grep -iB2 'yes.*cache is enabled' | awk {'print $1'} | head -1)
40
MODE=$(basename $0 | sed 's/^nscd_//g' | tr '_' '.')
41

    
42
case $1 in
43
	autoconf)
44
		[ -r "$NSCD_CFG" ] && [ $AUTOCONF_CHECK -gt 0 ] && echo yes || echo "no (nscd config not found or no database enabled)"
45
		exit 0
46
		;;
47
	suggest)
48
		echo $SUGGEST_CHECK
49
		exit 0
50
		;;
51
	config)
52
		# --lower-limit needs to be > 0 for logarithmic scaling
53
		cat <<CONFIG
54
graph_args --base 1000  --lower-limit 0
55
graph_scale yes
56
graph_title nscd - ${MODE//_/ } cache
57
graph_info This graph shows nscd $MODE statistics
58
graph_vlabel % or count
59
suggestedsize.label Suggested size
60
cachehitrate.label Cache hit rate in %
61
cachehitrate.info A low cache hit rate in combination with a shared cache configuration is normal, as clients can search the cache directly without asking the nscd daemon first
62
currnumber.label Current number of cached values
63
maxnumber.label Maximum number of cached values
64
graph_category system
65
CONFIG
66
		;;
67
	fetch|*)
68
			nscd -g | awk "/^$MODE cache/ {printline = 1; print; next} /^.*cache:/ {printline = 0} printline" | \
69
			egrep '(suggested size|cache hit rate|current number of cached values|maximum number of cached values)' | \
70
			sed 's/%//' | awk {' if (NR==1) print "suggestedsize.value " $1; if (NR==2) print "cachehitrate.value " $1; if (NR==3) print "currnumber.value " $1; if (NR==4) print "maxnumber.value " $1'}
71
		;;
72
esac