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>
|
2006-07-04 16:07:08 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Pandora_Wmi;
|
|
|
|
|
|
|
|
static LPWSTR
|
|
|
|
getWmiStr (LPCWSTR computer) {
|
|
|
|
static WCHAR wmi_str [256];
|
|
|
|
|
|
|
|
wcscpy (wmi_str, L"winmgmts:{impersonationLevel=impersonate}!\\\\");
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
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 + "\"";
|
|
|
|
cout << "Query: " << query << endl;
|
2006-07-04 16:07:08 +02:00
|
|
|
try {
|
|
|
|
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;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
query = "SELECT * FROM Win32_Service WHERE Name = \"" + service_name + "\"";
|
|
|
|
|
2006-07-04 16:07:08 +02:00
|
|
|
try {
|
|
|
|
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");
|
|
|
|
|
|
|
|
retval = (state == "Running") ? 1 : 0;
|
|
|
|
dhFreeString (state);
|
|
|
|
|
|
|
|
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;
|
|
|
|
string id, space_str;
|
|
|
|
unsigned long long space = 0;
|
2007-08-24 13:48:23 +02:00
|
|
|
string query;
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2007-08-24 13:48:23 +02:00
|
|
|
query = "SELECT DeviceID, FreeSpace FROM Win32_LogicalDisk WHERE DeviceID = \"" + disk_id + "\"";
|
|
|
|
|
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) {
|
2007-08-24 13:48:23 +02:00
|
|
|
dhGetValue (L"%d", &space, quickfix,
|
|
|
|
L".FreeSpace");
|
2007-08-29 16:30:09 +02:00
|
|
|
|
2007-08-24 13:48:23 +02:00
|
|
|
return space / 1024 / 1024;
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* @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-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;
|
|
|
|
long load_percentage;
|
|
|
|
std::ostringstream stm;
|
|
|
|
|
|
|
|
stm << cpu_id;
|
|
|
|
query = "SELECT * FROM Win32_Processor WHERE DeviceID = \"CPU" + stm.str () + "\"";
|
|
|
|
|
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 ()));
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
return load_percentage;
|
2006-07-12 11:15:00 +02:00
|
|
|
} NEXT_THROW (quickfix);
|
|
|
|
} catch (string errstr) {
|
2007-08-29 16:30:09 +02:00
|
|
|
cout << query << endl;
|
|
|
|
cout << errstr << endl;
|
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
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
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");
|
2006-07-04 16:07:08 +02: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
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
2006-07-04 16:07:08 +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 ("getSystemName error. %s", errstr.c_str ());
|
2006-07-04 16:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|