-static int lpar_read (void)
-{
- perfstat_partition_total_t lparstats;
- int status;
- struct utsname name;
- u_longlong_t ticks;
- u_longlong_t user_ticks, syst_ticks, wait_ticks, idle_ticks;
- u_longlong_t consumed_ticks;
- double entitled_proc_capacity;
-
- /* An LPAR has the same serial number as the physical system it is currently
- running on. It is a convenient way of tracking LPARs as they are moved
- from chassis to chassis through Live Partition Mobility (LPM). */
- if (uname (&name) != 0)
- {
- ERROR ("lpar plugin: uname failed.");
- return (-1);
- }
- sstrncpy (serial, name.machine, sizeof (serial));
-
- /* 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)
- {
- char errbuf[1024];
- ERROR ("lpar plugin: perfstat_partition_total failed: %s (%i)",
- sstrerror (errno, errbuf, sizeof (errbuf)),
- status);
- return (-1);
- }
-
- /* Number of ticks since we last run. */
- ticks = lparstats.timebase_last - lparstats_old.timebase_last;
- if (ticks == 0)
- {
- /* The stats have not been updated. Return now to avoid
- * dividing by zero */
- return (0);
- }
-
- /*
- * On a shared partition, we're "entitled" to a certain amount of
- * processing power, for example 250/100 of a physical CPU. Processing
- * capacity not used by the partition may be assigned to a different
- * partition by the hypervisor, so "idle" is hopefully a very small
- * number.
- *
- * A dedicated partition may donate its CPUs to another partition and
- * may steal ticks from somewhere else (another partition or maybe the
- * shared pool, I don't know --octo).
- */
-
- /* entitled_proc_capacity is in 1/100th of a CPU */
- entitled_proc_capacity = 0.01 * ((double) lparstats.entitled_proc_capacity);
- lpar_submit ("entitled", entitled_proc_capacity);
-
- /* The number of ticks actually spent in the various states */
- user_ticks = lparstats.puser - lparstats_old.puser;
- syst_ticks = lparstats.psys - lparstats_old.psys;
- wait_ticks = lparstats.pwait - lparstats_old.pwait;
- idle_ticks = lparstats.pidle - lparstats_old.pidle;
- consumed_ticks = user_ticks + syst_ticks + wait_ticks + idle_ticks;
-
- lpar_submit ("user", (double) user_ticks / (double) ticks);
- lpar_submit ("system", (double) syst_ticks / (double) ticks);
- lpar_submit ("wait", (double) wait_ticks / (double) ticks);
- lpar_submit ("idle", (double) idle_ticks / (double) ticks);
+static int lpar_read(void) {
+ perfstat_partition_total_t lparstats;
+ int status;
+ struct utsname name;
+ u_longlong_t ticks;
+ u_longlong_t user_ticks, syst_ticks, wait_ticks, idle_ticks;
+ u_longlong_t consumed_ticks;
+ double entitled_proc_capacity;
+
+ /* An LPAR has the same serial number as the physical system it is currently
+ running on. It is a convenient way of tracking LPARs as they are moved
+ from chassis to chassis through Live Partition Mobility (LPM). */
+ if (uname(&name) != 0) {
+ ERROR("lpar plugin: uname failed.");
+ return (-1);
+ }
+ sstrncpy(serial, name.machine, sizeof(serial));
+
+ /* 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) {
+ char errbuf[1024];
+ ERROR("lpar plugin: perfstat_partition_total failed: %s (%i)",
+ sstrerror(errno, errbuf, sizeof(errbuf)), status);
+ return (-1);
+ }
+
+ /* Number of ticks since we last run. */
+ ticks = lparstats.timebase_last - lparstats_old.timebase_last;
+ if (ticks == 0) {
+ /* The stats have not been updated. Return now to avoid
+ * dividing by zero */
+ return (0);
+ }
+
+ /*
+ * On a shared partition, we're "entitled" to a certain amount of
+ * processing power, for example 250/100 of a physical CPU. Processing
+ * capacity not used by the partition may be assigned to a different
+ * partition by the hypervisor, so "idle" is hopefully a very small
+ * number.
+ *
+ * A dedicated partition may donate its CPUs to another partition and
+ * may steal ticks from somewhere else (another partition or maybe the
+ * shared pool, I don't know --octo).
+ */
+
+ /* entitled_proc_capacity is in 1/100th of a CPU */
+ entitled_proc_capacity = 0.01 * ((double)lparstats.entitled_proc_capacity);
+ lpar_submit("entitled", entitled_proc_capacity);
+
+ /* The number of ticks actually spent in the various states */
+ user_ticks = lparstats.puser - lparstats_old.puser;
+ syst_ticks = lparstats.psys - lparstats_old.psys;
+ wait_ticks = lparstats.pwait - lparstats_old.pwait;
+ idle_ticks = lparstats.pidle - lparstats_old.pidle;
+ consumed_ticks = user_ticks + syst_ticks + wait_ticks + idle_ticks;
+
+ lpar_submit("user", (double)user_ticks / (double)ticks);
+ lpar_submit("system", (double)syst_ticks / (double)ticks);
+ lpar_submit("wait", (double)wait_ticks / (double)ticks);
+ lpar_submit("idle", (double)idle_ticks / (double)ticks);