[Linux实用工具]munin-node插件配置和插件编写
前面介绍了2篇munin使用的相关文章:
插件配置
ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes ln -s /usr/share/munin/plugins/mysql_innodb /etc/munin/plugins/mysql_innodb
service munin-node restart
插件编写
munin-node 提供的插件实例
#!/bin/sh # -*- sh -*- # vim: ft=sh if [ "$1" = "autoconf" ]; then grep -q ‘^Threads‘ /proc/$$/status && echo "yes" || echo "no" exit 0 fi if [ "$1" = "config" ]; then echo ‘graph_title Number of threads‘ #echo ‘graph_args --base 1000 -l 0 ‘ echo ‘graph_vlabel number of threads‘ echo ‘graph_category processes‘ echo ‘graph_info This graph shows the number of threads.‘ echo ‘threads.label threads‘ echo ‘threads.info The current number of threads.‘ exit 0 fi grep -s ‘^Threads‘ /proc/[0-9]*/status | awk ‘{ sum += $2; } END { print "threads.value", sum; }‘
参数说明
自定义插件
#!/bin/sh keyword=munin-node case $1 in (config) cat <<‘EOM‘ graph_title MY_TITLE graph_vlabel (%) graph_args --base 1000 -l 0 graph_scale no graph_category MY_CATEGORY EOM ps aux | grep $keyword | grep -v grep | awk ‘{print $3,$4}‘ | while read cpu mem do echo "CPU.label %CPU" echo "CPU.warning 200" echo "CPU.critical 400" echo "CPU.value $cpu" echo "MEM.label %MEM" echo "MEM.warning 20" echo "MEM.critical 50" echo "MEM.value $mem" done exit 0;; esac ps aux | grep $keyword | grep -v grep | awk ‘{print $3,$4}‘ | while read cpu mem do echo "CPU.value $cpu" echo "MEM.value $mem" done
# cat munin_info [munin-node_cpu] user root
开始使用独立博客了,原文地址在这里:
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。