-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virt plugin: support virDomainBlockStatsFlags #2103
Conversation
d65433a
to
997a243
Compare
997a243
to
6b2181e
Compare
src/virt.c
Outdated
if ((binfo->bi.rd_bytes != -1) && (binfo->bi.wr_bytes != -1)) | ||
submit_derive2("disk_octets", (derive_t)binfo->bi.rd_bytes, | ||
(derive_t)binfo->bi.wr_bytes, dom, type_instance); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but it looks like you're not sending the new statistics you fetch from libvirt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I don't! here I'm new adding support for the new API, and I plan to use it in another PR. I can add the patch consuming the data in this PR if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that would be nice.
Next, I'd like to add the block device "flush" stats:
But I'm not sure how to map them. I was thinking to extend the existing types like this: diff --git a/src/types.db b/src/types.db Or perhaps I can add a new type for disk_flush. What do you think? |
src/virt.c
Outdated
@@ -380,6 +380,10 @@ static void disk_submit(struct lv_block_info *binfo, virDomainPtr dom, | |||
if ((binfo->bi.rd_bytes != -1) && (binfo->bi.wr_bytes != -1)) | |||
submit_derive2("disk_octets", (derive_t)binfo->bi.rd_bytes, | |||
(derive_t)binfo->bi.wr_bytes, dom, type_instance); | |||
|
|||
if ((binfo->rd_total_times != -1) && (binfo->wr_total_times)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if wr_total_times is 0? Isn't that a valid reading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly mistake, fixing.
efe76d0
to
a69524b
Compare
We tend to be somewhat hesitant to adding new types and map stats to existing types as much as possible. I'm not sure what the best type would be in this case. cc'ing @octo who might have an idea. |
@rubenk @octo perhaps we can avoid to extend the default types.db. We can ship our own amended, or add a snippet if you accept #2068 . Is it ok to submit some stats not declared in the default types.db? e.g. something like
|
@mojaves you get the best types when you think of them as "units". For the most part, I think you answer the question youself:
→ type
Add a new entry to types.db:
Best regards, |
@octo thanks! will update my patch soon. |
I see we have already total_time_in_ms in types.db. I will investigate if ms resolution is good for us, so we can avoid adding a new type. |
7cadb79
to
a04ab87
Compare
Looks like the ms resolution is sufficient for use for the time being. We'll discuss in the future a finer-grained resolution (ns) should the need arise. Other than that the patches are under testing on my side. So far, so good, no issues spotted. |
|
ping? |
1 similar comment
ping? |
hit wrong button, reponened |
src/virt.c
Outdated
@@ -640,27 +770,22 @@ static int lv_read(user_data_t *ud) { | |||
|
|||
/* Get block device stats for each domain. */ | |||
for (int i = 0; i < state->nr_block_devices; ++i) { | |||
struct _virDomainBlockStats stats; | |||
struct block_device *bdev = &(state->block_devices[i]); | |||
int ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you declare this on line 778?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will move.
Hi @mojaves, I'm sorry for the late response. Life got in the way.. In general this looks good, I left one minor comment. |
Hi @rubenk , no problem, I totally understand. I'm totally fine with configurable stats, I also think it is a good idea. Let me refresh my patches. |
886ad01
to
27e4214
Compare
We want to export more disk stats, like disk_time. To do so, we must use the virDomainBlockStatsFlags API, but it could not be available on all the platforms collectd supports. To cope with that, we add a minimal layer around the API, and we use virDomainBlockStatsFlags only if available. This patch adds the code to use the new API and the fallback code in the case the platform' libvirt is too old. Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Francesco Romani <fromani@redhat.com>
Now that we switched to virDomainBLockStatsFlags, we can report the `flush` stats. Signed-off-by: Francesco Romani <fromani@redhat.com>
We are adding more metrics to the virt plugin, but not everyone may be interested in those. This patch add one more option to the virt plugin to enable or disable the new stats. For backward compatibility, the default is disabled. Signed-off-by: Francesco Romani <fromani@redhat.com>
27e4214
to
3eebd68
Compare
sorry about the mess, I'm transitioning from my personal account (@mojaves) to my work account (@fromanirh). Should be OK with my last push. If it isn't, I'm fine opening a new cleaner pull request. |
This is the confirmation from the other side that I'm transitioning my collectd contributions from @mojaves (personal account) to @fromanirh (work account) |
src/virt.c
Outdated
char *exstats[EX_STATS_MAX_FIELDS]; | ||
int numexstats; | ||
|
||
numexstats = strsplit(localvalue, exstats, STATIC_ARRAY_SIZE(exstats)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you combine line 610 and 612?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/virt.c
Outdated
int rc = -1; | ||
int ret; | ||
|
||
ret = virDomainBlockStatsFlags(dom, path, NULL, &nparams, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please combine this with line 657
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/virt.c
Outdated
continue; | ||
|
||
char *type_instance = NULL; | ||
if (blockdevice_format_basename && blockdevice_format == source) | ||
type_instance = strdup(basename(state->block_devices[i].path)); | ||
type_instance = strdup(basename(bdev->path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check for failure of strdup()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but rearranging the code in a slightly and hopefully better way
src/virt.c
Outdated
if ((stats.rd_req != -1) && (stats.wr_req != -1)) | ||
submit_derive2("disk_ops", (derive_t)stats.rd_req, (derive_t)stats.wr_req, | ||
state->block_devices[i].dom, type_instance); | ||
type_instance = strdup(bdev->path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/collectd.conf.pod
Outdated
|
||
Enable extra statistics. This allows the plugin to reported more detailed | ||
statistics about the behaviour of Virtual Machines. The argument is a | ||
space-separated list of selectors. Currently only B<disk> is supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally interpreted this as "this enables disk statistics in general". Might be nice to add a note that setting "disk" enables extra dist statistics like flush requests, with the emphasis on extra.
src/collectd.conf.pod
Outdated
@@ -8076,6 +8076,12 @@ How many read instances you want to use for this plugin. The default is one, | |||
and the sensible setting is a multiple of the B<ReadThreads> value. | |||
If you are not sure, just use the default setting. | |||
|
|||
=item B<ExtraStats> B<string> | |||
|
|||
Enable extra statistics. This allows the plugin to reported more detailed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
report
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks @fromanirh. I left just a few minor nits and then this is good to go in. |
Signed-off-by: Francesco Romani <fromani@redhat.com>
We want to export more disk stats, like disk_time.
To do so, we must use the virDomainBlockStatsFlags API, but it
could not be available on all the platforms collectd supports.
To cope with that, we add a minimal layer around the API, and
we use virDomainBlockStatsFlags only if available.
This patch adds the code to use the new API and the fallback code
in the case the platform' libvirt is too old.
Signed-off-by: Francesco Romani fromani@redhat.com