2016-10-22 20:42:05 -04:00
|
|
|
/** Statistic collection.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2017-04-27 13:08:17 +02:00
|
|
|
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
|
|
|
* @license GNU General Public License (version 3)
|
|
|
|
*
|
|
|
|
* VILLASnode
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 13:08:17 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 13:08:17 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************************/
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2018-06-29 08:37:37 +02:00
|
|
|
#pragma once
|
2016-10-22 20:42:05 -04:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2017-08-03 00:19:27 +02:00
|
|
|
#include <jansson.h>
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2018-06-29 09:06:04 +02:00
|
|
|
#include <villas/hist.h>
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2018-06-28 13:42:50 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-10-22 20:42:05 -04:00
|
|
|
/* Forward declarations */
|
|
|
|
struct sample;
|
|
|
|
struct node;
|
|
|
|
|
2017-03-20 09:15:54 -03:00
|
|
|
enum stats_format {
|
|
|
|
STATS_FORMAT_HUMAN,
|
|
|
|
STATS_FORMAT_JSON,
|
|
|
|
STATS_FORMAT_MATLAB
|
|
|
|
};
|
|
|
|
|
2016-11-07 22:18:26 -05:00
|
|
|
enum stats_id {
|
2018-06-29 08:37:14 +02:00
|
|
|
STATS_SKIPPED, /**< Counter for skipped samples due to hooks. */
|
|
|
|
STATS_TIME, /**< The processing time per sample within VILLAsnode. */
|
|
|
|
STATS_REORDERED, /**< Counter for reordered samples. */
|
|
|
|
STATS_GAP_SAMPLE, /**< Histogram for inter sample timestamps (as sent by remote). */
|
|
|
|
STATS_GAP_RECEIVED, /**< Histogram for inter sample arrival time (as seen by this instance). */
|
|
|
|
STATS_OWD, /**< Histogram for one-way-delay (OWD) of received samples. */
|
|
|
|
STATS_COUNT /**< Just here to have an updated number of statistics. */
|
2016-11-07 22:18:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct stats_delta {
|
2016-11-08 00:27:28 -05:00
|
|
|
double values[STATS_COUNT];
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2018-06-29 08:37:14 +02:00
|
|
|
int update; /**< Bitmask of stats_id. Only those which are masked will be updated */
|
2016-11-07 22:18:26 -05:00
|
|
|
};
|
|
|
|
|
2016-10-22 20:42:05 -04:00
|
|
|
struct stats {
|
2017-05-05 19:24:16 +00:00
|
|
|
struct hist histograms[STATS_COUNT];
|
2016-11-07 22:18:26 -05:00
|
|
|
|
2016-11-20 13:01:17 -05:00
|
|
|
struct stats_delta *delta;
|
2016-10-22 20:42:05 -04:00
|
|
|
};
|
|
|
|
|
2017-07-28 18:11:52 +02:00
|
|
|
int stats_lookup_format(const char *str);
|
|
|
|
|
2017-05-05 22:26:34 +00:00
|
|
|
int stats_init(struct stats *s, int buckets, int warmup);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2017-07-09 14:37:02 +02:00
|
|
|
int stats_destroy(struct stats *s);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2017-09-03 10:53:32 +02:00
|
|
|
void stats_update(struct stats *s, enum stats_id id, double val);
|
2016-11-07 22:18:26 -05:00
|
|
|
|
2018-07-07 17:07:45 +02:00
|
|
|
void stats_collect(struct stats *s, struct sample *smps[], size_t *cnt);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2017-09-03 10:53:32 +02:00
|
|
|
int stats_commit(struct stats *s);
|
2016-11-07 22:18:26 -05:00
|
|
|
|
2018-06-29 08:37:14 +02:00
|
|
|
json_t * stats_json(struct stats *s);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
|
|
|
void stats_reset(struct stats *s);
|
|
|
|
|
2018-07-03 20:43:05 +02:00
|
|
|
void stats_print_header(enum stats_format fmt);
|
|
|
|
void stats_print_footer(enum stats_format fmt);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2017-09-03 10:53:32 +02:00
|
|
|
void stats_print_periodic(struct stats *s, FILE *f, enum stats_format fmt, int verbose, struct node *p);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2017-03-20 09:15:54 -03:00
|
|
|
void stats_print(struct stats *s, FILE *f, enum stats_format fmt, int verbose);
|
2016-10-22 20:42:05 -04:00
|
|
|
|
2017-03-29 04:20:26 +02:00
|
|
|
enum stats_id stats_lookup_id(const char *name);
|
|
|
|
|
2018-06-28 13:42:50 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|