- submit_counter (plugin_inst, "cpu", "user", (counter_t) lparstats.puser);
- submit_counter (plugin_inst, "cpu", "system", (counter_t) lparstats.psys);
- submit_counter (plugin_inst, "cpu", "idle", (counter_t) lparstats.pidle);
- submit_counter (plugin_inst, "cpu", "wait", (counter_t) lparstats.pwait);
-
- /* FIXME: Use an appropriate GAUGE type here. */
- lpar_submit (plugin_inst, "ent", (double)lparstats.entitled_proc_capacity / 100.0);
- lpar_submit (plugin_inst, "max", (double)lparstats.max_proc_capacity / 100.0);
- lpar_submit (plugin_inst, "min", (double)lparstats.min_proc_capacity / 100.0);
-
- if (have_donate)
+ /*
+ * 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);
+
+#if PERFSTAT_SUPPORTS_DONATION
+ if (donate_flag)