Ignore wifi collector permission errors (#646)

Ignore the permission denined error when the wifi collector has no
permission to read metrics.
This commit is contained in:
Ben Kochie 2017-08-18 10:19:48 +02:00 committed by GitHub
parent b7cc6fbea7
commit 8839640cd1

View file

@ -144,11 +144,15 @@ func NewWifiCollector() (Collector, error) {
func (c *wifiCollector) Update(ch chan<- prometheus.Metric) error {
stat, err := newWifiStater(*collectorWifi)
if err != nil {
// Cannot access wifi metrics, report no error
// Cannot access wifi metrics, report no error.
if os.IsNotExist(err) {
log.Debug("wifi collector metrics are not available for this system")
return nil
}
if os.IsPermission(err) {
log.Debug("wifi collector got permission denied when accessing metrics")
return nil
}
return fmt.Errorf("failed to access wifi data: %v", err)
}