Skip to content

Commit

Permalink
Log and continue if err occurs when getting stats
Browse files Browse the repository at this point in the history
  • Loading branch information
arunvelsriram committed Aug 13, 2020
1 parent 9a129db commit 3c91e22
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/collector/sftp_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ func (s SFTPCollector) Collect(ch chan<- prometheus.Metric) {
fsStats, err := sftpClient.FSStats()
if err != nil {
log.WithFields(log.Fields{"event": "getting FS stats"}).Error(err)
return
}
for _, stat := range fsStats {
ch <- prometheus.MustNewConstMetric(fsTotalSpace, prometheus.GaugeValue, stat.TotalSpace, stat.Path)
ch <- prometheus.MustNewConstMetric(fsFreeSpace, prometheus.GaugeValue, stat.FreeSpace, stat.Path)
} else {
for _, stat := range fsStats {
ch <- prometheus.MustNewConstMetric(fsTotalSpace, prometheus.GaugeValue, stat.TotalSpace, stat.Path)
ch <- prometheus.MustNewConstMetric(fsFreeSpace, prometheus.GaugeValue, stat.FreeSpace, stat.Path)
}
}

objectStats, err := sftpClient.ObjectStats()
if err != nil {
log.WithFields(log.Fields{"event": "getting object stats"}).Error(err)
return
}
for _, stat := range objectStats {
ch <- prometheus.MustNewConstMetric(objectCount, prometheus.GaugeValue, stat.ObjectCount, stat.Path)
ch <- prometheus.MustNewConstMetric(objectSize, prometheus.GaugeValue, stat.ObjectSize, stat.Path)
} else {
for _, stat := range objectStats {
ch <- prometheus.MustNewConstMetric(objectCount, prometheus.GaugeValue, stat.ObjectCount, stat.Path)
ch <- prometheus.MustNewConstMetric(objectSize, prometheus.GaugeValue, stat.ObjectSize, stat.Path)
}
}
}

Expand Down

0 comments on commit 3c91e22

Please sign in to comment.