2 * m_estimator.c Parse/print estimator module options.
4 * This program is free software; you can u32istribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
26 static void est_help(void);
28 static void est_help(void)
30 fprintf(stderr, "Usage: ... estimator INTERVAL TIME-CONST\n");
31 fprintf(stderr, " INTERVAL is interval between measurements\n");
32 fprintf(stderr, " TIME-CONST is averaging time constant\n");
33 fprintf(stderr, "Example: ... est 1sec 8sec\n");
37 int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est)
40 char **argv = *p_argv;
41 unsigned A, time_const;
45 duparg("estimator", *argv);
46 if (matches(*argv, "help") == 0)
48 if (get_time(&A, *argv))
49 invarg("estimator", "invalid estimator interval");
51 if (matches(*argv, "help") == 0)
53 if (get_time(&time_const, *argv))
54 invarg("estimator", "invalid estimator time constant");
55 if (tc_setup_estimator(A, time_const, est) < 0) {
56 fprintf(stderr, "Error: estimator parameters are out of range.\n");
60 fprintf(stderr, "[estimator i=%u e=%u]\n", est->interval, est->ewma_log);