I've been looking at something like this for addition to my community cartridge for datastores. The basic way to do this is roll through the events and see which one's are related to a datastore and then fire when I find appropriate text and rule scope. I've not added the rule text yet, but the basic rule script looks like this, where the scope would be VMWDatastore:
ds = server.get("DataService") // Data Service
vCenters = #!VMWVirtualCenter#.getTopologyObjects() // Get all vCenters
for(vCenter in vCenters) // Loop through each vCenter's current events
I created a Simple Rule with the condition you provided. But when we disable an HBA on our ESX to simulate a Lost path. We received the "Lost path" events in Vcenter but the vfoglight rule doesnt pick it up.
Rule details:
-Simple Rule
-Data Driven
-Rule Scope: VMWDatastore
-Under "Fire" , pasted your condition under "Condition"
-Severity Level and action are empty
-Everything else is default.
-Rule is enabled
I see the events in VCenter Events and under each ESX and Datastore, but the rule doesnt seem to pick it up.
I see the events, and since they are coming from the Main vCenter events tab. Can we pull the events from each datastore event tab instead?
I think our issue is since our infrastructure is quite big the main vcenter events get clear fairly quick as tons of events are happening per seconds/minutes.
We pull the events information from the api for the recent history, so it should have all of them in there even if they clear from the vCenter UI. We don't pull historical events, that can bit a bit nasty of an API pull from VMware's perspective. If you can get the HBA to turn off again and run this again it should give us the text we need to get this event to fire properly.
That would be helpful, this will return a list of all of the current events and then the properties for each. From that it should be possible to figure out what is going on.
ds = server.get("DataService") // Data Service
def result = [] as List
vCenters = #!VMWVirtualCenter#.getTopologyObjects() // Get all vCenters
for(vCenter in vCenters) // Loop through each vCenter's current events
from the condition, it still doesnt catch the event, even if I see tons of events in VCenter under events or in Datatstore under specific datastores under events...
Is there a way to insert some kind of debug within the condition to see the events message?
Are you on vFog 6.6.1 or prior? There is a bug in the alarm service that could be causing this to not fire. Try running this groovy script from the script console and see if it returns true. Also we will want to make sure the event condition still has the datastore name equals part, otherwise this will return true for every datastore!
The only thing to still be careful on is this rule will fire on every datastore because the condition is true across the board. You need to add a filter for the datastore bit to match the name of the scope, otherwise it will show for every one.
DELL-Thomas B
171 Posts
1103
0
Posted July 21st, 2012 22:00
I've been looking at something like this for addition to my community cartridge for datastores. The basic way to do this is roll through the events and see which one's are related to a datastore and then fire when I find appropriate text and rule scope. I've not added the rule text yet, but the basic rule script looks like this, where the scope would be VMWDatastore:
ds = server.get("DataService") // Data Service
vCenters = #!VMWVirtualCenter#.getTopologyObjects() // Get all vCenters
for(vCenter in vCenters) // Loop through each vCenter's current events
{
events = ds.retrieveLatestValue(vCenter, "events").value
for(event in events) // Loop through each event
{
if (event.message.contains("Lost path redundancy to storage device") && (event.eventType == 'DatastoreEvent') && (event.datastore.name == scope.name))
{
return true // If text matches and it is a datastore event and the datastore matches the scope, return true
}
}
}
return false