mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
2006-11-24 Esteban Sánchez <estebans@artica.es>
* pandora_strutils.h, pandora_strutils.cc: Added strtoulong() to convert a string into a unsigned long integer. * wmi/pandora_wmi.h, pandora_wmi.cc: Modified getDisgkFreeSpace() to return a unsigned long integer. Used srttoulong() to transform the free disk into a log instead of an integer, that caused a negative value of free disk space when the amount was in the order of GB. * bin/PandoraAgent.exe: Updated to new commit. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@281 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
a00562e742
commit
0413104638
@ -1,3 +1,15 @@
|
|||||||
|
2006-11-24 Esteban Sánchez <estebans@artica.es>
|
||||||
|
|
||||||
|
* pandora_strutils.h, pandora_strutils.cc: Added strtoulong() to
|
||||||
|
convert a string into a unsigned long integer.
|
||||||
|
|
||||||
|
* wmi/pandora_wmi.h, pandora_wmi.cc: Modified getDisgkFreeSpace() to
|
||||||
|
return a unsigned long integer. Used srttoulong() to transform the
|
||||||
|
free disk into a log instead of an integer, that caused a negative
|
||||||
|
value of free disk space when the amount was in the order of GB.
|
||||||
|
|
||||||
|
* bin/PandoraAgent.exe: Updated to new commit.
|
||||||
|
|
||||||
2006-11-21 Esteban Sánchez <estebans@artica.es>
|
2006-11-21 Esteban Sánchez <estebans@artica.es>
|
||||||
|
|
||||||
* pandora_windows_service.cc: Changed the debug option of the
|
* pandora_windows_service.cc: Changed the debug option of the
|
||||||
|
Binary file not shown.
@ -119,6 +119,28 @@ Pandora_Strutils::strtoint (const string str) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tranform a string into a long integer.
|
||||||
|
*
|
||||||
|
* @param str String to convert.
|
||||||
|
*
|
||||||
|
* @return The long integer value of the string.
|
||||||
|
*
|
||||||
|
* @exception Invalid_Conversion throwed if the string has non-
|
||||||
|
* decimal values.
|
||||||
|
*/
|
||||||
|
unsigned long
|
||||||
|
Pandora_Strutils::strtoulong (const string str) {
|
||||||
|
unsigned long result;
|
||||||
|
|
||||||
|
if (! std::sscanf (str.c_str (), "%uld", &result)) {
|
||||||
|
throw Invalid_Conversion ();
|
||||||
|
}
|
||||||
|
printf ("%s - %u\n", str.c_str (), result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace every occurence of a pattern in a string with other substring.
|
* Replace every occurence of a pattern in a string with other substring.
|
||||||
*
|
*
|
||||||
|
@ -41,15 +41,16 @@ namespace Pandora_Strutils {
|
|||||||
*/
|
*/
|
||||||
class Invalid_Conversion : Pandora_Strutils::String_Exception {};
|
class Invalid_Conversion : Pandora_Strutils::String_Exception {};
|
||||||
|
|
||||||
string trim (const string str);
|
string trim (const string str);
|
||||||
|
|
||||||
string inttostr (const int i);
|
string inttostr (const int i);
|
||||||
string longtostr (const long i);
|
string longtostr (const long i);
|
||||||
string longtohex (const long i);
|
string longtohex (const long i);
|
||||||
|
|
||||||
int strtoint (const string str);
|
int strtoint (const string str);
|
||||||
|
unsigned long strtoulong (const string str);
|
||||||
|
|
||||||
string strreplace (string in, string pattern, string rep);
|
string strreplace (string in, string pattern, string rep);
|
||||||
|
|
||||||
void
|
void
|
||||||
stringtok (list<string> &l, string const &s,
|
stringtok (list<string> &l, string const &s,
|
||||||
|
@ -153,12 +153,12 @@ Pandora_Wmi::isServiceRunning (string service_name) {
|
|||||||
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
* @exception Pandora_Wmi_Exception Throwd if an error occured when reading
|
||||||
* from WMI database.
|
* from WMI database.
|
||||||
*/
|
*/
|
||||||
long
|
unsigned long
|
||||||
Pandora_Wmi::getDiskFreeSpace (string disk_id) {
|
Pandora_Wmi::getDiskFreeSpace (string disk_id) {
|
||||||
CDhInitialize init;
|
CDhInitialize init;
|
||||||
CDispPtr wmi_svc, quickfixes;
|
CDispPtr wmi_svc, quickfixes;
|
||||||
string id, space_str;
|
string id, space_str;
|
||||||
int space;
|
unsigned long space;
|
||||||
|
|
||||||
struct QFix {
|
struct QFix {
|
||||||
CDhStringA id, free_space;
|
CDhStringA id, free_space;
|
||||||
@ -185,7 +185,7 @@ Pandora_Wmi::getDiskFreeSpace (string disk_id) {
|
|||||||
space_str = fix.free_space;
|
space_str = fix.free_space;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
space = Pandora_Strutils::strtoint (space_str);
|
space = Pandora_Strutils::strtoulong (space_str);
|
||||||
} catch (Pandora_Exception e) {
|
} catch (Pandora_Exception e) {
|
||||||
throw Pandora_Wmi_Exception ();
|
throw Pandora_Wmi_Exception ();
|
||||||
}
|
}
|
||||||
|
@ -38,15 +38,15 @@ namespace Pandora_Wmi {
|
|||||||
*/
|
*/
|
||||||
class Pandora_Wmi_Exception : public Pandora_Exception { };
|
class Pandora_Wmi_Exception : public Pandora_Exception { };
|
||||||
|
|
||||||
int isProcessRunning (string process_name);
|
int isProcessRunning (string process_name);
|
||||||
int isServiceRunning (string service_name);
|
int isServiceRunning (string service_name);
|
||||||
long getDiskFreeSpace (string disk_id);
|
unsigned long getDiskFreeSpace (string disk_id);
|
||||||
int getCpuUsagePercentage (int cpu_id);
|
int getCpuUsagePercentage (int cpu_id);
|
||||||
long getFreememory ();
|
long getFreememory ();
|
||||||
string getOSName ();
|
string getOSName ();
|
||||||
string getOSVersion ();
|
string getOSVersion ();
|
||||||
string getOSBuild ();
|
string getOSBuild ();
|
||||||
string getSystemName ();
|
string getSystemName ();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user