";
echo "
" . $label;
echo " | ";
echo "" . $data;
echo " | ";
echo "";
}
}
$console_mode = 1;
if (!isset($argc))
$console_mode = 0;
if ($console_mode == 1) {
echo "\nPandora FMS PHP diagnostic tool v3.2 (c) Artica ST 2009-2010 \n";
if ($argc == 1 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
echo "\nThis command line script gives information about Pandora FMS database.
This program only can be executed from console, and need a parameter, the
full path to Pandora FMS 'config.php' file.
Usage:
php pandora_diag.php path_to_pandora_console
Example:
php pandora_diag.php /var/www/pandora_console
";
exit;
}
if (preg_match ('/[^a-zA-Z0-9_\/\.]|(\/\/)|(\.\.)/', $argv[1])) {
echo "Invalid path: $argv[1]. Always use absolute paths.";
exit;
}
include $argv[1]."/include/config.php";
}
else {
if (file_exists("../include/config.php"))
include "../include/config.php";
global $config;
// Not from console, this is a web session
if ((!isset($config["id_user"])) OR (!check_acl ($config["id_user"], 0, "PM"))) {
echo "You don't have privileges to use diagnostic tool
";
echo "Please login with an administrator account before try to use this tool
";
exit;
}
// Header
ui_print_page_header (__('Pandora FMS Diagnostic tool'), "", false, "", true);
echo "";
echo "".__("Pandora status info")." |
";
}
render_row ($build_version, "Pandora FMS Build");
render_row ($pandora_version, "Pandora FMS Version");
render_info_data ("SELECT value FROM tconfig where token ='MR'","Minor Release");
render_row ($config["homedir"], "Homedir");
render_row ($config["homeurl"], "HomeUrl");
render_info_data ("SELECT `value`
FROM tconfig
WHERE `token` = 'enterprise_installed'", "Enterprise installed");
$full_key = db_get_sql("SELECT value
FROM tupdate_settings
WHERE `key` = 'customer_key'");
$compressed_key = substr($full_key, 0,5).'...'.substr($full_key, -5);
render_row ($compressed_key,"Update Key");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE `key` = 'updating_code_path'", "Updating code path");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE `key` = 'current_update'", "Current Update #");
echo "".__("PHP setup")." |
";
render_row (phpversion(), "PHP Version");
render_row (ini_get('max_execution_time'), "PHP Max execution time");
render_row (ini_get('max_input_time'), "PHP Max input time");
render_row (ini_get('memory_limit'), "PHP Memory limit");
render_row (ini_get('session.cookie_lifetime'), "Session cookie lifetime");
echo "".__("Database size stats")." |
";
render_info_data ("SELECT COUNT(*) FROM tagente","Total agents");
render_info_data ("SELECT COUNT(*) FROM tagente_modulo","Total modules");
render_info_data ("SELECT COUNT(*) FROM tgrupo","Total groups");
render_info_data ("SELECT COUNT(*) FROM tagente_datos","Total module data records");
// render_info_data ("SELECT COUNT(*) FROM tagente_datos_string","Total module string data records");
// render_info_data ("SELECT COUNT(*) FROM tagente_datos_log4x","Total module log4x data records");
render_info_data ("SELECT COUNT(*) FROM tagent_access","Total agent access record");
// render_info ("tagente_estado");
// render_info ("talert_template_modules");
render_info_data ("SELECT COUNT(*) FROM tevento","Total events");
if($config['enterprise_installed'])
render_info_data ("SELECT COUNT(*) FROM ttrap","Total traps");
render_info_data ("SELECT COUNT(*) FROM tusuario","Total users");
render_info_data ("SELECT COUNT(*) FROM tsesion","Total sessions");
echo "".__("Database sanity")." |
";
render_info_data ("SELECT COUNT( DISTINCT tagente.id_agente)
FROM tagente_estado, tagente, tagente_modulo
WHERE tagente.disabled = 0
AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.estado = 3","Total unknown agents");
render_info_data ("SELECT COUNT(tagente_estado.estado)
FROM tagente_estado
WHERE tagente_estado.estado = 4","Total not-init modules");
$last_run_difference = '';
$diferencia = time() - date (
db_get_sql ("SELECT `value`
FROM tconfig
WHERE `token` = 'db_maintance'"));
$last_run_difference_months = 0;
$last_run_difference_weeks = 0;
$last_run_difference_days = 0;
$last_run_difference_minutos = 0;
$last_run_difference_seconds = 0;
while($diferencia >= 2419200){
$diferencia -= 2419200;
$last_run_difference_months++;
}
while($diferencia >= 604800){
$diferencia -= 604800;
$last_run_difference_weeks++;
}
while($diferencia >= 86400){
$diferencia -= 86400;
$last_run_difference_days++;
}
while($diferencia >= 3600){
$diferencia -= 3600;
$last_run_difference_hours++;
}
while($diferencia >= 60){
$diferencia -= 60;
$last_run_difference_minutes++;
}
$last_run_difference_seconds = $diferencia;
if($last_run_difference_months > 0){
$last_run_difference .= $last_run_difference_months.'month/s ';
}
if ($last_run_difference_weeks > 0) {
$last_run_difference .= $last_run_difference_weeks.' week/s ';
}
if ($last_run_difference_days > 0) {
$last_run_difference .= $last_run_difference_days.' day/s ';
}
if ($last_run_difference_hours > 0) {
$last_run_difference .= $last_run_difference_hours.' hour/s ';
}
if ($last_run_difference_minutes > 0) {
$last_run_difference .= $last_run_difference_minutes.' minute/s ';
}
$last_run_difference .= $last_run_difference_seconds.' second/s ago';
render_row ( date ("Y/m/d H:i:s",
db_get_sql ("SELECT `value`
FROM tconfig
WHERE `token` = 'db_maintance'")).' ('.$last_run_difference.')'.' *', "PandoraDB Last run");
echo "".__("Database status info")." |
";
switch ($config["dbtype"]) {
case "mysql":
render_info_data ("SELECT `value`
FROM tconfig
WHERE `token` = 'db_scheme_first_version'", "DB Schema Version (first installed)");
render_info_data ("SELECT `value`
FROM tconfig
WHERE `token` = 'db_scheme_version'", "DB Schema Version (actual)");
render_info_data ("SELECT `value`
FROM tconfig
WHERE `token` = 'db_scheme_build'", "DB Schema Build");
if(strpos($_SERVER['HTTP_USER_AGENT'],'Windows') == false){
echo "".__("System info")." |
";
$output = 'cat /proc/cpuinfo | grep "model name" | tail -1 | cut -f 2 -d ":"';
$output2 = 'cat /proc/cpuinfo | grep "processor" | wc -l';
render_row(exec($output).' x '.exec($output2),'CPU');
$output = 'cat /proc/meminfo | grep "MemTotal"';
render_row(exec($output),'RAM');
}
break;
case "postgresql":
render_info_data ("SELECT \"value\"
FROM tconfig
WHERE \"token\" = 'db_scheme_version'", "DB Schema Version");
render_info_data ("SELECT \"value\"
FROM tconfig
WHERE \"token\" = 'db_scheme_build'", "DB Schema Build");
render_info_data ("SELECT \"value\"
FROM tconfig
WHERE \"token\" = 'enterprise_installed'", "Enterprise installed");
render_row ( date ("Y/m/d H:i:s",
db_get_sql ("SELECT \"value\"
FROM tconfig WHERE \"token\" = 'db_maintance'")), "PandoraDB Last run");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE \"key\" = 'customer_key';", "Update Key");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE \"key\" = 'updating_code_path'", "Updating code path");
render_info_data ("SELECT value
FROM tupdate_settings
WHERE \"key\" = 'current_update'", "Current Update #");
break;
case "oracle":
render_info_data ("SELECT value
FROM tconfig
WHERE token = 'db_scheme_version'", "DB Schema Version");
render_info_data ("SELECT value
FROM tconfig
WHERE token = 'db_scheme_build'", "DB Schema Build");
render_info_data ("SELECT value
FROM tconfig
WHERE token = 'enterprise_installed'", "Enterprise installed");
render_row (db_get_sql ("SELECT value
FROM tconfig
WHERE token = 'db_maintance'"), "PandoraDB Last run");
render_info_data ("SELECT " . db_escape_key_identifier('value') .
" FROM tupdate_settings
WHERE \"key\" = 'customer_key'", "Update Key");
render_info_data ("SELECT " . db_escape_key_identifier('value') .
" FROM tupdate_settings
WHERE \"key\" = 'updating_code_path'", "Updating code path");
render_info_data ("SELECT " . db_escape_key_identifier('value') .
" FROM tupdate_settings
WHERE \"key\" = 'current_update'", "Current Update #");
break;
}
if ($console_mode == 0) {
echo "
";
}
echo "
";
echo "".__('(*) Please check your Pandora Server setup and be sure that database maintenance daemon is running. It\' very important to
keep up-to-date database to get the best performance and results in Pandora')."
";
?>