Automation

 View Only
last person joined: 10 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  matching on a nonstandard event for an event script

    Posted 11-11-2010 17:43

    Ladies and Gents,

     

    I am trying to match on the event listed below to activate an event script.  However because it is considered a "nonstatndard" event, I am having trouble getting a match.  Any ideas?

     

    Nov 11 20:18:51  home-firewall rpd[1020]: EVENT Add fe-0/0/2.0 index 72 10.0.1.2/24 -> 10.0.1.255 <Up Broadcast Multicast Localup>

     

    Thanks!

    Clay



  • 2.  RE: matching on a nonstandard event for an event script

    Posted 11-11-2010 22:40

    Clay,

    Not sure if this will help but I had to do essentially the same thing and Curtis helped me out a bunch!  Anyway, my non-standard event was SSH login using the following syslog event:

     

    Oct 25 19:31:37  CER-M7i sshd[7733]: Failed password for emergencylogin from 192.100.50.220 port 4735 ssh2

     

    In this case, I needed the username (emergencylogin) and Curtis showed me how to do that (but that's in the script).  This is what fires my script and is, I think, what you're asking about:

     

     

    /* embed event policy - only configuration required on the router
       is to include set event-options event-script file login-failure.slax.
       Changing anything in the event-definition requires the operational-mode command
       request system scripts event-scripts reload or commit full */
    
    var $event-definition = {
        <event-options> {
            <policy> {
                <name> "login-failure";
                <events> "system";
      <events> "login_failed"; <attributes-match> { <from-event-attribute> "system.message";
     <condition> "matches"; <to-event-attribute-value> " password for "; } <then> { <event-script> { <name> "login-failure.slax"; } } } } }

     In this case, the non-standard events logged by sshd appear as "system" generated events.  I then had to find some unique string that I could use to discriminate against; I used " password for ".  Now I know there are LOGIN_INFORMATION and UI_LOGIN events but LOGIN_INFORMATION only covers console logins and UI_LOGIN events include whenever a user runs a script, executes a commit, etc. and I could not have those events messing with my script.  Anyway, using that string worked and now every time there is a system event that contains " password for " in the message, login-failure.slax is fired.

     

    I am not an expert but I would assume that once you determine how rpd logs events (system, kernel, etc.) you need to identify some unique string that only matches the event(s) you want and then perform whatever logic is required in the script.

     

    Richard

     



  • 3.  RE: matching on a nonstandard event for an event script
    Best Answer

     
    Posted 11-12-2010 00:24

    Hi,

     

    As Richard pointed out you need to use the psuedo event to match the nonstandard event. The non standard events from RPD are also grouped under system. So, we need to write a policy for system with match to a unique string.

     

    Example something like this.

     

        policy rpd-mulitcast-up {
            events system;
            attributes-match {
                system.message matches "Up Broadcast Multicast Localup";
            }
            then {
                event-script abc;
            }
        }

    Change the match string in the attributes-match which uniquely identify your  event.

     

    Thanks,

    Sriram



  • 4.  RE: matching on a nonstandard event for an event script

    Posted 11-12-2010 06:10

    Is there a doc that show what logs to which type of event?  Meaning, how did you know that rpd logs under system?

     

    I appreciate the help from you both.  It is working now.

     

    Thanks for your time,

    Clay



  • 5.  RE: matching on a nonstandard event for an event script

     
    Posted 11-12-2010 07:26

    Hi,

     

    It is explained in the "Day One: Applying Junos Event Automation" book. Here is the relevant section.

     

    Event ID                                Description


    -------------------------------------------------------

    SYSTEM                                 Messages from Junos daemons and utilities.
    KERNEL                                Messages from Junos kernel.
    PIC                                          Messages from physical interface cards.
    PFE                                         Messages from the packet forwarding engine.
    LCC                                        Messages from TX Matrix line-card chassis.
    SCC                                        Messages from TX Matrix switch-card chassis.

     

    Thanks,

    Sriram



  • 6.  RE: matching on a nonstandard event for an event script

    Posted 11-12-2010 08:04

    Not that this is your problem, but again with the inconsistences...

     

    Day One says one thing, and the techpubs say another.  They might mean the same thing, but if someone does not know UNIX very well (like me), it leaves a question in their mind.  In this case, with my problem, I wanted to see something that said rpd IS a SYSTEM event.

     

    Again, thanks for your help, my script works like a champ now.

    Clay

     

     

     

    http://www.juniper.net/techpubs/en_US/junos10.2/information-products/topic-collections/config-guide-automation/topic-40433.html

    Table 18: Event ID by System Log Message Origin

    Event IDs

    Origin

    SYSTEM

    Messages from UNIX domain sockets

    KERNEL

    Messages from the kernel

    PIC

    Messages from PICs

    PFE

    Messages from the Packet Forwarding Engine

    LCC

    On a TX Matrix router, messages from as line-card chassis (LCC)

    SCC

    On a TX Matrix router, messages from a switch-card chassis (SCC)



  • 7.  RE: matching on a nonstandard event for an event script

    Posted 11-12-2010 09:19

    Thanks Clay.  I've created a documentation bug report to track and resolve this.

     

    Consistency is key 🙂