X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Flpar.c;h=c4189b7d32ae035da5122cd36570a6eec05efe0a;hp=412a721ab3707f3d448f13692599e2fc705855f6;hb=a9e50e9e30ecde17e167e271060c8183bfcbf407;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f diff --git a/src/lpar.c b/src/lpar.c index 412a721a..c4189b7d 100644 --- a/src/lpar.c +++ b/src/lpar.c @@ -61,10 +61,10 @@ static int lpar_config(const char *key, const char *value) { else report_by_serial = 0; } else { - return (-1); + return -1; } - return (0); + return 0; } /* int lpar_config */ static int lpar_init(void) { @@ -76,10 +76,9 @@ static int lpar_init(void) { sizeof(perfstat_partition_total_t), /* number = */ 1 /* (must be 1) */); if (status != 1) { - char errbuf[1024]; - ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)", - sstrerror(errno, errbuf, sizeof(errbuf)), status); - return (-1); + ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)", STRERRNO, + status); + return -1; } #if PERFSTAT_SUPPORTS_DONATION @@ -95,22 +94,17 @@ static int lpar_init(void) { pool_stats = 0; } - return (0); + return 0; } /* int lpar_init */ static void lpar_submit(const char *type_instance, double value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = (gauge_t)value; - - vl.values = values; + vl.values = &(value_t){.gauge = value}; vl.values_len = 1; if (report_by_serial) { sstrncpy(vl.host, serial, sizeof(vl.host)); sstrncpy(vl.plugin_instance, hostname_g, sizeof(vl.plugin)); - } else { - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); } sstrncpy(vl.plugin, "lpar", sizeof(vl.plugin)); sstrncpy(vl.type, "vcpu", sizeof(vl.type)); @@ -133,7 +127,7 @@ static int lpar_read(void) { from chassis to chassis through Live Partition Mobility (LPM). */ if (uname(&name) != 0) { ERROR("lpar plugin: uname failed."); - return (-1); + return -1; } sstrncpy(serial, name.machine, sizeof(serial)); @@ -143,10 +137,9 @@ static int lpar_read(void) { &lparstats, sizeof(perfstat_partition_total_t), /* number = */ 1 /* (must be 1) */); if (status != 1) { - char errbuf[1024]; - ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)", - sstrerror(errno, errbuf, sizeof(errbuf)), status); - return (-1); + ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)", STRERRNO, + status); + return -1; } /* Number of ticks since we last run. */ @@ -154,7 +147,7 @@ static int lpar_read(void) { if (ticks == 0) { /* The stats have not been updated. Return now to avoid * dividing by zero */ - return (0); + return 0; } /* @@ -231,16 +224,16 @@ static int lpar_read(void) { if (pool_busy_cpus < 0.0) pool_busy_cpus = 0.0; - ssnprintf(typinst, sizeof(typinst), "pool-%X-busy", lparstats.pool_id); + snprintf(typinst, sizeof(typinst), "pool-%X-busy", lparstats.pool_id); lpar_submit(typinst, pool_busy_cpus); - ssnprintf(typinst, sizeof(typinst), "pool-%X-idle", lparstats.pool_id); + snprintf(typinst, sizeof(typinst), "pool-%X-idle", lparstats.pool_id); lpar_submit(typinst, pool_idle_cpus); } memcpy(&lparstats_old, &lparstats, sizeof(lparstats_old)); - return (0); + return 0; } /* int lpar_read */ void module_register(void) { @@ -248,5 +241,3 @@ void module_register(void) { plugin_register_init("lpar", lpar_init); plugin_register_read("lpar", lpar_read); } /* void module_register */ - -/* vim: set sw=8 noet : */