On Mon, Oct 17, 2022 at 12:39:44PM +0200, Denis Fondras wrote:
> Le Mon, Oct 17, 2022 at 11:49:31AM +0200, Claudio Jeker a écrit :
> > On Wed, Oct 12, 2022 at 12:12:25PM +0200, Theo Buehler wrote:
> > > On Fri, Oct 07, 2022 at 12:37:10PM +0200, Claudio Jeker wrote:
> > 
> > > > +void
> > > > +ometric_set_state(struct ometric *om, const char *state, struct 
> > > > olabels *ol)
> > > > +{
> > > > +       struct olabels *extra;
> > > > +       size_t i;
> > > > +       int val;
> > > > +
> > > > +       if (om->type != OMT_STATESET)
> > > > +               errx(1, "%s incorrect ometric type", __func__);
> > > > +
> > > > +       for (i = 0; i < om->setsize; i++) {     
> > > > +               if (strcasecmp(state, om->stateset[i]) == 0)
> > > > +                       val = 1;
> > > > +               else
> > > > +                       val = 0;
> > > 
> > > could simplify this to
> > > 
> > >           val = strcasecmp(state, om->stateset[i]) == 0;
> > > 
> > > but I'm not sure if this is more readable
> > 
> > Not sure either. I prefer the explicit version. So I left the code as is.
> >  
> 
> I agree, let the code be easy to read. The compiler will optimise accordingly.
> 
> BTW, thank you for working on this Claudio.

No problems. I would like if someone could check the various metrics
exported. Maybe I missed something or implemented some metrics
incorrectly.

I know that the peer state set is a bit of a problem. So I added
bgpd_peer_state_raw to make it easier for grafana.
Also I'm not sure if bgpd_peer_up_seconds and bgpd_peer_down_seconds are
sensible metrics. Having metric depend on some state seems like a bad idea. 

So any feedback is welcome. I will commit this version now so it easier
for people to test.
-- 
:wq Claudio

Reply via email to