Skip to content
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

Merged
merged 11 commits into from
Feb 28, 2020
Merged

New plugin: redfish #2926

merged 11 commits into from
Feb 28, 2020

Conversation

mmozejkx
Copy link
Contributor

@mmozejkx mmozejkx commented Sep 14, 2018

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

- Collect data from Redfish interface
- Use libredfish C library

Change-Id: I95e0ee23ccb11f617d41c9edb0b57c651e5cbdb5
Signed-off-by: Mozejko, MarcinX <marcinx.mozejko@intel.com>
@rpv-tomsk rpv-tomsk added this to the 5.9 milestone Sep 24, 2018
Copy link
Member

@octo octo left a 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)
Copy link
Member

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;
Copy link
Member

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");
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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]);
Copy link
Member

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) {
Copy link
Member

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>
@mmozejkx
Copy link
Contributor Author

@octo Thanks for your feedback. We're working on creating a patch and it should be upstreamed soon.

Regards,
Marcin

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>
@mkobyli
Copy link
Contributor

mkobyli commented Nov 13, 2018

Hi @octo,
We updated our PR.
I'll be happy for your review. Please let me know, if PR need any fix.
Regards,
Michal

@mkobyli mkobyli mentioned this pull request Nov 13, 2018
@sunkuranganath
Copy link
Member

@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 \
Copy link
Contributor

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.

@mrunge mrunge modified the milestones: 5.9, 5.10 Jul 10, 2019
mmozejkx and others added 2 commits August 23, 2019 12:37
- 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>
@mrunge mrunge modified the milestones: 5.10.0, 5.11.0 Oct 11, 2019
@kkepka
Copy link
Contributor

kkepka commented Jan 14, 2020

my apologies for "merge ladder", should squash it..

@dago dago linked an issue Feb 17, 2020 that may be closed by this pull request
Copy link
Contributor

@dago dago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dago dago merged commit 1ec0d53 into collectd:master Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redfish plugin [wip]
9 participants