2006-07-04 16:07:08 +02:00
|
|
|
/* Class to manage the Windows Management Instrumentation(WMI).
|
|
|
|
It depends on disphelper library (http://disphelper.sourceforge.net)
|
|
|
|
|
|
|
|
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, MAB02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pandora_wmi.h"
|
|
|
|
#include "../pandora_strutils.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cctype>
|
2007-08-29 16:30:09 +02:00
|
|
|
#include <sstream>
|
2008-12-11 11:20:07 +01:00
|
|
|
#include <ctime>
|
2008-12-03 13:04:48 +01:00
|
|
|
#include <winuser.h>
|
2009-09-02 13:39:53 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define INVENTORY_FIELD_SEPARATOR
|
2006-07-04 16:07:08 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Pandora_Wmi;
|
|
|
|
|
|
|
|
static LPWSTR
|
|
|
|
getWmiStr (LPCWSTR computer) {
|
2008-12-03 13:04:48 +01:00
|
|
|
static WCHAR wmi_str[256];
|
2006-07-04 16:07:08 +02:00
|
|
|
|
2009-09-02 13:39:53 +02:00
|
|
|
wcscpy (wmi_str, L"winmgmts:{impersonationLevel=impersonate}!\\\\");
|
2008-12-03 13:04:48 +01:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
if (computer) {
|
2007-08-29 16:30:09 +02:00
|
|
|
wcsncat (wmi_str, computer, 128);
|
2006-07-04 16:07:08 +02:00
|
|
|
} else {
|
2007-08-29 16:30:09 +02:00
|
|
|
wcscat (wmi_str, L".");
|
|
|
|
}
|
2006-07-04 16:07:08 +02:00
|
|
|
|
|
|
|
wcscat (wmi_str, L"\\root\\cimv2");
|
2008-12-03 13:04:48 +01:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
return wmi_str;
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Check if a process is running.
|
|
|
|
*
|
|
|
|
* @param process_name Name of the process with extension.
|
|
|
|
*
|
|
|
|
* @return Number of instances of the process running.
|
|
|
|
*/
|
2006-07-04 16:07:08 +02:00
|
|
|
int
|
|
|
|
Pandora_Wmi::isProcessRunning (string process_name) {
|
2007-08-29 16:30:09 +02:00
|
|
|
CDhInitialize init;
|
2006-07-04 16:07:08 +02:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
|
|
|
string name;
|
|
|
|
int result = 0;
|
2007-08-29 16:30:09 +02:00
|
|
|
string query;
|
|
|
|
|
|
|
|
query = "SELECT * FROM Win32_Process WHERE Name=\"" + process_name + "\"";
|
2007-09-11 18:47:26 +02:00
|
|
|
|
2008-11-28 11:51:03 +01:00
|
|
|
try {
|
2006-07-04 16:07:08 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%T)",
|
|
|
|
query.c_str ()));
|
|
|
|
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
|
|
|
result++;
|
2006-07-04 16:07:08 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-05 16:02:05 +02:00
|
|
|
pandoraLog ("isProcessRunning error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Check if a Windows service is running.
|
|
|
|
*
|
|
|
|
* @param service_name Internal name of the service to check.
|
|
|
|
*
|
|
|
|
* @retval 1 The service is running
|
|
|
|
* @retval 0 The service is stopped
|
|
|
|
*/
|
2006-07-04 16:07:08 +02:00
|
|
|
int
|
|
|
|
Pandora_Wmi::isServiceRunning (string service_name) {
|
2007-08-29 16:30:09 +02:00
|
|
|
CDhInitialize init;
|
2006-07-04 16:07:08 +02:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
string query;
|
|
|
|
char *state;
|
2007-09-11 18:47:26 +02:00
|
|
|
string str_state;
|
2007-08-29 16:30:09 +02:00
|
|
|
int retval;
|
|
|
|
|
|
|
|
query = "SELECT * FROM Win32_Service WHERE Name = \"" + service_name + "\"";
|
|
|
|
|
2008-11-28 11:51:03 +01:00
|
|
|
try {
|
2006-07-04 16:07:08 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%T)",
|
|
|
|
query.c_str ()));
|
|
|
|
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
|
|
|
dhGetValue (L"%s", &state, quickfix,
|
|
|
|
L".State");
|
2007-09-11 18:47:26 +02:00
|
|
|
str_state = state;
|
2010-11-12 14:41:24 +01:00
|
|
|
if (str_state == "Running") {
|
|
|
|
retval = 1;
|
|
|
|
}
|
|
|
|
else if (str_state == "Stopped") {
|
|
|
|
retval = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
retval = -1;
|
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
dhFreeString (state);
|
2007-09-11 18:47:26 +02:00
|
|
|
|
2007-08-29 16:30:09 +02:00
|
|
|
return retval;
|
2006-07-04 16:07:08 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-05 16:02:05 +02:00
|
|
|
pandoraLog ("isServiceRunning error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-05 10:46:51 +02:00
|
|
|
return 0;
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the free space in a logical disk drive.
|
|
|
|
*
|
2007-08-29 16:30:09 +02:00
|
|
|
* @param disk_id Disk drive letter (C: for example).
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
*
|
|
|
|
* @return Free space amount in MB.
|
2006-08-31 14:42:36 +02:00
|
|
|
*
|
|
|
|
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
|
|
|
* from WMI database.
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
*/
|
2006-11-24 12:46:31 +01:00
|
|
|
unsigned long
|
2006-07-11 11:41:22 +02:00
|
|
|
Pandora_Wmi::getDiskFreeSpace (string disk_id) {
|
2006-11-27 12:59:52 +01:00
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2009-09-10 16:15:39 +02:00
|
|
|
double free_space = 0;
|
2007-08-24 13:48:23 +02:00
|
|
|
string query;
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2007-09-05 18:22:26 +02:00
|
|
|
query = "SELECT FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = \"" + disk_id + "\"";
|
|
|
|
|
|
|
|
struct QFix {
|
|
|
|
CDhStringA free_space;
|
|
|
|
};
|
|
|
|
|
2006-07-11 11:41:22 +02:00
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-11 11:41:22 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%T)",
|
|
|
|
query.c_str ()));
|
|
|
|
|
2006-07-11 11:41:22 +02:00
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2009-09-10 16:15:39 +02:00
|
|
|
dhGetValue (L"%e", &free_space, quickfix,
|
2007-08-24 13:48:23 +02:00
|
|
|
L".FreeSpace");
|
2007-09-05 18:22:26 +02:00
|
|
|
|
2009-09-10 16:15:39 +02:00
|
|
|
// 1048576 = 1024 * 1024
|
2009-11-19 01:40:26 +01:00
|
|
|
return (unsigned long) (free_space / 1048576);
|
2006-07-11 11:41:22 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-13 12:38:32 +02:00
|
|
|
pandoraLog ("getDiskFreeSpace error. %s", errstr.c_str ());
|
2006-07-11 11:41:22 +02:00
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
throw Pandora_Wmi_Exception ();
|
2006-07-11 11:41:22 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Get the free space in a logical disk drive.
|
|
|
|
*
|
|
|
|
* @param disk_id Disk drive letter (C: for example).
|
|
|
|
*
|
|
|
|
* @return Free space percentage.
|
|
|
|
*
|
|
|
|
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
|
|
|
* from WMI database.
|
|
|
|
*/
|
|
|
|
unsigned long
|
|
|
|
Pandora_Wmi::getDiskFreeSpacePercent (string disk_id) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2009-09-10 16:15:39 +02:00
|
|
|
double free_space = 0, size = 0;
|
2009-09-10 16:25:59 +02:00
|
|
|
string query;
|
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
|
|
|
|
|
|
|
query = "SELECT Size, FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = \"" + disk_id + "\"";
|
|
|
|
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
|
|
|
L".ExecQuery(%T)",
|
|
|
|
query.c_str ()));
|
|
|
|
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2009-09-10 16:15:39 +02:00
|
|
|
dhGetValue (L"%e", &free_space, quickfix,
|
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
|
|
|
L".FreeSpace");
|
2009-09-10 16:15:39 +02:00
|
|
|
dhGetValue (L"%e", &size, quickfix,
|
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
|
|
|
L".Size");
|
|
|
|
|
2010-06-30 17:40:25 +02:00
|
|
|
if (size == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (unsigned long) (free_space * 100 / size);
|
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
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("getDiskFreeSpace error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
|
|
|
|
throw Pandora_Wmi_Exception ();
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the CPU usage percentage in the last minutes.
|
|
|
|
*
|
|
|
|
* @param cpu_id CPU identifier.
|
|
|
|
*
|
|
|
|
* @return The usage percentage of the CPU.
|
2006-08-31 14:42:36 +02:00
|
|
|
*
|
2007-09-05 18:22:26 +02:00
|
|
|
* @exception Pandora_Wmi_Exception Throwed if an error occured when reading
|
2006-08-31 14:42:36 +02:00
|
|
|
* from WMI database.
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
*/
|
2006-07-12 11:15:00 +02:00
|
|
|
int
|
|
|
|
Pandora_Wmi::getCpuUsagePercentage (int cpu_id) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
string query;
|
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
|
|
|
long load_percentage, total_load;
|
|
|
|
int total_cpus;
|
2007-08-29 16:30:09 +02:00
|
|
|
std::ostringstream stm;
|
|
|
|
|
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
|
|
|
// Select all CPUs
|
|
|
|
if (cpu_id < 0) {
|
|
|
|
query = "SELECT * FROM Win32_Processor";
|
|
|
|
// Select a single CPUs
|
|
|
|
} else {
|
|
|
|
stm << cpu_id;
|
|
|
|
query = "SELECT * FROM Win32_Processor WHERE DeviceID = \"CPU" + stm.str () + "\"";
|
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-12 11:15:00 +02:00
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-12 11:15:00 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%T)",
|
|
|
|
query.c_str ()));
|
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
|
|
|
|
|
|
|
total_cpus = 0;
|
|
|
|
total_load = 0;
|
2006-07-12 11:15:00 +02:00
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhGetValue (L"%d", &load_percentage, quickfix,
|
|
|
|
L".LoadPercentage");
|
2009-12-18 21:04:42 +01:00
|
|
|
// Sanity check
|
|
|
|
if (load_percentage >= 0 && load_percentage <= 100) {
|
|
|
|
total_cpus++;
|
|
|
|
total_load += load_percentage;
|
|
|
|
}
|
2006-07-12 11:15:00 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
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
|
|
|
|
|
|
|
if (total_cpus == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return total_load / total_cpus;
|
2006-07-12 11:15:00 +02:00
|
|
|
} catch (string errstr) {
|
2006-07-13 12:38:32 +02:00
|
|
|
pandoraLog ("getCpuUsagePercentage error. %s", errstr.c_str ());
|
2006-07-12 11:15:00 +02:00
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
throw Pandora_Wmi_Exception ();
|
2006-07-12 11:15:00 +02:00
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the amount of free memory in the system
|
|
|
|
*
|
|
|
|
* @return The amount of free memory in MB.
|
2006-08-31 14:42:36 +02:00
|
|
|
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
|
|
|
* from WMI database.
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
*/
|
2006-07-13 12:38:32 +02:00
|
|
|
long
|
|
|
|
Pandora_Wmi::getFreememory () {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
long free_memory;
|
2006-07-13 12:38:32 +02:00
|
|
|
|
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-13 12:38:32 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT * FROM Win32_PerfRawData_PerfOS_Memory "));
|
|
|
|
|
2006-07-13 12:38:32 +02:00
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhGetValue (L"%d", &free_memory, quickfix,
|
|
|
|
L".AvailableMBytes");
|
|
|
|
|
|
|
|
return free_memory;
|
2006-07-13 12:38:32 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("getFreememory error. %s", errstr.c_str ());
|
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
throw Pandora_Wmi_Exception ();
|
2006-07-13 12:38:32 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Get the percentage of free memory in the system
|
|
|
|
*
|
|
|
|
* @return The percentage of free memory.
|
|
|
|
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
|
|
|
* from WMI database.
|
|
|
|
*/
|
|
|
|
long
|
|
|
|
Pandora_Wmi::getFreememoryPercent () {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc, quickfixes;
|
|
|
|
long free_memory, total_memory;
|
|
|
|
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT FreePhysicalMemory, TotalVisibleMemorySize FROM Win32_OperatingSystem "));
|
|
|
|
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
|
|
|
dhGetValue (L"%d", &free_memory, quickfix,
|
|
|
|
L".FreePhysicalMemory");
|
|
|
|
|
|
|
|
dhGetValue (L"%d", &total_memory, quickfix,
|
|
|
|
L".TotalVisibleMemorySize");
|
|
|
|
|
|
|
|
if (total_memory == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return free_memory * 100 / total_memory;
|
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("getFreememory error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
|
|
|
|
throw Pandora_Wmi_Exception ();
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the name of the operating system.
|
|
|
|
*
|
|
|
|
* @return The name of the operating system.
|
|
|
|
*/
|
2006-07-04 16:07:08 +02:00
|
|
|
string
|
|
|
|
Pandora_Wmi::getOSName () {
|
2007-08-29 16:30:09 +02:00
|
|
|
CDhInitialize init;
|
2006-07-04 16:07:08 +02:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
char *name = NULL;
|
2006-07-04 16:07:08 +02:00
|
|
|
string ret;
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-04 16:07:08 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT * FROM Win32_OperatingSystem "));
|
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhGetValue (L"%s", &name, quickfix,
|
|
|
|
L".Caption");
|
2007-09-05 18:22:26 +02:00
|
|
|
|
2007-08-29 16:30:09 +02:00
|
|
|
ret = name;
|
|
|
|
dhFreeString (name);
|
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-05 16:02:05 +02:00
|
|
|
pandoraLog ("getOSName error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the version of the operating system.
|
|
|
|
*
|
|
|
|
* @return The version of the operaing system.
|
|
|
|
*/
|
2006-07-04 16:07:08 +02:00
|
|
|
string
|
|
|
|
Pandora_Wmi::getOSVersion () {
|
2007-08-29 16:30:09 +02:00
|
|
|
CDhInitialize init;
|
2006-07-04 16:07:08 +02:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
char *version = NULL;
|
2006-07-04 16:07:08 +02:00
|
|
|
string ret;
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-04 16:07:08 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT * FROM Win32_OperatingSystem "));
|
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhGetValue (L"%s", &version, quickfix,
|
|
|
|
L".CSDVersion");
|
|
|
|
|
2010-04-16 15:12:23 +02:00
|
|
|
if (version != NULL) {
|
|
|
|
ret = version;
|
|
|
|
dhFreeString (version);
|
|
|
|
}
|
2006-07-04 16:07:08 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-05 16:02:05 +02:00
|
|
|
pandoraLog ("getOSVersion error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the build of the operating system.
|
|
|
|
*
|
|
|
|
* @return The build of the operating system.
|
|
|
|
*/
|
2006-07-04 16:07:08 +02:00
|
|
|
string
|
|
|
|
Pandora_Wmi::getOSBuild () {
|
2007-08-29 16:30:09 +02:00
|
|
|
CDhInitialize init;
|
2006-07-04 16:07:08 +02:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
char *build = NULL;
|
2006-07-04 16:07:08 +02:00
|
|
|
string ret;
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-04 16:07:08 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT * FROM Win32_OperatingSystem "));
|
2006-07-04 16:07:08 +02:00
|
|
|
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhGetValue (L"%s", &build, quickfix,
|
|
|
|
L".Version");
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
|
2007-08-29 16:30:09 +02:00
|
|
|
ret = build;
|
|
|
|
dhFreeString (build);
|
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-05 16:02:05 +02:00
|
|
|
pandoraLog ("getOSBuild error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-15 Esteban Sanchez <estebans@artica.es>
* autogen.sh, configure.in, Makefile.am, Doxyfile.in: Added to
repository. They are used to generate documentation, not to compile.
* main.cc: Added some comments. Style correction.
* pandora.[cc,h]: Added documentation comments. Changed visibility of
some attributes.
* pandora_agent_conf.[cc,h]: Added to Pandora namespace. Added
documentation comments.
* pandora_windows_service.[cc,h], pandora_strutils.[cc,h],
windows/pandora_windows_infp.[cc,h], ssh/pandora_ssh_test.[cc,h]:
Added documentation comments.
* ssh/pandora_ssh_client.[cc,h]:Added documentation comments. Removed
old method to connect with user and password. Style correction.
* misc/pandora_file.[cc,h]: Added documentation comments. Renamed some
parameters.
* modules/pandora_module.[cc,h]: Added documentation comments. Put a
name to the enumerators. Added a new class to agroupate all exceptions
produced by Pandora_Module child class objects. Changed visibility of
some attributes. Added some new methods and renamed others.
* modules/pandora_module_cpuusage.[cc,h],
modules/pandora_module_exec.[cc,h],
modules/pandora_module_freememory.[cc,h],
modules/pandora_module_freedisk.[cc,h], modules/pandora_module_proc.[cc,h],
modules/pandora_module_service.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes.
* modules/pandora_module_list.[cc,h]: Added documentation comments.
Some changes to adapt the objects to the Pandora_Module changes. Added
to Pandora_Modules namespace.
* windows/pandora_windows_wmi.[cc,h]: Added documentation comments.
Renamed Pandora_Wmi_Error to Pandora_Wmi_Exception.
* windows_service.[cc,h]: Added documentation comments. Changed
visibility of some attributes. Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@150 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2006-08-25 15:02:03 +02:00
|
|
|
/**
|
|
|
|
* Get the system name of the operating system.
|
|
|
|
*
|
|
|
|
* @return The system name of the operating system.
|
|
|
|
*/
|
2006-07-04 16:07:08 +02:00
|
|
|
string
|
|
|
|
Pandora_Wmi::getSystemName () {
|
2007-08-29 16:30:09 +02:00
|
|
|
CDhInitialize init;
|
2006-07-04 16:07:08 +02:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
2007-08-29 16:30:09 +02:00
|
|
|
char *name = NULL;
|
2006-07-04 16:07:08 +02:00
|
|
|
string ret;
|
|
|
|
|
|
|
|
try {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
2006-07-04 16:07:08 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
2007-08-29 16:30:09 +02:00
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT * FROM Win32_OperatingSystem "));
|
2006-07-04 16:07:08 +02:00
|
|
|
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
2007-08-29 16:30:09 +02:00
|
|
|
dhGetValue (L"%s", &name, quickfix,
|
|
|
|
L".CSName");
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
|
2007-08-29 16:30:09 +02:00
|
|
|
ret = name;
|
|
|
|
dhFreeString (name);
|
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2006-07-05 16:02:05 +02:00
|
|
|
pandoraLog ("getSystemName error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
2008-11-26 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.cc, pandora_strutils.h, ftp/pandora_ftp_client.cc,
ftp/pandora_ftp_test.cc, ftp/pandora_ftp_client.h,
ftp/pandora_ftp_test.h, windows/pandora_windows_info.h,
windows/pandora_wmi.cc, windows/pandora_windows_info.cc,
misc/pandora_file.cc, misc/pandora_file.h, pandora_agent_conf.cc,
ssh/pandora_ssh_client.cc, ssh/pandora_ssh_test.cc,
ssh/pandora_ssh_client.h, ssh/pandora_ssh_test.h,
pandora_agent_conf.h, windows_service.cc, windows_service.h,
modules/pandora_module.h, modules/pandora_module_logevent.cc,
modules/pandora_module_exec.cc, modules/pandora_module_logevent.h,
modules/pandora_module_exec.h, modules/pandora_module_freedisk.cc,
modules/pandora_module_freedisk.h, modules/pandora_module_service.cc,
modules/pandora_module_service.h, modules/pandora_module_proc.cc,
modules/pandora_data.cc, modules/pandora_module_proc.h,
modules/pandora_data.h, modules/pandora_module_factory.cc,
modules/pandora_module_odbc.cc, modules/pandora_module_odbc.h,
modules/pandora_module_factory.h,
modules/pandora_module_freememory.cc, modules/pandora_module_list.cc,
modules/pandora_module_freememory.h,
modules/pandora_module_cpuusage.cc, modules/pandora_module_cpuusage.h,
modules/pandora_module.cc, pandora.h: Tab style correction.
Indentation blankspaces moved to tab characters.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1262 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-11-26 11:08:19 +01:00
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2008-06-13 12:32:47 +02:00
|
|
|
|
2008-12-11 11:20:07 +01:00
|
|
|
/**
|
|
|
|
* Runs a program in a new process.
|
|
|
|
*
|
|
|
|
* @param command Command to run, with parameters
|
2009-02-09 18:47:24 +01:00
|
|
|
* @param flags Process creation flags
|
2008-12-11 11:20:07 +01:00
|
|
|
*/
|
|
|
|
bool
|
2009-02-09 18:47:24 +01:00
|
|
|
Pandora_Wmi::runProgram (string command, DWORD flags) {
|
2008-12-11 11:20:07 +01:00
|
|
|
PROCESS_INFORMATION process_info;
|
|
|
|
STARTUPINFO startup_info;
|
|
|
|
bool success;
|
|
|
|
char *cmd;
|
|
|
|
|
|
|
|
if (command == "")
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ZeroMemory (&startup_info, sizeof (startup_info));
|
|
|
|
startup_info.cb = sizeof (startup_info);
|
|
|
|
ZeroMemory (&process_info, sizeof (process_info));
|
|
|
|
|
|
|
|
pandoraDebug ("Start process \"%s\".", command.c_str ());
|
|
|
|
cmd = strdup (command.c_str ());
|
2009-02-09 18:47:24 +01:00
|
|
|
success = CreateProcess (NULL, cmd, NULL, NULL, FALSE, flags,
|
2008-12-11 11:20:07 +01:00
|
|
|
NULL, NULL, &startup_info, &process_info);
|
|
|
|
pandoraFree (cmd);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
pandoraDebug ("The process \"%s\" was started.", command.c_str ());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pandoraLog ("Could not start process \"%s\". Error %d", command.c_str (),
|
|
|
|
GetLastError());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start a Windows service.
|
|
|
|
*
|
|
|
|
* @param service_name Service internal name to start.
|
|
|
|
*
|
|
|
|
* @retval true If the service started.
|
|
|
|
* @retval false If the service could not start. A log message is created.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Pandora_Wmi::startService (string service_name) {
|
|
|
|
SC_HANDLE manager, service;
|
|
|
|
bool success;
|
|
|
|
|
|
|
|
manager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
|
|
if (manager == NULL) {
|
|
|
|
pandoraLog ("Could not access to service \"%s\" to start.",
|
|
|
|
service_name.c_str ());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
service = OpenService (manager, service_name.c_str (), GENERIC_EXECUTE);
|
|
|
|
if (service == NULL) {
|
|
|
|
pandoraLog ("Could not access to service \"%s\" to start.",
|
|
|
|
service_name.c_str ());
|
|
|
|
CloseServiceHandle (manager);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = StartService (service, 0, NULL);
|
|
|
|
|
|
|
|
CloseServiceHandle (service);
|
|
|
|
CloseServiceHandle (manager);
|
|
|
|
|
|
|
|
if (! success) {
|
|
|
|
pandoraLog ("Could not start service \"%s\". (Error %d)",
|
|
|
|
service_name.c_str (), GetLastError ());
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop a Windows service.
|
|
|
|
*
|
|
|
|
* @param service_name Service internal name to stop.
|
|
|
|
*
|
|
|
|
* @retval true If the service started.
|
|
|
|
* @retval false If the service could not stop. A log message is created.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Pandora_Wmi::stopService (string service_name) {
|
|
|
|
SC_HANDLE manager, service;
|
|
|
|
bool success;
|
2009-01-20 Ramon Novoa <rnovoa@artica.es>
* win32/ftp/pandora_ftp_client.cc,
win32/ftp/pandora_ftp_client.h,
win32/windows/pandora_wmi.cc,
win32/pandora_windows_service.h,
win32/pandora.h,
win32/udp_server/udp_server.cc,
win32/misc/pandora_file.cc,
win32/misc/pandora_file.h,
win32/ssh/pandora_ssh_client.cc,
win32/ssh/pandora_ssh_client.h,
win32/pandora_windows_service.cc: Removed some exceptions that made
the agent crash when the watchdog thread was running.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1371 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-20 23:21:31 +01:00
|
|
|
SERVICE_STATUS ssStatus;
|
|
|
|
|
2008-12-11 11:20:07 +01:00
|
|
|
manager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
|
|
if (manager == NULL) {
|
|
|
|
pandoraLog ("Could not access to service \"%s\" to stop.",
|
|
|
|
service_name.c_str ());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
service = OpenService (manager, service_name.c_str (), SERVICE_STOP);
|
|
|
|
if (service == NULL) {
|
|
|
|
pandoraLog ("Could not access to service \"%s\" to stop.",
|
|
|
|
service_name.c_str ());
|
|
|
|
CloseServiceHandle (manager);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-20 Ramon Novoa <rnovoa@artica.es>
* win32/ftp/pandora_ftp_client.cc,
win32/ftp/pandora_ftp_client.h,
win32/windows/pandora_wmi.cc,
win32/pandora_windows_service.h,
win32/pandora.h,
win32/udp_server/udp_server.cc,
win32/misc/pandora_file.cc,
win32/misc/pandora_file.h,
win32/ssh/pandora_ssh_client.cc,
win32/ssh/pandora_ssh_client.h,
win32/pandora_windows_service.cc: Removed some exceptions that made
the agent crash when the watchdog thread was running.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1371 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-20 23:21:31 +01:00
|
|
|
success = ControlService (service, SERVICE_CONTROL_STOP, &ssStatus);
|
2008-12-11 11:20:07 +01:00
|
|
|
|
|
|
|
CloseServiceHandle (service);
|
|
|
|
CloseServiceHandle (manager);
|
|
|
|
|
|
|
|
if (! success) {
|
|
|
|
pandoraLog ("Could not stop service \"%s\". (Error %d)",
|
|
|
|
service_name.c_str (), GetLastError ());
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2008-12-16 12:30:12 +01:00
|
|
|
/**
|
|
|
|
* Runs a generic WQL query.
|
|
|
|
*
|
|
|
|
* @param wmi_query WQL query.
|
|
|
|
* @param column Column to retrieve from the query result.
|
|
|
|
* @param rows List where the query result will be placed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Pandora_Wmi::runWMIQuery (string wmi_query, string column, list<string> &rows) {
|
2009-09-02 13:39:53 +02:00
|
|
|
CDhInitialize init;
|
2008-12-16 12:30:12 +01:00
|
|
|
CDispPtr wmi_svc, quickfixes;
|
|
|
|
char *value = NULL;
|
|
|
|
wstring column_w(column.length(), L' ');
|
|
|
|
wstring wmi_query_w(wmi_query.length(), L' ');
|
|
|
|
|
|
|
|
// Copy string to wstring.
|
|
|
|
std::copy(column.begin(), column.end(), column_w.begin());
|
|
|
|
std::copy(wmi_query.begin(), wmi_query.end(), wmi_query_w.begin());
|
|
|
|
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
dhCheck (dhGetValue (L"%o", &quickfixes, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
wmi_query_w.c_str ()));
|
|
|
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
|
|
|
dhGetValue (L"%s", &value, quickfix,
|
|
|
|
column_w.c_str ());
|
2009-01-20 Ramon Novoa <rnovoa@artica.es>
* win32/ftp/pandora_ftp_client.cc,
win32/ftp/pandora_ftp_client.h,
win32/windows/pandora_wmi.cc,
win32/pandora_windows_service.h,
win32/pandora.h,
win32/udp_server/udp_server.cc,
win32/misc/pandora_file.cc,
win32/misc/pandora_file.h,
win32/ssh/pandora_ssh_client.cc,
win32/ssh/pandora_ssh_client.h,
win32/pandora_windows_service.cc: Removed some exceptions that made
the agent crash when the watchdog thread was running.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1371 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-01-20 23:21:31 +01:00
|
|
|
if (value != NULL) {
|
|
|
|
rows.push_back (value);
|
|
|
|
}
|
2008-12-16 12:30:12 +01:00
|
|
|
dhFreeString (value);
|
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-02 13:39:53 +02:00
|
|
|
/**
|
|
|
|
* Gets all the sofware installed
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed.
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getSoftware (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, software_list = NULL;
|
|
|
|
char *name = NULL, *version = NULL;
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
2010-06-08 18:49:40 +02:00
|
|
|
|
2009-09-02 13:39:53 +02:00
|
|
|
dhCheck (dhGetValue (L"%o", &software_list, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT * FROM Win32_Product "));
|
|
|
|
|
|
|
|
FOR_EACH (software_item, software_list, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &name, software_item,
|
|
|
|
L".Name");
|
|
|
|
if (name != NULL) {
|
|
|
|
rows.push_back (name);
|
|
|
|
}
|
|
|
|
dhFreeString (name);
|
|
|
|
dhGetValue (L"%s", &version, software_item,
|
|
|
|
L".Version");
|
|
|
|
if (version != NULL) {
|
|
|
|
rows.push_back (version);
|
|
|
|
}
|
|
|
|
dhFreeString (version);
|
|
|
|
} NEXT_THROW (software_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the information about the CDRom
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed.
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getCdRomInfo (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, cd_info = NULL;
|
|
|
|
char *name = NULL, *description = NULL, *drive = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &cd_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Name, Description, Drive FROM Win32_CDROMDrive "));
|
|
|
|
|
|
|
|
FOR_EACH (cd_info_item, cd_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &name, cd_info_item,
|
|
|
|
L".Name");
|
|
|
|
if (name != NULL) {
|
|
|
|
ret += name;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(name);
|
|
|
|
dhGetValue (L"%s", &description, cd_info_item,
|
|
|
|
L".Description");
|
|
|
|
if (description != NULL) {
|
|
|
|
ret += " ";
|
|
|
|
ret += description;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (description);
|
|
|
|
dhGetValue (L"%s", &drive, cd_info_item,
|
|
|
|
L".Drive");
|
|
|
|
if (drive != NULL) {
|
|
|
|
ret += " (";
|
|
|
|
ret += drive;
|
|
|
|
ret += ")";
|
|
|
|
}
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
dhFreeString(drive);
|
|
|
|
} NEXT_THROW (cd_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the information about the Video Card
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed.
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getVideoInfo (list<string> &rows){
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, video_info = NULL;
|
|
|
|
char *caption = NULL, *adapter_RAM = NULL, *video_processor = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &video_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Caption, AdapterRAM, VideoProcessor FROM Win32_VideoController "));
|
|
|
|
|
|
|
|
FOR_EACH (video_info_item, video_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &caption, video_info_item,
|
|
|
|
L".Caption");
|
|
|
|
if (caption != NULL) {
|
|
|
|
ret += caption;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(caption);
|
|
|
|
dhGetValue (L"%s", &adapter_RAM, video_info_item,
|
|
|
|
L".AdapterRAM");
|
|
|
|
if (adapter_RAM != NULL) {
|
|
|
|
double ram_in_mb = atof(adapter_RAM) / 1048576;
|
|
|
|
ostringstream converter;
|
|
|
|
converter << ram_in_mb;
|
|
|
|
pandoraDebug("f:%f s:%s\n",ram_in_mb,adapter_RAM);
|
|
|
|
ret += " " + converter.str() + " MBytes";
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (adapter_RAM);
|
|
|
|
dhGetValue (L"%s", &video_processor, video_info_item,
|
|
|
|
L".VideoProcessor");
|
|
|
|
if (video_processor != NULL) {
|
|
|
|
ret += video_processor;
|
|
|
|
}
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
dhFreeString(video_processor);
|
|
|
|
} NEXT_THROW (video_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the information about the Hard Drives
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed.
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getHDsInfo (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, hd_info = NULL;
|
|
|
|
char *model = NULL, *system_name = NULL;
|
|
|
|
//long size = 0;
|
|
|
|
char * size = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &hd_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Model, Size, SystemName FROM Win32_DiskDrive "));
|
|
|
|
|
|
|
|
FOR_EACH (hd_info_item, hd_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &model, hd_info_item,
|
|
|
|
L".Model");
|
|
|
|
if (model != NULL) {
|
|
|
|
ret += model;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(model);
|
|
|
|
dhGetValue (L"%s", &size, hd_info_item,
|
|
|
|
L".Size");
|
|
|
|
if (size != NULL) {
|
|
|
|
double fsize = atof(size) / 1073741824;
|
|
|
|
ostringstream converter;
|
|
|
|
converter << fsize;
|
|
|
|
pandoraDebug("f:%f s:%s\n",fsize,size);
|
|
|
|
ret += converter.str() + " GBs";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraDebug("Size unknown\n");
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (size);
|
|
|
|
dhGetValue (L"%s", &system_name, hd_info_item,
|
|
|
|
L".SystemName");
|
|
|
|
if (system_name != NULL) {
|
|
|
|
ret += " (";
|
|
|
|
ret += system_name;
|
|
|
|
ret += ")";
|
|
|
|
}
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
dhFreeString(system_name);
|
|
|
|
} NEXT_THROW (hd_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the information about the CPUs
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed.
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getCPUsInfo (list<string> &rows){
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, cpu_info = NULL;
|
|
|
|
char *name = NULL, *speed = NULL, *description = NULL;
|
|
|
|
// Note speed is an uint32 but it works ok as char *
|
|
|
|
string ret = "", mhz =" MHz";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &cpu_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Name, MaxClockSpeed, Description FROM Win32_Processor "));
|
|
|
|
|
|
|
|
FOR_EACH (cpu_info_item, cpu_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &name, cpu_info_item,
|
|
|
|
L".Name");
|
|
|
|
if (name != NULL) {
|
|
|
|
ret += name;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(name);
|
|
|
|
dhGetValue (L"%s", &speed, cpu_info_item,
|
|
|
|
L".MaxClockSpeed");
|
|
|
|
if (speed != NULL) {
|
|
|
|
ret += speed + mhz;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (speed);
|
|
|
|
dhGetValue (L"%s", &description, cpu_info_item,
|
|
|
|
L".Description");
|
|
|
|
if (description != NULL) {
|
|
|
|
ret += description;
|
|
|
|
}
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
dhFreeString(description);
|
|
|
|
} NEXT_THROW (cpu_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Gets a string with the IPs from an array of string of IPs
|
|
|
|
*
|
|
|
|
* This is a helper to extract the IPs from the result of the WMI query at
|
|
|
|
* getNICsInfo, that returns a **string with the IPs so this function gets this
|
|
|
|
* parameter and retunrs a string with all the IPs separated by ' , '
|
|
|
|
* @param ip_array array of Strings of IPs as returned by the query on getNICsInfo
|
|
|
|
* @return A string with the IPs separated by ' , '
|
|
|
|
*/
|
|
|
|
string
|
|
|
|
getIPs(VARIANT *ip_array){
|
|
|
|
UINT i;
|
|
|
|
VARIANT *pvArray;
|
|
|
|
string ret = "";
|
|
|
|
if (V_VT(ip_array) == (VT_ARRAY | VT_VARIANT)) {
|
|
|
|
if (FAILED(SafeArrayAccessData(V_ARRAY(ip_array), (void **) &pvArray))) {
|
|
|
|
ret += "";
|
|
|
|
}
|
|
|
|
int num_ips = V_ARRAY(ip_array)->rgsabound[0].cElements;
|
|
|
|
pandoraDebug("Num IPs: %d\n",num_ips);
|
|
|
|
for (i = 0;i < num_ips;i++) {
|
|
|
|
if ((i > 0) && (i < num_ips - 1 ))
|
|
|
|
{
|
|
|
|
ret += " , ";
|
|
|
|
}
|
|
|
|
if (V_VT(&pvArray[i]) == VT_BSTR) {
|
|
|
|
LPSTR szStringA;
|
|
|
|
pandoraDebug("String[%u] (original): %S\n", i, V_BSTR(&pvArray[i]));
|
|
|
|
ret += Pandora_Strutils::strUnicodeToAnsi( V_BSTR(&pvArray[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(ip_array));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Gets the information about the Network Adapters
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed. each row has the
|
|
|
|
* Caption, MACAddress and IPAddress separated by ;
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getNICsInfo (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, nic_info = NULL;
|
|
|
|
VARIANT ip_addresses;
|
|
|
|
char *caption = NULL, *mac_address = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &nic_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Caption, MACAddress, IPAddress FROM Win32_NetworkAdapterConfiguration "));
|
|
|
|
|
|
|
|
FOR_EACH (nic_info_item, nic_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &caption, nic_info_item,
|
|
|
|
L".Caption");
|
|
|
|
if (caption != NULL) {
|
|
|
|
ret += caption;
|
|
|
|
}
|
|
|
|
dhFreeString(caption);
|
2010-10-04 19:24:10 +02:00
|
|
|
ret += inventory_field_separator;
|
2009-09-02 13:39:53 +02:00
|
|
|
dhGetValue (L"%s", &mac_address, nic_info_item,
|
|
|
|
L".MACAddress");
|
|
|
|
if (mac_address != NULL) {
|
|
|
|
ret += mac_address;
|
|
|
|
}
|
|
|
|
dhFreeString (mac_address);
|
2010-10-04 19:24:10 +02:00
|
|
|
ret += inventory_field_separator;
|
2009-09-02 13:39:53 +02:00
|
|
|
dhGetValue (L"%v", &ip_addresses, nic_info_item,
|
|
|
|
L".IPAddress");
|
|
|
|
if (&ip_addresses != NULL)
|
|
|
|
{
|
|
|
|
ret += getIPs(&ip_addresses);
|
|
|
|
}
|
|
|
|
VariantClear(&ip_addresses);
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
} NEXT_THROW (nic_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the information about the Patch Information
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed. each row has the
|
|
|
|
* HotFixID, Description and FixComments separated by ;
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getPatchInfo (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, patch_info = NULL;
|
|
|
|
char *hot_fix_id = NULL, *description = NULL, *comments = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &patch_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT HotFixID, Description, FixComments FROM Win32_QuickFixEngineering "));
|
|
|
|
|
|
|
|
FOR_EACH (patch_info_item, patch_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &hot_fix_id, patch_info_item,
|
|
|
|
L".HotFixID");
|
|
|
|
if (hot_fix_id != NULL) {
|
|
|
|
ret += hot_fix_id;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(hot_fix_id);
|
|
|
|
dhGetValue (L"%s", &description, patch_info_item,
|
|
|
|
L".Description");
|
|
|
|
if (description != NULL) {
|
|
|
|
ret += description;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (description);
|
|
|
|
dhGetValue (L"%s", &comments, patch_info_item,
|
|
|
|
L".FixComments");
|
|
|
|
if (comments != NULL) {
|
|
|
|
ret += comments;
|
|
|
|
}
|
|
|
|
dhFreeString(comments);
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
} NEXT_THROW (patch_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the information about the RAM
|
|
|
|
*
|
|
|
|
* @param rows List where the query result will be placed. each row has the
|
|
|
|
* Tag, Capacity and Name separated by ;
|
|
|
|
* @return An int with the number of Results found
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getRAMInfo (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, ram_info = NULL;
|
|
|
|
char *tag = NULL, *name = NULL, *capacity = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
if (wmi_svc == NULL) {
|
|
|
|
pandoraLog("Error getting wmi_svc\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraLog("wmi_svc is ok\n");
|
|
|
|
}
|
|
|
|
dhCheck (dhGetValue (L"%o", &ram_info, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Tag, Capacity, Name FROM Win32_PhysicalMemory "));
|
|
|
|
|
|
|
|
FOR_EACH (ram_info_item, ram_info, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &tag, ram_info_item,
|
|
|
|
L".Tag");
|
|
|
|
if (tag != NULL) {
|
|
|
|
ret += tag;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(tag);
|
|
|
|
dhGetValue (L"%s", &capacity, ram_info_item,
|
|
|
|
L".Capacity");
|
|
|
|
if (capacity != NULL) {
|
|
|
|
double fcapacity = atof(capacity) / 1048576;
|
|
|
|
ostringstream converter;
|
|
|
|
converter << fcapacity;
|
|
|
|
pandoraDebug("f:%f s:%s\n",fcapacity,capacity);
|
|
|
|
ret += converter.str() + " MBs";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandoraDebug("Capacity unknown\n");
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (capacity);
|
|
|
|
dhGetValue (L"%s", &name, ram_info_item,
|
|
|
|
L".Name");
|
|
|
|
if (name != NULL) {
|
|
|
|
ret += name;
|
|
|
|
}
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
dhFreeString(name);
|
|
|
|
} NEXT_THROW (ram_info_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
2009-09-10 16:15:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of running system services
|
|
|
|
*
|
|
|
|
* @param rows Result list.
|
|
|
|
* @return Result list length.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pandora_Wmi::getServices (list<string> &rows) {
|
|
|
|
CDhInitialize init;
|
|
|
|
CDispPtr wmi_svc = NULL, services = NULL;
|
|
|
|
char *name = NULL, *path_name = NULL, *state = NULL;
|
|
|
|
string ret = "";
|
|
|
|
int num_objects = 0;
|
|
|
|
|
|
|
|
try {
|
|
|
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
|
|
|
dhCheck (dhGetValue (L"%o", &services, wmi_svc,
|
|
|
|
L".ExecQuery(%S)",
|
|
|
|
L"SELECT Name, PathName, State FROM Win32_Service"));
|
|
|
|
|
|
|
|
FOR_EACH (service, services, NULL) {
|
|
|
|
num_objects++;
|
|
|
|
dhGetValue (L"%s", &name, service, L".Name");
|
|
|
|
if (name != NULL) {
|
|
|
|
ret += name;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString(name);
|
|
|
|
dhGetValue (L"%s", &path_name, service, L".PathName");
|
|
|
|
if (path_name != NULL) {
|
|
|
|
ret += path_name;
|
|
|
|
}
|
|
|
|
ret += inventory_field_separator;
|
|
|
|
dhFreeString (path_name);
|
|
|
|
dhGetValue (L"%s", &state, service, L".State");
|
|
|
|
if (state != NULL) {
|
|
|
|
ret += state;
|
|
|
|
}
|
|
|
|
dhFreeString(state);
|
|
|
|
rows.push_back(ret);
|
|
|
|
ret.clear();
|
|
|
|
} NEXT_THROW (service_item);
|
|
|
|
} catch (string errstr) {
|
|
|
|
pandoraLog ("runWMIQuery error. %s", errstr.c_str ());
|
|
|
|
}
|
|
|
|
return num_objects;
|
|
|
|
}
|
2011-08-18 11:41:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 {
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|