This post is more than 5 years old
4 Posts
0
158868
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
Brian91_4544b4
71 Posts
1
August 27th, 2013 07:00
Hi Alex
Yes, I'll try
Rule definition:
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:
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
vBundle.vm.snapshot.age.warning.days
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
Brian91_4544b4
71 Posts
0
August 26th, 2013 13:00
Hi Alex
It can be found in the vBundle-1 cartridge:
Brian
alexander ortiz
4 Posts
0
August 26th, 2013 13:00
HI Brian,
Thanks for you answer, I'm working with FVE 6.7, where I find this rule, what cartridge I need?
Regards,
-Alex
Brian91_4544b4
71 Posts
0
August 26th, 2013 13:00
Hi Alexander
We use a copy of the vBundle VM Snapshot Age rule and that seems to work for us.
Brian
alexander ortiz
4 Posts
0
August 26th, 2013 19:00
Hi Brian,
I don't have this cartridge and is no longer available, can you share the rule definition?
Thanks,
-Alex
alexander ortiz
4 Posts
0
August 27th, 2013 15:00
Thanks a lot Brian, you are great.
Regards,
-Alex
Brian91_4544b4
71 Posts
0
August 28th, 2013 07:00
Aw, shucks, thanks!