pandorafms/pandora_console/include/functions_snmp.php
mdtrooper 2d7ccc0c15 2013-06-13 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_snmp.php: changed the PHP function to execute
	command and now get the error string or return true if it runs fine.
	
	* godmode/snmpconsole/snmp_trap_generator.php: show the error when
	fail to call snmptrap, and show error when occurs.
	
	Fixes: #2270
	
	MERGED FROM THE BRANCH PANDORA_4.0




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8318 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-06-13 14:27:18 +00:00

42 lines
1.2 KiB
PHP

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// 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.
/**
* Generates a trap
*
* @param string Destiny host address.
* @param string Snmp community.
* @param string Snmp OID.
* @param string Snmp agent.
* @param string Data of the trap.
* @param string Snmp especific OID.
*/
function snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_data, $snmp_type) {
$command = "snmptrap -v 1 -c $snmp_community $snmp_host_address $snmp_oid $snmp_agent $snmp_type $snmp_data 0 2>&1";
$output = null;
exec($command, $output, $return);
if ($return == 0) {
return true;
}
else {
return implode(' ', $output);
}
}
?>