yes, this makes sense

On Mon, Feb 7, 2011 at 11:47 PM, Stuart Henderson <s...@spacehopper.org> wrote:
> Currently only "check tcp" displays times in the logs,
> "check icmp" and "check script" always display 0ms because the
> start time was not recorded (currently in struct ctl_tcp_event)
> so the duration can't be calculated.
>
> host 10.15.4.2, check tcp (2ms), state unknown -> down, availability 0.00%
>
> host 10.15.4.2, check icmp (0ms), state unknown -> up, availability 100.00%
>
> Diff below moves the bcopy(&tv...) so it applies to other check
> types and works (i.e. prints reasonable times rather than 0ms) for
> me. Any comments/oks?
>
> Index: hce.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/relayd/hce.c,v
> retrieving revision 1.56
> diff -u -p -1 -9 -r1.56 hce.c
> --- hce.c       30 Nov 2010 14:38:45 -0000      1.56
> +++ hce.c       7 Feb 2011 22:45:54 -0000
> @@ -242,52 +242,52 @@ hce_launch_checks(int fd, short event, v
>
>        if (gettimeofday(&tv, NULL) == -1)
>                fatal("hce_launch_checks: gettimeofday");
>
>        TAILQ_FOREACH(table, env->sc_tables, entry) {
>                if (table->conf.flags & F_DISABLE)
>                        continue;
>                if (table->conf.skip_cnt) {
>                        if (table->skipped++ > table->conf.skip_cnt)
>                                table->skipped = 0;
>                        if (table->skipped != 1)
>                                continue;
>                }
>                if (table->conf.check == CHECK_NOCHECK)
>                        fatalx("hce_launch_checks: unknown check type");
>
>                TAILQ_FOREACH(host, &table->hosts, entry) {
>                        if (host->flags & F_DISABLE || host->conf.parentid)
>                                continue;
> +                       bcopy(&tv, &host->cte.tv_start,
> +                           sizeof(host->cte.tv_start));
>                        switch (table->conf.check) {
>                        case CHECK_ICMP:
>                                schedule_icmp(env, host);
>                                break;
>                        case CHECK_SCRIPT:
>                                check_script(host);
>                                break;
>                        default:
>                                /* Any other TCP-style checks */
>                                host->last_up = host->up;
>                                host->cte.host = host;
>                                host->cte.table = table;
> -                               bcopy(&tv, &host->cte.tv_start,
> -                                   sizeof(host->cte.tv_start));
>                                check_tcp(&host->cte);
>                                break;
>                        }
>                }
>        }
>        check_icmp(env, &tv);
>
>        bcopy(&env->sc_interval, &tv, sizeof(tv));
>        evtimer_add(&env->sc_ev, &tv);
>  }
>
>  void
>  hce_notify_done(struct host *host, enum host_error he)
>  {
>        struct table            *table;
>        struct ctl_status        st;
>        struct timeval           tv_now, tv_dur;
>        u_long                   duration;
>        u_int                    logopt;

Reply via email to