event-handler
 
   
   Syntax
 
	  
		event-handler 
		 
		  event-handler-name 
		  [ 
		  action python-script 
		  file-name 
		  ] 
	 
 
	  
		event-handler 
		 
		  event-handler-name 
		  [ 
		  description 
		  description-text 
		  ] 
		 
	 
 
	  
	  
		event-handler 
		 
		  event-handler-name 
		  [ 
		  trigger 
		   
		  trigger-id 
		  raslog 
		  raslog-id 
		  [ 
		  pattern 
		  posix-ext-regex 
		  ] 
		  ] 
	 
 
	 no event-handler 
		 
		  event-handler-name 
		 
	 
 
	 Command Default
 
		No event-handler profile is enabled. 
		
 
	 
 
	 Parameters
 
		 
		   
			 -  
				  event-handler-name 
				 
			 
- Specifies the name of the event-handler
						profile. Valid values can have from 1 through 32 characters. The first
						character must be alphabetic. 
- action python-script 
				  file-name 
			 
- Specifies a Python file that runs when a trigger-condition occurs. Valid values range from 4 through 32 characters (including the 
				.py extension). The first character must be alphanumeric. 
			 
- description 
				  description-text 
			 
-  Specifies a string describing the
						event-handler profile. The string can be 1 through 128 ASCII characters in
						length. Do not use the ? character.
						If you need to use ! or \, precede
						each with \. 
- trigger 
				  trigger-id 
			 
- Defines an event-handler trigger and specifies an ID number for the trigger. Valid values are 1 through 100, and must be unique per event-handler profile. When the trigger-condition occurs, a Python script is run. 
				 
				   
					 - raslog 
						  raslog-id 
					 
- Specifies a RASlog message ID as the trigger. 
						 
						   
							 - pattern 
								  posix-ext-regex 
							 
- Specifies a POSIX extended regular expression to search for a match within the specified RASlog message ID. For examples, refer to the "trigger" topic. 
							 
 
 
Modes
 
		Global configuration mode 
		
 
		Event-handler configuration mode for an existing event handler. (There is no need to enter the 
		  exit command to return to global configuration mode.) 
		
 
	 
 
	 Usage Guidelines
 
		You can create multiple event-handler profiles. 
		
		You can optionally specify a description, a trigger, or the Python script with this command; or specify them later. 
		
 
		An 
		  
event-handler command creates or accesses an event-handler profile and can also define one of the following parameters: 
		
 
		  - Description 
		  
- One trigger 
		  
- The Python-script action that runs on any trigger 
		  
You can also define the above parameters—including one or more triggers—from event-handler configuration mode. 
		
A Python event-handler script runs only if all of the following occur: 
		
 
		  -  Using the 
			 copy command, copy the Python file to the 
			 flash:// location on the device. 
		  
- Using the 
			 event-handler command, create an event-handler profile. 
		  
- Either using the 
			 event-handler command or in configuration mode for that profile: 
			  
				- Using the 
				  trigger command, create one or more triggers. 
				
- Using the 
				  action command, specify the Python script that will be triggered. 
				
 
- Using the 
			 event-handler activate command, activate an instance of the event handler. 
		  
- The trigger event occurs. 
		  
If an event-handler profile is not activated, the 
		  no form of this command deletes it. 
		
 
	 
Examples
 
	  
		The following example creates an event-handler profile and accesses its configuration mode. 
		
 
		device# configure terminal
device(config)# event-handler eventHandler1
device(config-event-handler-eventHandler1)#