diff --git a/bindings/java/src/jni/win32/pdh.c b/bindings/java/src/jni/win32/pdh.c index a0449630..6fb70d77 100644 --- a/bindings/java/src/jni/win32/pdh.c +++ b/bindings/java/src/jni/win32/pdh.c @@ -102,6 +102,17 @@ JNIEXPORT jlong SIGAR_JNI(win32_Pdh_pdhAddCounter) /* Add the counter that created the data in the log file. */ status = PdhAddCounter(h_query, counter_path, 0, &h_counter); + + if (status == PDH_CSTATUS_NO_COUNTER) { + /* if given counter does not exist, + * try the same name w/ "/sec" appended + */ + char counter_sec[MAX_PATH]; + strcpy(counter_sec, counter_path); + strcat(counter_sec, "/sec"); + status = PdhAddCounter(h_query, counter_sec, 0, &h_counter); + } + JENV->ReleaseStringUTFChars(env, cp, counter_path); if (status != ERROR_SUCCESS) {