83 fprintf(stdout, "MySQL: connected\n"); |
83 fprintf(stdout, "MySQL: connected\n"); |
84 |
84 |
85 /* |
85 /* |
86 * Restore nodes from the database |
86 * Restore nodes from the database |
87 */ |
87 */ |
88 if (mysql_query(con, "SELECT * FROM mon_nodes")) { |
88 if (mysql_query(con, "SELECT * FROM mon_nodes ORDER BY node")) { |
89 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_nodes error %u (%s))", mysql_errno(con), mysql_error(con)); |
89 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_nodes error %u (%s))", mysql_errno(con), mysql_error(con)); |
90 } else { |
90 } else { |
91 res_set = mysql_store_result(con); |
91 res_set = mysql_store_result(con); |
92 if (res_set == NULL) { |
92 if (res_set == NULL) { |
93 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
93 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
133 } |
133 } |
134 mysql_free_result(res_set); |
134 mysql_free_result(res_set); |
135 } |
135 } |
136 } |
136 } |
137 |
137 |
138 if (mysql_query(con, "SELECT * FROM mon_fermenters")) { |
138 if (mysql_query(con, "SELECT * FROM mon_fermenters ORDER BY node,alias")) { |
139 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_fermenters error %u (%s))", mysql_errno(con), mysql_error(con)); |
139 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_fermenters error %u (%s))", mysql_errno(con), mysql_error(con)); |
140 } else { |
140 } else { |
141 res_set = mysql_store_result(con); |
141 res_set = mysql_store_result(con); |
142 if (res_set == NULL) { |
142 if (res_set == NULL) { |
143 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
143 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
229 } |
229 } |
230 mysql_free_result(res_set); |
230 mysql_free_result(res_set); |
231 } |
231 } |
232 } |
232 } |
233 |
233 |
234 if (mysql_query(con, "SELECT * FROM mon_co2meters")) { |
234 if (mysql_query(con, "SELECT * FROM mon_co2meters ORDER BY node,alias")) { |
235 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_co2meters error %u (%s))", mysql_errno(con), mysql_error(con)); |
235 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_co2meters error %u (%s))", mysql_errno(con), mysql_error(con)); |
236 } else { |
236 } else { |
237 res_set = mysql_store_result(con); |
237 res_set = mysql_store_result(con); |
238 if (res_set == NULL) { |
238 if (res_set == NULL) { |
239 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
239 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
273 } |
273 } |
274 mysql_free_result(res_set); |
274 mysql_free_result(res_set); |
275 } |
275 } |
276 } |
276 } |
277 |
277 |
278 if (mysql_query(con, "SELECT * FROM mon_ispindels")) { |
278 if (mysql_query(con, "SELECT * FROM mon_ispindels ORDER BY node,alias")) { |
279 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_ispindels error %u (%s))", mysql_errno(con), mysql_error(con)); |
279 syslog(LOG_NOTICE, "MySQL: SELECT * FROM mon_ispindels error %u (%s))", mysql_errno(con), mysql_error(con)); |
280 } else { |
280 } else { |
281 res_set = mysql_store_result(con); |
281 res_set = mysql_store_result(con); |
282 if (res_set == NULL) { |
282 if (res_set == NULL) { |
283 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |
283 syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con)); |