" . __('The agent hasn\'t got IP') . "";
return;
}
echo "
";
echo "
";
$operation = get_parameter ("operation", 0);
$community = get_parameter ("community", "public");
switch($operation) {
case 1:
$traceroute = whereis_the_command ('traceroute');
if (empty($traceroute)) {
ui_print_error_message(__('Traceroute executable does not exist.'));
}
else {
echo "
".__("Traceroute to "). $ip. "
";
echo "
";
echo system ("$traceroute $ip");
echo "
";
}
break;
case 2:
$ping = whereis_the_command ('ping');
if (empty($ping)) {
ui_print_error_message(__('Ping executable does not exist.'));
}
else {
echo "
".__("Ping to "). $ip. "
";
echo "
";
echo system ("$ping -c 5 $ip");
echo "
";
}
break;
case 4:
$nmap = whereis_the_command ('nmap');
if (empty($nmap)) {
ui_print_error_message(__('Nmap executable does not exist.'));
}
else {
echo "
".__("Basic TCP Scan on "). $ip. "
";
echo "
";
echo system ("$nmap -F $ip");
echo "
";
}
break;
case 5:
echo "
".__("Domain and IP information for "). $ip. "
";
$dig = whereis_the_command ('dig');
if (empty($dig)) {
ui_print_error_message(__('Dig executable does not exist.'));
}
else {
echo "
";
echo system ("dig $ip");
echo "
";
}
$whois = whereis_the_command ('whois');
if (empty($whois)) {
ui_print_error_message(__('Whois executable does not exist.'));
}
else {
echo "
";
echo system ("whois $ip");
echo "
";
}
break;
case 3:
echo "
".__("SNMP information for "). $ip. "
";
$snmpget = whereis_the_command ('snmpget');
if (empty($snmpget)) {
ui_print_error_message(__('SNMPget executable does not exist.'));
}
else {
echo "
" . __("Uptime") . "
";
echo "
";
echo exec ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
echo "
";
echo "
" . __("Device info") . "
";
echo "
";
echo system ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.1.0 ");
echo "
";
echo "
Interface Information
";
echo "
";
echo "".__("Interface");
echo " | ".__("Status");
$int_max = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.1.0 ");
for ($ax=0; $ax < $int_max; $ax++) {
$interface = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.2.$ax ");
$estado = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.8.$ax ");
echo " |
---|
$interface | $estado";
}
echo " |
";
}
break;
}
echo "
";
}
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 '