Implemented process disk IO metrics on Windows

This commit is contained in:
Netta Gavrieli 2013-07-30 06:04:06 -07:00
parent a62558af50
commit 273889f827
2 changed files with 30 additions and 0 deletions

View File

@ -345,6 +345,8 @@ typedef struct {
sigar_uint64_t handles;
sigar_uint64_t threads;
sigar_uint64_t page_faults;
sigar_uint64_t bytes_read;
sigar_uint64_t bytes_written;
} sigar_win32_pinfo_t;
typedef struct {

View File

@ -62,6 +62,8 @@ typedef enum {
#define PERF_TITLE_PPID 1410
#define PERF_TITLE_PRIORITY 682
#define PERF_TITLE_START_TIME 684
#define PERF_TITLE_IO_READ_BYTES_SEC 1420
#define PERF_TITLE_IO_WRITE_BYTES_SEC 1422
typedef enum {
PERF_IX_CPUTIME,
@ -74,6 +76,8 @@ typedef enum {
PERF_IX_PPID,
PERF_IX_PRIORITY,
PERF_IX_START_TIME,
PERF_IX_IO_READ_BYTES_SEC,
PERF_IX_IO_WRITE_BYTES_SEC,
PERF_IX_MAX
} perf_proc_offsets_t;
@ -1210,6 +1214,22 @@ SIGAR_DECLARE(int) sigar_proc_mem_get(sigar_t *sigar, sigar_pid_t pid,
return SIGAR_OK;
}
SIGAR_DECLARE(int) sigar_proc_disk_io_get(sigar_t *sigar, sigar_pid_t pid,
sigar_proc_disk_io_t *proc_disk_io)
{
int status = get_proc_info(sigar, pid);
sigar_win32_pinfo_t *pinfo = &sigar->pinfo;
if (status != SIGAR_OK) {
return status;
}
proc_disk_io->bytes_read = pinfo->bytes_read;
proc_disk_io->bytes_written = pinfo->bytes_written;
return SIGAR_OK;
}
#define TOKEN_DAC (STANDARD_RIGHTS_READ | READ_CONTROL | TOKEN_QUERY)
SIGAR_DECLARE(int)
@ -1441,6 +1461,12 @@ static int get_proc_info(sigar_t *sigar, sigar_pid_t pid)
case PERF_TITLE_START_TIME:
perf_offsets[PERF_IX_START_TIME] = offset;
break;
case PERF_TITLE_IO_READ_BYTES_SEC:
perf_offsets[PERF_IX_IO_READ_BYTES_SEC] = offset;
break;
case PERF_TITLE_IO_WRITE_BYTES_SEC:
perf_offsets[PERF_IX_IO_WRITE_BYTES_SEC] = offset;
break;
}
}
@ -1466,6 +1492,8 @@ static int get_proc_info(sigar_t *sigar, sigar_pid_t pid)
pinfo->handles = PERF_VAL(PERF_IX_HANDLE_CNT);
pinfo->threads = PERF_VAL(PERF_IX_THREAD_CNT);
pinfo->page_faults = PERF_VAL(PERF_IX_PAGE_FAULTS);
pinfo->bytes_read = PERF_VAL(PERF_IX_IO_READ_BYTES_SEC);
pinfo->bytes_written = PERF_VAL(PERF_IX_IO_WRITE_BYTES_SEC);
return SIGAR_OK;
}