2009-02-09 11:26:07 +01:00
|
|
|
/* Pandora agent service for Win32.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Artica ST.
|
|
|
|
Written by Esteban Sanchez.
|
|
|
|
|
|
|
|
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_WINDOWS_SERVICE_H__
|
|
|
|
#define __PANDORA_WINDOWS_SERVICE_H__
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include "windows_service.h"
|
|
|
|
#include "pandora_agent_conf.h"
|
|
|
|
#include "modules/pandora_module_list.h"
|
|
|
|
#include "ssh/pandora_ssh_client.h"
|
|
|
|
|
2010-07-07 17:14:18 +02:00
|
|
|
#define FTP_DEFAULT_PORT 21
|
|
|
|
#define SSH_DEFAULT_PORT 22
|
|
|
|
|
2009-02-09 11:26:07 +01:00
|
|
|
using namespace std;
|
|
|
|
using namespace Pandora_Modules;
|
|
|
|
|
|
|
|
namespace Pandora {
|
|
|
|
/**
|
|
|
|
* Class to implement the Pandora Windows service.
|
|
|
|
*/
|
|
|
|
class Pandora_Windows_Service : public Windows_Service {
|
|
|
|
private:
|
|
|
|
Pandora_Agent_Conf *conf;
|
|
|
|
Pandora_Module_List *modules;
|
|
|
|
long execution_number;
|
|
|
|
string agent_name;
|
|
|
|
long elapsed_transfer_time;
|
|
|
|
long transfer_interval;
|
|
|
|
bool started;
|
2009-09-22 Ramon Novoa <rnovoa@artica.es>
* debug_new.h, fast_mutex.h,
debug_new.cpp, static_assert.h: Added to repository. Wu Yongwei's
memory leak detection tool (part of Nvwa). Only compiled when
debugging is enabled.
* bin/util/tentacle_client.exe: Added to repository. Tentacle client
needed to build the installer.
* installer/pandora_2.0.mpi: moved to installer/pandora.mpi. Updated.
The installer can now be built directly from the installer
subdirectory.
* configure.in, Makefile.am, autogen.sh: Created a proper
configure.in and Makefile.am. The agent can now be cross-compiled
from Linux :-D
* bin/pandora_agent.conf: Fixed. A local configuration had been
uploaded.
* pandora_windows_service.h,pandora_windows_service.cc,
udp_server/udp_server.cc, udp_server/udp_server.h: Properly shutdown
the UDP server.
* modules/pandora_module_regexp.cc,
modules/pandora_module_inventory.cc,
modules/pandora_module_factory.cc,
modules/pandora_module.cc, pandora_strutils.cc,
pandora.h, pandora.cc: Fixed a couple of memory leaks. Small changes
to avoid compile warnings when cross-compiling from Linux.
* windows_service.cc: Removed the interactive service flag to avoid
'black windows'.
* main.cc: Include the memory leak detection tool if debugging is
enabled.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1966 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-22 13:48:25 +02:00
|
|
|
void *udp_server;
|
2010-07-21 12:03:20 +02:00
|
|
|
list<string> collection_disk;
|
|
|
|
|
2010-04-21 Ramon Novoa <rnovoa@artica.es>
* main.cc: Updated headers after tinyxml removal.
* modules/pandora_module_list.cc,
modules/pandora_module_factory.cc: Added support for plugin modules.
* modules/pandora_module_exec.cc, modules/pandora_module.h,
modules/pandora_module.cc: Added the module_timeout configuration
token and replaced tinyxml related code.
* bin/pandora_agent.conf: Added a sample plugin module. Added the
group configuration token (was missing).
* modules/pandora_module_plugin.cc,
modules/pandora_module_plugin.h: Added to repository. Plugin module.
* bin/util/df.vbs, bin/util/ps.vbs: Added to repository. Sample
VBScript plugins.
* pandora_windows_service.cc, pandora_windows_service.h,
modules/pandora_module_inventory.cc, ssh/pandora_ssh_test.cc,
ftp/pandora_ftp_test.cc, modules/pandora_module_inventory.h: Replaced
tinyxml related code.
* tinyxml, tinyxml/tinyxmlerror.cpp, tinyxml/tinystr.h,
tinyxml/tinyxmlparser.cpp, tinyxml/tinyxml.cpp,
tinyxml/tinyxml.h, tinyxml/tinystr.cpp: Removed from repository. No
longer used.
* installer/pandora.mpi, pandora.cc: Updated build to RC1.
* Makefile.am: Updated sources. Removed tinyxml and added the plugin
module.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2584 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2010-04-21 22:00:31 +02:00
|
|
|
string getXmlHeader ();
|
2009-02-09 11:26:07 +01:00
|
|
|
int copyDataFile (string filename);
|
|
|
|
int copyTentacleDataFile (string host,
|
|
|
|
string filename,
|
|
|
|
string port,
|
|
|
|
string ssl,
|
|
|
|
string pass,
|
|
|
|
string opts);
|
|
|
|
int copyScpDataFile (string host,
|
|
|
|
string remote_path,
|
|
|
|
string filename);
|
|
|
|
int copyFtpDataFile (string host,
|
|
|
|
string remote_path,
|
|
|
|
string filename,
|
|
|
|
string password);
|
|
|
|
int copyLocalDataFile (string remote_path,
|
|
|
|
string filename);
|
|
|
|
void recvDataFile (string filename);
|
|
|
|
void recvTentacleDataFile (string host,
|
|
|
|
string filename);
|
2010-07-16 13:43:07 +02:00
|
|
|
|
|
|
|
int unzipCollection(string zip_path, string dest_dir);
|
|
|
|
void checkCollections ();
|
2010-07-20 18:38:29 +02:00
|
|
|
void addCollectionsPath();
|
2011-07-14 10:58:18 +02:00
|
|
|
string checkAgentName(string filename);
|
2011-07-11 17:49:29 +02:00
|
|
|
void checkConfig (string file);
|
2010-07-21 12:03:20 +02:00
|
|
|
void purgeDiskCollections ();
|
2011-07-11 17:49:29 +02:00
|
|
|
void pandora_init_broker (string file_conf);
|
|
|
|
void pandora_run_broker (string config);
|
|
|
|
int count_broker_agents();
|
|
|
|
void check_broker_agents(string *all_conf);
|
2009-02-09 11:26:07 +01:00
|
|
|
|
|
|
|
Pandora_Windows_Service ();
|
2010-07-21 12:03:20 +02:00
|
|
|
|
2009-02-09 11:26:07 +01:00
|
|
|
public:
|
|
|
|
void pandora_run ();
|
|
|
|
void pandora_init ();
|
|
|
|
|
|
|
|
long interval;
|
|
|
|
public:
|
|
|
|
static Pandora_Windows_Service *getInstance ();
|
|
|
|
|
|
|
|
~Pandora_Windows_Service ();
|
|
|
|
|
|
|
|
void setValues (const char *svc_name,
|
|
|
|
const char *svc_display_name,
|
|
|
|
const char *svc_description);
|
|
|
|
|
|
|
|
void start ();
|
|
|
|
int sendXml (Pandora_Module_List *modules);
|
2009-05-25 Ramon Novoa <rnovoa@artica.es>
* windows/pandora_wmi.cc, windows/pandora_wmi.h: Added functions for the
new modules. Removed old logevent functions.
* pandora_windows_service.h, pandora_windows_service.cc: Added support
for data file buffering and startup delay.
* modules/pandora_module_logevent.cc, modules/pandora_module_logevent.h:
Rewritten to retrieve event log data using the PDH interface instead
of WMI (was too slow).
* modules/pandora_module_tcpcheck.cc, modules/pandora_module_tcpcheck.h,
modules/pandora_module_regexp.cc, modules/pandora_module_regexp.h,
modules/pandora_module_perfcounter.cc,
modules/pandora_module_perfcounter.h,
modules/pandora_module_freedisk_percent.cc,
modules/pandora_module_freedisk_percent.h,
modules/pandora_module_freememory_percent.cc,
modules/pandora_module_freememory_percent.h: Added to repository.
New modules, see http://openideas.info/wiki/.
* modules/pandora_module.h, modules/pandora_module.cc,
modules/pandora_module_factory.cc, modules/pandora_module_list.cc:
Added support for the new modules.
* bin/pandora_agent.conf: Included configuration examples for the new
modules.
* PandoraAgent.dev: Updated to compile the new modules.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1707 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-05-25 19:50:27 +02:00
|
|
|
void sendBufferedXml (string path);
|
2009-02-09 11:26:07 +01:00
|
|
|
Pandora_Agent_Conf *getConf ();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|