From fc562e3e9264474183b430f71972cca6434691b3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 3 Sep 2010 12:48:26 +0200 Subject: [PATCH] lpar plugin: Fix error handling of the "perfstat_partition_total" function. According to the documentation the function returns -1 on error. The code now assumes anything but one (the number of structures filled) as error. --- src/lpar.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lpar.c b/src/lpar.c index 113dff93..be4738bb 100644 --- a/src/lpar.c +++ b/src/lpar.c @@ -190,6 +190,8 @@ static int lpar_read_dedicated_partition (const perfstat_partition_total_t *data if (data->type.b.donate_enabled) { + /* FYI: PURR == Processor Utilization of Resources Register + * SPURR == Scaled PURR */ lpar_submit ("idle_donated", (counter_t) data->idle_donated_purr); lpar_submit ("busy_donated", (counter_t) data->busy_donated_purr); lpar_submit ("idle_stolen", (counter_t) data->idle_stolen_purr); @@ -202,12 +204,18 @@ static int lpar_read_dedicated_partition (const perfstat_partition_total_t *data static int lpar_read (void) { perfstat_partition_total_t lparstats; + int status; - /* Retrieve the current metrics */ - if (!perfstat_partition_total (NULL, &lparstats, - sizeof (perfstat_partition_total_t), 1)) + /* Retrieve the current metrics. Returns the number of structures filled. */ + status = perfstat_partition_total (/* name = */ NULL, /* (must be NULL) */ + &lparstats, sizeof (perfstat_partition_total_t), + /* number = */ 1 /* (must be 1) */); + if (status != 1) { - ERROR ("lpar plugin: perfstat_partition_total failed."); + char errbuf[1024]; + ERROR ("lpar plugin: perfstat_partition_total failed: %s (%i)", + sstrerror (errno, errbuf, sizeof (errbuf)), + status); return (-1); } -- 2.30.2