diff --git a/internal/tasks/inventorySnapshots.go b/internal/tasks/inventorySnapshots.go index af82881..779b80d 100644 --- a/internal/tasks/inventorySnapshots.go +++ b/internal/tasks/inventorySnapshots.go @@ -132,7 +132,10 @@ func (c *CronTask) RunVcenterSnapshotHourly(ctx context.Context, logger *slog.Lo if err != nil { return err } - minIntervalSeconds := intWithDefault(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds, 3600) / 2 + minIntervalSeconds := intWithDefault(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds, 3600) / 3 + if minIntervalSeconds < 1 { + minIntervalSeconds = 1 + } if !lastSnapshot.IsZero() && startTime.Sub(lastSnapshot) < time.Duration(minIntervalSeconds)*time.Second { c.Logger.Info("Skipping hourly snapshot, last snapshot too recent", "last_snapshot", lastSnapshot, @@ -1524,8 +1527,8 @@ func (c *CronTask) compareWithPreviousSnapshot( if tableUpdated { prevTableTouched = true } - expectedSeconds := int64(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds) / 2 - // Skip only if snapshots are closer together than half the configured cadence + expectedSeconds := int64(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds) / 3 + // Skip only if snapshots are closer together than one-third of the configured cadence if SnapshotTooSoon(prevSnapshotTime, startTime.Unix(), expectedSeconds) { c.Logger.Info("skipping new-VM detection because snapshots are too close together", "prev_table", prevTableName, "prev_snapshot_unix", prevSnapshotTime, "current_snapshot_unix", startTime.Unix(), "expected_interval_seconds", expectedSeconds) } else {