Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle non integer values for zone serial #97

Merged
merged 3 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type Counter struct {
// Counter represents a single zone counter value.
type ZoneCounter struct {
Name string
Serial uint64
Serial string
}

// Gauge represents a single gauge value.
Expand Down
2 changes: 1 addition & 1 deletion bind/v2/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type View struct {
type Zone struct {
Name string `xml:"name"`
Rdataclass string `xml:"rdataclass"`
Serial uint64 `xml:"serial"`
Serial string `xml:"serial"`
}

type Counter struct {
Expand Down
2 changes: 1 addition & 1 deletion bind/v3/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type Counter struct {
type ZoneCounter struct {
Name string `xml:"name,attr"`
Rdataclass string `xml:"rdataclass,attr"`
Serial uint64 `xml:"serial"`
Serial string `xml:"serial"`
}

// Client implements bind.Client and can be used to query a BIND v3 API.
Expand Down
8 changes: 5 additions & 3 deletions bind_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ func (c *viewCollector) Collect(ch chan<- prometheus.Metric) {

for _, v := range c.stats.ZoneViews {
for _, z := range v.ZoneData {
ch <- prometheus.MustNewConstMetric(
zoneSerial, prometheus.CounterValue, float64(z.Serial), v.Name, z.Name,
)
if suint, err := strconv.ParseUint(z.Serial, 10, 64); err == nil {
ch <- prometheus.MustNewConstMetric(
zoneSerial, prometheus.CounterValue, float64(suint), v.Name, z.Name,
)
}
}
}
}
Expand Down