1
1

Pack/unpack the disk and net stats so they get passed along

This commit was SVN r27844.
Этот коммит содержится в:
Ralph Castain 2013-01-16 21:54:48 +00:00
родитель cba06776f1
Коммит 92e297d1fa
4 изменённых файлов: 314 добавлений и 6 удалений

Просмотреть файл

@ -470,6 +470,96 @@ int opal_dss_pack_pstat(opal_buffer_t *buffer, const void *src,
return OPAL_SUCCESS;
}
static int pack_disk_stats(opal_buffer_t *buffer, opal_diskstats_t *dk)
{
uint64_t i64;
int ret;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &dk->disk, 1, OPAL_STRING))) {
return ret;
}
i64 = (uint64_t)dk->num_reads_completed;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_reads_merged;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_sectors_read;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->milliseconds_reading;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_writes_completed;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_writes_merged;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_sectors_written;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->milliseconds_writing;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->num_ios_in_progress;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->milliseconds_io;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)dk->weighted_milliseconds_io;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
return OPAL_SUCCESS;
}
static int pack_net_stats(opal_buffer_t *buffer, opal_netstats_t *ns)
{
uint64_t i64;
int ret;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ns->interface, 1, OPAL_STRING))) {
return ret;
}
i64 = (uint64_t)ns->num_bytes_recvd;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_packets_recvd;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_recv_errs;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_bytes_sent;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_packets_sent;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
i64 = (uint64_t)ns->num_send_errs;
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &i64, 1, OPAL_UINT64))) {
return ret;
}
return OPAL_SUCCESS;
}
/*
* OPAL_NODE_STAT
*/
@ -477,9 +567,12 @@ int opal_dss_pack_node_stat(opal_buffer_t *buffer, const void *src,
int32_t num_vals, opal_data_type_t type)
{
opal_node_stats_t **ptr;
int32_t i;
int32_t i, j;
int ret;
opal_list_item_t *item;
opal_diskstats_t *ds;
opal_netstats_t *ns;
ptr = (opal_node_stats_t **) src;
for (i = 0; i < num_vals; ++i) {
@ -519,6 +612,34 @@ int opal_dss_pack_node_stat(opal_buffer_t *buffer, const void *src,
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->sample_time, 1, OPAL_TIMEVAL))) {
return ret;
}
/* pack the number of disk stat objects on the list */
j = opal_list_get_size(&ptr[i]->diskstats);
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &j, 1, OPAL_INT32))) {
return ret;
}
/* pack them */
for (item = opal_list_get_first(&ptr[i]->diskstats);
item != opal_list_get_end(&ptr[i]->diskstats);
item = opal_list_get_next(item)) {
ds = (opal_diskstats_t*)item;
if (OPAL_SUCCESS != (ret = pack_disk_stats(buffer, ds))) {
return ret;
}
}
/* pack the number of net stat objects on the list */
j = opal_list_get_size(&ptr[i]->netstats);
if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &j, 1, OPAL_INT32))) {
return ret;
}
/* pack them */
for (item = opal_list_get_first(&ptr[i]->netstats);
item != opal_list_get_end(&ptr[i]->netstats);
item = opal_list_get_next(item)) {
ns = (opal_netstats_t*)item;
if (OPAL_SUCCESS != (ret = pack_net_stats(buffer, ns))) {
return ret;
}
}
}
return OPAL_SUCCESS;

Просмотреть файл

@ -159,10 +159,12 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_diskstats_t);
typedef struct {
opal_list_item_t super;
char *interface;
unsigned long num_bytes_read;
unsigned long num_packets_read;
unsigned long num_bytes_recvd;
unsigned long num_packets_recvd;
unsigned long num_recv_errs;
unsigned long num_bytes_sent;
unsigned long num_packets_sent;
unsigned long num_send_errs;
} opal_netstats_t;
OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_netstats_t);
typedef struct {

Просмотреть файл

@ -594,6 +594,179 @@ int opal_dss_unpack_pstat(opal_buffer_t *buffer, void *dest,
return OPAL_SUCCESS;
}
static int unpack_disk_stats(opal_buffer_t *buffer, opal_node_stats_t *ns)
{
int32_t i, m, n;
int ret;
opal_diskstats_t *dk;
uint64_t i64;
/* unpack the number of disk stat objects */
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &n, &m, OPAL_INT32))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack them */
for (i=0; i < n; i++) {
dk = OBJ_NEW(opal_diskstats_t);
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &dk->disk, &m, OPAL_STRING))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_reads_completed = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_reads_merged = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_sectors_read = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->milliseconds_reading = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_writes_completed = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_writes_merged = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_sectors_written = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->milliseconds_writing = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->num_ios_in_progress = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->milliseconds_io = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(dk);
return ret;
}
dk->weighted_milliseconds_io = i64;
opal_list_append(&ns->diskstats, &dk->super);
}
return OPAL_SUCCESS;
}
static int unpack_net_stats(opal_buffer_t *buffer, opal_node_stats_t *ns)
{
int32_t i, m, n;
int ret;
opal_netstats_t *net;
uint64_t i64;
/* unpack the number of net stat objects */
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &n, &m, OPAL_INT32))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack them */
for (i=0; i < n; i++) {
net = OBJ_NEW(opal_netstats_t);
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &net->interface, &m, OPAL_STRING))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_bytes_recvd = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_packets_recvd = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_recv_errs = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_bytes_sent = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_packets_sent = i64;
m=1;
if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &i64, &m, OPAL_UINT64))) {
OPAL_ERROR_LOG(ret);
OBJ_RELEASE(net);
return ret;
}
net->num_send_errs = i64;
opal_list_append(&ns->netstats, &net->super);
}
return OPAL_SUCCESS;
}
/*
* OPAL_NODE_STAT
*/
@ -673,6 +846,16 @@ int opal_dss_unpack_node_stat(opal_buffer_t *buffer, void *dest,
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack the disk stat objects */
if (OPAL_SUCCESS != (ret = unpack_disk_stats(buffer, ptr[i]))) {
OPAL_ERROR_LOG(ret);
return ret;
}
/* unpack the net stat objects */
if (OPAL_SUCCESS != (ret = unpack_net_stats(buffer, ptr[i]))) {
OPAL_ERROR_LOG(ret);
return ret;
}
}
return OPAL_SUCCESS;

Просмотреть файл

@ -434,10 +434,12 @@ static int query(pid_t pid,
/* pack the ones of interest into the struct */
ns = OBJ_NEW(opal_netstats_t);
ns->interface = strdup(dptr);
ns->num_bytes_read = strtoul(fields[0], NULL, 10);
ns->num_packets_read = strtoul(fields[1], NULL, 10);
ns->num_bytes_recvd = strtoul(fields[0], NULL, 10);
ns->num_packets_recvd = strtoul(fields[1], NULL, 10);
ns->num_recv_errs = strtoul(fields[2], NULL, 10);
ns->num_bytes_sent = strtoul(fields[8], NULL, 10);
ns->num_packets_sent = strtoul(fields[9], NULL, 10);
ns->num_send_errs = strtoul(fields[10], NULL, 10);
opal_list_append(&nstats->netstats, &ns->super);
opal_argv_free(fields);
}