2009-02-09 11:26:07 +01:00
|
|
|
/* Pandora agent service for Win32.
|
|
|
|
|
2020-11-27 13:52:35 +01:00
|
|
|
Copyright (c) 2006-2021 Artica ST.
|
2009-02-09 11:26:07 +01:00
|
|
|
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>
|
2012-01-03 18:23:23 +01:00
|
|
|
#include <time.h>
|
2009-02-09 11:26:07 +01:00
|
|
|
#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
|
2020-01-29 13:00:17 +01:00
|
|
|
#define SECONDARY_DIR "secondary" /* Path of the secondary buffer relative to the primary buffer. */
|
2010-07-07 17:14:18 +02:00
|
|
|
|
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 {
|
2020-01-29 13:00:17 +01:00
|
|
|
typedef int (Pandora::Pandora_Windows_Service::*copy_func_p)(string, bool);
|
2009-02-09 11:26:07 +01:00
|
|
|
private:
|
|
|
|
Pandora_Agent_Conf *conf;
|
|
|
|
Pandora_Module_List *modules;
|
2017-05-18 11:55:44 +02:00
|
|
|
Pandora_Module_List *broker_modules;
|
2009-02-09 11:26:07 +01:00
|
|
|
long execution_number;
|
|
|
|
string agent_name;
|
2016-09-29 12:50:04 +02:00
|
|
|
string alias;
|
2012-01-03 18:23:23 +01:00
|
|
|
time_t timestamp;
|
|
|
|
time_t run_time;
|
2009-02-09 11:26:07 +01:00
|
|
|
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;
|
2011-11-03 20:13:57 +01:00
|
|
|
bool tentacle_proxy;
|
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 ();
|
2020-01-29 13:00:17 +01:00
|
|
|
int copyDataFile (string filename, bool secondary_buffer = false);
|
|
|
|
int copyToSecondary (string filename, bool secondary_buffer = true);
|
2015-03-04 12:23:05 +01:00
|
|
|
string getValueFromCmdExec (string cmd_exec, int timeout);
|
|
|
|
string getAgentNameFromCmdExec (string cmd_exec);
|
2014-11-16 04:04:00 +01:00
|
|
|
string getCoordinatesFromCmdExec (string cmd_exec);
|
2009-02-09 11:26:07 +01:00
|
|
|
int copyTentacleDataFile (string host,
|
|
|
|
string filename,
|
|
|
|
string port,
|
|
|
|
string ssl,
|
|
|
|
string pass,
|
2015-06-03 09:03:27 +02:00
|
|
|
string opts,
|
|
|
|
int timeout);
|
2009-02-09 11:26:07 +01:00
|
|
|
int copyScpDataFile (string host,
|
|
|
|
string remote_path,
|
|
|
|
string filename);
|
|
|
|
int copyFtpDataFile (string host,
|
|
|
|
string remote_path,
|
|
|
|
string filename,
|
2015-06-03 09:03:27 +02:00
|
|
|
string password,
|
|
|
|
int timeout);
|
2009-02-09 11:26:07 +01:00
|
|
|
int copyLocalDataFile (string remote_path,
|
|
|
|
string filename);
|
|
|
|
void recvDataFile (string filename);
|
|
|
|
void recvTentacleDataFile (string host,
|
2015-06-03 09:03:27 +02:00
|
|
|
string filename,
|
|
|
|
int timeout);
|
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-11-03 20:13:57 +01:00
|
|
|
int 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);
|
2019-09-24 19:13:55 +02:00
|
|
|
void pandora_run_broker (string config, long executions=0);
|
2011-07-11 17:49:29 +02:00
|
|
|
int count_broker_agents();
|
|
|
|
void check_broker_agents(string *all_conf);
|
2011-11-03 20:13:57 +01:00
|
|
|
int launchTentacleProxy();
|
2011-07-28 19:34:51 +02:00
|
|
|
int killTentacleProxy();
|
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:
|
2013-04-11 17:39:28 +02:00
|
|
|
void pandora_run (int forced_run);
|
2009-02-09 11:26:07 +01:00
|
|
|
void pandora_run ();
|
|
|
|
void pandora_init ();
|
2017-05-18 11:55:44 +02:00
|
|
|
void pandora_init (bool reload_modules);
|
2009-02-09 11:26:07 +01:00
|
|
|
|
|
|
|
long interval;
|
2012-01-03 18:23:23 +01:00
|
|
|
long interval_sec;
|
|
|
|
long intensive_interval;
|
2009-02-09 11:26:07 +01:00
|
|
|
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 ();
|
2020-10-01 20:56:09 +02:00
|
|
|
int sendXml (Pandora_Module_List *modules, string extra = "");
|
2020-01-29 13:00:17 +01:00
|
|
|
void sendBufferedXml (string path, copy_func_p copy_func, bool secondary_buffer);
|
2012-01-03 18:23:23 +01:00
|
|
|
Pandora_Agent_Conf *getConf ();
|
2016-12-07 15:51:21 +01:00
|
|
|
string getEHKey (string ehorus_conf);
|
2012-01-03 18:23:23 +01:00
|
|
|
long getInterval ();
|
|
|
|
long getIntensiveInterval ();
|
2016-09-29 12:50:04 +02:00
|
|
|
string generateAgentName ();
|
2012-01-03 18:23:23 +01:00
|
|
|
|
2009-02-09 11:26:07 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|