%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/src/publicnginx/
Upload File :
Create Path :
Current File : //usr/local/src/publicnginx/muninpatch

#!/bin/bash


function add_munin_patch {
	if [ -f /etc/munin/plugin-conf.d/cpanel.conf ]; then
		echo ""
		echo "=== Updating Munin configuration ==="

		if grep -q "\[apache_status\]" /etc/munin/plugin-conf.d/cpanel.conf
		then
			echo "Munin patched already, nothing to do here"
		else
			cat >> "/etc/munin/plugin-conf.d/cpanel.conf" <<EOF

[apache_status]
env.ports 8081
env.label 8081

EOF
		fi

		ln -s /usr/local/cpanel/3rdparty/share/munin/plugins/nginx_request /etc/munin/plugins/nginx_request
		ln -s /usr/local/cpanel/3rdparty/share/munin/plugins/nginx_status /etc/munin/plugins/nginx_status

		sleep 10
		service munin-node restart
	fi
}

function remove_munin_patch {
	if [ -f /etc/munin/plugin-conf.d/cpanel.conf ]; then
		echo ""
		echo "=== Updating Munin configuration ==="

		if grep -q "\[apache_status\]" /etc/munin/plugin-conf.d/cpanel.conf
		then
			sed -i 's:\[apache_status\]::' /etc/munin/plugin-conf.d/cpanel.conf
			sed -i 's:env\.ports 8081::' /etc/munin/plugin-conf.d/cpanel.conf
			sed -i 's:env\.label 8081::' /etc/munin/plugin-conf.d/cpanel.conf
		else
			
			echo -e "\033[35;1m Munin not installed or not Pached, nothing to do here \033[0m"
		fi

		rm -f /etc/munin/plugins/nginx_request
		rm -f /etc/munin/plugins/nginx_status

		service munin-node restart
	fi
}



### Define actions ###
case $1 in
install)

	echo ""
	echo " ****************************************************"
	echo " *               Paching Munin                      *"
	echo " ****************************************************"

	add_munin_patch


	echo " ****************************************************"
	echo " *               Munin Pached                       *"
	echo " ****************************************************"
	echo ""
		;;
remove)


	remove_munin_patch

	echo ""
	echo " ****************************************************"
	echo " *         Munin Patch Removal Complete             *"
	echo " ****************************************************"
	echo ""
	;;

*)
	echo ""
	echo -e "\033[35;1m Please define an action: install | remove \033[0m"
	echo ""
	;;
esac

Zerion Mini Shell 1.0