Merge branch 'develop' into 1396-new-circular-percentile-item-in-visual-console-dev

This commit is contained in:
Arturo Gonzalez 2017-10-26 13:40:01 +02:00
commit 704511aa56
192 changed files with 53494 additions and 68287 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, AIX version
# Version 7.0NG.714, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, FreeBSD Version
# Version 7.0NG.714, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, HP-UX Version
# Version 7.0NG.714, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, GNU/Linux
# Version 7.0NG.714, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, GNU/Linux
# Version 7.0NG.714, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, Solaris Version
# Version 7.0NG.714, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2010 Artica Soluciones Tecnologicas
# Version 7.0NG.713
# Version 7.0NG.714
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.713, AIX version
# Version 7.0NG.714, AIX version
# General Parameters
# ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.713
# Version 7.0NG.714
# FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.713, HPUX Version
# Version 7.0NG.714, HPUX Version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713
# Version 7.0NG.714
# Licensed under GPL license v2,
# (c) 2003-2010 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713
# Version 7.0NG.714
# Licensed under GPL license v2,
# (c) 2003-2009 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713
# Version 7.0NG.714
# Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents
# Version 7.0NG.713, Solaris version
# Version 7.0NG.714, Solaris version
# General Parameters
# ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, AIX version
# Version 7.0NG.714, AIX version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.713-171005
Version: 7.0NG.714-171026
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.713-171005"
pandora_version="7.0NG.714-171026"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, GNU/Linux
# Version 7.0NG.714, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, FreeBSD Version
# Version 7.0NG.714, FreeBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, HP-UX Version
# Version 7.0NG.714, HP-UX Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, GNU/Linux
# Version 7.0NG.714, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, GNU/Linux
# Version 7.0NG.714, GNU/Linux
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, NetBSD Version
# Version 7.0NG.714, NetBSD Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents
# Version 7.0NG.713, Solaris Version
# Version 7.0NG.714, Solaris Version
# Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com

View File

@ -40,8 +40,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.713';
use constant AGENT_BUILD => '171005';
use constant AGENT_VERSION => '7.0NG.714';
use constant AGENT_BUILD => '171026';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;
@ -1363,7 +1363,7 @@ sub md5 {
# Append bit /* bit, not byte */ length of unpadded message as 64-bit
# little-endian integer to message.
$msg .= unpack ("B32", pack ("V", $bit_len));
$msg .= unpack ("B32", pack ("V", $bit_len >> 32));
$msg .= unpack ("B32", pack ("V", ($bit_len >> 16) >> 16));
# Process the message in successive 512-bit chunks.
for (my $i = 0; $i < length ($msg); $i += 512) {
@ -1579,6 +1579,9 @@ sub guess_os_version ($) {
# AIX
} elsif ($os eq 'aix') {
$os_version = "$2.$1" if (`uname -rv` =~ /\s*(\d)\s+(\d)\s*/);
# Darwin
} elsif ($os eq 'darwin') {
$os_version = `defaults read loginwindow SystemVersionStampAsString`;
# Windows
} elsif ($os =~ /win/i) {
$os_version = `ver`;

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.713
%define release 171005
%define version 7.0NG.714
%define release 171026
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
@ -24,7 +24,7 @@ Requires(preun): chkconfig /bin/rm /usr/sbin/userdel
Requires: fileutils textutils unzip
Requires: util-linux procps grep
Requires: /sbin/ip /bin/awk
Requires: perl perl(Sys::Syslog) perl(IO::Socket::SSL)
Requires: perl perl(Sys::Syslog)
# Required by plugins
#Requires: sh-utils sed passwd net-tools rpm
AutoReq: 0

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent
#
%define name pandorafms_agent_unix
%define version 7.0NG.713
%define release 171005
%define version 7.0NG.714
%define release 171026
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}
@ -67,6 +67,7 @@ then
fi
%post
mkdir -p /var/log/pandora
chown pandora:root /var/log/pandora
if [ ! -d /etc/pandora ] ; then
mkdir -p /etc/pandora
@ -91,6 +92,9 @@ if [ ! -e /etc/pandora/collections ]; then
fi
cp -aRf /usr/share/pandora_agent/pandora_agent_logrotate /etc/logrotate.d/pandora_agent
# Enable the service on SystemD
systemctl enable pandora_agent_daemon.service
mkdir -p /var/spool/pandora/data_out
chkconfig pandora_agent_daemon on

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION="7.0NG.713"
PI_BUILD="171005"
PI_VERSION="7.0NG.714"
PI_BUILD="171026"
OS_NAME=`uname -s`
FORCE=0

View File

@ -3,7 +3,7 @@ if DEBUG
PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc debug_new.cpp
PandoraAgent_CXXFLAGS=-g -O0
else
PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc
PandoraAgent_SOURCES = misc/pandora_file.cc modules/pandora_data.cc modules/pandora_module_factory.cc modules/pandora_module.cc modules/pandora_module_list.cc modules/pandora_module_plugin.cc modules/pandora_module_inventory.cc modules/pandora_module_freememory.cc modules/pandora_module_exec.cc modules/pandora_module_perfcounter.cc modules/pandora_module_proc.cc modules/pandora_module_tcpcheck.cc modules/pandora_module_freememory_percent.cc modules/pandora_module_freedisk.cc modules/pandora_module_freedisk_percent.cc modules/pandora_module_logevent.cc modules/pandora_module_logchannel.cc modules/pandora_module_service.cc modules/pandora_module_cpuusage.cc modules/pandora_module_wmiquery.cc modules/pandora_module_regexp.cc modules/pandora_module_ping.cc modules/pandora_module_snmpget.cc udp_server/udp_server.cc main.cc pandora_strutils.cc pandora.cc windows_service.cc pandora_agent_conf.cc windows/pandora_windows_info.cc windows/pandora_wmi.cc pandora_windows_service.cc misc/md5.c misc/sha256.cc windows/wmi/disphelper.c ssh/libssh2/channel.c ssh/libssh2/mac.c ssh/libssh2/session.c ssh/libssh2/comp.c ssh/libssh2/misc.c ssh/libssh2/sftp.c ssh/libssh2/crypt.c ssh/libssh2/packet.c ssh/libssh2/userauth.c ssh/libssh2/hostkey.c ssh/libssh2/publickey.c ssh/libssh2/kex.c ssh/libssh2/scp.c ssh/pandora_ssh_client.cc ssh/pandora_ssh_test.cc ftp/pandora_ftp_client.cc ftp/pandora_ftp_test.cc
PandoraAgent_CXXFLAGS=-O2
endif

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent
# (c) 2006-2014 Artica Soluciones Tecnologicas
# Version 7.0NG.713
# Version 7.0NG.714
# This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes}
AppName
{Pandora FMS Windows Agent v7.0NG.713}
{Pandora FMS Windows Agent v7.0NG.714}
ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{171005}
{171026}
ViewReadme
{Yes}

View File

@ -248,7 +248,9 @@ Pandora_Module::parseModuleKindFromString (string kind) {
} else if (kind == module_inventory_str) {
return MODULE_INVENTORY;
} else if (kind == module_logevent_str) {
return MODULE_LOGEVENT;
return MODULE_LOGEVENT;
} else if (kind == module_logchannel_str) {
return MODULE_LOGCHANNEL;
} else if (kind == module_wmiquery_str) {
return MODULE_WMIQUERY;
} else if (kind == module_perfcounter_str) {

View File

@ -86,6 +86,7 @@ namespace Pandora_Modules {
MODULE_FREEMEMORY_PERCENT, /**< The module checks the amount of
* freememory in the system */
MODULE_LOGEVENT, /**< The module checks for log events */
MODULE_LOGCHANNEL, /**< The module checks for log events on channel using XML functions*/
MODULE_WMIQUERY, /**< The module runs WQL queries */
MODULE_PERFCOUNTER, /**< The module reads performance counters */
MODULE_TCPCHECK, /**< The module checks whether a tcp port is open */
@ -126,6 +127,7 @@ namespace Pandora_Modules {
const string module_cpuusage_str = "module_cpuusage";
const string module_inventory_str = "module_inventory";
const string module_logevent_str = "module_logevent";
const string module_logchannel_str = "module_logchannel";
const string module_wmiquery_str = "module_wmiquery";
const string module_perfcounter_str = "module_perfcounter";
const string module_tcpcheck_str = "module_tcpcheck";

View File

@ -31,6 +31,7 @@
#include "pandora_module_cpuusage.h"
#include "pandora_module_inventory.h"
#include "pandora_module_logevent.h"
#include "pandora_module_logchannel.h"
#include "pandora_module_wmiquery.h"
#include "pandora_module_perfcounter.h"
#include "pandora_module_tcpcheck.h"
@ -69,6 +70,7 @@ using namespace Pandora_Strutils;
#define TOKEN_MIN_FF_EVENT ("module_min_ff_event ")
#define TOKEN_DESCRIPTION ("module_description ")
#define TOKEN_LOGEVENT ("module_logevent")
#define TOKEN_LOGCHANNEL ("module_logchannel")
#define TOKEN_SOURCE ("module_source ")
#define TOKEN_EVENTTYPE ("module_eventtype ")
#define TOKEN_EVENTCODE ("module_eventcode ")
@ -121,6 +123,7 @@ using namespace Pandora_Strutils;
#define TOKEN_MACRO ("module_macro")
#define TOKEN_NATIVE_ENCODING ("module_native_encoding")
#define TOKEN_ALERT_TEMPLATE ("module_alert_template")
#define TOKEN_USER_SESSION ("module_user_session ")
string
parseLine (string line, string token) {
@ -157,8 +160,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_freedisk_percent, module_freememory_percent;
string module_dsn, module_freememory;
string module_logevent, module_source, module_eventtype, module_eventcode;
string module_logchannel;
string module_pattern, module_application, module_async;
string module_watchdog, module_start_command;
string module_watchdog, module_start_command, module_user_session;
string module_wmiquery, module_wmicolumn;
string module_retries, module_startdelay, module_retrydelay;
string module_perfcounter, module_tcpcheck;
@ -195,6 +199,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_proc = "";
module_service = "";
module_logevent = "";
module_logchannel = "";
module_source = "";
module_eventtype = "";
module_eventcode = "";
@ -253,6 +258,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_ff_interval = "";
module_native_encoding = "";
module_alert_template = "";
module_user_session = "";
macro = "";
stringtok (tokens, definition, "\n");
@ -342,6 +348,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_logevent == "") {
module_logevent = parseLine (line, TOKEN_LOGEVENT);
}
if (module_logchannel == "") {
module_logchannel = parseLine (line, TOKEN_LOGCHANNEL);
}
if (module_source == "") {
module_source = parseLine (line, TOKEN_SOURCE);
}
@ -507,6 +516,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_alert_template == "") {
module_alert_template = parseLine (line, TOKEN_ALERT_TEMPLATE);
module_alert_template.erase (0,1);
}
if (module_user_session == "") {
module_user_session = parseLine (line, TOKEN_USER_SESSION);
}
if (macro == "") {
@ -724,6 +737,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
}
}
if (module_logchannel != "") {
pos_macro = module_logchannel.find(macro_name);
if (pos_macro != string::npos){
module_logchannel.replace(pos_macro, macro_name.size(), macro_value);
}
}
if (module_source != "") {
pos_macro = module_source.find(macro_name);
if (pos_macro != string::npos){
@ -1085,6 +1105,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_alert_template.replace(pos_macro, macro_name.size(), macro_value);
}
}
if (module_user_session != "") {
pos_macro = module_user_session.find(macro_name);
if (pos_macro != string::npos){
module_user_session.replace(pos_macro, macro_name.size(), macro_value);
}
}
}
}
}
@ -1121,6 +1148,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_proc->setRetries (atoi(module_retries.c_str ()));
module_proc->setStartDelay (atoi(module_startdelay.c_str ()));
module_proc->setRetryDelay (atoi(module_retrydelay.c_str ()));
module_proc->setUserSession (is_enabled(module_user_session));
}
}
} else if (module_service != "") {
@ -1173,6 +1201,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_eventcode,
module_pattern,
module_application);
}
else if (module_logchannel != "") {
module = new Pandora_Module_Logchannel (module_name,
module_source,
module_eventtype,
module_eventcode,
module_pattern);
} else if (module_wmiquery != "") {
module = new Pandora_Module_WMIQuery (module_name,
module_wmiquery, module_wmicolumn);

View File

@ -30,12 +30,13 @@
#include "pandora_module_cpuusage.h"
#include "pandora_module_inventory.h"
#include "pandora_module_logevent.h"
#include "pandora_module_logchannel.h"
#include "pandora_module_wmiquery.h"
#include "pandora_module_perfcounter.h"
#include "pandora_module_tcpcheck.h"
#include "pandora_module_regexp.h"
#include "pandora_module_plugin.h"
#include "pandora_module_ping.h"
#include "pandora_module_ping.h"
#include "pandora_module_snmpget.h"
#include <fstream>
@ -226,12 +227,13 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition)
Pandora_Module_Freememory *module_freememory;
Pandora_Module_Freememory_Percent *module_freememory_percent;
Pandora_Module_Logevent *module_logevent;
Pandora_Module_Logchannel *module_logchannel;
Pandora_Module_WMIQuery *module_wmiquery;
Pandora_Module_Perfcounter *module_perfcounter;
Pandora_Module_Tcpcheck *module_tcpcheck;
Pandora_Module_Regexp *module_regexp;
Pandora_Module_Plugin *module_plugin;
Pandora_Module_Ping *module_ping;
Pandora_Module_Ping *module_ping;
Pandora_Module_SNMPGet *module_snmpget;
module = Pandora_Module_Factory::getModuleFromDefinition (definition);
@ -288,6 +290,10 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition)
module_logevent = (Pandora_Module_Logevent *) module;
modules->push_back (module_logevent);
break;
case MODULE_LOGCHANNEL:
module_logchannel = (Pandora_Module_Logchannel *) module;
modules->push_back (module_logchannel);
break;
case MODULE_WMIQUERY:
module_wmiquery = (Pandora_Module_WMIQuery *) module;
modules->push_back (module_wmiquery);
@ -315,7 +321,7 @@ Pandora_Modules::Pandora_Module_List::parseModuleDefinition (string definition)
case MODULE_SNMPGET:
module_snmpget = (Pandora_Module_SNMPGet *) module;
modules->push_back (module_snmpget);
break;
break;
default:
break;
}

View File

@ -0,0 +1,582 @@
/* Pandora logchannel module. This module checks for log events that match a given
pattern using XML functions provided by wevtapi.
Copyright (C) 2017 Artica ST.
Written by Fermin Hernandez.
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; either version 2, or (at your option)
any later version.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include "pandora_module_logchannel.h"
#include "../windows/pandora_wmi.h"
#include "../pandora_windows_service.h"
#include "pandora_module_logchannel.h"
#include "pandora_strutils.h"
using namespace Pandora;
using namespace Pandora_Modules;
using namespace Pandora_Strutils;
// Pointers to Wevtapi.dll functions
static HINSTANCE WINEVENT = NULL;
static EvtQueryT EvtQueryF = NULL;
static EvtNextT EvtNextF = NULL;
static EvtSeekT EvtSeekF = NULL;
static EvtCreateRenderContextT EvtCreateRenderContextF = NULL;
static EvtRenderT EvtRenderF = NULL;
static EvtCloseT EvtCloseF = NULL;
static EvtFormatMessageT EvtFormatMessageF = NULL;
static EvtOpenPublisherMetadataT EvtOpenPublisherMetadataF = NULL;
static EvtCreateBookmarkT EvtCreateBookmarkF = NULL;
static EvtUpdateBookmarkT EvtUpdateBookmarkF = NULL;
/**
* Creates a Pandora_Module_Logchannel object.
*
* @param name Module name.
* @param service_name Service internal name to check.
*/
Pandora_Module_Logchannel::Pandora_Module_Logchannel (string name, string source, string type, string id, string pattern)
: Pandora_Module (name) {
int i;
vector<wstring> query;
vector<wstring>::iterator query_it;
string upper_type = type;
// Convert the type string to uppercase
for (i = 0; i < type.length(); i++) {
upper_type[i] = toupper(type[i]);
}
// Set the type filter
int type_number = -1;
if (upper_type.compare("ERROR") == 0) {
type_number = EVENTLOG_ERROR_TYPE;
} else if (upper_type.compare("WARNING") == 0) {
type_number = EVENTLOG_WARNING_TYPE;
} else if (upper_type.compare("INFORMATION") == 0) {
type_number = EVENTLOG_INFORMATION_TYPE;
} else if (upper_type.compare("AUDIT SUCCESS") == 0) {
type_number = EVENTLOG_AUDIT_SUCCESS;
} else if (upper_type.compare("AUDIT FAILURE") == 0) {
type_number = EVENTLOG_AUDIT_FAILURE;
}
// Append type to log query
if (type_number != -1) {
wstringstream ss;
ss << L"*[System[Level='" << type_number << L"']]";
query.push_back(ss.str());
}
// Set the id
int id_number = strtoul (id.c_str (), NULL, 0);
if (id_number != 0) {
wstringstream ss;
ss << L"*[System[EventID='" << id_number << L"']]";
query.push_back(ss.str());
}
// Fill the filter
if (query.size() == 0) {
this->filter = L"*";
} else {
int i = 0;
// Add filters with and
wstring item_query;
while (query.size() > 1) {
item_query = query.back();
query.pop_back();
this->filter += item_query + L" and ";
}
// Append the last value without the and
item_query = query.back();
this->filter += item_query;
}
this->source = source;
this->pattern = pattern;
if (! pattern.empty ()) {
// Compile the regular expression
if (regcomp (&this->regexp, pattern.c_str (), REG_EXTENDED) != 0) {
pandoraLog ("Invalid regular expression %s", pattern.c_str ());
}
}
this->bookmark_xml = L"";
this->setKind (module_logchannel_str);
// Load Wevtapi.dll and some functions
if (WINEVENT == NULL) {
WINEVENT = LoadLibrary("Wevtapi.dll");
if (WINEVENT == NULL) {
// Log to the bedug log, since this is not an error
pandoraLog ("Library Wevtapi.dll not available");
return;
}
EvtQueryF = (EvtQueryT) GetProcAddress (WINEVENT, "EvtQuery");
if (EvtQueryF == NULL) {
pandoraLog ("Error loading function EvtQuery from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtNextF = (EvtNextT) GetProcAddress (WINEVENT, "EvtNext");
if (EvtNextF == NULL) {
pandoraLog ("Error loading function EvtNext from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtSeekF = (EvtSeekT) GetProcAddress (WINEVENT, "EvtSeek");
if (EvtSeekF == NULL) {
pandoraLog ("Error loading function EvtSeek from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtCreateRenderContextF = (EvtCreateRenderContextT) GetProcAddress (WINEVENT, "EvtCreateRenderContext");
if (EvtCreateRenderContextF == NULL) {
pandoraLog ("Error loading function EvtCreateRenderContext from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtRenderF = (EvtRenderT) GetProcAddress (WINEVENT, "EvtRender");
if (EvtRenderF == NULL) {
pandoraLog ("Error loading function EvtRender from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtCloseF = (EvtCloseT) GetProcAddress (WINEVENT, "EvtClose");
if (EvtCloseF == NULL) {
pandoraLog ("Error loading function EvtClose from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtFormatMessageF = (EvtFormatMessageT) GetProcAddress (WINEVENT, "EvtFormatMessage");
if (EvtFormatMessageF == NULL) {
pandoraLog ("Error loading function EvtFormatMessage from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtOpenPublisherMetadataF = (EvtOpenPublisherMetadataT) GetProcAddress (WINEVENT, "EvtOpenPublisherMetadata");
if (EvtOpenPublisherMetadataF == NULL) {
pandoraLog ("Error loading function EvtOpenPublisherMetadata from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtCreateBookmarkF = (EvtCreateBookmarkT) GetProcAddress (WINEVENT, "EvtCreateBookmark");
if (EvtCreateBookmarkF == NULL) {
pandoraLog ("Error loading function EvtCreateBookmark from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
EvtUpdateBookmarkF = (EvtUpdateBookmarkT) GetProcAddress (WINEVENT, "EvtUpdateBookmark");
if (EvtUpdateBookmarkF == NULL) {
pandoraLog ("Error loading function EvtUpdateBookmark from Wevtapi.dll");
FreeLibrary (WINEVENT);
WINEVENT = NULL;
return;
}
}
}
void
Pandora_Module_Logchannel::run () {
list<LogChannelList> event_list;
list<LogChannelList>::iterator event;
SYSTEMTIME system_time;
// Run
try {
Pandora_Module::run ();
} catch (Interval_Not_Fulfilled e) {
return;
}
// Initialize log event query
this->initializeLogChannel();
// Read events on a list
this->getLogEvents (event_list);
// Return if no data stored on list
if (event_list.size () < 1) return;
for (event = event_list.begin (); event != event_list.end(); ++event) {
// Store the data
this->setOutput (event->message, &(event->timestamp));
}
}
/**
* Fill the first bookmark of events.
*/
void
Pandora_Module_Logchannel::initializeLogChannel () {
EVT_HANDLE hEvents[1];
EVT_HANDLE hResults;
EVT_HANDLE hBookmark;
DWORD dwReturned = 0;
// Check whether the first bookmark is set
if (!this->bookmark_xml.empty()) return;
// Open the event log with a query
hResults = EvtQueryF (
NULL,
strAnsiToUnicode (this->source.c_str()).c_str(),
this->filter.c_str(),
EvtOpenChannelPath | EvtQueryForwardDirection
);
if (hResults == NULL) {
pandoraDebug ("Could not open event log channel. Error: '%d'", GetLastError());
return;
}
// Put the events on the last event
if (!EvtSeekF(hResults, 0, NULL, 0, EvtSeekRelativeToLast)) {
pandoraDebug("Cannot positionate the event at first. 'Error %d'.", GetLastError());
EvtCloseF(hResults);
return;
}
// Read next event to positionate the bookmark
if (!EvtNextF(hResults, 1, hEvents, INFINITE, 0, &dwReturned)) {
if (GetLastError() != ERROR_NO_MORE_ITEMS) {
pandoraDebug ("EvtNext (initializeLogChannel) error: %d", GetLastError());
EvtCloseF(hResults);
return;
}
}
// If no events read, do not use bookmark to read all events
if (dwReturned == 0) {
pandoraDebug("No events found positionating bookmark.");
EvtCloseF(hResults);
return;
}
// Create the bookmar
pandoraDebug("Creating bookmark to channel %s", this->source.c_str());
hBookmark = EvtCreateBookmarkF(NULL);
if (hBookmark == NULL) {
pandoraDebug("EvtCreateBookmark (initializeLogChannel) failed %d", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hEvents[0]);
return;
}
if (!EvtUpdateBookmarkF(hBookmark, hEvents[0])) {
pandoraDebug("EvtUpdateBookmarkF (initializeLogChannel) failed %d", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hEvents[0]);
EvtCloseF(hBookmark);
return;
}
// Save the bookmark like an XML.
this->updateBookmarkXML(hBookmark);
// Clean tasks
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
}
/**
* Update the bookmark XML. Returns false if fails
*/
bool
Pandora_Module_Logchannel::updateBookmarkXML (EVT_HANDLE hBookmark) {
LPWSTR pBookmarkXml = NULL;
DWORD dwBufferSize = 0;
DWORD dwBufferUsed = 0;
DWORD dwPropertyCount = 0;
DWORD status = 0;
if (!EvtRenderF(NULL, hBookmark, EvtRenderBookmark, dwBufferSize, pBookmarkXml, &dwBufferUsed, &dwPropertyCount)){
if (ERROR_INSUFFICIENT_BUFFER == (status = GetLastError())){
dwBufferSize = dwBufferUsed;
pBookmarkXml = (LPWSTR)malloc(dwBufferSize);
if (pBookmarkXml){
EvtRenderF(NULL, hBookmark, EvtRenderBookmark, dwBufferSize, pBookmarkXml, &dwBufferUsed, &dwPropertyCount);
}
else{
pandoraDebug("Error loading the bookmark. Cannot load enough memory");
this->cleanBookmark();
free(pBookmarkXml);
return false;
}
}
if (ERROR_SUCCESS != (status = GetLastError())){
pandoraDebug("EvtRender (updateBookmarkXML) failed with %d\n", GetLastError());
this->cleanBookmark();
free(pBookmarkXml);
return false;
}
}
this->bookmark_xml = pBookmarkXml;
free(pBookmarkXml);
return true;
}
/**
* Clean the bookmark XML.
*/
void
Pandora_Module_Logchannel::cleanBookmark () {
this->bookmark_xml = L"";
}
/**
* Reads available events from the event log.
*/
void
Pandora_Module_Logchannel::getLogEvents (list<LogChannelList> &event_list) {
EVT_HANDLE hResults = NULL;
EVT_HANDLE hBookmark = NULL;
EVT_HANDLE hEvents[1];
EVT_HANDLE hContext = NULL;
PEVT_VARIANT pRenderedValues = NULL;
EVT_HANDLE hProviderMetadata = NULL;
LPWSTR pwsMessage = NULL;
LPWSTR ppValues[] = {L"Event/System/Provider/@Name", L"Event/System/TimeCreated/@SystemTime"};
DWORD count = sizeof(ppValues)/sizeof(LPWSTR);
DWORD dwReturned = 0;
DWORD dwBufferSize = 0;
DWORD dwBufferUsed = 0;
DWORD dwPropertyCount = 0;
DWORD status = ERROR_SUCCESS;
SYSTEMTIME eventTime;
FILETIME lft, ft;
bool update_bookmark = false;
// An empty bookmark XML means that log cannot be open
if (this->bookmark_xml.empty()) return;
// Open the event log with a query
hResults = EvtQueryF (
NULL,
strAnsiToUnicode (this->source.c_str()).c_str(),
this->filter.c_str(),
EvtOpenChannelPath | EvtQueryForwardDirection
);
if (hResults == NULL) {
pandoraDebug ("Could not open event log channel '%s'. Error: '%d'", this->source.c_str(), GetLastError());
EvtCloseF(hResults);
this->cleanBookmark();
return;
}
// Seek on the bookmark
hBookmark = EvtCreateBookmarkF(this->bookmark_xml.c_str());
if (hBookmark == NULL) {
pandoraDebug("Cannot read the string bookmark. Error: %d.", GetLastError());
EvtCloseF(hResults);
this->cleanBookmark();
return;
}
if (!EvtSeekF(hResults, 1, hBookmark, 0, EvtSeekRelativeToBookmark)) {
pandoraDebug("Cannot positionate the event at bookmark. Error %d.", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hBookmark);
this->cleanBookmark();
return;
}
// Read events one by one
hEvents[0] = NULL;
while (EvtNextF(hResults, 1, hEvents, INFINITE, 0, &dwReturned)) {
hContext = EvtCreateRenderContextF(count, (LPCWSTR*)ppValues, EvtRenderContextValues);
if (NULL == hContext) {
pandoraDebug ("EvtCreateRenderContext error: %d", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
this->cleanBookmark();
return;
}
// Reinitialize the buffers
dwBufferSize = 0;
dwBufferUsed = 0;
if (! EvtRenderF(hContext, hEvents[0], EvtRenderEventValues, dwBufferSize, pRenderedValues, &dwBufferUsed, &dwPropertyCount)) {
if ((status = GetLastError()) == ERROR_INSUFFICIENT_BUFFER) {
dwBufferSize = dwBufferUsed;
pRenderedValues = (PEVT_VARIANT)malloc(dwBufferSize);
if (pRenderedValues) {
EvtRenderF(hContext, hEvents[0], EvtRenderEventValues, dwBufferSize, pRenderedValues, &dwBufferUsed, &dwPropertyCount);
}
else {
pandoraDebug ("EvtRender error: %d", status);
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
EvtCloseF(hContext);
this->cleanBookmark();
return;
}
}
if ((status = GetLastError()) != ERROR_SUCCESS) {
pandoraDebug ("EvtRender error getting buffer size: %d", status);
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
EvtCloseF(hContext);
this->cleanBookmark();
return;
}
}
// Get the SYSTEMTIME of log
ULONGLONG ullTimeStamp = pRenderedValues[1].FileTimeVal;
ft.dwHighDateTime = (DWORD)((ullTimeStamp >> 32) & 0xFFFFFFFF);
ft.dwLowDateTime = (DWORD)(ullTimeStamp & 0xFFFFFFFF);
// Time format conversions
if (!FileTimeToLocalFileTime(&ft, &lft)){
pandoraDebug("UTC FILETIME to LOCAL FILETIME error: %d.", GetLastError());
} else if (!FileTimeToSystemTime(&lft, &eventTime)){
pandoraDebug("FILETIME to SYSTEMTIME error: %d.", GetLastError());
}
// Get the handle to the provider's metadata that contains the message strings
hProviderMetadata = EvtOpenPublisherMetadataF(NULL, pRenderedValues[0].StringVal, NULL, 0, 0);
if (hProviderMetadata == NULL) {
pandoraDebug ("EvtOpenPublisherMetadata error: %d", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
EvtCloseF(hContext);
free(pRenderedValues);
this->cleanBookmark();
return;
}
// Read the event message
pwsMessage = GetMessageString(hProviderMetadata, hEvents[0], EvtFormatMessageEvent);
if (pwsMessage == NULL) {
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
EvtCloseF(hContext);
free(pRenderedValues);
EvtCloseF(hProviderMetadata);
this->cleanBookmark();
return;
}
// Check the regex and save the message if pass the regex
if (this->pattern.empty () || regexec (&this->regexp, strUnicodeToAnsi(pwsMessage).c_str (), 0, NULL, 0) == 0){
// Save the event message
LogChannelList event_item;
event_item.message = strUnicodeToAnsi(pwsMessage);
event_item.timestamp= eventTime;
event_list.push_back (event_item);
}
// Clean up some used vars
EvtCloseF(hContext);
free(pRenderedValues);
EvtCloseF(hProviderMetadata);
free(pwsMessage);
// Update the bookmark
if (!EvtUpdateBookmarkF(hBookmark, hEvents[0])) {
pandoraDebug("EvtUpdateBookmarkF (getLogEvents) failed %d", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hBookmark);
EvtCloseF(hEvents[0]);
this->cleanBookmark();
return;
}
// Cleanup current event and read the next log
EvtCloseF(hEvents[0]);
hEvents[0] = NULL;
// Information token to update bookmark
update_bookmark = true;
}
status = GetLastError();
if (status != ERROR_NO_MORE_ITEMS) {
pandoraDebug ("EvtNext getLogEvents error: %d", GetLastError());
EvtCloseF(hResults);
EvtCloseF(hBookmark);
this->cleanBookmark();
return;
}
// Update bookmark if there is new events
if (update_bookmark) this->updateBookmarkXML(hBookmark);
// Clean handlers
EvtCloseF(hResults);
EvtCloseF(hBookmark);
}
// Gets the specified message string from the event. If the event does not
// contain the specified message, the function returns NULL.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/dd996923(v=vs.85).aspx
LPWSTR
Pandora_Module_Logchannel::GetMessageString(EVT_HANDLE hMetadata, EVT_HANDLE hEvent, EVT_FORMAT_MESSAGE_FLAGS FormatId) {
LPWSTR pBuffer = NULL;
DWORD dwBufferSize = 0;
DWORD dwBufferUsed = 0;
DWORD status = 0;
if (!EvtFormatMessageF(hMetadata, hEvent, 0, 0, NULL, FormatId, dwBufferSize, pBuffer, &dwBufferUsed)) {
status = GetLastError();
if (ERROR_INSUFFICIENT_BUFFER == status) {
// An event can contain one or more keywords. The function returns keywords
// as a list of keyword strings. To process the list, you need to know the
// size of the buffer, so you know when you have read the last string, or you
// can terminate the list of strings with a second null terminator character
// as this example does.
if ((EvtFormatMessageKeyword == FormatId)) {
pBuffer[dwBufferSize-1] = L'\0';
}
else {
dwBufferSize = dwBufferUsed;
}
pBuffer = (LPWSTR)malloc(dwBufferSize * sizeof(WCHAR));
if (pBuffer) {
EvtFormatMessageF(hMetadata, hEvent, 0, 0, NULL, FormatId, dwBufferSize, pBuffer, &dwBufferUsed);
// Add the second null terminator character.
if ((EvtFormatMessageKeyword == FormatId)) {
pBuffer[dwBufferUsed-1] = L'\0';
}
}
else {
return NULL;
}
}
else {
pandoraDebug ("EvtFormatMessage error: %d", status);
return NULL;
}
}
return pBuffer;
}

View File

@ -0,0 +1,76 @@
/* Pandora logchannel module. This module checks for log events that match a given
pattern using XML functions provided by wevtapi.
Copyright (C) 2017 Artica ST.
Written by Fermin Hernandez.
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; either version 2, or (at your option)
any later version.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PANDORA_MODULE_LOGCHANNEL_H__
#define __PANDORA_MODULE_LOGCHANNEL_H__
#include "pandora_module.h"
#include "boost/regex.h"
#include "../windows/winevt.h"
// Log event read buffer size
#define BUFFER_SIZE 1024
// Types for pointers to Wevtapi.dll functions
typedef EVT_HANDLE WINAPI (*EvtQueryT) (EVT_HANDLE Session, LPCWSTR Path, LPCWSTR Query, DWORD Flags);
typedef WINBOOL WINAPI (*EvtNextT) (EVT_HANDLE ResultSet, DWORD EventArraySize, EVT_HANDLE* EventArray, DWORD Timeout, DWORD Flags, PDWORD Returned);
typedef WINBOOL WINAPI (*EvtSeekT) (EVT_HANDLE ResultSet, LONGLONG Position, EVT_HANDLE Bookmark, DWORD Timeout, DWORD Flags);
typedef EVT_HANDLE WINAPI (*EvtCreateRenderContextT) (DWORD ValuePathsCount, LPCWSTR *ValuePaths, DWORD Flags);
typedef WINBOOL WINAPI (*EvtRenderT) (EVT_HANDLE Context, EVT_HANDLE Fragment, DWORD Flags, DWORD BufferSize, PVOID Buffer, PDWORD BufferUsed, PDWORD PropertyCount);
typedef WINBOOL WINAPI (*EvtCloseT) (EVT_HANDLE Object);
typedef WINBOOL WINAPI (*EvtFormatMessageT) (EVT_HANDLE PublisherMetadata, EVT_HANDLE Event, DWORD MessageId, DWORD ValueCount, PEVT_VARIANT Values, DWORD Flags, DWORD BufferSize, LPWSTR Buffer, PDWORD BufferUsed);
typedef EVT_HANDLE WINAPI (*EvtOpenPublisherMetadataT) (EVT_HANDLE Session, LPCWSTR PublisherIdentity, LPCWSTR LogFilePath, LCID Locale, DWORD Flags);
typedef EVT_HANDLE WINAPI (*EvtCreateBookmarkT) (LPCWSTR BookmarkXml);
typedef WINBOOL WINAPI (*EvtUpdateBookmarkT) (EVT_HANDLE Bookmark, EVT_HANDLE Event);
namespace Pandora_Modules {
/**
* This module checks for log events that match a given
* pattern. Events can be filtered by source and type.
*/
class Pandora_Module_Logchannel : public Pandora_Module {
struct LogChannelList {
string message;
SYSTEMTIME timestamp;
};
private:
regex_t regexp;
string source;
string pattern;
wstring filter;
wstring bookmark_xml;
HANDLE messages_dll;
void initializeLogChannel ();
bool updateBookmarkXML (EVT_HANDLE hBookmark);
void getLogEvents (list<LogChannelList> &event_list);
void cleanBookmark ();
LPWSTR GetMessageString(EVT_HANDLE hMetadata, EVT_HANDLE hEvent, EVT_FORMAT_MESSAGE_FLAGS FormatId);
public:
Pandora_Module_Logchannel (string name, string source, string type, string id, string pattern);
void run ();
};
}
#endif

View File

@ -48,6 +48,7 @@ Pandora_Module_Proc::Pandora_Module_Proc (string name, string process_name)
this->setKind (module_proc_str);
this->watchdog = false;
this->user_session = false;
this->start_command = "";
this->retries = 3;
this->start_delay = 5000;
@ -95,6 +96,11 @@ Pandora_Module_Proc::getRetryDelay () const {
return this->retry_delay;
}
bool
Pandora_Module_Proc::getUserSession () const {
return this->user_session;
}
void
Pandora_Module_Proc::setWatchdog (bool watchdog) {
this->watchdog = watchdog;
@ -131,6 +137,11 @@ Pandora_Module_Proc::setRetryDelay (int mseconds) {
this->retry_delay = mseconds;
}
void
Pandora_Module_Proc::setUserSession (bool usession) {
this->user_session = usession;
}
void
async_run (Pandora_Module_Proc *module) {
HANDLE *processes = NULL;
@ -156,7 +167,7 @@ async_run (Pandora_Module_Proc *module) {
}
Sleep (module->getRetryDelay ());
Pandora_Wmi::runProgram (module->getStartCommand ());
Pandora_Wmi::runProgram (module->getStartCommand (), NULL, module->getUserSession());
Sleep (module->getStartDelay ());
counter++;
continue;

View File

@ -32,6 +32,7 @@ namespace Pandora_Modules {
string process_name;
HANDLE thread;
bool watchdog;
bool user_session;
string start_command;
int retries;
int start_delay;
@ -46,12 +47,14 @@ namespace Pandora_Modules {
int getRetries () const;
int getStartDelay () const;
int getRetryDelay () const;
bool getUserSession () const;
void setWatchdog (bool watchdog);
void setStartCommand (string command);
void setRetries (int retries);
void setStartDelay (int mseconds);
void setRetryDelay (int mseconds);
void setUserSession (bool usession);
void run ();
};

View File

@ -124,7 +124,6 @@ async_run (Pandora_Module_Service *module) {
// If time out and polling,
// check the service status actively
if (result == WAIT_TIMEOUT && polling) {
pandoraLog("Timeout. Polling");
module->execute_async_service(prev_res, module, modules);
}
continue;

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.713(Build 171005)")
#define PANDORA_VERSION ("7.0NG.714(Build 171026)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.713(Build 171005))"
VALUE "ProductVersion", "(7.0NG.714(Build 171026))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -369,16 +369,16 @@ Pandora_Wmi::getOSName () {
dhGetValue (L"%s", &name, quickfix,
L".Caption");
if (name != NULL) {
// Remove the (R) character.
for (int i = 0; i < strlen(name); i++) {
if ((unsigned char)name[i] == 0xAE) {
name[i] = ' ';
}
}
ret = name;
dhFreeString (name);
}
if (name != NULL) {
// Remove the (R) character.
for (int i = 0; i < strlen(name); i++) {
if ((unsigned char)name[i] == 0xAE) {
name[i] = ' ';
}
}
ret = name;
dhFreeString (name);
}
} NEXT_THROW (quickfix);
} catch (string errstr) {
@ -411,12 +411,12 @@ Pandora_Wmi::getOSVersion () {
L".CSDVersion");
if (version != NULL) {
// Remove the (R) character.
for (int i = 0; i < strlen(version); i++) {
if ((unsigned char)version[i] == 0xAE) {
version[i] = ' ';
}
}
// Remove the (R) character.
for (int i = 0; i < strlen(version); i++) {
if ((unsigned char)version[i] == 0xAE) {
version[i] = ' ';
}
}
ret = version;
dhFreeString (version);
}
@ -501,7 +501,7 @@ Pandora_Wmi::getSystemName () {
* @param flags Process creation flags
*/
bool
Pandora_Wmi::runProgram (string command, DWORD flags) {
Pandora_Wmi::runProgram (string command, DWORD flags, BOOL user_session) {
PROCESS_INFORMATION process_info;
STARTUPINFO startup_info;
bool success;
@ -514,11 +514,75 @@ Pandora_Wmi::runProgram (string command, DWORD flags) {
startup_info.cb = sizeof (startup_info);
ZeroMemory (&process_info, sizeof (process_info));
pandoraDebug ("Start process \"%s\".", command.c_str ());
cmd = strdup (command.c_str ());
success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, flags,
NULL, NULL, &startup_info, &process_info);
pandoraFree (cmd);
if (user_session) {
DWORD sessionId = WTSGetActiveConsoleSessionId();
startup_info.cb = sizeof(STARTUPINFO);
startup_info.hStdError = 0;
startup_info.hStdInput = 0;
startup_info.hStdOutput = 0;
if (
startup_info.hStdError != 0
|| startup_info.hStdInput != 0
|| startup_info.hStdOutput != 0
) {
startup_info.dwFlags |= STARTF_USESTDHANDLES;
}
HANDLE procHandle = GetCurrentProcess();
HANDLE token, userToken;
// Tray to open the process
if (OpenProcessToken(procHandle, TOKEN_DUPLICATE, &token) == 0) {
pandoraDebug ("Open Process Token fails with error %d.", GetLastError());
return false;
}
// Duplicate token
if (DuplicateTokenEx(token,
MAXIMUM_ALLOWED,
0,
SecurityImpersonation,
TokenPrimary,
&userToken) == 0) {
pandoraDebug ("Duplicate token fails with error %d.", GetLastError());
return false;
}
// Set Token Information
if (SetTokenInformation(userToken,
(TOKEN_INFORMATION_CLASS)TokenSessionId,
&sessionId,
sizeof(sessionId)) == 0) {
// Error 1314 will be thrown if agent is not running as service.
if (GetLastError() != 1314) {
pandoraDebug ("Set token information fails with error %d.", GetLastError());
return false;
}
}
LPSTR command_exec = (LPSTR)command.c_str();
// Create Process As User
// Changed inherit and command
success = CreateProcessAsUser(
userToken,
0,
command_exec,
0,
0,
FALSE,
flags,
0,
NULL,
&startup_info,
&process_info);
} else {
pandoraDebug ("Start process \"%s\".", command.c_str ());
cmd = strdup (command.c_str ());
success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, flags,
NULL, NULL, &startup_info, &process_info);
pandoraFree (cmd);
}
if (success) {
pandoraDebug ("The process \"%s\" was started.", command.c_str ());
@ -949,7 +1013,7 @@ getIPs(VARIANT *ip_array){
if (V_VT(&pvArray[i]) == VT_BSTR) {
if (i > 0) {
ret += " , ";
}
}
LPSTR szStringA;
ret += Pandora_Strutils::strUnicodeToAnsi( V_BSTR(&pvArray[i]));
}

View File

@ -53,7 +53,7 @@ namespace Pandora_Wmi {
string getOSBuild ();
string getSystemName ();
string getSystemAddress ();
bool runProgram (string command, DWORD flags = 0);
bool runProgram (string command, DWORD flags = 0, BOOL user_session = false);
bool startService (string service_name);
bool stopService (string service_name);
void runWMIQuery (string wmi_query,

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.713-171005
Version: 7.0NG.714-171026
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.713-171005"
pandora_version="7.0NG.714-171026"
package_pear=0
package_pandora=1

View File

@ -66,11 +66,14 @@ function mainAgentsModules() {
$modulegroup = get_parameter('modulegroup', 0);
$refr = get_parameter('refresh', 0); // By default 30 seconds
$recursion = get_parameter('recursion', 0);
$group_id = (int)get_parameter('group_id', 0);
$offset = (int)get_parameter('offset', 0);
$hor_offset = (int)get_parameter('hor_offset', 0);
$block = $config['block_size'];
if(get_parameter('modulegroup') != null){
$agents_id = (array)get_parameter('id_agents2', -1);
}
$selection_a_m = (int)get_parameter('selection_agent_module');
$modules_selected = (array)get_parameter('module', 0);
$update_item = (string)get_parameter('edit_item','');
@ -139,6 +142,8 @@ function mainAgentsModules() {
$filter_groups_label = '<b>'.__('Group').'</b>';
$filter_groups = html_print_select_groups(false, "AR", true, 'group_id', $group_id, '', '', '', true, false, true, '', false , 'width: auto;');
$filter_recursion_label = '<b>'.__('Recursion').'</b>';
$filter_recursion = html_print_checkbox('recursion', 1, 0, true);
//groups module
$filter_module_groups_label = '<b>'.__('Module group').'</b>';
$filter_module_groups = html_print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name",
@ -245,12 +250,12 @@ function mainAgentsModules() {
if($config['pure'] != 1){
echo '<form method="post" action="'
. ui_get_url_refresh (array ('offset' => $offset, 'hor_offset' => $offset,'group_id' => $group_id, 'modulegroup' => $modulegroup)).'">';
. ui_get_url_refresh (array ('offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup)).'">';
echo '<table class="databox filters" cellpadding="0" cellspacing="0" border="0" style="width:100%;">';
echo "<tr>";
echo "<td>" . $filter_groups_label . "</td>";
echo "<td>" . $filter_groups . "</td>";
echo "<td>" . $filter_groups ."&nbsp;&nbsp;&nbsp;". $filter_recursion_label . $filter_recursion. "</td>";
echo "<td></td>";
echo "<td></td>";
echo "<td>" . $filter_module_groups_label . "</td>";
@ -375,9 +380,14 @@ function mainAgentsModules() {
}
if ($group_id > 0) {
$filter_groups['id_grupo'] = $group_id;
if($recursion){
$filter_groups['id_grupo'] = array_merge($group_id,
groups_get_id_recursive($group_id, true));
}
else{
$filter_groups['id_grupo'] = $group_id;
}
}
$agents = agents_get_agents ($filter_groups);
$nagents = count($agents);
@ -675,12 +685,14 @@ $ignored_params['refresh']='';
}
$("#group_id").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : this.value,
"privilege" : "AW",
"keys_prefix" : "_"
"keys_prefix" : "_",
"recursion" : $('#checkbox-recursion').is(':checked')
},
function (data, status) {
$("#id_agents2").html('');
@ -699,7 +711,34 @@ $ignored_params['refresh']='';
"json"
);
});
$("#checkbox-recursion").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : $("#group_id").val(),
"privilege" : "AW",
"keys_prefix" : "_",
"recursion" : $('#checkbox-recursion').is(':checked')
},
function (data, status) {
$("#id_agents2").html('');
$("#module").html('');
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
option = $("<option></option>")
.attr ("value", value["id_agente"])
.html (value["alias"]);
$("#id_agents").append (option);
$("#id_agents2").append (option);
});
},
"json"
);
});
$("#modulegroup").change (function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",

View File

@ -182,7 +182,7 @@ function extension_db_check_tables_differences($connection_test,
ui_print_result_message(
empty($diff_tables),
__('Successful the DB Pandora has all tables'),
__('Unsuccessful the DB Pandora has not all tables. The missing tables are (%s)',
__('Pandora DB could not retrieve all tables. The missing tables are (%s)',
implode(", ", $diff_tables)));
if (!empty($diff_tables)) {
@ -264,7 +264,7 @@ function extension_db_check_tables_differences($connection_test,
switch ($config_field) {
case 'type':
ui_print_error_message(
__('Unsuccessful the field %s in the table %s must be setted the type with %s.',
__('Unsuccessful the field %s in the table %s must be set the type with %s.',
$name_field, $table, $value));
ui_print_info_message(
__('You can execute this SQL query for to fix.') . "<br />" .
@ -298,7 +298,7 @@ function extension_db_check_tables_differences($connection_test,
break;
case 'key':
ui_print_error_message(
__('Unsuccessful the field %s in the table %s must be setted the key as defined in the SQL file.',
__('Unsuccessful the field %s in the table %s must be set the key as defined in the SQL file.',
$name_field, $table));
ui_print_info_message(
__('Please check the SQL file for to know the kind of key needed.'));
@ -311,7 +311,7 @@ function extension_db_check_tables_differences($connection_test,
$null_defect = " NOT NULL";
}
ui_print_error_message(
__('Unsuccessful the field %s in the table %s must be setted %s as default value.',
__('Unsuccessful the field %s in the table %s must be set %s as default value.',
$name_field, $table, $value));
ui_print_info_message(
__('You can execute this SQL query for to fix.') . "<br />" .
@ -322,7 +322,7 @@ function extension_db_check_tables_differences($connection_test,
break;
case 'extra':
ui_print_error_message(
__('Unsuccessful the field %s in the table %s must be setted as defined in the SQL file.',
__('Unsuccessful the field %s in the table %s must be set as defined in the SQL file.',
$name_field, $table));
ui_print_info_message(
__('Please check the SQL file for to know the kind of extra config needed.'));

View File

@ -1,818 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
if (is_ajax()) {
$generate_info = (bool) get_parameter("generate_info");
if ($generate_info) {
$pandora_diag = (bool) get_parameter("pandora_diag");
$system_info = (bool) get_parameter("system_info");
$log_info = (bool) get_parameter("log_info");
$log_num_lines = (int) get_parameter('log_num_lines', 2000);
$checks = array();
$checks['pandora_diagnostic'] = $pandora_diag;
$checks['system_info'] = $system_info;
$checks['log_info'] = $log_info;
$result = generate_info($checks, $log_num_lines);
echo json_encode($result);
return;
}
return;
}
function getPandoraDiagnostic(&$systemInfo) {
global $config;
global $build_version;
global $pandora_version;
$systemInfo["Pandora FMS Build"] = $build_version;
$systemInfo["Pandora FMS Version"] = $pandora_version;
$systemInfo["Homedir"] = $config["homedir"];
$systemInfo["HomeUrl"] = $config["homeurl"];
$systemInfo["PHP Version"] = phpversion();
$systemInfo['tagente'] = db_get_sql("SELECT COUNT(*) FROM tagente");
$systemInfo['tagent_access'] = db_get_sql("SELECT COUNT(*) FROM tagent_access");
$systemInfo['tagente_datos'] = db_get_sql("SELECT COUNT(*) FROM tagente_datos");
$systemInfo['tagente_datos_string'] = db_get_sql("SELECT COUNT(*) FROM tagente_datos_string");
$systemInfo['tagente_estado'] = db_get_sql("SELECT COUNT(*) FROM tagente_estado");
$systemInfo['tagente_modulo'] = db_get_sql("SELECT COUNT(*) FROM tagente_modulo");
$systemInfo['talert_actions'] = db_get_sql("SELECT COUNT(*) FROM talert_actions");
$systemInfo['talert_commands'] = db_get_sql("SELECT COUNT(*) FROM tagente");
$systemInfo['talert_template_modules'] = db_get_sql("SELECT COUNT(*) FROM talert_template_modules");
$systemInfo['tlayout'] = db_get_sql("SELECT COUNT(*) FROM tlayout");
if ($config['enterprise_installed'])
$systemInfo['tlocal_component'] = db_get_sql("SELECT COUNT(*) FROM tlocal_component");
$systemInfo['tserver'] = db_get_sql("SELECT COUNT(*) FROM tserver");
$systemInfo['treport'] = db_get_sql("SELECT COUNT(*) FROM treport");
$systemInfo['ttrap'] = db_get_sql("SELECT COUNT(*) FROM ttrap");
$systemInfo['tusuario'] = db_get_sql("SELECT COUNT(*) FROM tusuario");
$systemInfo['tsesion'] = db_get_sql("SELECT COUNT(*) FROM tsesion");
switch ($config["dbtype"]) {
case "mysql":
$systemInfo['db_scheme_version'] = db_get_sql("SELECT `value` FROM tconfig WHERE `token` = 'db_scheme_version'");
$systemInfo['db_scheme_build'] = db_get_sql("SELECT `value` FROM tconfig WHERE `token` = 'db_scheme_build'");
$systemInfo['enterprise_installed'] = db_get_sql("SELECT `value` FROM tconfig WHERE `token` = 'enterprise_installed'");
$systemInfo['db_maintance'] = date ("Y/m/d H:i:s", db_get_sql ("SELECT `value` FROM tconfig WHERE `token` = 'db_maintance'"));
$systemInfo['customer_key'] = db_get_sql("SELECT value FROM tupdate_settings WHERE `key` = 'customer_key';");
$systemInfo['updating_code_path'] = db_get_sql("SELECT value FROM tupdate_settings WHERE `key` = 'updating_code_path'");
$systemInfo['current_update'] = db_get_sql("SELECT value FROM tupdate_settings WHERE `key` = 'current_update'");
break;
case "postgresql":
$systemInfo['db_scheme_version'] = db_get_sql("SELECT \"value\" FROM tconfig WHERE \"token\" = 'db_scheme_version'");
$systemInfo['db_scheme_build'] = db_get_sql("SELECT \"value\" FROM tconfig WHERE \"token\" = 'db_scheme_build'");
$systemInfo['enterprise_installed'] = db_get_sql("SELECT \"value\" FROM tconfig WHERE \"token\" = 'enterprise_installed'");
$systemInfo['db_maintance'] = date ("Y/m/d H:i:s", db_get_sql ("SELECT \"value\" FROM tconfig WHERE \"token\" = 'db_maintance'"));
$systemInfo['customer_key'] = db_get_sql("SELECT value FROM tupdate_settings WHERE \"key\" = 'customer_key';");
$systemInfo['updating_code_path'] = db_get_sql("SELECT value FROM tupdate_settings WHERE \"key\" = 'updating_code_path'");
$systemInfo['current_update'] = db_get_sql("SELECT value FROM tupdate_settings WHERE \"key\" = 'current_update'");
break;
case "oracle":
$systemInfo['db_scheme_version'] = db_get_sql("SELECT " . db_escape_key_identifier('value') . " FROM tconfig WHERE \"token\" = 'db_scheme_version'");
$systemInfo['db_scheme_build'] = db_get_sql("SELECT " . db_escape_key_identifier('value') . " FROM tconfig WHERE \"token\" = 'db_scheme_build'");
$systemInfo['enterprise_installed'] = db_get_sql("SELECT " . db_escape_key_identifier('value') . " FROM tconfig WHERE \"token\" = 'enterprise_installed'");
$systemInfo['db_maintance'] = db_get_sql ("SELECT " . db_escape_key_identifier('value') . " FROM tconfig WHERE \"token\" = 'db_maintance'");
$systemInfo['customer_key'] = db_get_sql("SELECT " . db_escape_key_identifier('value') . " FROM tupdate_settings WHERE \"key =\" 'customer_key';");
$systemInfo['updating_code_path'] = db_get_sql("SELECT " . db_escape_key_identifier('value') . " FROM tupdate_settings WHERE \"key =\" 'updating_code_path'");
$systemInfo['current_update'] = db_get_sql("SELECT " . db_escape_key_identifier('value') . " FROM tupdate_settings WHERE \"key =\" 'current_update'");
break;
}
}
function getSystemInfo(&$systemInfo, $script = false) {
global $config;
$systemInfo['system_name'] = php_uname('s');
$systemInfo['system_host'] = php_uname('n');
$systemInfo['system_release'] = php_uname('r');
$systemInfo['system_version'] = php_uname('v');
$systemInfo['system_machine'] = php_uname('m');
if (!$script) {
$systemInfo['apache_version'] = apache_get_version();
$systemInfo['apache_modules'] = apache_get_modules();
}
$systemInfo['php_ini'] = ini_get_all();
$systemInfo['phpversion'] = phpversion();
foreach (get_loaded_extensions() as $module) {
$systemInfo['php_load_extensions'][$module] = phpversion($module);
}
$result = shell_exec('df -h | tail --lines=+2');
$temp = explode("\n", $result);
$disk = array();
foreach($temp as $line) {
$line = preg_replace('/[ ][ ]*/', " ", $line);
$temp2 = explode(' ', $line);
if (count($temp2) < 5) {
break;
}
$info = array(
'Filesystem' => $temp2[0],
'Size' => $temp2[1],
'Used' => $temp2[2],
'Use%' => $temp2[3],
'Avail' => $temp2[4],
'Mounted_on' => $temp2[5]
);
$disk[] = $info;
}
$systemInfo['disk'] = $disk;
$result = shell_exec('uptime');
preg_match('/.* load average: (.*)/', $result, $matches);
$systemInfo['load_average'] = $matches[1];
$result = shell_exec('ps -Ao cmd | tail --lines=+2');
$temp = explode("\n", $result);
foreach ($temp as $line) {
if ($line != '') {
$process[] = $line;
}
}
$systemInfo['process'] = $process;
$logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
$result = shell_exec('du -h ' . $logs_directory . ' | cut -d"/" -f1');
$systemInfo['size_var_log_pandora'] = $result;
$result = shell_exec('date');
$systemInfo['date'] = $result;
}
function getLastLinesLog($file, $numLines = 2000) {
$result = shell_exec('tail -n ' . $numLines . ' ' . $file);
return $result;
}
function show_logfile($file_name, $numLines = 2000) {
global $config;
if (!file_exists($file_name)) {
echo "<h2 class=error>" . __("Cannot find file") . "(" . $file_name .
")</h2>";
}
else {
if (!is_readable($file_name)) {
echo "<h2 class=error>" . __("Cannot read file") . "(" . $file_name .
")</h2>";
}
else {
echo "<h2>" . $file_name . "</h2>";
echo "<textarea style='width: 98%; height: 200px;' name='$file_name'>";
echo shell_exec('tail -n ' . $numLines . ' ' . $file_name);
echo "</textarea>";
}
}
}
function logFilesLines($file_name, $numLines) {
global $config;
if (!file_exists($file_name)) {
return '';
}
else {
if (!is_readable($file_name)) {
return '';
}
else {
return shell_exec('tail -n ' . $numLines . ' ' . $file_name);
}
}
}
function getLastLog($numLines = 2000) {
global $config;
$logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
show_logfile($config["homedir"]."/pandora_console.log", $numLines);
show_logfile($logs_directory."/pandora_server.log", $numLines);
show_logfile($logs_directory."/pandora_server.error", $numLines);
show_logfile("/etc/mysql/my.cnf", $numLines);
show_logfile($config["homedir"]."/include/config.php", $numLines);
show_logfile("/etc/pandora/pandora_server.conf", $numLines);
show_logfile("/var/log/syslog", $numLines);
}
function show_array($title, $anchor, $array = array()) {
$table = new StdClass();
$table->width = '100%';
$table->class = "databox filters";
$table->head = array();
$table->head[0] = $title;
$table->data = array();
foreach ($array as $index => $item) {
if (!is_array($item)) {
$row = array();
$row[] = $index;
$row[] = $item;
$table->data[] = $row;
}
else {
foreach ($item as $index2 => $item2) {
if (!is_array($item2)) {
$row = array();
$row[] = $index;
$row[] = $index2;
$row[] = $item2;
$table->data[] = $row;
}
else {
foreach ($item2 as $index3 => $item3) {
$row = array();
$row[] = $index;
$row[] = $index2;
$row[] = $index3;
$row[] = $item3;
$table->data[] = $row;
}
}
}
}
}
echo "<h1><a name='" . $anchor . "'>" . $title . "</a></h1>";
html_print_table($table);
}
function generate_info($checks, $log_num_lines = 2000) {
global $config;
$pandora_diag = isset($checks['pandora_diagnostic']) ? $checks['pandora_diagnostic'] : false;
$system_info = isset($checks['system_info']) ? $checks['system_info'] : false;
$log_info = isset($checks['log_info']) ? $checks['log_info'] : false;
$tempDirSystem = sys_get_temp_dir();
$nameDir = 'dir_' . uniqid();
$tempDir = $tempDirSystem . '/' . $nameDir . '/';
mkdir($tempDir);
$zipArchive = $config['attachment_store'] . '/last_info.zip';
@unlink($zipArchive);
$url_zip = ui_get_full_url(false);
$url = $url_zip . 'attachment/last_info.zip';
$result = array();
$result['success'] = false;
$result['url'] = $url;
$result['location'] = $zipArchive;
$some_check = $log_info || $system_info || $pandora_diag;
$zip = new ZipArchive;
$zip_openned = $zip->open($zipArchive, ZIPARCHIVE::CREATE) === true;
if ($some_check && $zip_openned) {
if ($pandora_diag) {
$systemInfo = array();
getPandoraDiagnostic($systemInfo);
$file = fopen($tempDir . 'pandora_diagnostic.txt', 'w');
if ($file !== false) {
ob_start();
foreach ($systemInfo as $index => $item) {
if (is_array($item)) {
foreach ($item as $secondIndex => $secondItem) {
echo $index. ";" . $secondIndex . ";" . $secondItem . "\n";
}
}
else {
echo $index . ";" . $item . "\n";
}
}
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$zip->addFile($tempDir . 'pandora_diagnostic.txt', 'pandora_diagnostic.txt');
}
if ($system_info) {
$info = array();
getSystemInfo($info);
$file = fopen($tempDir . 'system_info.txt', 'w');
if ($file !== false) {
ob_start();
$string = "";
foreach ($info as $index => $item) {
if (is_array($item)) {
foreach ($item as $secondIndex => $secondItem) {
if (is_array($secondItem)) {
foreach ($secondItem as $thirdIndex => $thirdItem) {
if (is_array($thirdItem)) {
echo $index. ";" . $secondIndex . ";" . $thirdIndex . "\n";
}
else {
echo $index. ";" . $secondIndex . ";" . $thirdIndex . ";" . $thirdItem . "\n";
}
}
}
else {
echo $index. ";" . $secondIndex . ";" . $secondItem . "\n";
}
}
}
else {
echo $index . ";" . $item . "\n";
}
}
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$zip->addFile($tempDir . 'system_info.txt', 'system_info.txt');
}
$server_logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
if ($log_info) {
file_put_contents($tempDir . 'pandora_console.log.lines_' . $log_num_lines, getLastLinesLog($config["homedir"]."/pandora_console.log", $log_num_lines));
$zip->addFile($tempDir . 'pandora_console.log.lines_' . $log_num_lines, 'pandora_console.log.lines_' . $log_num_lines);
file_put_contents($tempDir . 'pandora_server.log.lines_' . $log_num_lines, getLastLinesLog($server_logs_directory."/pandora_server.log", $log_num_lines));
$zip->addFile($tempDir . 'pandora_server.log.lines_' . $log_num_lines, 'pandora_server.log.lines_' . $log_num_lines);
file_put_contents($tempDir . 'pandora_server.error.lines_' . $log_num_lines, getLastLinesLog($server_logs_directory."/pandora_server.error", $log_num_lines));
$zip->addFile($tempDir . 'pandora_server.error.lines_' . $log_num_lines, 'pandora_server.error.lines_' . $log_num_lines);
file_put_contents($tempDir . 'my.cnf.lines_' . $log_num_lines, getLastLinesLog("/etc/mysql/my.cnf", $log_num_lines));
$zip->addFile($tempDir . 'my.cnf.lines_' . $log_num_lines, 'my.cnf.lines_' . $log_num_lines);
file_put_contents($tempDir . 'config.php.lines_' . $log_num_lines, getLastLinesLog($config["homedir"]."/include/config.php", $log_num_lines));
$zip->addFile($tempDir . 'config.php.lines_' . $log_num_lines, 'config.php.lines_' . $log_num_lines);
file_put_contents($tempDir . 'pandora_server.conf.lines_' . $log_num_lines, getLastLinesLog("/etc/pandora/pandora_server.conf", $log_num_lines));
$zip->addFile($tempDir . 'pandora_server.conf.lines_' . $log_num_lines, 'pandora_server.conf.lines_' . $log_num_lines);
file_put_contents($tempDir . 'syslog.lines_' . $log_num_lines, getLastLinesLog("/var/log/syslog", $log_num_lines));
$zip->addFile($tempDir . 'syslog.lines_' . $log_num_lines, 'syslog.lines_' . $log_num_lines);
}
$zip->close();
$result['date'] = ui_print_timestamp(filectime($zipArchive), true);
$result['success'] = true;
}
elseif (!$some_check) {
$result['message'] = __('No options selected');
}
elseif (!$zip_openned) {
$result['message'] = __('There was an error with the zip file');
}
return $result;
}
function mainSystemInfo() {
global $config;
if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) {
db_pandora_audit("ACL Violation", "Trying to access Setup Management");
require ("general/noaccess.php");
return;
}
$show = (bool) get_parameter('show');
$generate = (bool) get_parameter('generate');
$pandora_diag = (bool) get_parameter('pandora_diag', 0);
$system_info = (bool) get_parameter('system_info', 0);
$log_info = (bool) get_parameter('log_info', 0);
$log_num_lines = (int) get_parameter('log_num_lines', 2000);
ui_print_page_header (__("System Info"), "images/extensions.png", false, "", true, "" );
echo '<div class="notify">';
echo __("This extension can run as PHP script in a shell for extract more information, but it must be run as root or across sudo. For example: <i>sudo php /var/www/pandora_console/extensions/system_info.php -d -s -c</i>");
echo '</div>';
$table = new StdClass();
$table->width = '100%';
$table->class = 'databox filters';
$table->align = array();
if ($pandora_diag) {
$table->data[0][0] = '<a href="#diag_info">' .
__('Pandora Diagnostic info') . "</a>";
}
else {
$table->data[0][0] = __('Pandora Diagnostic info');
}
$table->data[0][0] .= html_print_checkbox('pandora_diag', 1, $pandora_diag, true);
if ($system_info) {
$table->data[0][2] = '<a href="#system_info">' . __('System info') . '</a>';
}
else {
$table->data[0][2] = __('System info');
}
$table->data[0][2] .= html_print_checkbox('system_info', 1, $system_info, true);
if ($log_info) {
$table->data[0][3] = '<a href="#log_info">' . __('Log Info') . '</a>';
}
else {
$table->data[0][3] = __('Log Info');
}
$table->data[0][3] .= html_print_checkbox('log_info', 1, $log_info, true);
$table->data[0][4] = __('Number lines of log');
$table->data[0][4] .= html_print_input_text('log_num_lines', $log_num_lines, __('Number lines of log'), 5, 10, true);
$default_location = $config['attachment_store'] . '/last_info.zip';
$file_exists = file_exists($default_location) && is_readable($default_location);
$table_file = new StdClass();
$table_file->id = "table_file";
$table_file->class = "databox filters";
$table_file->width = '100%';
$table_file->style = array();
$table_file->style[0] = "font-weight: bold";
$table_file->data = array();
$display_file_link = $file_exists ? "" : "style=\"display: none;\"";
$url = ui_get_full_url(false) . "attachment/last_info.zip";
$file_link = "<a href=\"$url\" $display_file_link>";
$file_link .= html_print_image('images/file.png', true, array('title' => __('Download'))); // Download image
$file_link .= "</a>";
$data = array();
$data[0] = __('File');
$data['cell-link'] = $file_link;
$table_file->data['row_link'] = $data;
$data = array();
$data[0] = __('Created');
$data['cell-date'] = $file_exists ? ui_print_timestamp(filectime($default_location), true) : '';
$table_file->data['row_date'] = $data;
$data = array();
$data[0] = __('Location');
$data['cell-location'] = $file_exists ? $default_location : '';
$table_file->data['row_location'] = $data;
echo "<form method='post' action='index.php?extension_in_menu=gsetup&sec=gextensions&sec2=extensions/system_info'>";
html_print_table($table);
$display_table_file = $file_exists ? "" : "style=\"display: none;\"";
echo "<div id=\"table_file_container\" $display_table_file>";
html_print_table($table_file);
echo "</div>";
echo "<div style='width: " . $table->width . "; text-align: right;'>";
html_print_submit_button(__('Generate file'), 'generate', false, 'class="sub next"');
html_print_image('images/spinner.gif', false, array('id' => 'spinner_img', 'title' => __('Loading'), 'style' => 'display: none;'));
echo "</div>";
echo "</form>";
if ($show) {
if ($pandora_diag) {
$info = array();
getPandoraDiagnostic($info);
show_array(__('Pandora Diagnostic info'), 'diag_info', $info);
}
if ($system_info) {
$info = array();
getSystemInfo($info);
show_array(__('System info'), 'system_info', $info);
}
if ($log_info) {
echo "<h1><a name='log_info'>" . __('Log Info') . "</a></h1>";
getLastLog($log_num_lines);
}
}
elseif ($generate) {
$checks = array();
$checks['pandora_diagnostic'] = $pandora_diag;
$checks['system_info'] = $system_info;
$checks['log_info'] = $log_info;
$result = generate_info($checks, $log_num_lines);
if ($result['success']) {
echo '<b>' . __('File') . ':</b> ' . $result['url'] . '<br />';
echo '<b>' . __('Location') . ':</b> ' . $result['location'];
}
elseif (isset($result['message'])) {
echo $result['message'];
}
else {
echo __('Error');
}
}
?>
<script type="text/javascript">
$("#submit-generate").click(function(e) {
e.preventDefault();
if ($("#checkbox-pandora_diag").prop('checked')
|| $("#checkbox-system_info").prop('checked')
|| $("#checkbox-log_info").prop('checked')) {
generate_info();
} else {
alert('<?php echo __('At least one option must be selected'); ?>');
}
});
function generate_info () {
$("#submit-generate").hide();
$("#spinner_img").show();
$.ajax({
url: 'ajax.php',
type: 'POST',
dataType: 'json',
data: {
page: <?php echo json_encode(EXTENSIONS_DIR) ?> + '/system_info',
generate_info: 1,
pandora_diag: Number($("#checkbox-pandora_diag").prop('checked')),
system_info: Number($("#checkbox-system_info").prop('checked')),
log_info: Number($("#checkbox-log_info").prop('checked')),
log_num_lines: $("#text-log_num_lines").val()
},
complete: function() {
$("#spinner_img").hide();
$("#submit-generate").show();
},
success: function(data) {
if (data.success) {
$("#table_file-row_link-cell-link").find("a").prop("href", data.url).show();
$("#table_file-row_date-cell-date").html(data.date);
$("#table_file-row_location-cell-location").html(data.location);
$("#table_file_container").slideDown();
}
else {
$("#table_file-row_link-cell-link").find("a").prop("href", "");
$("#table_file-row_date-cell-date").html("");
$("#table_file-row_location-cell-location").html("");
$("#table_file_container").slideUp();
alert(data.message);
}
},
error: function(xhr, textStatus, errorThrown) {
$("#table_file-row_link-cell-link").find("a").prop("href", "");
$("#table_file-row_date-cell-date").html("");
$("#table_file-row_location-cell-location").html("");
$("#table_file_container").slideUp();
alert('<?php echo __('Error'); ?>');
}
});
}
</script>
<?php
}
function consoleMode() {
//Execution across the shell
global $config;
global $argv;
$tempDirSystem = sys_get_temp_dir();
$nameDir = 'dir_' . uniqid();
$tempDir = $tempDirSystem . '/' . $nameDir . '/';
$result = mkdir($tempDir);
if ($result == false) {
echo "Error in creation of temp dir.";
return;
}
$pandoraDiag = false;
$pandoraSystemInfo = false;
$pandoraConfFiles = false;
if ((array_search('-h', $argv) !== false)
|| (array_search('--help', $argv) !== false)) {
echo "Usage is:\n" .
"\t-h --help : show this help\n" .
"\t-d --pandora_diagnostic : generate pandora diagnostic data\n" .
"\t-s --system_info : generate system info data\n" .
"\t-c --conf_files : generate conf\n";
}
else {
$index = array_search('-d', $argv);
if ($index === false) {
$index = array_search('--pandora_diagnostic', $argv);
}
if ($index !== false) {
$pandoraDiag = true;
}
$index = array_search('-s', $argv);
if ($index === false) {
$index = array_search('--system_info', $argv);
}
if ($index !== false) {
$pandoraSystemInfo = true;
}
$index = array_search('-c', $argv);
if ($index === false) {
$index = array_search('--conf_files', $argv);
}
if ($index !== false) {
$pandoraConfFiles = true;
}
if ($pandoraDiag) {
$systemInfo = array();
getPandoraDiagnostic($systemInfo);
$file = fopen($tempDir . 'pandora_diagnostic.txt', 'w');
if ($file !== false) {
ob_start();
foreach ($systemInfo as $index => $item) {
if (is_array($item)) {
foreach ($item as $secondIndex => $secondItem) {
echo $index. ";" . $secondIndex . ";" . $secondItem . "\n";
}
}
else {
echo $index . ";" . $item . "\n";
}
}
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
}
if ($pandoraSystemInfo) {
$systemInfo = array();
getSystemInfo($systemInfo, true);
$file = fopen($tempDir . 'system_info.txt', 'w');
if ($file !== false) {
ob_start();
foreach ($systemInfo as $index => $item) {
if (is_array($item)) {
foreach ($item as $secondIndex => $secondItem) {
if (is_array($secondItem)) {
foreach ($secondItem as $thirdIndex => $thirdItem) {
echo $index. ";" . $secondIndex . ";" . $thirdIndex . ";" . $thirdItem . "\n";
}
}
else {
echo $index. ";" . $secondIndex . ";" . $secondItem . "\n";
}
}
}
else {
echo $index . ";" . $item . "\n";
}
}
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
}
if ($pandoraConfFiles) {
$lines = 2000;
$system_logs_directory = (!empty($config["server_log_dir"])) ? io_safe_output($config["server_log_dir"]) : "/var/log/pandora";
$file = fopen($tempDir . 'pandora_console.log' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog($config["homedir"]."/pandora_console.log", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'pandora_server.log' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog($system_logs_directory."/pandora_server.log", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'pandora_server.error' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog($system_logs_directory."/pandora_server.error", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'my.cnf', 'w');
if ($file !== false) {
ob_start();
echo file_get_contents('/etc/mysql/my.cnf');
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'my.cnf', 'w');
if ($file !== false) {
ob_start();
echo file_get_contents($config["homedir"]."/include/config.php");
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'pandora_server.conf', 'w');
if ($file !== false) {
ob_start();
echo file_get_contents("/etc/pandora/pandora_server.conf");
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'syslog' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog("/var/log/syslog", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'pandora_server.error' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog($system_logs_directory."/pandora_server.error", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
$file = fopen($tempDir . 'pandora_server.log' . $lines, 'w');
if ($file !== false) {
ob_start();
echo getLastLinesLog($system_logs_directory."/pandora_server.log", $lines);
$output = ob_get_clean();
fwrite($file, $output);
fclose($file);
}
}
echo 'tar zcvf ' . $tempDirSystem . '/' . $nameDir . '.tar.gz ' . $tempDir . '*' . "\n";
$result = shell_exec('tar zcvf ' . $tempDirSystem . '/' . $nameDir . '.tar.gz ' . $tempDir . '*');
//TODO Delete the temp directory
echo "You find the result file in " . $tempDirSystem . '/' . $nameDir . ".tar.gz\n";
}
}
if (!isset($argv)) {
//Execution across the browser
extensions_add_godmode_function('mainSystemInfo');
extensions_add_godmode_menu_option(__('System Info'), 'PM', 'gextensions', null, "v1r1");
}
else {
$dir = dirname($_SERVER['PHP_SELF']);
$dir = str_replace("\\", "/", $dir); // Windows compatibility
if (file_exists($dir . "/../include/config.php"))
include $dir . "/../include/config.php";
consoleMode();
}
?>

View File

@ -125,7 +125,7 @@ echo "<tr><th style='background-color:#b1b1b1;font-weight:bold;font-style:italic
render_row (phpversion(), "PHP Version");
render_row (ini_get('max_execution_time'), "PHP Max ejecution time");
render_row (ini_get('max_execution_time'), "PHP Max execution time");
render_row (ini_get('max_input_time'), "PHP Max input time");
@ -161,13 +161,9 @@ render_info_data ("SELECT COUNT( DISTINCT tagente.id_agente)
AND tagente_estado.id_agente = tagente.id_agente
AND tagente_estado.estado = 3","Total unknown agents");
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 = 4","Total not-init modules");
render_info_data ("SELECT COUNT(tagente_estado.estado)
FROM tagente_estado
WHERE tagente_estado.estado = 4","Total not-init modules");
$last_run_difference = '';

View File

@ -1150,10 +1150,10 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned;
INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 4);
INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 7);
UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager';
DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise';
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '708');
INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '714');
-- ---------------------------------------------------------------------
-- Table `tplanned_downtime_agents`

View File

@ -181,7 +181,7 @@ $order_collation = "";
switch ($config["dbtype"]) {
case "mysql":
$order_collation = "";
//$order_collation = "COLLATE utf8_general_ci";
$order_collation = "COLLATE utf8_general_ci";
break;
case "postgresql":
case "oracle":
@ -540,10 +540,6 @@ if ($agents !== false) {
}
echo '<span class="left">';
echo "<strong>";
if ($agent['quiet']) {
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
echo "&nbsp;";
}
if (check_acl ($config["id_user"], $agent["id_grupo"], "AW")) {
$main_tab = 'main';
@ -562,8 +558,10 @@ if ($agents !== false) {
"</a>";
echo "</strong>";
$in_planned_downtime = db_get_value_filter('id', 'tplanned_downtime_agents', array('id_agent' => $agent["id_agente"]));
$in_planned_downtime = db_get_sql('SELECT executed FROM tplanned_downtime
INNER JOIN tplanned_downtime_agents ON tplanned_downtime.id = tplanned_downtime_agents.id_downtime
WHERE tplanned_downtime_agents.id_agent = '. $agent["id_agente"] . ' AND tplanned_downtime.executed = 1');
if ($agent["disabled"]) {
ui_print_help_tip(__('Disabled'));
@ -571,6 +569,11 @@ if ($agents !== false) {
echo "</em>";
}
}
if ($agent['quiet']) {
echo "&nbsp;";
html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => ""));
}
if ($in_planned_downtime) {
ui_print_help_tip (__('Agent in planned downtime'), false, 'images/minireloj-16.png');

View File

@ -1,110 +0,0 @@
<?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;
ui_print_page_header (__('Database maintenance').' &raquo; '.__('Database audit purge'), "images/gm_db.png", false, "", true);
check_login ();
if (! check_acl ($config['id_user'], 0, "DM")) {
db_pandora_audit("ACL Violation",
"Trying to access Database Management Audit");
require ("general/noaccess.php");
return;
}
// All data (now)
$time["all"] = get_system_time ();
// 1 day ago
$time["1day"] = $time["all"] - SECONDS_1DAY;
// 3 days ago
$time["3day"] = $time["all"] - ( SECONDS_1DAY * 3);
// 1 week ago
$time["1week"] = $time["all"] - SECONDS_1WEEK;
// 2 weeks ago
$time["2week"] = $time["all"] - SECONDS_2WEEK;
// 1 month ago
$time["1month"] = $time["all"] - SECONDS_1MONTH;
// Three months ago
$time["3month"] = $time["all"] - SECONDS_3MONTHS;
// Todo for a good DB maintenance
/*
- Delete too on datos_string and and datos_inc tables
- A function to "compress" data, and interpolate big chunks of data (1 month - 60000 registers)
onto a small chunk of interpolated data (1 month - 600 registers)
- A more powerful selection (by Agent, by Module, etc).
*/
# ADQUIRE DATA PASSED AS FORM PARAMETERS
# ======================================
# Purge data using dates
if (isset($_POST["purgedb"])) { # Fixed 2005-1-13, nil
$from_date = get_parameter_post("date_purge");
$deleted = db_process_sql_delete('tsesion', array('utimestamp' => '< ' . $from_date));
if ($deleted)
ui_print_success_message(__('Success data deleted'));
else
ui_print_error_message(__('Error deleting data'));
}
# End of get parameters block
echo "<table cellpadding='4' cellspacing='4' class='databox filters' width='100%'>";
echo "<tr><td class='datos'>";
$result = db_get_row_sql ("SELECT COUNT(*) AS total, MIN(fecha) AS first_date, MAX(fecha) AS latest_date FROM tsesion");
echo "<b>".__('Total')."</b></td>";
echo "<td class='datos'>".$result["total"]." ".__('Records')."</td>";
echo "<tr>";
echo "<td class='datos2'><b>".__('First date')."</b></td>";
echo "<td class='datos2'>".$result["first_date"]."</td></tr>";
echo "<tr><td class='datos'>";
echo "<b>".__('Latest date')."</b></td>";
echo "<td class='datos'>".$result["latest_date"]."</td>";
echo "</tr></table>";
?>
<h4><?php echo __('Purge data') ?></h4>
<form name="db_audit" method="post" action="index.php?sec=gdbman&sec2=godmode/db/db_audit">
<table width='100%' cellpadding='4' cellspacing='4' class='databox filters'>
<tr><td class='datos'>
<select name="date_purge">
<option value="<?php echo $time["3month"] ?>"><?php echo __('Purge audit data over 90 days') ?></option>
<option value="<?php echo $time["1month"] ?>"><?php echo __('Purge audit data over 30 days') ?></option>
<option value="<?php echo $time["2week"] ?>"><?php echo __('Purge audit data over 14 days') ?></option>
<option value="<?php echo $time["1week"] ?>"><?php echo __('Purge audit data over 7 days') ?></option>
<option value="<?php echo $time["3day"] ?>"><?php echo __('Purge audit data over 3 days') ?></option>
<option value="<?php echo $time["1day"] ?>"><?php echo __('Purge audit data over 1 day') ?></option>
<option value="<?php echo $time["all"] ?>"><?php echo __('Purge all audit data') ?></option>
</select>
</td>
<td class="datos">
<input class="sub wand" type="submit" name="purgedb" value="<?php echo __('Do it!') ?>" onClick="if (!confirm('<?php echo __('Are you sure?') ?>')) return false;">
</table>
</form>

View File

@ -1,94 +0,0 @@
<?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 ();
ui_print_page_header (__('Database maintenance').' &raquo; ' .
__('Event database cleanup'), "images/gm_db.png", false, "", true);
if (! check_acl ($config['id_user'], 0, "DM")) {
db_pandora_audit("ACL Violation", "Trying to access Database Management Event");
require ("general/noaccess.php");
exit;
}
# ADQUIRE DATA PASSED AS FORM PARAMETERS
# ======================================
# Purge data using dates
if (isset ($_POST["date_purge"])) {
$from_date = (int) get_parameter_post ("date_purge");
$deleted = db_process_sql_delete('tevento',
array('utimestamp' => '< ' . $from_date));
if ($deleted !== false) {
ui_print_success_message(__('Successfully deleted old events'));
}
else {
ui_print_error_message(__('Error deleting old events'));
}
}
# End of get parameters block
$row = db_get_row_sql ("
SELECT COUNT(*) AS total,
MIN(timestamp) AS first_date,
MAX(timestamp) AS latest_date
FROM tevento");
$table = new stdClass();
$table->data = array ();
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->class = "databox filters";
$table->width = '100%';
$table->data[0][0] = '<b>'.__('Total').':</b>';
$table->data[0][1] = $row["total"].' '.__('Records');
$table->data[1][0] = '<b>'.__('First date').':</b>';
$table->data[1][1] = $row["first_date"];
$table->data[2][0] = '<b>'.__('Latest data').':</b>';
$table->data[2][1] = $row["latest_date"];
html_print_table ($table);
unset ($table);
echo '<h4>'.__('Purge data').'</h4>';
echo '<form name="db_audit" method="post" action="index.php?sec=gdbman&sec2=godmode/db/db_event">';
echo '<table width="100%" cellpadding="4" cellspacing="4" class="databox filters">
<tr><td class="datos">';
$time = get_system_time ();
$fields = array ();
$fields[$time - SECONDS_3MONTHS] = __('Purge event data over 90 days');
$fields[$time - SECONDS_1MONTH] = __('Purge event data over 30 days');
$fields[$time - SECONDS_2WEEK] = __('Purge event data over 14 days');
$fields[$time - SECONDS_1WEEK] = __('Purge event data over 7 days');
$fields[$time - (SECONDS_1WEEK * 3)] = __('Purge event data over 3 days');
$fields[$time - SECONDS_1DAY] = __('Purge event data over 1 day');
$fields[$time] = __('Purge all event data');
html_print_select ($fields, "date_purge", '', '', '', '0', false, false, false, "w255");
echo '</td><td class="datos">';
html_print_submit_button (__('Do it!'),'purgedb', false, 'class="sub wand" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;"');
echo '</td></tr></table></form>';
?>

View File

@ -1,36 +0,0 @@
<?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, "DM")) {
db_pandora_audit("ACL Violation",
"Trying to access Database Management Info");
require ("general/noaccess.php");
return;
}
require_once ($config['homedir'] . '/include/functions_graph.php');
ui_print_page_header (__('Database maintenance').' &raquo; '.__('Database information'), "images/gm_db.png", false, "", true);
echo '<h4>'.__('Module data received').'</h4>';
echo grafico_db_agentes_purge(0, 600, 400);
?>

View File

@ -1,356 +0,0 @@
<?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;
require_once ($config["homedir"] . '/include/functions_graph.php');
require_once($config['homedir'] . "/include/functions_agents.php");
require_once($config['homedir'] . "/include/functions_modules.php");
check_login ();
if (! check_acl ($config['id_user'], 0, "DM")) {
db_pandora_audit( "ACL Violation",
"Trying to access Database Purge Section");
include ("general/noaccess.php");
exit;
}
//id_agent = -1: None selected; id_agent = 0: All
$id_agent = (int) get_parameter_post ("agent", -1);
ui_print_page_header (__('Database maintenance') . ' &raquo; ' .
__('Database purge'), "images/gm_db.png", false, "", true);
echo grafico_db_agentes_purge($id_agent);
echo '<br /><br />';
echo '<h4>' . __('Get data from agent') . '</h4>';
// All data (now)
$time["all"] = get_system_time ();
// 1 day ago
$time["1day"] = $time["all"] - SECONDS_1DAY;
// 3 days ago
$time["3day"] = $time["all"] - SECONDS_1DAY * 3;
// 1 week ago
$time["1week"] = $time["all"] - SECONDS_1WEEK;
// 2 weeks ago
$time["2week"] = $time["all"] - SECONDS_1WEEK * 2;
// 1 month ago
$time["1month"] = $time["all"] - SECONDS_1MONTH;
// Three months ago
$time["3month"] = $time["all"] - SECONDS_3MONTHS;
//Init data
$data["1day"] = 0;
$data["3day"] = 0;
$data["1week"] = 0;
$data["2week"] = 0;
$data["1month"] = 0;
$data["3month"] = 0;
$data["total"] = 0;
// Purge data using dates
if (isset($_POST["purgedb"])) {
$from_date = get_parameter_post ("date_purge", 0);
if ($id_agent > 0) {
echo sprintf(
__("Purge task launched for agent %s :: Data older than %s"),
agents_get_name ($id_agent), human_time_description_raw ($from_date));
echo "<h3>" .
__('Please be patient. This operation can take a long time depending on the amount of modules.') .
"</h3>";
$sql = sprintf ("SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente = %d", $id_agent);
$result = db_get_all_rows_sql ($sql);
if (empty ($result)) {
$result = array ();
}
$errors = 0;
$affected = 0;
foreach ($result as $row) {
echo sprintf(__('Deleting records for module %s'),
modules_get_agentmodule_name ($row["id_agente_modulo"]));
echo "<br />";
flush (); //Flush here in case there are errors and the script dies, at least we know where we ended
set_time_limit (); //Reset the time limit just in case
$result = db_process_sql_delete('tagente_datos',
array('id_agente_modulo' => $row["id_agente_modulo"],
'utimestamp' => '< ' . $from_date));
if ($result === false)
$errors++;
else
$affected += $result;
if ($errors == 0) {
$result = db_process_sql_delete('tagente_datos_inc',
array('id_agente_modulo' => $row["id_agente_modulo"],
'utimestamp' => '< ' . $from_date));
if ($result === false)
$errors++;
else
$affected += $result;
}
if ($errors == 0) {
$result = db_process_sql_delete('tagente_datos_string',
array('id_agente_modulo' => $row["id_agente_modulo"],
'utimestamp' => '< ' . $from_date));
if ($result === false)
$errors++;
else
$affected += $result;
}
if ($errors == 0) {
$result = db_process_sql_delete('tagente_datos_log4x',
array('id_agente_modulo' => $row["id_agente_modulo"],
'utimestamp' => '< ' . $from_date));
if ($result === false)
$errors++;
else
$affected += $result;
}
}
if ($errors > 0) {
echo sprintf(__('Total errors: %s'), $errors);
echo sprintf(__('Total records deleted: %s'), $affected);
}
else {
echo sprintf(__('Total records deleted: %s'), $affected);
}
}
else {
//All agents
echo __('Deleting records for all agents');
flush ();
db_process_sql_delete('tagente_datos',
array('utimestamp' => '< ' . $from_date));
db_process_sql_delete('tagente_datos_inc',
array('utimestamp' => '< ' . $from_date));
db_process_sql_delete('tagente_datos_string',
array('utimestamp' => '< ' . $from_date));
db_process_sql_delete('tagente_datos_log4x',
array('utimestamp' => '< ' . $from_date));
}
echo "<br /><br />";
}
# Select Agent for further operations.
$agents = agents_get_group_agents (0, true);
$agents[-1] = __('Choose agent');
$agents[0] = __('All agents');
echo '<form action="index.php?sec=gdbman&sec2=godmode/db/db_purge" method="post">';
echo '<div style="width:100%;">';
html_print_select ($agents, "agent", $id_agent, "this.form.submit();", "", "", false, false, false);
ui_print_help_tip (__("Select the agent you want information about"));
echo '<noscript>';
html_print_submit_button (__('Get data'), 'purgedb_ag', false, 'class="sub upd"');
ui_print_help_tip (__("Click here to get the data from the agent specified in the select box"));
echo '</noscript><br />';
if ($id_agent > 0) {
$title = __('Information on agent %s in the database', agents_get_name ($id_agent));
}
else {
$title = __('Information on all agents in the database');
}
echo '<h4>' . $title . '</h4>';
//Flush before we do some SQL stuff
flush ();
if ($id_agent > 0) { //If the agent is not All or Not selected
$modules = agents_get_modules ($id_agent);
$query = sprintf (" AND id_agente_modulo IN (%s)", implode (",", array_keys ($modules)));
}
else {
$query = "";
}
$data["1day"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > %d %s", $time["1day"], $query));
$data["3day"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > %d %s", $time["3day"], $query));
$data["1week"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > %d %s", $time["1week"], $query));
$data["2week"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > %d %s", $time["2week"], $query));
$data["1month"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > %d %s", $time["1month"], $query));
$data["3month"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE utimestamp > %d %s", $time["3month"], $query));
$data["total"] = db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos
WHERE 1=1 %s", $query));
$data["1day"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE utimestamp > %d %s", $time["1day"], $query));
$data["3day"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE utimestamp > %d %s", $time["3day"], $query));
$data["1week"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE utimestamp > %d %s", $time["1week"], $query));
$data["2week"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE utimestamp > %d %s", $time["2week"], $query));
$data["1month"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE utimestamp > %d %s", $time["1month"], $query));
$data["3month"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE utimestamp > %d %s", $time["3month"], $query));
$data["total"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_inc
WHERE 1=1 %s", $query));
$data["1day"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > %d %s", $time["1day"], $query));
$data["3day"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > %d %s", $time["3day"], $query));
$data["1week"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > %d %s", $time["1week"], $query));
$data["2week"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > %d %s", $time["2week"], $query));
$data["1month"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > %d %s", $time["1month"], $query));
$data["3month"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE utimestamp > %d %s", $time["3month"], $query));
$data["total"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_string
WHERE 1=1 %s", $query));
$data["1day"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > %d %s", $time["1day"], $query));
$data["3day"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > %d %s", $time["3day"], $query));
$data["1week"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > %d %s", $time["1week"], $query));
$data["2week"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > %d %s", $time["2week"], $query));
$data["1month"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > %d %s", $time["1month"], $query));
$data["3month"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE utimestamp > %d %s", $time["3month"], $query));
$data["total"] += db_get_sql (sprintf ("
SELECT COUNT(*)
FROM tagente_datos_log4x
WHERE 1=1 %s", $query));
$table->width = '98%';
$table->border = 0;
$table->class = "databox";
$table->data[0][0] = __('Packets less than three months old');
$table->data[0][1] = format_numeric($data["3month"]);
$table->data[1][0] = __('Packets less than one month old');
$table->data[1][1] = format_numeric($data["1month"]);
$table->data[2][0] = __('Packets less than two weeks old');
$table->data[2][1] = format_numeric($data["2week"]);
$table->data[3][0] = __('Packets less than one week old');
$table->data[3][1] = format_numeric($data["1week"]);
$table->data[4][0] = __('Packets less than three days old');
$table->data[4][1] = format_numeric($data["3day"]);
$table->data[5][0] = __('Packets less than one day old');
$table->data[5][1] = format_numeric($data["1day"]);
$table->data[6][0] = '<strong>'.__('Total number of packets').'</strong>';
$table->data[6][1] = '<strong>'.format_numeric($data["total"]).'</strong>';
html_print_table ($table);
echo '<br />';
echo '<h4>' . __('Purge data') . '</h4>';
$table->data = array ();
$times = array ();
$times[$time["3month"]] = __('Purge data over 3 months');
$times[$time["1month"]] = __('Purge data over 1 month');
$times[$time["2week"]] = __('Purge data over 2 weeks');
$times[$time["1week"]] = __('Purge data over 1 week');
$times[$time["3day"]] = __('Purge data over 3 days');
$times[$time["1day"]] = __('Purge data over 1 day');
$times[$time["all"]] = __('All data until now');
$table->data[0][0] = html_print_select ($times, 'date_purge', '', '',
'', '', true, false, false);
$table->data[0][1] = html_print_submit_button (__('Purge'), "purgedb",
false, 'class="sub wand"', true);
html_print_table ($table);
echo '</form>';
?>

View File

@ -1,122 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 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, "DM")) {
db_pandora_audit("ACL Violation","Trying to access Database Debug Admin section");
require ("general/noaccess.php");
exit;
}
require_once($config['homedir'] . "/include/functions_agents.php");
require_once($config['homedir'] . "/include/functions_modules.php");
require_once($config['homedir'] . '/include/functions_users.php');
ui_print_page_header (__('Database maintenance').' &raquo; '.__('Database debug'), "images/gm_db.png", false, "", true);
if ((isset ($_GET["operacion"])) && (!isset ($_POST["update_agent"]))) {
// DATA COPY
if (isset ($_POST["eliminar"])) {
$max = get_parameter_post ("max", 0);
$min = get_parameter_post ("min", 0);
if ($max == $min) {
ui_print_error_message(__('Error').': '.__('Maximum is equal to minimum'));
return;
}
$origen_modulo = get_parameter_post ("origen_modulo", array ());
if (empty ($origen_modulo)) {
ui_print_success_message(__('Error').': '.__('No modules have been selected'));
return;
}
// Source (agent)
$id_origen = (int) get_parameter_post ("origen", 0);
// Copy
foreach ($origen_modulo as $id_agentemodulo) {
echo "<br /><br />".__('Filtering data module')."<b> [".modules_get_agentmodule_name ($id_agentemodulo)."]</b>";
if ($config["dbtype"] == 'oracle') {
$sql = sprintf ("DELETE FROM tagente_datos
WHERE id_agente_modulo = %d
AND (datos < TO_BINARY_DOUBLE('%s')
OR datos > TO_BINARY_DOUBLE('%s'))", $id_agentemodulo, $min, $max);
}
else {
$sql = sprintf ("DELETE FROM tagente_datos
WHERE id_agente_modulo = %d
AND (datos < '%s'
OR datos > '%s')", $id_agentemodulo, $min, $max);
}
db_process_sql ($sql);
}
} //if copy modules or alerts
echo '<br /><br />';
ui_print_success_message(__('Filtering completed'));
}
echo '<form method="post" action="index.php?sec=gdbman&sec2=godmode/db/db_refine&operacion=1">';
echo "<table width='100%' border='0' cellspacing='4' cellpadding='4' class='databox filters'>";
echo '<tr><td class="datost">';
echo '<div style="float:left; width: 250px;">';
echo '<b>'.__('Source agent').'</b><br /><br />';
$agent_selected = get_parameter_post ("origen", 0);
$agents = agents_get_group_agents (array_keys (users_get_groups ($config["id_user"], "DM")));
html_print_select ($agents, "origen", $agent_selected, 'javascript:this.form.update_agent.click();', __('No agent selected'), '0', false, false, false, '', false, 'max-width:300px !important;');
echo '&nbsp;&nbsp;';
html_print_submit_button (__('Get Info'), 'update_agent', false, 'style="display:none;"');
echo '<br /><br />';
echo '<b>'.__('Modules').'</b><br /><br />';
$module_selected = get_parameter_post ("origen", array ());
$modules = agents_get_modules ($module_selected, false, 'delete_pending != 1');
html_print_select ($modules, "origen_modulo[]", $module_selected, '', '', '0', false, true, false, '', false, 'max-width: 300px !important;');
echo '</div>'; //Left div
echo '<div style="float:left; width:\'98%\'; margin-left:20% ">
<b>'.__('Purge data out of these limits').'</b><br /><br />';
echo '<table><tr><td>';
echo __('Minimum').': ';
echo '</td><td>';
html_print_input_text ("min", 0, __('Minimum'), 4, 0, false);
echo '</td></tr>';
echo '<tr><td>';
echo __('Maximum').': ';
echo '</td><td>';
html_print_input_text ("max", 0, __('Maximum'), 4, 0, false);
echo '</td></tr>';
echo '</table>';
echo '</div>';
echo '<div style="clear:both;">&nbsp;</div>';
html_print_submit_button (__('Delete'), 'eliminar', false, 'class="sub delete" onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;"');
echo '</td></tr></table>';
?>

View File

@ -600,7 +600,7 @@ $(document).ready (function () {
var params = {
"page" : "operation/agentes/ver_agente",
"get_agent_modules_json" : 1,
"get_id_and_name" : 1,
"get_distinct_name" : 1,
"indexed" : 0,
"privilege" : "AW"
};
@ -799,7 +799,6 @@ $(document).ready (function () {
var others = true;
}
if(any && others){
document.forms["form_modules"].agents[i].selected = false;
document.forms["form_modules"].agents[0].selected = false;
}
}
@ -815,7 +814,6 @@ $(document).ready (function () {
var others = true;
}
if(any && others){
document.forms["form_modules"].module[i].selected = false;
document.forms["form_modules"].module[0].selected = false;
}
}

View File

@ -741,7 +741,7 @@ $(document).ready (function () {
var params = {
"page" : "operation/agentes/ver_agente",
"get_agent_modules_json" : 1,
"get_id_and_name" : 1,
"get_distinct_name" : 1,
"indexed" : 0
};
@ -1098,7 +1098,6 @@ $(document).ready (function () {
var others = true;
}
if(any && others){
document.forms["form_edit"].agents[i].selected = false;
document.forms["form_edit"].agents[0].selected = false;
}
}
@ -1114,7 +1113,6 @@ $(document).ready (function () {
var others = true;
}
if(any && others){
document.forms["form_edit"].module[i].selected = false;
document.forms["form_edit"].module[0].selected = false;
}
}

View File

@ -304,17 +304,16 @@ if (check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0,
$sub["godmode/setup/news"]["id"] = 'Site news';
$sub["godmode/setup/file_manager"]["text"] = __('File manager');
$sub["godmode/setup/file_manager"]["id"] = 'File manager';
}
if (is_user_admin($config['id_user'])) {
$sub["gdbman"]["text"] = __('Admin tools');
$sub["gdbman"]["id"] = 'DB maintenance';
$sub["gdbman"]["type"] = "direct";
$sub["gdbman"]["subtype"] = "nolink";
$sub2 = array ();
if(is_user_admin($config['id_user'])){
$sub["extensions/db_status"]["text"] = __('DB Schema Check');
$sub["extensions/db_status"]["id"] = 'DB Schema Check';
$sub["extensions/db_status"]["sec"] = "gbman";
$sub["extensions/dbmanager"]["text"] = __('DB Interface');
$sub["extensions/dbmanager"]["id"] = 'DB Interface';
$sub["extensions/dbmanager"]["sec"] = "gbman";
}
$sub["gdbman"]["sub2"] = $sub2;
}
$menu_godmode["gextensions"]["sub"] = $sub;
@ -337,14 +336,10 @@ if (is_array ($config['extensions'])) {
continue;
}
$extmenu = $extension['godmode_menu'];
if ($extmenu["name"] == 'DB interface' && !is_user_admin($config['id_user'])) {
continue;
}
if ($extmenu["name"] == 'DB Schema check' && !is_user_admin($config['id_user'])) {
continue;
if($extension['godmode_menu']['name'] != 'DB Schema check' && $extension['godmode_menu']['name'] != 'DB interface'){
$extmenu = $extension['godmode_menu'];
}
//Check the ACL for this user
@ -363,6 +358,9 @@ if (is_array ($config['extensions'])) {
if (strlen($extmenu['fatherId']) > 0) {
if (array_key_exists('subfatherId',$extmenu)) {
if (strlen($extmenu['subfatherId']) > 0) {
if($extmenu['name'] = "DB schema check"){
}
$menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]["text"] = __($extmenu['name']);
$menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]["id"] = $extmenu['name'];
$menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]["refr"] = 0;

View File

@ -46,6 +46,9 @@ $delete_layout = (bool) get_parameter ('delete_layout');
$refr = (int) get_parameter('refr', $config['vc_refr']);
$offset = (int) get_parameter('offset', 0);
$pagination = (int) get_parameter ("pagination", $config["block_size"]);
$search = (string) get_parameter("search","");
$ag_group = (int)get_parameter("ag_group",0);
$recursion = get_parameter("recursion",0);
if ($delete_layout || $copy_layout) {
// Visual console required
@ -199,6 +202,50 @@ if ($delete_layout || $copy_layout) {
}
}
if ($ag_group > 0) {
$ag_groups = array();
$ag_groups = (array)$ag_group;
if ($recursion) {
$ag_groups = groups_get_id_recursive($ag_group, true);
}
}
echo "<table class='databox filters' width='100%' style='font-weight: bold; margin-bottom: 10px;'>
<tr>";
if(!is_metaconsole()){
echo "<form method='post'
action='index.php?sec=network&amp;sec2=godmode/reporting/map_builder'>";
} else {
echo "<form method='post'
action='index.php?sec=screen&sec2=screens/screens&action=visualmap'>";
}
echo "<td style='width:33%;'>";
echo __('Search') . '&nbsp;';
html_print_input_text ("search", $search, '', 50);
echo "</td>";
echo "<td style='width:25%;'>";
echo __('Group') . '&nbsp;';
$own_info = get_user_info($config['id_user']);
if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW"))
$return_all_group = false;
else
$return_all_group = true;
html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false);
echo "<td style='width:25%;'>";
echo __('Group Recursion') . '&nbsp;';
html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()');
echo "</td><td style='width:22%;'>";
echo "<input name='search_visual_console' type='submit' class='sub search' value='".__('Search')."'>";
echo "</form>";
echo "</td>";
echo "</tr></table>";
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox data';
@ -228,31 +275,69 @@ $table->align[4] = 'left';
// or has "VR" privileges, otherwise show only maps of user group
$filters['offset'] = $offset;
$filters['limit'] = $pagination;
if(!empty($search)){
$filters['name'] = io_safe_input($search);
}
if($ag_group){
$filters['group'] = array_flip($ag_groups);
}
$own_info = get_user_info ($config['id_user']);
if (!defined('METACONSOLE')) {
$url = 'index.php?sec=network&amp;sec2=godmode/reporting/map_builder&pagination='.$pagination;
$url = 'index.php?sec=network&amp;sec2=godmode/reporting/map_builder&recursion='.$recursion.'&ag_group='.$ag_group.'&search='.$search.'&pagination='.$pagination;
}
else {
$url = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pagination='.$pagination;
$url = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&recursion='.$recursion.'&ag_group='.$ag_group.'&search='.$search.'&pagination='.$pagination;
}
if ($own_info['is_admin'] || $vconsoles_read) {
$maps = visual_map_get_user_layouts (0,false,$filters);
$total_maps = count(visual_map_get_user_layouts());
if($ag_group){
$maps = visual_map_get_user_layouts (0,false,$filters,false);
unset($filters['offset']);
unset($filters['limit']);
$total_maps = count(visual_map_get_user_layouts(0,false,$filters,false));
}else{
$maps = visual_map_get_user_layouts (0,false,$filters);
unset($filters['offset']);
unset($filters['limit']);
$total_maps = count(visual_map_get_user_layouts(0,false,$filters));
}
}
else {
$maps = visual_map_get_user_layouts ($config['id_user'], false,
$filters, false);
unset($filters['offset']);
unset($filters['limit']);
$total_maps = count(visual_map_get_user_layouts ($config['id_user'], false,
false, false));
$filters, false));
}
if (!$maps && !is_metaconsole()) {
require_once ($config['homedir'] . "/general/firts_task/map_builder.php");
$total = count(visual_map_get_user_layouts ($config['id_user'], false,
false, false));
if(!$total){
require_once ($config['homedir'] . "/general/firts_task/map_builder.php");
} else {
ui_print_info_message(
array(
'no_close'=>false,
'message'=> __('No available data to show')));
}
}
elseif (!$maps && is_metaconsole()) {
ui_print_info_message(
array(
'no_close'=>true,
'message'=> __('There are no visual console defined yet.')));
$total = count(visual_map_get_user_layouts ($config['id_user'], false,
false, false));
if(!$total){
ui_print_info_message(
array(
'no_close'=>true,
'message'=> __('There are no visual console defined yet.')));
}else{
ui_print_info_message(
array(
'no_close'=>false,
'message'=> __('No available data to show')));
}
}
else {
ui_pagination ($total_maps, $url, $offset, $pagination);

View File

@ -911,6 +911,9 @@ You can of course remove the warnings, that's why we include the source and do n
elseif(check_acl ($config['id_user'], 0, "RM"))
html_print_select_groups($config['id_user'],
"RM", true, 'combo_group', $group, '');
echo "&nbsp;&nbsp;&nbsp;".__('Recursion').html_print_checkbox('recursion', 1, 0, true);
?>
</td>
</tr>
@ -1079,7 +1082,6 @@ You can of course remove the warnings, that's why we include the source and do n
}
}
}
// html_debug($agents);
html_print_select($agents2, 'id_agents2[]', $agents_select, $script = '', "", 0, false, true, true, '', false, "min-width: 180px");
?>
</td>
@ -2002,7 +2004,38 @@ $(document).ready (function () {
"get_agents_group_json" : 1,
"id_group" : this.value,
"privilege" : "AW",
"keys_prefix" : "_"
"keys_prefix" : "_",
"recursion" : $('#checkbox-recursion').is(':checked')
},
function (data, status) {
$("#id_agents").html('');
$("#id_agents2").html('');
$("#module").html('');
jQuery.each (data, function (id, value) {
// Remove keys_prefix from the index
id = id.substring(1);
option = $("<option></option>")
.attr ("value", value["id_agente"])
.html (value["alias"]);
$("#id_agents").append (option);
$("#id_agents2").append (option);
});
},
"json"
);
}
);
$("#checkbox-recursion").change (
function () {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : $("#combo_group").val(),
"privilege" : "AW",
"keys_prefix" : "_",
"recursion" : $('#checkbox-recursion').is(':checked')
},
function (data, status) {
$("#id_agents").html('');

View File

@ -1,3 +1,37 @@
<script type="text/javascript">
function check_all_checkboxes() {
if ($("input[name=all_delete]").prop("checked")) {
$(".check_delete").prop("checked", true);
$('.check_delete').each(function(){
$('.massive_report_form_elements').prop("disabled", false);
});
}
else {
$(".check_delete").prop("checked", false);
$('.check_delete').each(function(){
$('.massive_report_form_elements').prop("disabled", true);
});
}
}
$( document ).ready(function() {
$('.check_delete').click(function(){
$('.check_delete').each(function(){
if($(this).prop( "checked" )){
$('#hidden-id_report_'+$(this).val()).prop("disabled", false);
}
else{
$('#hidden-id_report_'+$(this).val()).prop("disabled", true);
}
});
});
});
</script>
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
@ -564,7 +598,8 @@ switch ($action) {
$next++;
if(!defined('METACONSOLE'))
$table->head[$next] = '<span title="Operations">' .
__('Op.') . '</span>';
__('Op.') . '</span>'.html_print_checkbox('all_delete', 0, false, true, false,
'check_all_checkboxes();');
//$table->size = array ();
$table->size[$next] = '10%';
@ -703,9 +738,13 @@ switch ($action) {
$data[$next] .= '<form method="post" style="display:inline;" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
$data[$next] .= html_print_input_hidden ('id_report', $report['id_report'], true);
$data[$next] .= html_print_input_hidden ('action','delete_report', true);
$data[$next] .= html_print_input_image ('delete', 'images/cross.png', 1, '',
$data[$next] .= html_print_input_image ('delete', 'images/cross.png', 1, 'margin-right: 10px;',
true, array ('title' => __('Delete')));
$data[$next] .= html_print_checkbox_extended ('massive_report_check', $report['id_report'], false, false, '', 'class="check_delete"', true);
$data[$next] .= '</form>';
}
}
@ -733,8 +772,19 @@ switch ($action) {
else
echo '<div class="action-buttons" style="width: 100%;">';
html_print_submit_button (__('Create report'), 'create', false, 'class="sub next"');
echo "</div>";
echo "</form>";
echo '<form style="display:inline;" id="massive_report_form" method="post" action="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=main&action=delete">';
foreach ($reports as $report) {
echo '<input class="massive_report_form_elements" id="hidden-id_report_'.$report['id_report'].'" name="id_report[]" type="hidden" disabled value="'.$report['id_report'].'">';
}
echo '<input id="hidden-action" name="action" type="hidden" value="delete_report">';
html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete" style="margin-left:5px;"');
echo '</form>';
echo "</div>";
}
enterprise_hook('close_meta_frame');
@ -2059,3 +2109,4 @@ switch ($activeTab) {
enterprise_hook('close_meta_frame');
?>

View File

@ -304,7 +304,7 @@ function update_button_palette_callback() {
alert('Undefined height');
return false;
}
$("#text_" + idItem).html(values['label']);
if(values['show_statistics'] == 1){
@ -613,9 +613,6 @@ function readFields() {
values['process_simple_value'] = $("select[name=process_value]").val();
values['background'] = $("#background_image").val();
values['period'] = undefined != $("#hidden-period").val() ? $("#hidden-period").val() : $("#period").val();
if (values['period'] == null) {
values['period'] = undefined != $("#hidden-period").val() ? $("#hidden-period").val() : $("#period_select").val();
}
values['width'] = $("input[name=width]").val();
values['width_data_image'] = $("#data_image_width").val();
if(selectedItem == 'simple_value' || creationItem == 'simple_value'){
@ -710,10 +707,6 @@ function create_button_palette_callback() {
alert($("#message_alert_no_agent").html());
validate = false;
}
if ((values['module'] == 0)) {
alert($("#message_alert_no_module").html());
validate = false;
}
break;
case 'label':
if ((values['label'] == '')) {
@ -2115,6 +2108,8 @@ function setEventsBar(id_data, values) {
if (data['no_data'] == true) {
if (values['width'] == "0" || values['height'] == "0") {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
$("#" + id_data + " img").css('width', '500px');
$("#" + id_data + " img").css('height', '40px');
}
else {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
@ -2126,8 +2121,8 @@ function setEventsBar(id_data, values) {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
if($('#text-width').val() == 0 || $('#text-height').val() == 0){
$("#" + id_data + " img").css('width', '300px');
$("#" + id_data + " img").css('height', '180px');
$("#" + id_data + " img").css('width', '500px');
$("#" + id_data + " img").css('height', '40px');
}
else{
$("#" + id_data + " img").css('width', $('#text-width').val()+'px');

View File

@ -205,11 +205,7 @@ switch ($activeTab) {
// If the background is changed the size is reseted
$background_now = $visualConsole['background'];
/*if ($background_now != $background && $background) {
$sizeBackground = getimagesize($config['homedir'] . '/images/console/background/' . $background);
$values['width'] = $sizeBackground[0];
$values['height'] = $sizeBackground[1];
}*/
$values['width'] = $width;
$values['height'] = $height;
switch ($action) {
@ -237,33 +233,31 @@ switch ($activeTab) {
break;
case 'save':
if (!defined('METACONSOLE')) {
if ($values['name'] != "" && $values['background'])
$idVisualConsole = db_process_sql_insert('tlayout', $values);
else
$idVisualConsole = false;
if ($values['name'] != "" && $values['background'])
$idVisualConsole = db_process_sql_insert('tlayout', $values);
else
$idVisualConsole = false;
if ($idVisualConsole !== false) {
db_pandora_audit( "Visual console builder", "Create visual console #$idVisualConsole");
$action = 'edit';
$statusProcessInDB = array('flag' => true,
'message' => ui_print_success_message(__('Successfully created.'), '', true));
if ($idVisualConsole !== false) {
db_pandora_audit( "Visual console builder", "Create visual console #$idVisualConsole");
$action = 'edit';
$statusProcessInDB = array('flag' => true,
'message' => ui_print_success_message(__('Successfully created.'), '', true));
// Return the updated visual console
$visualConsole = db_get_row_filter('tlayout',
array('id' => $idVisualConsole));
// Update the ACL
//$vconsole_read = $vconsole_read_new;
$vconsole_write = $vconsole_write_new;
$vconsole_manage = $vconsole_manage_new;
}
else {
db_pandora_audit( "Visual console builder", "Fail try to create visual console");
$statusProcessInDB = array('flag' => false,
'message' => ui_print_error_message(__('Could not be created.'), '', true));
}
// Return the updated visual console
$visualConsole = db_get_row_filter('tlayout',
array('id' => $idVisualConsole));
// Update the ACL
//$vconsole_read = $vconsole_read_new;
$vconsole_write = $vconsole_write_new;
$vconsole_manage = $vconsole_manage_new;
}
break;
else {
db_pandora_audit( "Visual console builder", "Fail try to create visual console");
$statusProcessInDB = array('flag' => false,
'message' => ui_print_error_message(__('Could not be created.'), '', true));
}
break;
}
break;

View File

@ -222,7 +222,7 @@ $table->data[37][0] = __('audit log directory') .
ui_print_help_tip (__("Directory where audit log is stored."), true);
$table->data[37][1] = html_print_input_text ('auditdir', io_safe_output($config["auditdir"]), '', 30, 100, true);
$table->data[38][0] = __('To use alias as name when creating agent');
$table->data[38][0] = __('Set alias as name by default in agent creation');
$table->data[38][1] = __('Yes').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('alias_as_name', 1, '', $config["alias_as_name"], true).'&nbsp;&nbsp;';
$table->data[38][1] .= __('No').'&nbsp;&nbsp;&nbsp;'.html_print_radio_button ('alias_as_name', 0, '', $config["alias_as_name"], true);

View File

@ -313,7 +313,7 @@ foreach ($listIcons as $index => $value)
$table_gis->data[$row][0] = __('Default icon in GIS') .
ui_print_help_tip(__('Agent icon for GIS Maps. If set to "none", group icon will be used'), true);
$table_gis->data[$row][1] = html_print_select($arraySelectIcon,
"gis_default_icon", $config["gis_default_icon"], "", __('None'),
"gis_default_icon", $config["gis_default_icon"], "", __('Agent icon group'),
'', true);
$table_gis->data[$row][1] .= "&nbsp;" .
html_print_button(__("View"), 'gis_icon_preview', false, '', '', true);
@ -535,6 +535,26 @@ $table_chars->data[$row][0] .= ui_print_help_tip(__('Show percentile 95 in graph
$table_chars->data[$row][1] = html_print_input_text ('percentil', $config['percentil'], '', 20, 20, true);
$row++;
$table_chars->data[$row][0] = __('Graph TIP view:');
$table_chars->data[$row][0] .= ui_print_help_tip(__('This option may cause performance issues'), true);
$options_full_escale = array();
$options_full_escale[0] = __('None');
$options_full_escale[1] = __('All');
$options_full_escale[2] = __('On Boolean graphs');
$table_chars->data[$row][1] = html_print_select($options_full_escale, 'full_scale_option', $config["full_scale_option"], '', '', 0, true, false, false);
$row++;
/*
$table_font->data[$row][0] = __('Font path');
$fonts = load_fonts();
$table_font->data[$row][1] = html_print_select($fonts, 'fontpath',
io_safe_output($config["fontpath"]), '', '', 0, true);
$row++;
*/
echo "<fieldset>";
echo "<legend>" . __('Charts configuration') . "</legend>";
html_print_table ($table_chars);

View File

@ -565,7 +565,7 @@ $values = array (
'Tactical view'=>__('Tactical view'),
'Alert detail' => __('Alert detail'),
'Other'=>__('Other'));
if (enterprise_installed()) {
if (enterprise_installed() && !is_metaconsole()) {
$values['Dashboard'] = __('Dashboard');
}
$table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info["section"]), 'show_data_section();', '', -1, true, false, false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 746 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 702 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 705 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Some files were not shown because too many files have changed in this diff Show More