bmsd/nodes.c

changeset 384
442d23455ae4
parent 0
033898178630
child 502
a8a6901b5a99
equal deleted inserted replaced
383:2395bdfac387 384:442d23455ae4
27 #include "xutil.h" 27 #include "xutil.h"
28 #include "nodes.h" 28 #include "nodes.h"
29 #include "mysql.h" 29 #include "mysql.h"
30 30
31 31
32 sys_node_list *nodes = NULL; 32 sys_node_list *nodes = NULL;
33 33
34 extern int debug; 34 extern int debug;
35 35 extern sys_fermenter_list *fermenters;
36 36
37 37
38 void node_birth_data(char *topic, char *payload) 38 void node_birth_data(char *topic, char *payload)
39 { 39 {
40 struct json_object *jobj, *val, *metric, *metric2; 40 struct json_object *jobj, *val, *metric, *metric2;
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 241
242
243 void nodes_check_online()
244 {
245 sys_node_list *tmpn;
246 sys_fermenter_list *tmpf;
247 time_t now = time(NULL);
248
249 for (tmpn = nodes; tmpn; tmpn = tmpn->next) {
250 if (tmpn->online && ((now - tmpn->lastseen) > 600)) {
251 syslog(LOG_NOTICE, "Timeout node `%s/%s'", tmpn->group_id, tmpn->node);
252 tmpn->online = false;
253 node_mysql_death(tmpn->node);
254
255 for (tmpf = fermenters; tmpf; tmpf = tmpf->next) {
256 if (strcmp(tmpf->node, tmpn->node) == 0) {
257 if (tmpf->online) {
258 syslog(LOG_NOTICE, "Timeout fermenter %s/%s", tmpf->node, tmpf->alias);
259 tmpf->online = false;
260 fermenter_mysql_death(tmpf->node, tmpf->alias);
261 }
262 }
263 }
264 }
265 }
266 }
267
268

mercurial