Monitoring Yate with Munin

From Yate Documentation
Revision as of 12:42, 15 August 2013 by Monica (Talk | contribs)

Jump to: navigation, search

Yate can be monitored with Munin.

In order for this to work, you simply need to install the following plugin.

#!/usr/bin/php -q
<?php /*
#
# Copyright (C) 2007 alloDom <gnu at allodom.fr>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# If you improve this script please send your version to my email address
# with the copyright notice upgrade with your name.
#
# $Log$
# Version 1.0  2004/04/27  Julien Tessier
# Initial release.
#
#%# family=voip
#%# capabilities=autoconf
*/
 
	$modules = array(
		"yrtp",
		"sip",
		"iax",
		"h323"
	);
 
	if (isset($argv[1]) && $argv[1] == "autoconf") {
	        echo "yes\n";
		exit;
	}

	if (isset($argv[1]) && $argv[1] == "config") {
	        echo "graph_title Yate active channels\n";
        	echo "graph_args --base 1000 -l 0\n";
        	echo "graph_vlabel active channels\n";
	        echo "graph_category voip\n";
	        echo "graph_info This graph shows the current channels used in Yate."; 
	        echo "It can't show peeks since update is done every 5 minutes.\n";
		foreach ($modules as $module) {
	        	echo "$module.label ".strtoupper($module)."\n";
 	        	echo "$module.info ".strtoupper($module)." channels\n";
		}
		exit;
	}

	$fp = fsockopen("127.0.0.1", 5038, $errno, $errstr, 30);
	if ($fp) {
		$content = "";
		do {
        		$content .= @fgets($fp, 1024);
		} while (strpos($content, "ready.") === false);
		fwrite($fp, "status\n");
		do {
        		$content .= @fgets($fp, 1024);
		} while (strpos($content, "%%-status") === false);
		fclose($fp);
		foreach ($modules as $module) {
			$start = strpos($content, "name=$module");
			if ($start !== false) {
				$part = substr($content, $start);
				$part = substr($part, strpos($part, "chans=")+6);
				$part = intval($part);
				echo "$module.value $part\n";
			}
		}
	}
?>
Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers