mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-27 14:39:53 -08:00
Use a descriptive name for the file descriptor.
This commit is contained in:
parent
6ff620e387
commit
d1fa279105
|
@ -157,7 +157,7 @@ func NewDrbdCollector() (Collector, error) {
|
||||||
|
|
||||||
func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
statsFile := procFilePath("drbd")
|
statsFile := procFilePath("drbd")
|
||||||
f, err := os.Open(statsFile)
|
file, err := os.Open(statsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
log.Debugf("Not collecting DRBD statistics, as %s does not exist: %s", statsFile)
|
log.Debugf("Not collecting DRBD statistics, as %s does not exist: %s", statsFile)
|
||||||
|
@ -165,9 +165,9 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer file.Close()
|
||||||
|
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(file)
|
||||||
scanner.Split(bufio.ScanWords)
|
scanner.Split(bufio.ScanWords)
|
||||||
device := "unknown"
|
device := "unknown"
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
|
Loading…
Reference in a new issue