-
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
New plugin: redfish #2926
New plugin: redfish #2926
Conversation
- Collect data from Redfish interface - Use libredfish C library Change-Id: I95e0ee23ccb11f617d41c9edb0b57c651e5cbdb5 Signed-off-by: Mozejko, MarcinX <marcinx.mozejko@intel.com>
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.
Hi @mmozejkx,
thank you very much for your PR! I've left a bunch of comments inline; don't worry, it's all just coding style. The approach looked good to me, though I don't know Redfish well. Unfortunately I didn't have time to look at the tests, but I'm happy with any tests that we have :)
Best regards,
—octo
src/redfish.c
Outdated
/* Preparing query pointers list for every service */ | ||
for (size_t i = 0; i < service->queries_num; i++) { | ||
redfish_query_t *ptr; | ||
if (c_avl_get(ctx->queries, service->queries[i], (void **)&ptr) != 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.
I'd cast to (void *)
here to improve portability, i.e.: (void *)&ptr
src/redfish.c
Outdated
for (llentry_t *le = llist_head(ctx->services); le != NULL; le = le->next) { | ||
redfish_service_t *service = (redfish_service_t *)le->value; | ||
/* Ignore redfish version */ | ||
service->flags |= 0x00000001; |
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.
The hex notation and bitwise or'ing indicate a magic constant. Is there a symbolic name you could use instead?
src/redfish.c
Outdated
return 0; | ||
|
||
error: | ||
ERROR(PLUGIN_NAME ": Failed to allocate memory for service queries list"); |
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.
You can get here for other reasons. I'd recomment printing the error message before using goto
.
src/redfish.c
Outdated
}; | ||
typedef union redfish_value_u redfish_value_t; | ||
|
||
redfish_ctx_t *ctx; |
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.
This should be static
.
src/redfish.c
Outdated
goto free_ctx; | ||
|
||
/* Creating placeholder for queries */ | ||
ctx->queries = c_avl_create((int (*)(const void *, const void *))strcmp); |
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.
Again, just cast to (void *)
– this cast is hindering readability more than it is helping.
redfish_service_t *service = (redfish_service_t *)le->value; | ||
for (llentry_t *le = llist_head(service->query_ptrs); le != NULL; | ||
le = le->next) { | ||
redfish_query_t *query = (redfish_query_t *)le->value; |
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.
Optional: unnecessary cast.
|
||
static int redfish_read(__attribute__((unused)) user_data_t *ud) { | ||
for (llentry_t *le = llist_head(ctx->services); le != NULL; le = le->next) { | ||
redfish_service_t *service = (redfish_service_t *)le->value; |
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.
Optional: unnecessary cast.
src/redfish.c
Outdated
|
||
llist_destroy(service->query_ptrs); | ||
|
||
sfree(service->name); |
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've seen this list of sfree statements for various service members before. Maybe put that into a service_destroy()
function?
src/redfish.c
Outdated
|
||
cleanupServiceEnumerator(service->redfish); | ||
for (size_t i = 0; i < service->queries_num; i++) | ||
sfree(service->queries[i]); |
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.
Optional: Consider using strarray_free()
.
src/redfish.c
Outdated
char *key; | ||
redfish_query_t *query; | ||
|
||
while (c_avl_iterator_next(i, (void **)&key, (void **)&query) == 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.
Cast to (void *)
Add unit tests. Change-Id: Iecef07b148ca2ac067cf912bb4a6af2d2190b810 Signed-off-by: Adrian Boczkowski <adrianx.boczkowski@intel.com>
@octo Thanks for your feedback. We're working on creating a patch and it should be upstreamed soon. Regards, |
Fix segmentation fault Fix memory leaks Change-Id: I8691c292af323145536528f16525206acbfb03f7 Signed-off-by: Mozejko, MarcinX <marcinx.mozejko@intel.com> Signed-off-by: Adrian Boczkowski <adrianx.boczkowski@intel.com>
Hi @octo, |
@mkobyli Could you please resolve the conflicts? |
Makefile.am
Outdated
redfish_la_LIBADD = $(BUILD_WITH_LIBREDFISH_LIBS) -lredfish | ||
|
||
test_plugin_redfish_SOURCES = src/redfish_test.c \ | ||
src/daemon/utils_avltree.c \ |
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 followup on changed location of utils_avltree.
- Collect data from Redfish interface - Use libredfish C library redfish plugin: addressing comments from PR collectd#2926 Add unit tests. Fix race condition. Fix segmentation fault. Fix memory leaks. ChangeLog: Redfish plugin: Collect sensor data using Redfish protocol. Signed-off-by: Marcin Mozejko <marcinx.mozejko@intel.com> Signed-off-by: Adrian Boczkowski <adrianx.boczkowski@intel.com> Signed-off-by: Zoltan Szabo <zoltan.4.szabo@nokia.com> Signed-off-by: Michal Kobylinski <michal.kobylinski@intel.com>
my apologies for "merge ladder", should squash it.. |
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.
LGTM
This is a C plugin that collects sensor data using Redfish protocol.
It can get multiple resources from different hardware that support Redfish.
NOTE: Version of this code is an early drop.
Any feedback appreciated.
ChangeLog: Redfish plugin: Collect sensor data from Redfish endpoints.
[edit @kkepka:] added changelog