Skip to content

Commit

Permalink
Merge pull request #5 from myfreeweb/master
Browse files Browse the repository at this point in the history
Deduplicate trackers, fixes #4
  • Loading branch information
metalmatze authored Oct 11, 2018
2 parents f92c590 + da36758 commit 1652e5f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/transmission-exporter/torrent_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,17 @@ func (tc *TorrentCollector) Collect(ch chan<- prometheus.Metric) {
id, t.Name,
)

tstats := make(map[string]transmission.TrackerStat)

for _, tracker := range t.TrackerStats {
if tr, exists := tstats[tracker.Host]; exists {
tr.DownloadCount += tracker.DownloadCount
} else {
tstats[tracker.Host] = tracker
}
}

for _, tracker := range tstats {
ch <- prometheus.MustNewConstMetric(
tc.Downloads,
prometheus.GaugeValue,
Expand Down

0 comments on commit 1652e5f

Please sign in to comment.