Add support for zfs-autosnapshot format
This commit is contained in:
parent
6899f331d6
commit
b410d1f1ec
@ -45,8 +45,12 @@ var (
|
||||
// @zfs-auto-snap_weekly-2022-12-19-08h00U
|
||||
// @zfs-auto-snap_monthly-2022-12-01-08h00U
|
||||
linuxSnapshotPattern = regexp.MustCompile(`^[^@]+@zfs-auto-snap_(?:frequent|daily|hourly|weekly|monthly)-(\d{4}-\d{2}-\d{2}-\d{2}h\d{2}U)$`)
|
||||
// @mom-20230812163001
|
||||
autosnapshotPattern = regexp.MustCompile(`^[^@]+@[^-]+-(\d{14})$`)
|
||||
|
||||
freenasSnapshotFormat = "20060102.1504"
|
||||
linuxSnapshotFormat = "2006-01-02-15h04U"
|
||||
autosnapshotFormat = "20060102150405"
|
||||
|
||||
fetchRequestDurationMetric = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "ssh_fetch_duration_seconds",
|
||||
@ -186,6 +190,21 @@ func fetchSnapshotStats(host string, c *ssh.Client) (snapshotStats, error) {
|
||||
stats[name].Timestamp = t
|
||||
}
|
||||
}
|
||||
if m := autosnapshotPattern.FindStringSubmatch(l); len(m) == 2 {
|
||||
foundSnapshot = true
|
||||
t, err := time.Parse(autosnapshotFormat, m[1])
|
||||
if err != nil {
|
||||
glog.Errorf("[%s] Malformed time in autosnapshot %q: %v", host, m[1], err)
|
||||
continue
|
||||
}
|
||||
glog.V(3).Infof("filesystem: %s timestamp %v", l, t)
|
||||
stats[name].LinuxCounts++
|
||||
snapshotTime := stats[name].Timestamp
|
||||
glog.V(3).Infof("snapshotTime.Before(t) = %v snapshotTime: %v t: %v", snapshotTime.Before(t), snapshotTime, t)
|
||||
if snapshotTime.Before(t) {
|
||||
stats[name].Timestamp = t
|
||||
}
|
||||
}
|
||||
if !foundSnapshot {
|
||||
glog.V(3).Infof("[%s] Skipping snapshot with non-conforming timestamp %q", host, l)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user