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
This commit is contained in:
parent
233963865f
commit
2d7ccc0c15
|
@ -1,3 +1,15 @@
|
|||
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
|
||||
|
||||
2013-06-13 Mario Pulido <mario.pulido@artica.es>
|
||||
|
||||
* images/help/actions.png,
|
||||
|
|
|
@ -36,18 +36,25 @@ $generate_trap = (bool) get_parameter ("generate_trap", 0);
|
|||
|
||||
ui_print_page_header (__("SNMP Trap generator"), "images/op_snmp.png", false, "", false);
|
||||
|
||||
if($generate_trap) {
|
||||
if ($generate_trap) {
|
||||
$result = true;
|
||||
if($snmp_host_address != '' && $snmp_community != '' && $snmp_oid != '' && $snmp_agent != '' && $snmp_value != '' && $snmp_type != -1) {
|
||||
snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_value, $snmp_type);
|
||||
$error = '';
|
||||
if ($snmp_host_address != '' && $snmp_community != '' && $snmp_oid != '' && $snmp_agent != '' && $snmp_value != '' && $snmp_type != -1) {
|
||||
$result = snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_value, $snmp_type);
|
||||
|
||||
if ($result !== true) {
|
||||
$error = $result;
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$error = __('Empty parameters');
|
||||
$result = false;
|
||||
}
|
||||
|
||||
ui_print_result_message ($result,
|
||||
__('Successfully generated'),
|
||||
__('Could not be generated'));
|
||||
__('Successfully generated'),
|
||||
sprintf(__('Could not be generated: %s'), $error));
|
||||
}
|
||||
|
||||
$traps_generator = '<form method="POST" action="index.php?sec=snmpconsole&sec2=godmode/snmpconsole/snmp_trap_generator">';
|
||||
|
|
|
@ -25,7 +25,17 @@
|
|||
* @param string Snmp especific OID.
|
||||
*/
|
||||
function snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_data, $snmp_type) {
|
||||
system("snmptrap -v 1 -c $snmp_community $snmp_host_address $snmp_oid $snmp_agent $snmp_type $snmp_data 0");
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue