Create a rule / alarm for older snapshot

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Brian91
2 Iron

RE: Create a rule / alarm for older snapshot

Jump to solution

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

7 Replies
Brian91
2 Iron

RE: Create a rule / alarm for older snapshot

Jump to solution

Hi Alexander

We use a copy of the vBundle VM Snapshot Age rule and that seems to work for us.

Brian

0 Kudos

RE: Create a rule / alarm for older snapshot

Jump to solution

HI Brian,

Thanks for you answer, I'm working with FVE 6.7, where I find this rule, what cartridge I need?

Regards,

-Alex

0 Kudos
Brian91
2 Iron

RE: Create a rule / alarm for older snapshot

Jump to solution

Hi Alex

It can be found in the vBundle-1 cartridge:

Capture.JPG

Brian

0 Kudos

RE: Create a rule / alarm for older snapshot

Jump to solution

Hi Brian,

I don't have this cartridge and is no longer available, can you share the rule definition?

Thanks,

-Alex

0 Kudos
Highlighted
Brian91
2 Iron

RE: Create a rule / alarm for older snapshot

Jump to solution

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

RE: Create a rule / alarm for older snapshot

Jump to solution

Thanks a lot Brian, you are great.

Regards,

-Alex

0 Kudos
Brian91
2 Iron

RE: Create a rule / alarm for older snapshot

Jump to solution

Aw, shucks, thanks!

0 Kudos