(ch chan<- prometheus.Metric)
| 136 | } |
| 137 | |
| 138 | func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) error { |
| 139 | zpoolPaths, err := filepath.Glob(procFilePath(filepath.Join(c.linuxProcpathBase, c.linuxZpoolIoPath))) |
| 140 | if err != nil { |
| 141 | return err |
| 142 | } |
| 143 | |
| 144 | for _, zpoolPath := range zpoolPaths { |
| 145 | file, err := os.Open(zpoolPath) |
| 146 | if err != nil { |
| 147 | // this file should exist, but there is a race where an exporting pool can remove the files -- ok to ignore |
| 148 | c.logger.Debug("Cannot open file for reading", "path", zpoolPath) |
| 149 | return errZFSNotAvailable |
| 150 | } |
| 151 | |
| 152 | err = c.parsePoolProcfsFile(file, zpoolPath, func(poolName string, s zfsSysctl, v uint64) { |
| 153 | ch <- c.constPoolMetric(poolName, s, v) |
| 154 | }) |
| 155 | file.Close() |
| 156 | if err != nil { |
| 157 | return err |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | zpoolObjsetPaths, err := filepath.Glob(procFilePath(filepath.Join(c.linuxProcpathBase, c.linuxZpoolObjsetPath))) |
| 162 | if err != nil { |
| 163 | return err |
| 164 | } |
| 165 | |
| 166 | for _, zpoolPath := range zpoolObjsetPaths { |
| 167 | file, err := os.Open(zpoolPath) |
| 168 | if err != nil { |
| 169 | // This file should exist, but there is a race where an exporting pool can remove the files. Ok to ignore. |
| 170 | c.logger.Debug("Cannot open file for reading", "path", zpoolPath) |
| 171 | return errZFSNotAvailable |
| 172 | } |
| 173 | |
| 174 | err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { |
| 175 | ch <- c.constPoolObjsetMetric(poolName, datasetName, s, v) |
| 176 | }) |
| 177 | file.Close() |
| 178 | if err != nil { |
| 179 | return err |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | zpoolStatePaths, err := filepath.Glob(procFilePath(filepath.Join(c.linuxProcpathBase, c.linuxZpoolStatePath))) |
| 184 | if err != nil { |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | if zpoolStatePaths == nil { |
| 189 | c.logger.Debug("No pool state files found") |
| 190 | return nil |
| 191 | } |
| 192 | |
| 193 | for _, zpoolPath := range zpoolStatePaths { |
| 194 | file, err := os.Open(zpoolPath) |
| 195 | if err != nil { |
no test coverage detected