2021-10-15 10:05:00 -05:00
|
|
|
package monitoring
|
|
|
|
|
|
|
|
import (
|
2021-12-13 14:23:31 -05:00
|
|
|
"fmt"
|
2021-10-15 10:05:00 -05:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MetricServer interface {
|
|
|
|
SendMetric(interface{})
|
|
|
|
// works like SendMetric, but adds the metric regardless of the value of 'enabled' field for MetricServer
|
|
|
|
ForceSendMetric(interface{})
|
|
|
|
ReceiveMetrics() interface{}
|
|
|
|
IsEnabled() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func getDirSize(path string) (int64, error) {
|
|
|
|
var size int64
|
|
|
|
|
|
|
|
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if !info.IsDir() {
|
|
|
|
size += info.Size()
|
|
|
|
}
|
2021-12-13 14:23:31 -05:00
|
|
|
|
2021-10-15 10:05:00 -05:00
|
|
|
return err
|
|
|
|
})
|
|
|
|
|
2021-12-13 14:23:31 -05:00
|
|
|
return size, fmt.Errorf("getDirSize: %w", err)
|
2021-10-15 10:05:00 -05:00
|
|
|
}
|