Skip to content

Commit

Permalink
Merge pull request #19 from axoflow/orphan-counter
Browse files Browse the repository at this point in the history
ignore orphaned counters
  • Loading branch information
furiel authored Apr 25, 2024
2 parents c28c53a + 237dd1d commit 83879ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pkg/syslog-ng-ctl/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,17 @@ func parseStats(rsp string) (stats []Stat, errs error) {
errs = errors.Join(errs, err)
continue
}
stats = append(stats, Stat{
SourceName: fields[0],
SourceID: fields[1],
SourceInstance: fields[2],
SourceState: SourceState(fields[3][0]),
Type: fields[4],
Number: num,
})

if fields[3] != string(SourceStateOrphaned) {
stats = append(stats, Stat{
SourceName: fields[0],
SourceID: fields[1],
SourceInstance: fields[2],
SourceState: SourceState(fields[3][0]),
Type: fields[4],
Number: num,
})
}
}
return
}
12 changes: 12 additions & 0 deletions pkg/syslog-ng-ctl/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ src.internal;s_src#1;;a;processed;59
src.internal;s_src#1;;a;stamp;1673105444
destination;d_newserr;;a;processed;0
global;scratch_buffers_bytes;;a;queued;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;eps_last_1h;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;eps_last_24h;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;dropped;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;processed;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;queued;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;memory_usage;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;written;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;truncated_bytes;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;eps_since_start;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;msg_size_max;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;truncated_count;0
dst.network;#anon-destination0#0;tcp,localhost:1234;o;msg_size_avg;0
.
`
expected := []Stat{
Expand Down

0 comments on commit 83879ef

Please sign in to comment.