Foglight

Create a rule / alarm for older snapshot

Hello,

I'm trying to create a rule / alarm, that firing for the snapshots when have older than X days.

I use the Topology: VMWareSnapshot.

Using an adaptation of the function for create the older snapshot report, I tried to create the rule.

creationSnapshot=scope.creationTime.getTime();

now = new Date().getTime();

diffHours = (now - creationSnapshot)/3600000;

diffDays  = diffHours /24;

(diffDays>=registry("VMW:Old.Snapshot.Warning"));

When I test the condition in the script console, and in the rule condition, it works fine, but when the rule never firing.

Am I forgetting something?

Thank for any help or any ideas

Regards,

Alexander Ortiz

Strategic Solutions Consultant

Dell | Software Group, MCLA APM

office +57 312 568 4791, mobile +57 312 568 4791
email alexander.ortiz@software.dell.com

Parents
No Data
Reply
  • Hi Alex

    Yes, I'll try

    Rule definition:

    Capture.JPG

    Only the Warning condition is enabled:

    Condition

    // Rule: vBundle-1 VM Snap Shot Age

    // First - Check VM Ignore List

    // Second - Check VM has Active Snap

    // Third - Check Snapshot Age

    // Read Ignore list from Registry

    def IgnoreList = registry("vBundle.vm.snapshot.age.ignore.list");

    // Get VM Name

    def VMName1 = scope.get("name");

    def boolean Found = false;

    if (IgnoreList != null) {

      Found = IgnoreList.contains(VMName1);}

    if (Found) return false;

    // Check if VM has an active snapshot

    if(scope.currentSnapshot == null){

      return false}

    // Evaluate Snapshot Age

    def NumOfDays = registry("vBundle.vm.snapshot.age.warning.days");

    try { 

      creationTime= scope.currentSnapshot.get("creationTime").getTime();

      if (creationTime==null) return false;

      now = new Date().getTime();

      diffHours = (now - creationTime)/3600000;

      diffDays  = diffHours /24;

      if (diffDays >= NumOfDays)

       return true;

      else return false}

    catch (Exception e) {return false;}

    Alarm Message:

    [Warning] Virtual Machine: "@VMName" Has a snapshot named: "@SnapshotName" that is older than @WarningDays days. Remove old snapshots.

    There are no Severity Level Variables defined.

    The Action is an EmailAction:

    mail.message

    VM (@VMName) has a snapshot that is @WarningDays Days Old

    View the alarm at: @foglight_rule_alarm_link

    mail.subject

    [Warning] VM (@VMName) has an old Snapshot

    Behavior:

    Capture.JPG

    Rule Variables:

    Expression   CriticalDays  return registry ("vBundle.vm.snapshot.age.critical.days");

    Expression   FatalDays     return registry ("vBundle.vm.snapshot.age.fatal.days");

    Expression   SnapshotName  scope.currentSnapshot.name;

    Expression   VMName        return scope.get("name");

    Expression   WarningDays   return registry ("vBundle.vm.snapshot.age.warning.days");

    Registry Settings:

    vBundle.vm.snapshot.age.ignore.list

    Capture.JPG

    vBundle.vm.snapshot.age.warning.days

    Capture.JPG

    The OOTB warning days are 7 (warning), 14 (critical) and 30 (fatal).

    I hope that's all clear for you

    If you want the Critical and Fatal conditions, let me know.

    Brian

Children
No Data