@@ -15,12 +15,6 @@ type TrafficCollector struct {
1515 client *netgear_client.NetgearClient
1616 metrics map[string]prometheus.Gauge
1717
18- calculateDelta bool
19- previousIn float64
20- previousOut float64
21- trafficInMetric prometheus.Gauge
22- trafficOutMetric prometheus.Gauge
23-
2418 trafficScrapesTotalMetric prometheus.Counter
2519 trafficScrapeErrorsTotalMetric prometheus.Counter
2620 lastTrafficScrapeErrorMetric prometheus.Gauge
@@ -52,7 +46,7 @@ var TrafficCollectorFields = [...]string{
5246 "LastMonthUploadAverage",
5347}
5448
55- func NewTrafficCollector(namespace string, client *netgear_client.NetgearClient, calculateDelta bool ) *TrafficCollector {
49+ func NewTrafficCollector(namespace string, client *netgear_client.NetgearClient) *TrafficCollector {
5650 metrics := make(map[string]prometheus.Gauge)
5751 for _, name := range TrafficCollectorFields {
5852 metrics[name] = prometheus.NewGauge(
@@ -65,23 +59,6 @@ func NewTrafficCollector(namespace string, client *netgear_client.NetgearClient,
6559 )
6660 }
6761
68- trafficInMetric := prometheus.NewGauge(
69- prometheus.GaugeOpts{
70- Namespace: namespace,
71- Subsystem: "traffic",
72- Name: "download",
73- Help: "Value downloaded since previous check",
74- },
75- )
76- trafficOutMetric := prometheus.NewGauge(
77- prometheus.GaugeOpts{
78- Namespace: namespace,
79- Subsystem: "traffic",
80- Name: "upload",
81- Help: "Value uploaded since previous check",
82- },
83- )
84-
8562 trafficScrapesTotalMetric := prometheus.NewCounter(
8663 prometheus.CounterOpts{
8764 Namespace: namespace,
@@ -132,12 +109,6 @@ func NewTrafficCollector(namespace string, client *netgear_client.NetgearClient,
132109 client: client,
133110 metrics: metrics,
134111
135- calculateDelta: calculateDelta,
136- trafficInMetric: trafficInMetric,
137- previousIn: float64(-1),
138- trafficOutMetric: trafficOutMetric,
139- previousOut: float64(-1),
140-
141112 trafficScrapesTotalMetric: trafficScrapesTotalMetric,
142113 trafficScrapeErrorsTotalMetric: trafficScrapeErrorsTotalMetric,
143114 lastTrafficScrapeErrorMetric: lastTrafficScrapeErrorMetric,
@@ -180,47 +151,6 @@ func (c *TrafficCollector) Collect(ch chan<- prometheus.Metric) {
180151 }
181152 }
182153
183- if c.calculateDelta {
184- currentIn, _ := strconv.ParseFloat(stats["TodayDownload"], 64)
185- currentOut, _ := strconv.ParseFloat(stats["TodayUpload"], 64)
186-
187- /* On the first scrape, the previous values are -1. Since we are calcluating
188- a delta only, pretend this one was zero and update our previous value */
189- if c.previousIn < 0 {
190- c.previousIn = currentIn
191- }
192- if c.previousOut < 0 {
193- c.previousOut = currentOut
194- }
195-
196- newIn := currentIn - c.previousIn
197- newOut := currentOut - c.previousOut
198-
199- log.Infof("In - previous: %v, current: %v, new: %v", c.previousIn, currentIn, newIn)
200- log.Infof("Out - previous: %v, current: %v, new: %v", c.previousOut, currentOut, newOut)
201- log.Debugf("Raw stats returned:\n")
202- for k, v := range stats {
203- log.Debugf(" %v => %v", k, v)
204- }
205-
206- c.previousIn = currentIn
207- c.previousOut = currentOut
208-
209- /* Metric rolled to next day or this collector started. Assume 0 */
210- if newIn < 0 {
211- newIn = 0
212- }
213- if newOut < 0 {
214- newOut = 0
215- }
216-
217- c.trafficInMetric.Set(newIn)
218- c.trafficInMetric.Collect(ch)
219-
220- c.trafficOutMetric.Set(newOut)
221- c.trafficOutMetric.Collect(ch)
222- }
223-
224154 c.trafficScrapeErrorsTotalMetric.Collect(ch)
225155
226156 c.trafficScrapesTotalMetric.Inc()
@@ -241,11 +171,6 @@ func (c *TrafficCollector) Describe(ch chan<- *prometheus.Desc) {
241171 c.metrics[name].Describe(ch)
242172 }
243173
244- if c.calculateDelta {
245- c.trafficInMetric.Describe(ch)
246- c.trafficOutMetric.Describe(ch)
247- }
248-
249174 c.trafficScrapesTotalMetric.Describe(ch)
250175 c.trafficScrapeErrorsTotalMetric.Describe(ch)
251176 c.lastTrafficScrapeErrorMetric.Describe(ch)
0 commit comments