Monitorizar puntos de montaje nfs con munin

18 01 2012

Par monitorizar los punto de montaje nfs en un servidor podemos utilizar los siguientes plugins que he desarrollado:

Primero colocamos un script para el init llamado /etc/init.d/nfs-iostat :

#!/bin/sh
### BEGIN INIT INFO
# Provides: nfs-iostat
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop nfs iostat monitor
### END INIT INFO
CLT_BIN=/usr/local/bin/iostat.sh
case "$1" in
start)
echo "Iniciando nfs iostat monitor..."
$CLT_BIN start
;;
stop)
echo "Parando nfs iostat monitor..."
killall iostat
;;
restart)
$0 stop
sleep 5
$0 start
;;
status)
if pidof -o %PPID iostat > /dev/null; then
echo "Nfs monitor iniciado."
exit 0
else
echo "Nfs monitor Parado."
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
Instalándolo con “# update-rc.d nfs-iostat defaults”

Ponemos una línea en el cron para limpiar el log:
00 00 * * * echo "" > /var/log/iostat.log; chmod ugo+r /var/log/iostat.log

Creamos el archivo /usr/local/bin/iostat.sh :
#!/bin/bash
nohup iostat -nk 300 > /var/log/iostat.log 2> /dev/null &

Creamos los archivos de los plugins en /etc/munin/plugins/:
nfs_iostat_ops:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $8} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_rkB_dir:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $4} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_rkB_nor:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $2} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_rkB_svr:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $6} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_rops:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $9} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_wkB_dir:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $5} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_wkB_nor:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $3} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_wkB_svr:

echo "no (/proc/stat not readable)"
exit 0
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title kB written by the NFS client via NFS WRITE request.'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel kB / sec'
echo 'graph_scale no'
echo 'graph_category disk'
echo 'graph_info Indicate the number of kilobytes written from the server by the NFS client via an NFS WRITE request.'
# cat a | grep -A 500 Filesystem a | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
# if (echo $Line | grep "/" >> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $7} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

nfs_iostat_wops:
#!/bin/sh
# -*- sh -*-
: <> /dev/null); then
NAME=`echo "$Line" | awk '{print $1} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.label $NAME"
echo "$HASH.type GAUGE"
echo "$HASH.min 0"
echo "$HASH.info I/O on nfs"
# fi
done
exit 0
fi
tac $LOG | grep -m1 Filesystem -B 50 | grep -v Filesystem | sed '/^ *$/d' | while read Line; do
VALUE=`echo "$Line" | awk '{print $10} '`
HASH=`echo "$Line" | awk '{print $1} ' | md5sum | cut -d - -f1 | sed 's/ //g'`
echo "$HASH.value $VALUE"
done

Por último, añadir al final de “/etc/munin/plugin-conf.d/munin-node”:
[nfs_iostat*]
user root

Reiniciar munin y ya debería funcionar, tal que así:

munin nfs monitor

Advertisements

Actions

Information

One response

18 01 2012
Monitorizar puntos de montaje nfs con munin « sanchezdiego.com.ar

[…] El Hombre que Reventó de Informaciónhttps://elhombrequereventodeinformacion.wordpress.com/2012/01/18/monitorizar-puntos-de-montaje-nfs-co… Boludeces « Wikipedia inició un “apagón” histórico    Favoritos en […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: