From 397100426e7913363c8c879d25e6ca39dc8fdf67 Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Wed, 14 Jan 2015 11:23:54 +0100 Subject: [PATCH] Added nscd plugin --- plugins/nscd/nscd_ | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 plugins/nscd/nscd_ diff --git a/plugins/nscd/nscd_ b/plugins/nscd/nscd_ new file mode 100755 index 00000000..a6e8877b --- /dev/null +++ b/plugins/nscd/nscd_ @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# nscd (name server caching daemon) statistics +# +# Tested with nscd 2.13 on Debian 7.8 +# +# This plugin is capable to show: +# - per-database (passwd, group, hosts, services): +# - Suggested size +# - Cache hit rate +# - Number of currently cached values +# - Number of max cached values +# +# Required permissions: +# - root permissions to run "nscd -g" +# +# OS: *NIX +# +# Author: Oliver Ladner +# +# Configuration: +# - set env.nscd_cfg to nscd.conf path if necessary +# - Configure to run as root in /etc/munin/plugin-conf.d/munin-node +# [nscd_*] +# user root +# +# Notes: +# +# 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. See http://goo.gl/dkwzDH + +#%# family=auto +#%# capabilities=autoconf suggest + +source $MUNIN_LIBDIR/plugins/plugin.sh +NSCD_CFG=${nscd_cfg:-/etc/nscd.conf} +AUTOCONF_CHECK=$(nscd -g | grep -ic 'yes.*cache is enabled') +SUGGEST_CHECK=$(nscd -g | grep -iB2 'yes.*cache is enabled' | awk {'print $1'} | head -1) +MODE=$(basename $0 | sed 's/^nscd_//g' | tr '_' '.') + +case $1 in + autoconf) + [ -r "$NSCD_CFG" ] && [ $AUTOCONF_CHECK -gt 0 ] && echo yes || echo "no (nscd config not found or no database enabled)" + exit 0 + ;; + suggest) + echo $SUGGEST_CHECK + exit 0 + ;; + config) + # --lower-limit needs to be > 0 for logarithmic scaling + cat <