Application Perf Mgmt (BAC / BSM) Support and News Forum
Showing results for 
Search instead for 
Do you mean 

Delete event with groovy script in EPI

SOLVED
Go to Solution
Frequent Advisor

Delete event with groovy script in EPI

Hi

 

I have a requirement where i'd like to delete an event from OMi after an EPI script has finished processing it.

 

I've looked through the API guides but can't seem to find any methods to allow me to do it.

 

Is this possible?

 

Thanks

Mick

1 ACCEPTED SOLUTIONS
Highlighted
HPE Expert

Re: Delete event with groovy script in EPI

Something like that should work:

 

def process(List<Event> events) {

    for (Iterator<Event> it = events.iterator(); it.hasNext();) {      

           Event event = it.next();       

          <do your event processing here for the event>     

            it.remove()     

     }   

 }  

8 REPLIES
Highlighted
HPE Expert

Re: Delete event with groovy script in EPI

Something like that should work:

 

def process(List<Event> events) {

    for (Iterator<Event> it = events.iterator(); it.hasNext();) {      

           Event event = it.next();       

          <do your event processing here for the event>     

            it.remove()     

     }   

 }  

Frequent Advisor

Re: Delete event with groovy script in EPI

Thanks, works great!

Occasional Visitor

Re: Delete event with groovy script in EPI

HI !

 

I need to remove the event after a validation, this is the script:

 

def process(List<Event> events)
{

for (Iterator<Event> it = events.iterator(); it.hasNext();)
{
Event e = it.next();
if ( event.getSubCategory() == "ATFTPService" )
{
it.remove()
}
}

}

 

but doesn´t work.

 

Any Help me

Frequent Advisor

Re: Delete event with groovy script in EPI

Hi

 

That code should work. does it work if you remove the event.getSubCategory() == "ATFTPService" clause?

Occasional Visitor

Re: Delete event with groovy script in EPI

Hi !

 

Yes, It´s works but i only want delete events with specific field, that is the reason for the clause if.

 

Regards

Occasional Visitor

Re: Delete event with groovy script in EPI

This is the complete script:

 

import java.util.List;
import com.hp.opr.api.scripting.Event;
import java.util.Iterator;

class GroovyScriptSkeleton
{
def init()
{
}

def destroy()
{
}

def process(List<Event> events)
{
for (Iterator<Event> it = events.iterator(); it.hasNext();)
{
Event e = it.next();
if ( event.getSubCategory() == "ATFTPService" )
{
it.remove()
}
}
}
}

 

And this is the error in the script.log :

 

 

2015-09-30 15:46:40,758 [RMI TCP Connection(85431)-150.100.229.242] ERROR ScriptExecutionExceptionHandler.handleScriptError(26) - Error in groovy script with id 8b0741b6-5242-0eb2-e5b8-1f75f07d84cf
groovy.lang.MissingPropertyException: No such property: event for class: GroovyScriptSkeleton
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.callGroovyObjectGetProperty(GetEffectivePogoPropertySite.java:69)
at GroovyScriptSkeleton.process(script1443645835052345594257.groovy:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:706)
at GroovyScriptSkeleton.invokeMethod(script1443645835052345594257.groovy)
at com.hp.opr.epi.ScriptExecutorImpl.executeScript(ScriptExecutorImpl.java:194)
at com.hp.opr.epi.ScriptExecutionService$ScriptExecutionTask.call(ScriptExecutionService.java:227)
at com.hp.opr.epi.ScriptExecutionService$ScriptExecutionTask.call(ScriptExecutionService.java:211)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

 

Regards

Frequent Advisor

Re: Delete event with groovy script in EPI

you declared the instance Event as "e" not event.

Occasional Visitor

Re: Delete event with groovy script in EPI

I have corrected the script and was run correctly.

 

Thnaks