1 /** |
1 /** |
2 * @file nodes.c |
2 * @file nodes.c |
3 * @brief Handle nodes status |
3 * @brief Handle nodes status |
4 * @author Michiel Broek <mbroek at mbse dot eu> |
4 * @author Michiel Broek <mbroek at mbse dot eu> |
5 * |
5 * |
6 * Copyright (C) 2018-2020 |
6 * Copyright (C) 2018-2022 |
7 * |
7 * |
8 * This file is part of the bms (Brewery Management System) |
8 * This file is part of the bms (Brewery Management System) |
9 * |
9 * |
10 * This is free software; you can redistribute it and/or modify it |
10 * This is free software; you can redistribute it and/or modify it |
11 * under the terms of the GNU General Public License as published by the |
11 * under the terms of the GNU General Public License as published by the |
311 for (tmpp = nodes; tmpp; tmpp = tmpp->next) { |
311 for (tmpp = nodes; tmpp; tmpp = tmpp->next) { |
312 if (strcmp(tmpp->node, edge_node) == 0) { |
312 if (strcmp(tmpp->node, edge_node) == 0) { |
313 tmpp->online = false; |
313 tmpp->online = false; |
314 msg = xstrcpy((char *)"{\"node\":\""); |
314 msg = xstrcpy((char *)"{\"node\":\""); |
315 msg = xstrcat(msg, edge_node); |
315 msg = xstrcat(msg, edge_node); |
316 msg = xstrcat(msg, (char *)"\",\"group\":\""); |
316 msg = xstrcat(msg, (char *)"\",\"group_id\":\""); |
317 msg = xstrcat(msg, group_id); |
317 msg = xstrcat(msg, group_id); |
318 msg = xstrcat(msg, (char *)"\",\"online\":0}"); |
318 msg = xstrcat(msg, (char *)"\",\"online\":0}"); |
319 ws_broadcast(msg); |
319 ws_broadcast(msg); |
320 free(msg); |
320 free(msg); |
321 msg = NULL; |
321 msg = NULL; |
342 syslog(LOG_NOTICE, "Timeout node `%s/%s' after %ld seconds", tmpn->group_id, tmpn->node, (now - tmpn->lastseen)); |
342 syslog(LOG_NOTICE, "Timeout node `%s/%s' after %ld seconds", tmpn->group_id, tmpn->node, (now - tmpn->lastseen)); |
343 tmpn->online = false; |
343 tmpn->online = false; |
344 node_mysql_death(tmpn->node); |
344 node_mysql_death(tmpn->node); |
345 msg = xstrcpy((char *)"{\"node\":\""); |
345 msg = xstrcpy((char *)"{\"node\":\""); |
346 msg = xstrcat(msg, tmpn->node); |
346 msg = xstrcat(msg, tmpn->node); |
347 msg = xstrcat(msg, (char *)"\",\"group\":\""); |
347 msg = xstrcat(msg, (char *)"\",\"group_id\":\""); |
348 msg = xstrcat(msg, tmpn->group_id); |
348 msg = xstrcat(msg, tmpn->group_id); |
349 msg = xstrcat(msg, (char *)"\",\"online\":0}"); |
349 msg = xstrcat(msg, (char *)"\",\"online\":0}"); |
350 ws_broadcast(msg); |
350 ws_broadcast(msg); |
351 syslog(LOG_NOTICE, msg); |
|
352 free(msg); |
351 free(msg); |
353 msg = NULL; |
352 msg = NULL; |
354 |
353 |
355 for (tmpf = fermenters; tmpf; tmpf = tmpf->next) { |
354 for (tmpf = fermenters; tmpf; tmpf = tmpf->next) { |
356 if (strcmp(tmpf->node, tmpn->node) == 0) { |
355 if (strcmp(tmpf->node, tmpn->node) == 0) { |