Ignore wifi collector permission errors
Ignore the permission denined error when the wifi collector has no
permission to read metrics.
@@ -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)
}
