User Tools

Site Tools


munin_plugins

Munin Plugins

#!/bin/sh
 
##############################
# Show Munin our config
config() {
	magento=$(printenv | grep '^\magento_' | cut -d= -f1)
	set -- junk $magento
	shift
	for site; do
		var=${site}
		echo "multigraph ${var}"
		name=$(echo ${var} | rev | cut -d'_' -f 1 | rev)
 
		echo "graph_title ${name} Load Time"
		echo "graph_category magento "
		load=$(printenv ${var} | tr ";" "\n")
		set -- junk $load
		shift
		for site; do
			graph=($(echo ${site} | tr "|" "\n"))
			line=${graph[0],,}
			echo "${line}.label ${graph[0]}"
		done
	done
}
 
##############################
# Gather information and print it out for Munin
values() {
	magento=$(printenv | grep '^\magento_' | cut -d= -f1)
	set -- junk $magento
	shift
	for site; do
		var=${site}
		printf "multigraph ${var}\n"
		load=$(printenv ${var} | tr ";" "\n")
		set -- junk $load
		shift
		for site; do
			graph=($(echo ${site} | tr "|" "\n"))
			line=${graph[0],,}
			printf "${line}.value "
			#curl -o /dev/null -s -w %{time_total}\\n  ${graph[1]}
			wget=$((LC_ALL=E time -p wget --page-requisites --delete-after ${graph[1]})  2>&1 > /dev/null |grep real | sed 's/*.real//' | tr -d 'real ')
			echo "${wget}0"
		done	
	done
}
 
##############################
# Main
case $1 in
    config)
        config
        ;;
    autoconf)
        autoconf
        ;;
    *)
        values
        ;;
esac
munin_plugins.txt · Last modified: 2015/01/26 12:18 by admin