2011-08-18 Sergio Martin <sergio.martin@artica.es>
* win32/windows/pandora_windows_info.h win32/windows/pandora_wmi.cc win32/windows/pandora_wmi.h win32/windows/pandora_windows_info.cc win32/bin/PandoraAgent.exe win32/bin/pandora_agent.conf win32/pandora_windows_service.cc: Added to the windows agent the address token with manual (specified address) and auto (detecting from WMI the address) modes git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4763 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
5215fbb641
commit
c35cb15176
|
@ -1,3 +1,15 @@
|
|||
2011-08-18 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* win32/windows/pandora_windows_info.h
|
||||
win32/windows/pandora_wmi.cc
|
||||
win32/windows/pandora_wmi.h
|
||||
win32/windows/pandora_windows_info.cc
|
||||
win32/bin/PandoraAgent.exe
|
||||
win32/bin/pandora_agent.conf
|
||||
win32/pandora_windows_service.cc: Added to the windows agent
|
||||
the address token with manual (specified address) and auto
|
||||
(detecting from WMI the address) modes
|
||||
|
||||
2011-08-10 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* unix/pandora_agent.php: Fixed error reading collections of the configuration file.
|
||||
|
|
Binary file not shown.
|
@ -29,6 +29,12 @@ temporal "$AgentTemp$"
|
|||
|
||||
# agent_name My_Custom_Agent_name
|
||||
|
||||
# address: Enforce to server a ip address to this agent
|
||||
# You can also try to detect the first IP using "auto", for example
|
||||
#address auto
|
||||
# or setting a fixed IP address, like for example:
|
||||
#address 192.168.36.73
|
||||
|
||||
# Group assigned for this agent (descriptive, p.e: Servers)
|
||||
#group Servers
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ Pandora_Windows_Service::lauchTentacleProxy() {
|
|||
string
|
||||
Pandora_Windows_Service::getXmlHeader () {
|
||||
char timestamp[20];
|
||||
string agent_name, os_name, os_version, encoding, value, xml;
|
||||
string agent_name, os_name, os_version, encoding, value, xml, address;
|
||||
time_t ctime;
|
||||
struct tm *ctime_tm = NULL;
|
||||
|
||||
|
@ -397,6 +397,19 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||
xml += "\" timestamp=\"";
|
||||
xml += timestamp;
|
||||
}
|
||||
|
||||
// Get agent address
|
||||
address = conf->getValue ("address");
|
||||
if (address != "") {
|
||||
if(address == "auto") {
|
||||
address = Pandora_Windows_Info::getSystemAddress ();
|
||||
}
|
||||
|
||||
if(address != "") {
|
||||
xml += "\" address=\"";
|
||||
xml += address;
|
||||
}
|
||||
}
|
||||
|
||||
xml += "\" interval=\"" + conf->getValue ("interval") +
|
||||
"\" os_name=\"" + os_name +
|
||||
|
|
|
@ -67,6 +67,16 @@ Pandora_Windows_Info::getSystemName () {
|
|||
return Pandora_Wmi::getSystemName ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the address of the running system.
|
||||
*
|
||||
* @return The system IP address.
|
||||
*/
|
||||
string
|
||||
Pandora_Windows_Info::getSystemAddress () {
|
||||
return Pandora_Wmi::getSystemAddress ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system path of the running operating system.
|
||||
*
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Pandora_Windows_Info {
|
|||
string getOSVersion ();
|
||||
string getOSBuild ();
|
||||
string getSystemName ();
|
||||
string getSystemAddress ();
|
||||
string getSystemPath ();
|
||||
HANDLE *getProcessHandles (string name, int *num_procs);
|
||||
string getRegistryValue (HKEY root, const string treepath, const string keyname);
|
||||
|
|
|
@ -1188,3 +1188,43 @@ Pandora_Wmi::getServices (list<string> &rows) {
|
|||
}
|
||||
return num_objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system address
|
||||
*
|
||||
* @return The system address
|
||||
*/
|
||||
string
|
||||
Pandora_Wmi::getSystemAddress () {
|
||||
CDhInitialize init;
|
||||
CDispPtr wmi_svc = NULL, nic_info = NULL;
|
||||
VARIANT ip_addresses;
|
||||
char *caption = NULL, *mac_address = NULL;
|
||||
string ret = "";
|
||||
|
||||
try {
|
||||
pandoraLog ("0");
|
||||
|
||||
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
||||
dhCheck (dhGetValue (L"%o", &nic_info, wmi_svc,
|
||||
L".ExecQuery(%S)",
|
||||
L"SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True"));
|
||||
|
||||
FOR_EACH (nic_info_item, nic_info, NULL) {
|
||||
dhGetValue (L"%v", &ip_addresses, nic_info_item,
|
||||
L".IPAddress");
|
||||
|
||||
if (&ip_addresses != NULL)
|
||||
{
|
||||
ret = getIPs(&ip_addresses);
|
||||
if(ret != "0.0.0.0") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} NEXT_THROW (nic_info_item);
|
||||
} catch (string errstr) {
|
||||
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace Pandora_Wmi {
|
|||
string getOSVersion ();
|
||||
string getOSBuild ();
|
||||
string getSystemName ();
|
||||
string getSystemAddress ();
|
||||
bool runProgram (string command, DWORD flags = 0);
|
||||
bool startService (string service_name);
|
||||
bool stopService (string service_name);
|
||||
|
|
Loading…
Reference in New Issue