func responderPolicy(emit emitFn, r *nitro.ResponseStat) { for _, p := range r.ResponderPolicy { post := " name=" + tsdb.Clean(*p.Name) emit("responderpolicy.HitsRate"+post, *p.HitsRate) emit("responderpolicy.UndefHitsRate"+post, *p.UndefHitsRate) } }
func lbvserver(emit emitFn, r *nitro.ResponseStat) { lbvservers.Snapshot(r.LBVServer...) active := lbvservers.RecentlyActive() for _, vs := range r.LBVServer { if !active[vs.Name] { continue } name := strings.Replace(vs.Name, ".", "-", -1) pre := "vserver." post := " vserver=" + tsdb.Clean(name) stateUp := 1 if vs.State != "UP" { stateUp = 0 } emit(pre+"CurClntConnections"+post, *vs.CurClntConnections) emit(pre+"CurSrvrConnections"+post, *vs.CurSrvrConnections) emit(pre+"Health"+post, *vs.Health) emit(pre+"RequestBytesRate"+post, *vs.RequestBytesRate) emit(pre+"ResponseBytesRate"+post, *vs.ResponseBytesRate) emit(pre+"SpilloverThreshold"+post, *vs.SpilloverThreshold) emit(pre+"Spillovers"+post, *vs.Spillovers) emit(pre+"StateUp"+post, stateUp) if vs.Type == "HTTP" { emit(pre+"RequestsRate"+post, *vs.RequestsRate) emit(pre+"ResponsesRate"+post, *vs.ResponsesRate) } } }
func encode() { enc := tsdb.NewEncoder(os.Stdout) for p := range tsdbChan { p.XAppendTags("host", tsdb.Clean(config.Host())) if err := enc.Encode(p); err != nil { log.Fatal(err) } } }
// TODO: packets_rate func nic(emit emitFn, r *nitro.ResponseStat) { for _, x := range r.Interface { post := " interface=" + tsdb.Clean(x.ID) emit("nic.bytes direction=In"+post, *x.TotRxBytes) emit("nic.bytes direction=Out"+post, *x.TotTxBytes) emit("nic.errors direction=In type=Discard"+post, *x.ErrIfInDiscards) emit("nic.errors direction=In type=Other"+post, *x.ErrPktRx) emit("nic.errors direction=Out type=Discard"+post, *x.NicErrIfOutDiscards) emit("nic.errors direction=Out type=Other"+post, *x.ErrPktTx) emit("nic.packets direction=In"+post, *x.TotRxPkts) emit("nic.packets direction=Out"+post, *x.TotTxPkts) // XXX: can't remember why these got commented out. Uncomment and // see what blows up. // emit("nic.errors direction=In type=Drop"+post, *x.ErrDroppedRxPkts) // emit("nic.errors direction=Out type=Drop"+post, *x.ErrDroppedTxPkts) // emit("nic.errors direction=Unknown type=Hang"+post, *x.ErrLinkHangs) // emit("nic.errors direction=Out type=Stall"+post, *x.NicTxStalls) // emit("nic.errors direction=In type=Stall"+post, *x.NicRxStalls) // emit("nic.errors direction=NotApplicable type=Disable"+post, *x.NicErrDisables) // emit("nic.errors direction=NotApplicable type=DuplexMismatch"+post, *x.ErrDuplexMismatch) // emit("nic.errors direction=NotApplicable type=Mute"+post, *x.ErrNicMuted) } }
func service(emit emitFn, r *nitro.ResponseStat) { for vserver, services := range byVServer(r.Service) { var total struct { ActiveConn uint64 ActiveTransactions uint64 CurClntConnections uint64 CurReusePool uint64 CurSrvrConnections uint64 RequestBytesRate float64 RequestsRate float64 ResponseBytesRate float64 ResponsesRate float64 StateUp int SurgeCount uint64 SvrEstablishedConn uint64 SvrNotEstablishedConn uint64 } vserver = strings.Replace(vserver, ".", "-", -1) for _, svc := range services { pre := "service." + tsdb.Clean(vserver) + "." post := " service=" + tsdb.Clean(svc.Name) stateUp := 1 if svc.State != "UP" { stateUp = 0 } svrNotEstablishedConn := *svc.CurSrvrConnections - *svc.SvrEstablishedConn emit(pre+"CurClntConnections"+post, *svc.CurClntConnections) emit(pre+"CurSrvrConnections"+post, *svc.CurSrvrConnections) emit(pre+"MaxClients"+post, *svc.MaxClients) emit(pre+"RequestBytesRate"+post, *svc.RequestBytesRate) emit(pre+"ResponseBytesRate"+post, *svc.ResponseBytesRate) emit(pre+"StateUp"+post, stateUp) emit(pre+"SurgeCount"+post, *svc.SurgeCount) emit(pre+"SvrEstablishedConn"+post, *svc.SvrEstablishedConn) emit(pre+"SvrNotEstablishedConn"+post, svrNotEstablishedConn) // NB: MaxClients deliberately omitted; it's confusing when aggregated. total.CurClntConnections += *svc.CurClntConnections total.CurSrvrConnections += *svc.CurSrvrConnections total.RequestBytesRate += *svc.RequestBytesRate total.ResponseBytesRate += *svc.ResponseBytesRate total.StateUp += stateUp total.SurgeCount += *svc.SurgeCount total.SvrEstablishedConn += *svc.SvrEstablishedConn total.SvrNotEstablishedConn += svrNotEstablishedConn if svc.ServiceType == "HTTP" { activeConn := *svc.SvrEstablishedConn - *svc.CurReusePool emit(pre+"ActiveConn"+post, activeConn) emit(pre+"ActiveTransactions"+post, *svc.ActiveTransactions) emit(pre+"AvgSvrTTFB"+post, *svc.AvgSvrTTFB) emit(pre+"CurReusePool"+post, *svc.CurReusePool) emit(pre+"RequestsRate"+post, *svc.RequestsRate) emit(pre+"ResponsesRate"+post, *svc.ResponsesRate) total.ActiveConn += activeConn total.ActiveTransactions += *svc.ActiveTransactions total.CurReusePool += *svc.CurReusePool total.RequestsRate += *svc.RequestsRate total.ResponsesRate += *svc.ResponsesRate } } post := " vserver=" + tsdb.Clean(vserver) emit("total.service.CurClntConnections"+post, total.CurClntConnections) emit("total.service.CurSrvrConnections"+post, total.CurSrvrConnections) emit("total.service.RequestBytesRate"+post, total.RequestBytesRate) emit("total.service.ResponseBytesRate"+post, total.ResponseBytesRate) emit("total.service.StateUp"+post, total.StateUp) emit("total.service.SurgeCount"+post, total.SurgeCount) emit("total.service.SvrEstablishedConn"+post, total.SvrEstablishedConn) emit("total.service.SvrNotEstablishedConn"+post, total.SvrNotEstablishedConn) if len(services) > 0 && services[0].ServiceType == "HTTP" { emit("total.service.ActiveConn"+post, total.ActiveConn) emit("total.service.ActiveTransactions"+post, total.ActiveTransactions) emit("total.service.CurReusePool"+post, total.CurReusePool) emit("total.service.RequestsRate"+post, total.RequestsRate) emit("total.service.ResponsesRate"+post, total.ResponsesRate) } } }
func filterPolicy(emit emitFn, r *nitro.ResponseConfig) { for _, p := range r.FilterPolicy { post := " name=" + tsdb.Clean(p.Name) emit("filterpolicy.Hits"+post, *p.Hits) } }