Merge pull request #46 from hyperic/i18n

Some metrics are missing the '/sec' suffix. This fix first tries to add
This commit is contained in:
hananaharonof 2014-09-03 14:12:38 +03:00
commit b89060c481
1 changed files with 20 additions and 2 deletions

View File

@ -284,6 +284,24 @@ public class Pdh extends Win32 {
return trans.toString();
}
private long addPdhCounter(String path, boolean format) throws Win32Exception {
long counter;
/*
* Some metrics are missing the '/sec' suffix. This flow,
* first tries to add the counter without the '/sec' and
* if fails, try again with it. If the seconds call fails,
* throw an exception.This issue must be addressed
* at the java level (and not C code), since the counter
* names must be translated before.
*/
try {
counter = pdhAddCounter(this.query, translate(path));
} catch (Win32Exception e) {
counter = pdhAddCounter(this.query, translate(path + "/sec"));
}
return counter;
}
private double getValue(String path, boolean format)
throws Win32Exception {
@ -291,8 +309,8 @@ public class Pdh extends Win32 {
pdhConnectMachine(this.hostname);
}
long counter =
pdhAddCounter(this.query, translate(path));
long counter = addPdhCounter(path, format);
try {
return pdhGetValue(this.query, counter, format);
} finally {