Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Rule Based Event ManagementWorkshop 2013-03-12 / Version: 1.0.1         markus.schneider73@gmail.com                      ...
Agenda➢OpenNMS Activation of Drools   Complex Correlation Example   Auto Event Example   Drools with Groovy Example   ...
OpenNMS Activation of Drools   Drools is part of the correlation engine   Correlation engine is not activated by default...
RunbookReady, Steady, Go...https://gist.github.com/m-schneiderOUCE 2013                             4
RunbookExecution Order1. SETUP YOUR ENV2. UPDATE OUCE2013 REPOSITORY3. OPEN THE WEB BROWSER4. NODE DISCOVERY5. ACTIVATE DR...
$> showtime03/12/13   OUCE 2013   6
Agenda   OpenNMS Activation of Drools➢Complex Correlation Example   Auto Event Example   Drools with Groovy Example   ...
Basic Rule Creation Workflow                                                       Edit                              Defin...
Workshop Configuration(1) Clone Git repository   $> git clone http://www.github.com/                    m­schneider/ouce20...
Workshop Configuration(3) Add the following line to the end of eventconf.xml    $> echo        <event­file>events/Xzample....
File Dependencies$OPENNMS_HOME/etc                   reference   Xzample.event   eventconf.xml                            ...
RunbookExecution Order7. COMPLEX CORRELATION EXAMPLE       CONFIGURATIONOUCE 2013                        12
$> showtime03/12/13   OUCE 2013   13
Complex Correlation Example                                        Symptom Event                                        Ca...
Send EventGrep for Drools log file entries$> tail ­f  $OPENNMS_HOME/logs/daemon/output.log    | grep ­­­>$> ./send­event.p...
Event Sequence            Problem Event            Webserver1 DownOUCE 2013                     16
Alarm ViewOUCE 2013    17
Send Event$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver2"    ­p "subSource webserver2"    ­p "source sendevent.pl...
Event Sequence            Problem Event     Problem Event            Webserver1 Down   Webserver2 DownOUCE 2013           ...
Alarm ViewOUCE 2013    20
Event Sequence                                      Symptom Event                                      CarDirectDown      ...
Alarm ViewOUCE 2013    22
Send Event$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver1"    ­p "subSource webserver1"    ­p "source sendevent.pl...
Event Sequence                                       Symptom Event                                       CarDirectDown    ...
Alarm ViewOUCE 2013    25
Send Event$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver2"   ­p "subSource webserver2"    ­p "source sendevent.pl"...
Complex Correlation Example                                        Symptom Event                                        Ca...
Alarm ViewOUCE 2013    28
RunbookExecution Order7. COMPLEX CORRELATION EXAMPLE       SEND EVENTSOUCE 2013                        29
$> showtime03/12/13   OUCE 2013   30
Agenda   OpenNMS Activation of Drools   Complex Correlation Example➢Auto Event Example   Drools with Groovy Example   ...
Auto Event Example                               Created by            Symptom Event      Drools timer            …/autoTa...
Auto Event ExamplePractical Use Case ScenarioPractical Use Case Scenario                                                  ...
Send Event$> ./send­event.pl ­n $NODEID ­s autoTask     ­d "droolsTimer"    ­p "subSource drools"     ­p "source send­even...
Log FileOUCE 2013   35
Send Event$> ./send­event.pl ­n $NODEID ­s autoTask     ­d "droolsTimer"    ­p "subSource drools"     ­p "source send­even...
Alarm ViewOUCE 2013    37
RunbookExecution Order8. AUTO EVENT EXAMPLEOUCE 2013               38
$> showtime03/12/13   OUCE 2013   39
Agenda   OpenNMS Activation of Drools   Complex Correlation Example   Auto Event Example➢Drools with Groovy Example   ...
Knowledge Session CreationThree main fundamental concepts:       Knowledge Builder       Knowledge Base       Knowledge...
Knowledge Session Creation  OverviewStep 1         KnowledgeBuilder         KnowledgeBuilder                              ...
Knowledge Builder   Building KnowledgePackage from knowledge definitions   Knowledge Builder Factory creates Knowledge B...
Knowledge Builder         KnowledgeBuilder kbuilder =                 KnowledgeBuilderFactory.newKnowledgeBuilder()       ...
Knowledge Base   Main purpose is to store and reuse knowledge definitions   Creation of Knowledge Base is expensive   P...
Knowledge Base    KnowledgeBase kbase =               KnowledgeBaseFactory.newKnowledgeBase()    kbase.addKnowledgePackage...
Knowledge SessionStateless Session   Doesnt maintain the context between one    interaction and the next one   Doesnt ke...
Knowledge Session    StatefulKnowledgeSession ksession =                          kbase.newStatefulKnowledgeSession()    E...
Drools with Groovy(1) Go to the cloned Git repository   $> cd ~/ouce2013/groovy/non­gradle   $> ./change­rules.shOUCE 2013...
Drools with Groovy(2) Program Files   $> cd ~/ouce2013/groovy/non­gradle/change­      rules/src/org/xzample/droolsOUCE 201...
RunbookExecution Order9. DROOLS WITH GROOVYOUCE 2013               51
$> showtime03/12/13   OUCE 2013   52
Agenda   OpenNMS Activation of Drools   Complex Correlation Example   Auto Event Example   Drools with Groovy Example➢...
More InfoWorkshop Slides   http://de.slideshare.net/mschneider73/OUCE2013-RBEM-WSGitHub   https://gist.github.com/m-schn...
More InfoGroovy   http://groovy.codehaus.org/   http://groovy.codehaus.org/Getting+Started+GuideOUCE 2013               ...
Comments & Questions    Thank you for your attentionContact details:markus.schneider73@gmail.comwww.rapideca.org03/12/13  ...
Upcoming SlideShare
Loading in …5
×

Ouce2013-RBEM-WS

1,369 views

Published on

  • Be the first to comment

Ouce2013-RBEM-WS

  1. 1. Rule Based Event ManagementWorkshop 2013-03-12 / Version: 1.0.1 markus.schneider73@gmail.com created with
  2. 2. Agenda➢OpenNMS Activation of Drools Complex Correlation Example Auto Event Example Drools with Groovy Example More InformationOUCE 2013 2
  3. 3. OpenNMS Activation of Drools Drools is part of the correlation engine Correlation engine is not activated by default Drools needs to be configured OpenNMS comes with:  example Configurations  example Rules OpenNMS uses Drools version: 5.1.1OUCE 2013 3
  4. 4. RunbookReady, Steady, Go...https://gist.github.com/m-schneiderOUCE 2013 4
  5. 5. RunbookExecution Order1. SETUP YOUR ENV2. UPDATE OUCE2013 REPOSITORY3. OPEN THE WEB BROWSER4. NODE DISCOVERY5. ACTIVATE DROOLS6. SIMPLE DROOLS RULE TESTOUCE 2013 5
  6. 6. $> showtime03/12/13 OUCE 2013 6
  7. 7. Agenda OpenNMS Activation of Drools➢Complex Correlation Example Auto Event Example Drools with Groovy Example More InformationOUCE 2013 7
  8. 8. Basic Rule Creation Workflow Edit Define custom Create custom eventconf.xml events in the event config for including the event config custom event cfg Edit Define custom Create custom drools-engine.xml rules in the rule file for referencing the rule file Custom *.drl file Restart opennmsOUCE 2013 8
  9. 9. Workshop Configuration(1) Clone Git repository $> git clone http://www.github.com/  m­schneider/ouce2013(2) Copy all example configurations and rules $> cd ./ouce2013/config/opennms/etc  $> sudo cp drools­engine.xml       XzampleRules01.drl   XzampleRules02.drl   $OPENNMS_HOME/etc $> sudo cp events/Xzample.events.xml        $OPENNMS_HOME/etc/events      OUCE 2013 9
  10. 10. Workshop Configuration(3) Add the following line to the end of eventconf.xml $> echo     <event­file>events/Xzample.events.xml      </event­file> >>       OPENNMS_HOME/etc/eventconf.xml(4) Restart OpenNMS  $> sudo service opennms restart       OUCE 2013 10
  11. 11. File Dependencies$OPENNMS_HOME/etc reference Xzample.event eventconf.xml .xml All Xzample Events reference drools-engine XzampleRules01 Complex Correlation .xml .drl Example XzampleRules02 Auto Event .drl ExampleOUCE 2013 11
  12. 12. RunbookExecution Order7. COMPLEX CORRELATION EXAMPLE  CONFIGURATIONOUCE 2013 12
  13. 13. $> showtime03/12/13 OUCE 2013 13
  14. 14. Complex Correlation Example Symptom Event CarDirectDown Problem Event Problem Event Webserver1 Down Webserver2 Down Resolution Event CarDirectUp Resolution Event Resolution Event Webserver1 Up Webserver2 Up CarDirect Events are created by DroolsOUCE 2013 14
  15. 15. Send EventGrep for Drools log file entries$> tail ­f  $OPENNMS_HOME/logs/daemon/output.log    | grep ­­­>$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver1"    ­p "subSource webserver1"    ­p "source sendevent.pl"      uei.opennms.org/webserver/down ­x 4OUCE 2013 15
  16. 16. Event Sequence Problem Event Webserver1 DownOUCE 2013 16
  17. 17. Alarm ViewOUCE 2013 17
  18. 18. Send Event$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver2"    ­p "subSource webserver2"    ­p "source sendevent.pl"     uei.opennms.org/webserver/down ­x 4OUCE 2013 18
  19. 19. Event Sequence Problem Event Problem Event Webserver1 Down Webserver2 DownOUCE 2013 19
  20. 20. Alarm ViewOUCE 2013 20
  21. 21. Event Sequence Symptom Event CarDirectDown Problem Event Problem Event Webserver1 Down Webserver2 DownOUCE 2013 21
  22. 22. Alarm ViewOUCE 2013 22
  23. 23. Send Event$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver1"    ­p "subSource webserver1"    ­p "source sendevent.pl"   uei.opennms.org/webserver/up ­x 3OUCE 2013 23
  24. 24. Event Sequence Symptom Event CarDirectDown Problem Event Problem Event Webserver1 Down Webserver2 Down Resolution Event CarDirectUp Resolution Event Webserver1 UpOUCE 2013 24
  25. 25. Alarm ViewOUCE 2013 25
  26. 26. Send Event$> ./send­event.pl ­n $NODEID ­s Http    ­d "webserver2"   ­p "subSource webserver2"    ­p "source sendevent.pl"     uei.opennms.org/webserver/up ­x 3OUCE 2013 26
  27. 27. Complex Correlation Example Symptom Event CarDirectDown Problem Event Problem Event Webserver1 Down Webserver2 Down Resolution Event CarDirectUp Resolution Event Resolution Event Webserver1 Up Webserver2 UpOUCE 2013 27
  28. 28. Alarm ViewOUCE 2013 28
  29. 29. RunbookExecution Order7. COMPLEX CORRELATION EXAMPLE  SEND EVENTSOUCE 2013 29
  30. 30. $> showtime03/12/13 OUCE 2013 30
  31. 31. Agenda OpenNMS Activation of Drools Complex Correlation Example➢Auto Event Example Drools with Groovy Example More InfoOUCE 2013 31
  32. 32. Auto Event Example Created by Symptom Event Drools timer …/autoTask/run RuleSymptom Event Symptom Event.../droolsTimer/start .../droolsTimer/stopOUCE 2013 32
  33. 33. Auto Event ExamplePractical Use Case ScenarioPractical Use Case Scenario ScriptD triggers the custom script every 5 seconds Custom Script Cloud Drools ScriptD check- Service status. Event groovy if (status == true) Drools creates Eventan event every 5 uei.opennms.org/droolsTimer/stop seconds OUCE 2013 33
  34. 34. Send Event$> ./send­event.pl ­n $NODEID ­s autoTask     ­d "droolsTimer"    ­p "subSource drools"     ­p "source send­event.pl"     uei.opennms.org/droolsTimer/start ­x 4OUCE 2013 34
  35. 35. Log FileOUCE 2013 35
  36. 36. Send Event$> ./send­event.pl ­n $NODEID ­s autoTask     ­d "droolsTimer"    ­p "subSource drools"     ­p "source send­event.pl"     uei.opennms.org/droolsTimer/stop ­x 4OUCE 2013 36
  37. 37. Alarm ViewOUCE 2013 37
  38. 38. RunbookExecution Order8. AUTO EVENT EXAMPLEOUCE 2013 38
  39. 39. $> showtime03/12/13 OUCE 2013 39
  40. 40. Agenda OpenNMS Activation of Drools Complex Correlation Example Auto Event Example➢Drools with Groovy Example More InformationOUCE 2013 40
  41. 41. Knowledge Session CreationThree main fundamental concepts:  Knowledge Builder  Knowledge Base  Knowledge SessionOUCE 2013 41
  42. 42. Knowledge Session Creation OverviewStep 1 KnowledgeBuilder KnowledgeBuilder *.drl Factory KnowledgeBuilder KnowledgeBuilder *.drl FactoryStep 2 KnowledgeBase KnowledgeBase Knowledge Knowledge KnowledgeBase KnowledgeBase Factory Factory Packages Packages Stateless StatefulStep 3 Stateless Stateful Knowldege Knowldege Knowldege Knowldege Session Session Session Session OUCE 2013 42
  43. 43. Knowledge Builder Building KnowledgePackage from knowledge definitions Knowledge Builder Factory creates Knowledge Builder Knowleged definitions are:  Rules, Processes and Types Can add multiple resources of different types:  DRL, DRF, PKG etc... Errors reported by hasErrors & getError methodOUCE 2013 43
  44. 44. Knowledge Builder KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder() kbuilder.add( ResourceFactory.newClassPathResource("rules.drl"), ResourceType.DRL); if ( kbuilder.hasErrors() ) { println( kbuilder.getErrors().toString() ) throw new RuntimeException( "Unable to                                  compile "rules.drl"." ) } KnowledgeBuilderStep 1 KnowledgeBuilder KnowledgeBuilder *.drl *.drl Factory KnowledgeBuilder Factory OUCE 2013 44
  45. 45. Knowledge Base Main purpose is to store and reuse knowledge definitions Creation of Knowledge Base is expensive Provides methods for creating knowledge sessions Maintains a reference to all of the created knowledge sessions Knowledge Base can be reused instead of creating a new one every timeOUCE 2013 45
  46. 46. Knowledge Base KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase() kbase.addKnowledgePackages( kbuilder.getKnowledgePackages())Step 2 KnowledgeBase KnowledgeBase Knowledge Knowledge KnowledgeBase KnowledgeBase Factory Factory Packages Packages OUCE 2013 46
  47. 47. Knowledge SessionStateless Session Doesnt maintain the context between one interaction and the next one Doesnt keep information from previous callsStateful Session Keeps the information from several calls and interactions Previous calls can be used to add and enrich the information we already haveOUCE 2013 47
  48. 48. Knowledge Session StatefulKnowledgeSession ksession =    kbase.newStatefulKnowledgeSession() Event event = new Event(uei:"uei.opennms.org/                      webserver/down",                     severity:6,                     priority:2,                     message:"webserver1 not available") ksession.insert( event ) ksession.fireAllRules()Step 3 Stateless Stateless Stateful Stateful Knowldege Knowldege Knowldege Knowldege Session Session Session Session OUCE 2013 48
  49. 49. Drools with Groovy(1) Go to the cloned Git repository $> cd ~/ouce2013/groovy/non­gradle $> ./change­rules.shOUCE 2013 49
  50. 50. Drools with Groovy(2) Program Files $> cd ~/ouce2013/groovy/non­gradle/change­    rules/src/org/xzample/droolsOUCE 2013 50
  51. 51. RunbookExecution Order9. DROOLS WITH GROOVYOUCE 2013 51
  52. 52. $> showtime03/12/13 OUCE 2013 52
  53. 53. Agenda OpenNMS Activation of Drools Complex Correlation Example Auto Event Example Drools with Groovy Example➢More InformationOUCE 2013 53
  54. 54. More InfoWorkshop Slides http://de.slideshare.net/mschneider73/OUCE2013-RBEM-WSGitHub https://gist.github.com/m-schneider/5143591#file-ouce2013-rbem-ws-runbookOpenNMS http://www.opennms.org/documentation/java-apidocs-stable/ http://www.opennms.org/documentation/java-apidocs- stable/org/opennms/netmgt/xml/event/Event.html http://www.opennms.org/documentation/java-apidocs- stable/org/opennms/netmgt/model/events/EventBuilder.html http://opennms.git.sourceforge.net/git/gitweb.cgi? p=opennms/opennms;a=tree;f=opennms-correlation/drools-correlation- engine/src/main/java/org/opennms/netmgt/correlation/drools;h=aaffefdf28ac3f e585cbab4db41b45f118ab85d9;hb=HEADOUCE 2013 54
  55. 55. More InfoGroovy http://groovy.codehaus.org/ http://groovy.codehaus.org/Getting+Started+GuideOUCE 2013 55
  56. 56. Comments & Questions Thank you for your attentionContact details:markus.schneider73@gmail.comwww.rapideca.org03/12/13 OUCE 2013 56

×