Show some stats at the end
This commit is contained in:
parent
fa2780a40d
commit
903f7d128a
13
ponymap.c
13
ponymap.c
|
@ -334,6 +334,9 @@ struct app_context
|
||||||
struct generator generator; ///< Unit generator
|
struct generator generator; ///< Unit generator
|
||||||
struct indicator indicator; ///< Status indicator
|
struct indicator indicator; ///< Status indicator
|
||||||
|
|
||||||
|
size_t stats_hosts; ///< How many hosts we've scanned
|
||||||
|
size_t stats_results; ///< How many services we've found
|
||||||
|
|
||||||
// We need this list ordered from the oldest running target,
|
// We need this list ordered from the oldest running target,
|
||||||
// therefore we track the tail to allow O(1) appends.
|
// therefore we track the tail to allow O(1) appends.
|
||||||
|
|
||||||
|
@ -537,8 +540,10 @@ unit_abort (struct unit *u)
|
||||||
|
|
||||||
if (u->success)
|
if (u->success)
|
||||||
{
|
{
|
||||||
// Now we're a part of the target
|
|
||||||
struct target *target = u->target;
|
struct target *target = u->target;
|
||||||
|
target->ctx->stats_results++;
|
||||||
|
|
||||||
|
// Now we're a part of the target
|
||||||
LIST_PREPEND (target->results, u);
|
LIST_PREPEND (target->results, u);
|
||||||
u->target = NULL;
|
u->target = NULL;
|
||||||
target_unref (target);
|
target_unref (target);
|
||||||
|
@ -1494,6 +1499,8 @@ generator_make_target (struct app_context *ctx)
|
||||||
|
|
||||||
LIST_APPEND_WITH_TAIL (ctx->running_targets, ctx->running_tail, target);
|
LIST_APPEND_WITH_TAIL (ctx->running_targets, ctx->running_tail, target);
|
||||||
target_update_indicator (ctx->running_targets);
|
target_update_indicator (ctx->running_targets);
|
||||||
|
|
||||||
|
ctx->stats_hosts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2017,6 +2024,10 @@ main (int argc, char *argv[])
|
||||||
while (ctx.polling)
|
while (ctx.polling)
|
||||||
poller_run (&ctx.poller);
|
poller_run (&ctx.poller);
|
||||||
|
|
||||||
|
printf ("Scanned %zu %s, identified %zu %s\n",
|
||||||
|
ctx.stats_hosts, ctx.stats_hosts == 1 ? "host" : "hosts",
|
||||||
|
ctx.stats_results, ctx.stats_results == 1 ? "service" : "services");
|
||||||
|
|
||||||
if (ctx.json_results && json_dump_file (ctx.json_results,
|
if (ctx.json_results && json_dump_file (ctx.json_results,
|
||||||
ctx.json_filename, JSON_INDENT (2) | JSON_SORT_KEYS | JSON_ENCODE_ANY))
|
ctx.json_filename, JSON_INDENT (2) | JSON_SORT_KEYS | JSON_ENCODE_ANY))
|
||||||
print_error ("failed to write JSON output");
|
print_error ("failed to write JSON output");
|
||||||
|
|
Loading…
Reference in New Issue