mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: expand domain memory statistics with 'last-update' timestamp
QEMU reports timestamp along with other memory statistics, but this information is not saved into domain statistics. It could be useful to determine if the data reported is fresh or not. Balloon statistics are not reported in hrf, so no modifications are made in qemu_monitor_text.c. Signed-off-by: Derbyshev Dmitry <dderbyshev@virtuozzo.com>
This commit is contained in:
parent
65bf044686
commit
200a40f94e
@ -609,11 +609,14 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
VIR_DOMAIN_MEMORY_STAT_USABLE = 8,
|
VIR_DOMAIN_MEMORY_STAT_USABLE = 8,
|
||||||
|
|
||||||
|
/* Timestamp of the last update of statistics */
|
||||||
|
VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE = 9,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The number of statistics supported by this version of the interface.
|
* The number of statistics supported by this version of the interface.
|
||||||
* To add new statistics, add them to the enum and increase this value.
|
* To add new statistics, add them to the enum and increase this value.
|
||||||
*/
|
*/
|
||||||
VIR_DOMAIN_MEMORY_STAT_NR = 9,
|
VIR_DOMAIN_MEMORY_STAT_NR = 10,
|
||||||
|
|
||||||
# ifdef VIR_ENUM_SENTINELS
|
# ifdef VIR_ENUM_SENTINELS
|
||||||
VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR
|
VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR
|
||||||
|
@ -5991,6 +5991,8 @@ virDomainGetInterfaceParameters(virDomainPtr domain,
|
|||||||
* to swap, corresponds to 'Available' in /proc/meminfo
|
* to swap, corresponds to 'Available' in /proc/meminfo
|
||||||
* VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON:
|
* VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON:
|
||||||
* Current balloon value (in kb).
|
* Current balloon value (in kb).
|
||||||
|
* VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE
|
||||||
|
* Timestamp of the last statistic
|
||||||
*
|
*
|
||||||
* Returns: The number of stats provided or -1 in case of failure.
|
* Returns: The number of stats provided or -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
|
@ -1633,10 +1633,10 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
|
|||||||
* rates and/or whether data has been collected since a previous cycle.
|
* rates and/or whether data has been collected since a previous cycle.
|
||||||
* It's currently unused.
|
* It's currently unused.
|
||||||
*/
|
*/
|
||||||
#define GET_BALLOON_STATS(FIELD, TAG, DIVISOR) \
|
#define GET_BALLOON_STATS(OBJECT, FIELD, TAG, DIVISOR) \
|
||||||
if (virJSONValueObjectHasKey(statsdata, FIELD) && \
|
if (virJSONValueObjectHasKey(OBJECT, FIELD) && \
|
||||||
(got < nr_stats)) { \
|
(got < nr_stats)) { \
|
||||||
if (virJSONValueObjectGetNumberUlong(statsdata, FIELD, &mem) < 0) { \
|
if (virJSONValueObjectGetNumberUlong(OBJECT, FIELD, &mem) < 0) { \
|
||||||
VIR_DEBUG("Failed to get '%s' value", FIELD); \
|
VIR_DEBUG("Failed to get '%s' value", FIELD); \
|
||||||
} else { \
|
} else { \
|
||||||
/* Not being collected? No point in providing bad data */ \
|
/* Not being collected? No point in providing bad data */ \
|
||||||
@ -1707,20 +1707,22 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_BALLOON_STATS("stat-swap-in",
|
GET_BALLOON_STATS(statsdata, "stat-swap-in",
|
||||||
VIR_DOMAIN_MEMORY_STAT_SWAP_IN, 1024);
|
VIR_DOMAIN_MEMORY_STAT_SWAP_IN, 1024);
|
||||||
GET_BALLOON_STATS("stat-swap-out",
|
GET_BALLOON_STATS(statsdata, "stat-swap-out",
|
||||||
VIR_DOMAIN_MEMORY_STAT_SWAP_OUT, 1024);
|
VIR_DOMAIN_MEMORY_STAT_SWAP_OUT, 1024);
|
||||||
GET_BALLOON_STATS("stat-major-faults",
|
GET_BALLOON_STATS(statsdata, "stat-major-faults",
|
||||||
VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT, 1);
|
VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT, 1);
|
||||||
GET_BALLOON_STATS("stat-minor-faults",
|
GET_BALLOON_STATS(statsdata, "stat-minor-faults",
|
||||||
VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT, 1);
|
VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT, 1);
|
||||||
GET_BALLOON_STATS("stat-free-memory",
|
GET_BALLOON_STATS(statsdata, "stat-free-memory",
|
||||||
VIR_DOMAIN_MEMORY_STAT_UNUSED, 1024);
|
VIR_DOMAIN_MEMORY_STAT_UNUSED, 1024);
|
||||||
GET_BALLOON_STATS("stat-total-memory",
|
GET_BALLOON_STATS(statsdata, "stat-total-memory",
|
||||||
VIR_DOMAIN_MEMORY_STAT_AVAILABLE, 1024);
|
VIR_DOMAIN_MEMORY_STAT_AVAILABLE, 1024);
|
||||||
GET_BALLOON_STATS("stat-available-memory",
|
GET_BALLOON_STATS(statsdata, "stat-available-memory",
|
||||||
VIR_DOMAIN_MEMORY_STAT_USABLE, 1024);
|
VIR_DOMAIN_MEMORY_STAT_USABLE, 1024);
|
||||||
|
GET_BALLOON_STATS(data, "last-update",
|
||||||
|
VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE, 1);
|
||||||
ret = got;
|
ret = got;
|
||||||
cleanup:
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
|
@ -375,6 +375,8 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
vshPrint(ctl, "actual %llu\n", stats[i].val);
|
vshPrint(ctl, "actual %llu\n", stats[i].val);
|
||||||
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
|
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
|
||||||
vshPrint(ctl, "rss %llu\n", stats[i].val);
|
vshPrint(ctl, "rss %llu\n", stats[i].val);
|
||||||
|
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE)
|
||||||
|
vshPrint(ctl, "last_update %llu\n", stats[i].val);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user