}
}
+static void
+rspamd_fill_health_reply (struct rspamd_main *srv, struct rspamd_srv_reply *rep)
+{
+ GHashTableIter it;
+ gpointer k, v;
+
+ memset (&rep->reply.health, 0, sizeof (rep->reply));
+ g_hash_table_iter_init (&it, srv->workers);
+
+ while (g_hash_table_iter_next (&it, &k, &v)) {
+ struct rspamd_worker *wrk = (struct rspamd_worker *)v;
+
+ if (wrk->hb.nbeats < 0) {
+ rep->reply.health.workers_hb_lost ++;
+ }
+ else if (rspamd_worker_is_scanner (wrk)) {
+ rep->reply.health.scanners_count ++;
+ }
+
+ rep->reply.health.workers_count ++;
+ }
+
+ rep->reply.status = (g_hash_table_size (srv->workers) > 0);
+}
+
static void
rspamd_srv_handler (EV_P_ ev_io *w, int revents)
worker->hb.last_event = ev_time ();
rdata->rep.reply.heartbeat.status = 0;
break;
+ case RSPAMD_SRV_HEALTH:
+ rspamd_fill_health_reply (srv, &rdata->rep);
+ break;
default:
msg_err ("unknown command type: %d", cmd.type);
break;