2013-05-20 Miguel de Dios <miguel.dedios@artica.es>
* extensions/net_tools.php: added a entry to godmode for set the paths of commands. Fixes: #2220 * include/functions_config.php, include/functions_extensions.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8161 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
1a11c002cb
commit
c04b50ea5b
|
@ -1,3 +1,13 @@
|
|||
2013-05-20 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extensions/net_tools.php: added a entry to godmode for set the
|
||||
paths of commands.
|
||||
|
||||
Fixes: #2220
|
||||
|
||||
* include/functions_config.php, include/functions_extensions.php:
|
||||
cleaned source code style.
|
||||
|
||||
2013-05-20 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_html.php
|
||||
|
|
|
@ -19,11 +19,46 @@ $id_agente = get_parameter ("id_agente");
|
|||
// This extension is usefull only if the agent has associated IP
|
||||
$address = agents_get_address($id_agente);
|
||||
|
||||
if(!empty($address) || empty($id_agente)) {
|
||||
if (!empty($address) || empty($id_agente)) {
|
||||
extensions_add_opemode_tab_agent ('network_tools','Network Tools','extensions/net_tools/nettool.png',"main_net_tools", "v1r1");
|
||||
}
|
||||
|
||||
function whereis_the_command ($command) {
|
||||
global $config;
|
||||
|
||||
if (isset($config['network_tools_config'])) {
|
||||
$network_tools_config = json_decode($config['network_tools_config'], true);
|
||||
$traceroute_path = $network_tools_config['traceroute_path'];
|
||||
$ping_path = $network_tools_config['ping_path'];
|
||||
$nmap_path = $network_tools_config['nmap_path'];
|
||||
$dig_path = $network_tools_config['dig_path'];
|
||||
$snmpget_path = $network_tools_config['snmpget_path'];
|
||||
|
||||
switch ($command) {
|
||||
case 'traceroute':
|
||||
if (!empty($traceroute_path))
|
||||
return $traceroute_path;
|
||||
break;
|
||||
case 'ping':
|
||||
if (!empty($ping_path))
|
||||
return $ping_path;
|
||||
break;
|
||||
case 'nmap':
|
||||
if (!empty($nmap_path))
|
||||
return $nmap_path;
|
||||
break;
|
||||
case 'dig':
|
||||
if (!empty($dig_path))
|
||||
return $dig_path;
|
||||
break;
|
||||
case 'snmpget':
|
||||
if (!empty($snmpget_path))
|
||||
return $snmpget_path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ob_start();
|
||||
system('whereis '. $command);
|
||||
|
@ -58,13 +93,14 @@ function main_net_tools () {
|
|||
echo "<table class=databox width=650>";
|
||||
echo "<tr><td>";
|
||||
echo __("Operation");
|
||||
ui_print_help_tip(__('You can set the command path in the menu Administration -> Extensions -> Config Network Tools'));
|
||||
echo "<td>";
|
||||
echo "<select name='operation'>";
|
||||
echo "<option value=1>".__("Traceroute");
|
||||
echo "<option value=2>".__("Ping host & Latency");
|
||||
echo "<option value=3>".__("SNMP Interface status");
|
||||
echo "<option value=4>".__("Basic TCP Port Scan");
|
||||
echo "<option value=5>".__("DiG/Whois Lookup");
|
||||
echo "<option value='1'>" . __("Traceroute");
|
||||
echo "<option value='2'>" . __("Ping host & Latency");
|
||||
echo "<option value='3'>" . __("SNMP Interface status");
|
||||
echo "<option value='4'>" . __("Basic TCP Port Scan");
|
||||
echo "<option value='5'>" . __("DiG/Whois Lookup");
|
||||
echo "</select>";
|
||||
echo "<td>";
|
||||
echo __("SNMP Community");
|
||||
|
@ -76,8 +112,8 @@ function main_net_tools () {
|
|||
echo "</form>";
|
||||
|
||||
|
||||
$operation = get_parameter ("operation",0);
|
||||
$community = get_parameter ("community","public");
|
||||
$operation = get_parameter ("operation", 0);
|
||||
$community = get_parameter ("community", "public");
|
||||
|
||||
switch($operation) {
|
||||
case 1:
|
||||
|
@ -176,4 +212,84 @@ function main_net_tools () {
|
|||
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
function godmode_net_tools() {
|
||||
global $config;
|
||||
|
||||
ui_print_page_header (__('Config Network Tools'));
|
||||
|
||||
$update_traceroute = (bool)get_parameter('update_traceroute', 0);
|
||||
|
||||
$traceroute_path = (string)get_parameter('traceroute_path', '');
|
||||
$ping_path = (string)get_parameter('ping_path', '');
|
||||
$nmap_path = (string)get_parameter('nmap_path', '');
|
||||
$dig_path = (string)get_parameter('dig_path', '');
|
||||
$snmpget_path = (string)get_parameter('snmpget_path', '');
|
||||
|
||||
|
||||
if ($update_traceroute) {
|
||||
$network_tools_config = array();
|
||||
$network_tools_config['traceroute_path'] = $traceroute_path;
|
||||
$network_tools_config['ping_path'] = $ping_path;
|
||||
$network_tools_config['nmap_path'] = $nmap_path;
|
||||
$network_tools_config['dig_path'] = $dig_path;
|
||||
$network_tools_config['snmpget_path'] = $snmpget_path;
|
||||
|
||||
$result = config_update_value('network_tools_config', json_encode($network_tools_config));
|
||||
|
||||
ui_print_result_message($result, __('Set the paths.'),
|
||||
__('Set the paths.'));
|
||||
}
|
||||
else {
|
||||
|
||||
if (isset($config['network_tools_config'])) {
|
||||
$network_tools_config = json_decode($config['network_tools_config'], true);
|
||||
$traceroute_path = $network_tools_config['traceroute_path'];
|
||||
$ping_path = $network_tools_config['ping_path'];
|
||||
$nmap_path = $network_tools_config['nmap_path'];
|
||||
$dig_path = $network_tools_config['dig_path'];
|
||||
$snmpget_path = $network_tools_config['snmpget_path'];
|
||||
}
|
||||
}
|
||||
|
||||
$table = null;
|
||||
$table->width = "80%";
|
||||
|
||||
$table->data = array();
|
||||
|
||||
$table->data[0][0] = __("Traceroute path");
|
||||
$table->data[0][0] .= ui_print_help_tip(__('If it is empty, Pandora searchs the traceroute system.'), true);
|
||||
$table->data[0][1] = html_print_input_text('traceroute_path', $traceroute_path, '', 40, 255, true);
|
||||
|
||||
$table->data[1][0] = __("Ping path");
|
||||
$table->data[1][0] .= ui_print_help_tip(__('If it is empty, Pandora searchs the ping system.'), true);
|
||||
$table->data[1][1] = html_print_input_text('ping_path', $ping_path, '', 40, 255, true);
|
||||
|
||||
$table->data[2][0] = __("Nmap path");
|
||||
$table->data[2][0] .= ui_print_help_tip(__('If it is empty, Pandora searchs the nmap system.'), true);
|
||||
$table->data[2][1] = html_print_input_text('nmap_path', $nmap_path, '', 40, 255, true);
|
||||
|
||||
$table->data[3][0] = __("Dig path");
|
||||
$table->data[3][0] .= ui_print_help_tip(__('If it is empty, Pandora searchs the dig system.'), true);
|
||||
$table->data[3][1] = html_print_input_text('dig_path', $dig_path, '', 40, 255, true);
|
||||
|
||||
$table->data[4][0] = __("Snmpget path");
|
||||
$table->data[4][0] .= ui_print_help_tip(__('If it is empty, Pandora searchs the snmpget system.'), true);
|
||||
$table->data[4][1] = html_print_input_text('snmpget_path', $snmpget_path, '', 40, 255, true);
|
||||
|
||||
echo '<form id="form_setup" method="post" >';
|
||||
echo "<fieldset>";
|
||||
echo "<legend>" . __('Options') . "</legend>";
|
||||
html_print_input_hidden('update_traceroute', 1);
|
||||
html_print_table($table);
|
||||
echo "</fieldset>";
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
extensions_add_godmode_menu_option (__('Config Network Tools'), 'PM');
|
||||
extensions_add_godmode_function ('godmode_net_tools');
|
||||
?>
|
||||
|
|
|
@ -77,7 +77,7 @@ function config_update_config () {
|
|||
|
||||
// Include functions_io to can call __() function
|
||||
include_once($config['homedir'] . '/include/functions_io.php');
|
||||
|
||||
|
||||
/* If user is not even log it, don't try this */
|
||||
if (! isset ($config['id_user'])) {
|
||||
$config['error_config_update_config'] = array();
|
||||
|
|
|
@ -285,7 +285,7 @@ function extensions_load_extensions ($extensions) {
|
|||
|
||||
foreach ($extensions as $extension) {
|
||||
$extension_file = $extension['file'];
|
||||
require_once (realpath ($extension['dir']."/".$extension_file));
|
||||
require_once (realpath ($extension['dir'] . "/" . $extension_file));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue