Compare commits
No commits in common. "7ae07d544790485996674a983996147078090570" and "b4b5d5cc95e07b1bba3060297d10d83f69a38ca6" have entirely different histories.
7ae07d5447
...
b4b5d5cc95
@ -1 +1 @@
|
|||||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjNg0CLtUgQedbmKEJkUfefwiRQQLxsjPUN603bpSKSYkXbAJarUH33iUrIiRLf3IbJ/Nhc0yfo3hUfvrx6W7aQO2w/aaf3dugnCXXXE1FpFgIN9QJqRkMs7P/WuMI7RBYlkvPitbf85krzYuE4sJ/gt+wqGykWO6Yop4xF08BrVoxbWTe6I94ekkYcAAY77IqO2814l/ob4QY7l63DTHAvf5MN/yiUnLu7uYr71eeci4tAFl1IB37XrOyM0BndUbY6WKy7ymbSazJ8/TXX3TYk761TEMzvO79IB2OU0fD1frA17li4iF5vq14Bome2HCxZ44BWH2hDCq09U8cqYrr zfs_replcation_exporter
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjNg0CLtUgQedbmKEJkUfefwiRQQLxsjPUN603bpSKSYkXbAJarUH33iUrIiRLf3IbJ/Nhc0yfo3hUfvrx6W7aQO2w/aaf3dugnCXXXE1FpFgIN9QJqRkMs7P/WuMI7RBYlkvPitbf85krzYuE4sJ/gt+wqGykWO6Yop4xF08BrVoxbWTe6I94ekkYcAAY77IqO2814l/ob4QY7l63DTHAvf5MN/yiUnLu7uYr71eeci4tAFl1IB37XrOyM0BndUbY6WKy7ymbSazJ8/TXX3TYk761TEMzvO79IB2OU0fD1frA17li4iF5vq14Bome2HCxZ44BWH2hDCq09U8cqYrr wathiede@big
|
||||||
|
|||||||
@ -32,21 +32,9 @@ var (
|
|||||||
const snapshotListCmd = "/sbin/zfs list -t snapshot -H -o name -s name"
|
const snapshotListCmd = "/sbin/zfs list -t snapshot -H -o name -s name"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// FreeNAS example:
|
// Example: @auto-20171001.1400-2w
|
||||||
// @auto-20171001.1400-2w
|
snapshotPattern = regexp.MustCompile(`^[^@]+@auto-(\d{8}\.\d{4})-\d+[mwy]$`)
|
||||||
freenasSnapshotPattern = regexp.MustCompile(`^[^@]+@auto-(\d{8}\.\d{4})-\d+[mwy]$`)
|
snapshotFormat = "20060102.1504"
|
||||||
// Linux examples:
|
|
||||||
// @zfs-auto-snap_frequent-2023-01-15-18h00U
|
|
||||||
// @zfs-auto-snap_frequent-2023-01-15-18h15U
|
|
||||||
// @zfs-auto-snap_frequent-2023-01-15-18h30U
|
|
||||||
// @zfs-auto-snap_frequent-2023-01-15-18h45U
|
|
||||||
// @zfs-auto-snap_daily-2023-01-14-08h00U
|
|
||||||
// @zfs-auto-snap_hourly-2023-01-14-19h00U
|
|
||||||
// @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)$`)
|
|
||||||
freenasSnapshotFormat = "20060102.1504"
|
|
||||||
linuxSnapshotFormat = "2006-01-02-15h04U"
|
|
||||||
|
|
||||||
fetchRequestDurationMetric = prometheus.NewGauge(prometheus.GaugeOpts{
|
fetchRequestDurationMetric = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "ssh_fetch_duration_seconds",
|
Name: "ssh_fetch_duration_seconds",
|
||||||
@ -142,6 +130,8 @@ func fetchSnapshotStats(host string, c *ssh.Client) (snapshotStats, error) {
|
|||||||
stats := snapshotStats(make(map[filesystemName]*filesystemStat))
|
stats := snapshotStats(make(map[filesystemName]*filesystemStat))
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
l := scanner.Text()
|
l := scanner.Text()
|
||||||
|
m := snapshotPattern.FindStringSubmatch(l)
|
||||||
|
|
||||||
filesystem := l
|
filesystem := l
|
||||||
if idx := strings.Index(l, "@"); idx != -1 {
|
if idx := strings.Index(l, "@"); idx != -1 {
|
||||||
filesystem = l[:idx]
|
filesystem = l[:idx]
|
||||||
@ -151,13 +141,10 @@ func fetchSnapshotStats(host string, c *ssh.Client) (snapshotStats, error) {
|
|||||||
stats[name] = &filesystemStat{}
|
stats[name] = &filesystemStat{}
|
||||||
}
|
}
|
||||||
stats[name].Counts++
|
stats[name].Counts++
|
||||||
|
if len(m) == 2 {
|
||||||
var foundSnapshot bool
|
t, err := time.Parse(snapshotFormat, m[1])
|
||||||
if m := freenasSnapshotPattern.FindStringSubmatch(l); len(m) == 2 {
|
|
||||||
foundSnapshot = true
|
|
||||||
t, err := time.Parse(freenasSnapshotFormat, m[1])
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("[%s] Malformed time in freenas snapshot %q: %v", host, m[1], err)
|
glog.Errorf("[%s] Malformed time in snapshot %q: %v", host, m[1], err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("filesystem: %s timestamp %v", l, t)
|
glog.V(3).Infof("filesystem: %s timestamp %v", l, t)
|
||||||
@ -167,23 +154,7 @@ func fetchSnapshotStats(host string, c *ssh.Client) (snapshotStats, error) {
|
|||||||
if snapshotTime.Before(t) {
|
if snapshotTime.Before(t) {
|
||||||
stats[name].Timestamp = t
|
stats[name].Timestamp = t
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if m := linuxSnapshotPattern.FindStringSubmatch(l); len(m) == 2 {
|
|
||||||
foundSnapshot = true
|
|
||||||
t, err := time.Parse(linuxSnapshotFormat, m[1])
|
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("[%s] Malformed time in linux snapshot %q: %v", host, m[1], err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
glog.V(3).Infof("filesystem: %s timestamp %v", l, t)
|
|
||||||
stats[name].FreenasCounts++
|
|
||||||
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)
|
glog.V(3).Infof("[%s] Skipping snapshot with non-conforming timestamp %q", host, l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user