e1d: stat_items for the GPS-DO related bits
It is interesting from a monitoring point of view to be able to correlate the GPSDO state with other performance counters we export. While each GPS-DO only exists once per icE1usb, we still export the state per line, to make it easy for external monitoring to have one set of counters per line. Change-Id: I1f98610b7c725146a3f016a8737440be5baae858
This commit is contained in:
parent
f7716183a5
commit
f23274d184
12
src/e1d.h
12
src/e1d.h
|
@ -28,6 +28,7 @@
|
|||
#include <osmocom/core/isdnhdlc.h>
|
||||
#include <osmocom/core/linuxlist.h>
|
||||
#include <osmocom/core/rate_ctr.h>
|
||||
#include <osmocom/core/stat_item.h>
|
||||
#include <osmocom/core/timer.h>
|
||||
#include <osmocom/vty/command.h>
|
||||
|
||||
|
@ -45,6 +46,8 @@ enum e1d_vty_node {
|
|||
};
|
||||
|
||||
#define line_ctr_add(line, idx, add) rate_ctr_add(rate_ctr_group_get_ctr((line)->ctrs, idx), add)
|
||||
#define line_stat_set(line, idx, add) \
|
||||
osmo_stat_item_set(osmo_stat_item_group_get_item((line)->stats, idx), add)
|
||||
|
||||
enum e1d_line_ctr {
|
||||
LINE_CTR_LOS,
|
||||
|
@ -58,6 +61,14 @@ enum e1d_line_ctr {
|
|||
LINE_CTR_FRAMES_DEMUXED_E1O,
|
||||
};
|
||||
|
||||
enum e1d_line_stat_item {
|
||||
LINE_GPSDO_STATE,
|
||||
LINE_GPSDO_ANTENNA,
|
||||
LINE_GPSDO_TUNE_COARSE,
|
||||
LINE_GPSDO_TUNE_FINE,
|
||||
LINE_GPSDO_FREQ_EST,
|
||||
};
|
||||
|
||||
enum e1_ts_mode {
|
||||
E1_TS_MODE_OFF = 0,
|
||||
E1_TS_MODE_RAW,
|
||||
|
@ -118,6 +129,7 @@ struct e1_line {
|
|||
|
||||
void *drv_data;
|
||||
struct rate_ctr_group *ctrs;
|
||||
struct osmo_stat_item_group *stats;
|
||||
|
||||
/* timeslots for channelized mode */
|
||||
struct e1_ts ts[32];
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <osmocom/core/utils.h>
|
||||
#include <osmocom/core/stats.h>
|
||||
#include <osmocom/core/rate_ctr.h>
|
||||
#include <osmocom/core/stat_item.h>
|
||||
#include <osmocom/core/timer.h>
|
||||
#include <osmocom/e1d/proto.h>
|
||||
|
||||
|
@ -68,6 +69,23 @@ static const struct rate_ctr_group_desc line_ctrg_desc = {
|
|||
.ctr_desc = line_ctr_description,
|
||||
};
|
||||
|
||||
static const struct osmo_stat_item_desc line_stat_description[] = {
|
||||
[LINE_GPSDO_STATE] = { "gpsdo:state", "GPSDO State" },
|
||||
[LINE_GPSDO_ANTENNA] = { "gpsdo:antenna", "GSPDO Antenna State" },
|
||||
[LINE_GPSDO_TUNE_COARSE]= { "gpsdo:tune:coarse", "GSPDO Coarse Tuning" },
|
||||
[LINE_GPSDO_TUNE_FINE] = { "gpsdo:tune:fine", "GSPDO Fine Tuning" },
|
||||
[LINE_GPSDO_FREQ_EST] = { "gpsdo:freq_est", "GSPDO Frequency Estimate" },
|
||||
};
|
||||
|
||||
static const struct osmo_stat_item_group_desc line_stats_desc = {
|
||||
.group_name_prefix = "e1d_line",
|
||||
.group_description = "Stat items for E1 line",
|
||||
.class_id = OSMO_STATS_CLASS_GLOBAL,
|
||||
.num_items = ARRAY_SIZE(line_stat_description),
|
||||
.item_desc = line_stat_description,
|
||||
};
|
||||
|
||||
|
||||
/* watchdog timer, called once per second to check if we still receive data on the line */
|
||||
static void line_watchdog_cb(void *data)
|
||||
{
|
||||
|
@ -253,8 +271,13 @@ e1_line_new(struct e1_intf *intf, int line_id, void *drv_data)
|
|||
|
||||
line->ctrs = rate_ctr_group_alloc(line, &line_ctrg_desc, intf->id << 8 | line->id);
|
||||
OSMO_ASSERT(line->ctrs);
|
||||
|
||||
line->stats = osmo_stat_item_group_alloc(line, &line_stats_desc, intf->id << 8 | line->id);
|
||||
OSMO_ASSERT(line->stats);
|
||||
|
||||
snprintf(name, sizeof(name), "I%u:L%u", intf->id, line->id);
|
||||
rate_ctr_group_set_name(line->ctrs, name);
|
||||
osmo_stat_item_group_set_name(line->stats, name);
|
||||
|
||||
llist_add_tail(&line->list, &intf->lines);
|
||||
|
||||
|
|
10
src/usb.c
10
src/usb.c
|
@ -707,6 +707,7 @@ _e1_usb_intf_gpsdo_status_cb(struct e1_intf *intf, const uint8_t *data, size_t l
|
|||
struct e1_usb_intf_data *id = intf->drv_data;
|
||||
struct e1usb_gpsdo_status *last_st = &id->gpsdo.last_status;
|
||||
const struct e1usb_gpsdo_status *st;
|
||||
struct e1_line *line;
|
||||
|
||||
if (len < sizeof(*st)) {
|
||||
LOGPIF(intf, DE1D, LOGL_ERROR, "GPSDO status %zu < %zu!\n", len, sizeof(*st));
|
||||
|
@ -742,6 +743,15 @@ _e1_usb_intf_gpsdo_status_cb(struct e1_intf *intf, const uint8_t *data, size_t l
|
|||
LOGPIF(intf, DE1D, LOGL_ERROR, "GPS Fix LOST\n");
|
||||
}
|
||||
|
||||
/* update stat_items for statsd / monitoring */
|
||||
llist_for_each_entry(line, &intf->lines, list) {
|
||||
line_stat_set(line, LINE_GPSDO_STATE, st->state);
|
||||
line_stat_set(line, LINE_GPSDO_ANTENNA, st->antenna_state);
|
||||
line_stat_set(line, LINE_GPSDO_TUNE_COARSE, libusb_le16_to_cpu(st->tune.coarse));
|
||||
line_stat_set(line, LINE_GPSDO_TUNE_FINE, libusb_le16_to_cpu(st->tune.fine));
|
||||
line_stat_set(line, LINE_GPSDO_FREQ_EST, osmo_load32le(&st->freq_est));
|
||||
}
|
||||
|
||||
/* update our state */
|
||||
memcpy(last_st, st, sizeof(*last_st));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue