pandorafms/pandora_console/operation/servers/recon_view.php

183 lines
5.7 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 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 General Public License
// as published by the Free Software Foundation for 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.
// Load global vars
global $config;
check_login ();
if (! check_acl ($config['id_user'], 0, "PM")) {
db_pandora_audit("ACL Violation",
"Trying to access recon task viewer");
require ("general/noaccess.php");
return;
}
//Get all recon servers
$servers = db_get_all_rows_sql('SELECT * FROM tserver WHERE server_type = 3');
if ($servers === false) {
$servers = array ();
return;
}
2015-06-08 09:32:01 +02:00
else {
$recon_task = db_get_all_rows_sql('SELECT * FROM trecon_task');
if ($recon_task === false) {
ui_print_page_header (__('Recon View'), "images/op_recon.png", false, "", false);
require_once ($config['homedir'] . "/general/firts_task/recon_view.php");
return;
}
2015-06-08 09:32:01 +02:00
else {
require_once ($config["homedir"] . '/include/functions_graph.php');
require_once ($config["homedir"] . '/include/functions_servers.php');
require_once ($config['homedir'] . "/include/functions_network_profiles.php");
2015-06-08 09:32:01 +02:00
if (check_acl ($config['id_user'], 0, "AW")) {
$options['manage']['text'] = "<a href='index.php?sec=estado&sec2=godmode/servers/manage_recontask'>" . html_print_image("images/setup.png", true, array('title' => __('Manage'))) . "</a>";
}
2015-06-08 09:32:01 +02:00
$options[]['text'] = "<a href='index.php?sec=estado&sec2=operation/servers/recon_view'>" . html_print_image("images/refresh_mc.png", true, array('title' => __('Refresh'))) . "</a>";
2015-06-08 09:32:01 +02:00
ui_print_page_header (__('Recon View'), "images/op_recon.png", false, "", false, $options);
2015-06-08 09:32:01 +02:00
$modules_server = 0;
$total_modules = 0;
$total_modules_data = 0;
2015-06-08 09:32:01 +02:00
// --------------------------------
// FORCE A RECON TASK
// --------------------------------
if (check_acl ($config['id_user'], 0, "PM")) {
if (isset ($_GET["force"])) {
$id = (int) get_parameter_get ("force", 0);
servers_force_recon_task($id);
}
}
2015-06-08 09:32:01 +02:00
foreach ($servers as $serverItem) {
$id_server = $serverItem["id_server"];
$server_name = servers_get_name ($id_server);
$recon_tasks = db_get_all_rows_field_filter ("trecon_task", "id_recon_server", $id_server);
2015-06-08 09:32:01 +02:00
// Show network tasks for Recon Server
if ($recon_tasks === false) {
$recon_tasks = array ();
}
2015-06-08 09:32:01 +02:00
2015-06-25 10:07:53 +02:00
$table = new StdClass();
$table->cellpadding = 4;
$table->cellspacing = 4;
2015-06-12 15:50:46 +02:00
$table->width = "100%";
$table->class = "databox data";
$table->head = array ();
$table->data = array ();
$table->align = array ();
2015-06-08 09:32:01 +02:00
$table->head[0] = __('Force');
2015-06-12 15:50:46 +02:00
$table->align[0] = "left";
2015-06-08 09:32:01 +02:00
$table->head[1] = __('Task name');
2015-06-12 15:50:46 +02:00
$table->align[1] = "left";
2015-06-08 09:32:01 +02:00
$table->head[2] = __('Interval');
2015-06-12 15:50:46 +02:00
$table->align[2] = "left";
2015-06-08 09:32:01 +02:00
$table->head[3] = __('Network');
2015-06-12 15:50:46 +02:00
$table->align[3] = "left";
2015-06-08 09:32:01 +02:00
$table->head[4] = __('Status');
2015-06-12 15:50:46 +02:00
$table->align[4] = "left";
2015-06-08 09:32:01 +02:00
$table->head[5] = __('Template');
2015-06-12 15:50:46 +02:00
$table->align[5] = "left";
2015-06-08 09:32:01 +02:00
$table->head[6] = __('Progress');
2015-06-12 15:50:46 +02:00
$table->align[6] = "left";
2015-06-08 09:32:01 +02:00
$table->head[7] = __('Updated at');
2015-06-12 15:50:46 +02:00
$table->align[7] = "left";
2015-06-08 09:32:01 +02:00
$table->head[8] = __('Edit');
2015-06-12 15:50:46 +02:00
$table->align[8] = "left";
2015-06-08 09:32:01 +02:00
foreach ($recon_tasks as $task) {
$data = array ();
if($task["disabled"] == 0) {
$data[0] = '<a href="index.php?sec=estado&amp;sec2=operation/servers/recon_view&amp;server_id='.$id_server.'&amp;force='.$task["id_rt"].'">';
$data[0] .= html_print_image ("images/target.png", true, array ("title" => __('Force')));
$data[0] .= '</a>';
}
else {
$data[0] = '';
}
$data[1] = '<b>'. $task["name"].'</b>';
2015-06-08 09:32:01 +02:00
$data[2] = human_time_description_raw ($task["interval_sweep"]);
2015-06-08 09:32:01 +02:00
2015-06-08 11:05:19 +02:00
if ($task["id_recon_script"] == 0) {
$data[3] = $task["subnet"];
}
else {
$data[3] = "-";
}
if ($task["status"] <= 0) {
$data[4] = __('Done');
}
else {
$data[4] = __('Pending');
}
2015-06-08 09:32:01 +02:00
2015-06-08 11:05:19 +02:00
if ($task["id_recon_script"] == 0) {
// Network recon task
$data[5] = html_print_image ("images/network.png", true, array ("title" => __('Network recon task')))."&nbsp;&nbsp;";
$data[5] .= network_profiles_get_name ($task["id_network_profile"]);
}
else {
// APP recon task
$data[5] = html_print_image ("images/plugin.png", true). "&nbsp;&nbsp;";
$data[5] .= db_get_sql (sprintf("SELECT name FROM trecon_script WHERE id_recon_script = %d", $task["id_recon_script"]));
}
2015-06-08 09:32:01 +02:00
if ($task["status"] <= 0 || $task["status"] > 100) {
$data[6] = "-";
}
else {
$data[6] = progress_bar($task['status'], 100, 20, __('Progress').':'.$task["status"].'%', 1);
}
$data[7] = ui_print_timestamp ($task["utimestamp"], true);
2015-06-08 09:32:01 +02:00
if (check_acl ($config["id_user"], $task["id_group"], "PM")) {
$data[8] = '<a href="index.php?sec=gservers&amp;sec2=godmode/servers/manage_recontask_form&amp;update='.$task["id_rt"].'">'.html_print_image ("images/wrench_orange.png", true).'</a>';
}
else {
$data[8] = '';
}
array_push ($table->data, $data);
}
2015-06-08 09:32:01 +02:00
if (empty ($table->data)) {
echo '<div class="nf">'.__("Server") . " " . $server_name . " " . __("has no recon tasks assigned").'</div>';
}
else {
html_print_table ($table);
}
unset ($table);
}
}
}
?>