Juniper Networks Junos OS Developer Guide
PDF
سند
تبلیغات
تبلیغات

Junos® OS
Event Automation and Event Policy Developer
Guide
Release
13.3
Published: 2013-11-26
Copyright © 2013, Juniper Networks, Inc.
Event Automation and Event Policy Developer
Guide
Release
13.3
Published: 2013-11-26
Copyright © 2013, Juniper Networks, Inc.

Juniper Networks, Inc.
1194 North Mathilda Avenue
Sunnyvale, California 94089
USA
408-745-2000
www.juniper.net
Juniper Networks, Junos, Steel-Belted Radius, NetScreen, and ScreenOS are registered trademarks of Juniper Networks, Inc. in the United
States and other countries. The Juniper Networks Logo, the Junos logo, and JunosE are trademarks of Juniper Networks, Inc. All other
trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Juniper Networks assumes no responsibility for any inaccuracies in this document. Juniper Networks reserves the right to change, modify,
transfer, or otherwise revise this publication without notice.
Junos® OS Event Automation and Event Policy Developer Guide
13.3
Copyright © 2013, Juniper Networks, Inc.
All rights reserved.
The information in this document is current as of the date on the title page.
YEAR 2000 NOTICE
Juniper Networks hardware and software products are Year 2000 compliant. Junos OS has no known time-related limitations through the
year 2038. However, the NTP application is known to have some difficulty in the year 2036.
END USER LICENSE AGREEMENT
The Juniper Networks product that is the subject of this technical documentation consists of (or is intended for use with) Juniper Networks
software. Use of such software is subject to the terms and conditions of the End User License Agreement (“EULA”) posted at
http://www.juniper.net/support/eula.html. By downloading, installing or using such software, you agree to the terms and conditions of
that EULA.
Copyright © 2013, Juniper Networks, Inc.ii
1194 North Mathilda Avenue
Sunnyvale, California 94089
USA
408-745-2000
www.juniper.net
Juniper Networks, Junos, Steel-Belted Radius, NetScreen, and ScreenOS are registered trademarks of Juniper Networks, Inc. in the United
States and other countries. The Juniper Networks Logo, the Junos logo, and JunosE are trademarks of Juniper Networks, Inc. All other
trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Juniper Networks assumes no responsibility for any inaccuracies in this document. Juniper Networks reserves the right to change, modify,
transfer, or otherwise revise this publication without notice.
Junos® OS Event Automation and Event Policy Developer Guide
13.3
Copyright © 2013, Juniper Networks, Inc.
All rights reserved.
The information in this document is current as of the date on the title page.
YEAR 2000 NOTICE
Juniper Networks hardware and software products are Year 2000 compliant. Junos OS has no known time-related limitations through the
year 2038. However, the NTP application is known to have some difficulty in the year 2036.
END USER LICENSE AGREEMENT
The Juniper Networks product that is the subject of this technical documentation consists of (or is intended for use with) Juniper Networks
software. Use of such software is subject to the terms and conditions of the End User License Agreement (“EULA”) posted at
http://www.juniper.net/support/eula.html. By downloading, installing or using such software, you agree to the terms and conditions of
that EULA.
Copyright © 2013, Juniper Networks, Inc.ii

Table of Contents
About the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Documentation and Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Supported Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Using the Examples in This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Merging a Full Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Merging a Snippet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Documentation Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Documentation Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Requesting Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Self-Help Online Tools and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Opening a Case with JTAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Part 1 Overview
Chapter 1 Event Policy Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Event Notifications and Policies Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
How Event Policies Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Chapter 2 Event Scripts Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Event Scripts Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Event Script Programming Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
How Event Scripts Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Part 2 Configuration
Chapter 3 Triggering an Event Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Using Correlated Events to Trigger an Event Policy . . . . . . . . . . . . . . . . . . . . . . . . . 11
Representing the Correlating Event in an Event Policy . . . . . . . . . . . . . . . . . . . . . . 14
Triggering an Event Policy Based on Event Count . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Using Regular Expressions to Refine the Set of Events That Trigger a Policy . . . . . 15
Generating Internal Events to Trigger Event Policies . . . . . . . . . . . . . . . . . . . . . . . . 16
Using Nonstandard System Log Messages to Trigger Event Policies . . . . . . . . . . . 17
Chapter 4 Configuring Event Policy Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Configuring an Event Policy to Execute Operational Mode Commands . . . . . . . . . 19
Configuring an Event Policy to Change the Configuration . . . . . . . . . . . . . . . . . . . 22
Configuring an Event Policy to Change the Configuration Overview . . . . . . . . 23
Example: Changing the Configuration Using an Event Policy . . . . . . . . . . . . . 24
Example: Changing the Interface Configuration in Response to an Event . . . 30
Executing Event Scripts in an Event Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Configuring Event Policies to Ignore an Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
iiiCopyright © 2013, Juniper Networks, Inc.
About the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Documentation and Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Supported Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Using the Examples in This Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Merging a Full Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Merging a Snippet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Documentation Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Documentation Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Requesting Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Self-Help Online Tools and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Opening a Case with JTAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Part 1 Overview
Chapter 1 Event Policy Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Event Notifications and Policies Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
How Event Policies Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Chapter 2 Event Scripts Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Event Scripts Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Event Script Programming Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
How Event Scripts Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Part 2 Configuration
Chapter 3 Triggering an Event Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Using Correlated Events to Trigger an Event Policy . . . . . . . . . . . . . . . . . . . . . . . . . 11
Representing the Correlating Event in an Event Policy . . . . . . . . . . . . . . . . . . . . . . 14
Triggering an Event Policy Based on Event Count . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Using Regular Expressions to Refine the Set of Events That Trigger a Policy . . . . . 15
Generating Internal Events to Trigger Event Policies . . . . . . . . . . . . . . . . . . . . . . . . 16
Using Nonstandard System Log Messages to Trigger Event Policies . . . . . . . . . . . 17
Chapter 4 Configuring Event Policy Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Configuring an Event Policy to Execute Operational Mode Commands . . . . . . . . . 19
Configuring an Event Policy to Change the Configuration . . . . . . . . . . . . . . . . . . . 22
Configuring an Event Policy to Change the Configuration Overview . . . . . . . . 23
Example: Changing the Configuration Using an Event Policy . . . . . . . . . . . . . 24
Example: Changing the Interface Configuration in Response to an Event . . . 30
Executing Event Scripts in an Event Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Configuring Event Policies to Ignore an Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
iiiCopyright © 2013, Juniper Networks, Inc.

Changing the User Privilege Level for an Event Policy Action . . . . . . . . . . . . . . . . . 42
Example: Configuring Event Policies to Raise SNMP Traps . . . . . . . . . . . . . . . . . . 43
Overview of Using Event Policies to Raise SNMP Traps . . . . . . . . . . . . . . . . . 43
Example: Raising an SNMP Trap in Response to an Event . . . . . . . . . . . . . . . 44
Configuring the System Log Priority of the Triggering Event in an Event Policy . . 46
Understanding the Event System Log Priority in an Event Policy . . . . . . . . . . 46
Example: Configuring the Event System Log Priority in an Event Policy . . . . . 47
Chapter 5 Configuring Event Policy File Archiving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Event Policy File Archiving Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Example: Defining Destinations for File Archiving by Event Policies . . . . . . . . . . . 54
Example: Configuring an Event Policy to Upload Files . . . . . . . . . . . . . . . . . . . . . . 57
Configuring the Delay Before Files Are Uploaded by an Event Policy . . . . . . . . . . 63
Configuring an Event Policy to Retry the File Upload Action . . . . . . . . . . . . . . . . . 65
Chapter 6 Configuring Event Policy Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Changing the User Privilege Level for an Event Policy Action . . . . . . . . . . . . . . . . . 67
Chapter 7 Configuring Limits on the Number of Event Policies . . . . . . . . . . . . . . . . . . . 69
Example: Configuring Limits on Executed Event Policies and Memory Allocation
for Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Chapter 8 Creating and Executing Event Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Required Boilerplate for Event Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Capturing and Using Event Details and Remote Execution Details in Event
Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Mapping Operational Mode Commands and Output Fields to Junos XML
Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Using RPCs and Operational Mode Commands in Event Scripts . . . . . . . . . . . . . . 77
Using RPCs in Event Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Displaying the RPC Tags for a Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Using Operational Mode Commands in Event Scripts . . . . . . . . . . . . . . . . . . 79
Enabling an Event Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Executing an Event Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Replacing an Event Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Configuring Checksum Hashes for an Event Script . . . . . . . . . . . . . . . . . . . . . . . . 82
Example: Configuring Limits on Executed Event Policies and Memory Allocation
for Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Chapter 9 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Example: Assigning a Transfer Delay to an Event Policy Action . . . . . . . . . . . . . . . 87
Example: Associating an Optional User with an Event Policy Action . . . . . . . . . . 89
Example: Controlling Event Policy Using a Regular Expression . . . . . . . . . . . . . . . 90
Example: Correlating Events Based on Event Attributes . . . . . . . . . . . . . . . . . . . . 90
Example: Correlating Events Based on Receipt of Other Events Within a Specified
Time Interval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Example: Generating an Internal Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Example: Ignoring Events Based on Receipt of Other Events . . . . . . . . . . . . . . . . 92
Example: Limiting Event Script Output Based on a Specific Event Type . . . . . . . . 93
Example: Representing the Correlating Event in an Event Policy . . . . . . . . . . . . . . 94
Example: Retrying the File Upload Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Copyright © 2013, Juniper Networks, Inc.iv
Event Automation and Event Policy Developer Guide
Example: Configuring Event Policies to Raise SNMP Traps . . . . . . . . . . . . . . . . . . 43
Overview of Using Event Policies to Raise SNMP Traps . . . . . . . . . . . . . . . . . 43
Example: Raising an SNMP Trap in Response to an Event . . . . . . . . . . . . . . . 44
Configuring the System Log Priority of the Triggering Event in an Event Policy . . 46
Understanding the Event System Log Priority in an Event Policy . . . . . . . . . . 46
Example: Configuring the Event System Log Priority in an Event Policy . . . . . 47
Chapter 5 Configuring Event Policy File Archiving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Event Policy File Archiving Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Example: Defining Destinations for File Archiving by Event Policies . . . . . . . . . . . 54
Example: Configuring an Event Policy to Upload Files . . . . . . . . . . . . . . . . . . . . . . 57
Configuring the Delay Before Files Are Uploaded by an Event Policy . . . . . . . . . . 63
Configuring an Event Policy to Retry the File Upload Action . . . . . . . . . . . . . . . . . 65
Chapter 6 Configuring Event Policy Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Changing the User Privilege Level for an Event Policy Action . . . . . . . . . . . . . . . . . 67
Chapter 7 Configuring Limits on the Number of Event Policies . . . . . . . . . . . . . . . . . . . 69
Example: Configuring Limits on Executed Event Policies and Memory Allocation
for Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Chapter 8 Creating and Executing Event Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Required Boilerplate for Event Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Capturing and Using Event Details and Remote Execution Details in Event
Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Mapping Operational Mode Commands and Output Fields to Junos XML
Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Using RPCs and Operational Mode Commands in Event Scripts . . . . . . . . . . . . . . 77
Using RPCs in Event Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Displaying the RPC Tags for a Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Using Operational Mode Commands in Event Scripts . . . . . . . . . . . . . . . . . . 79
Enabling an Event Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Executing an Event Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Replacing an Event Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Configuring Checksum Hashes for an Event Script . . . . . . . . . . . . . . . . . . . . . . . . 82
Example: Configuring Limits on Executed Event Policies and Memory Allocation
for Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Chapter 9 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Example: Assigning a Transfer Delay to an Event Policy Action . . . . . . . . . . . . . . . 87
Example: Associating an Optional User with an Event Policy Action . . . . . . . . . . 89
Example: Controlling Event Policy Using a Regular Expression . . . . . . . . . . . . . . . 90
Example: Correlating Events Based on Event Attributes . . . . . . . . . . . . . . . . . . . . 90
Example: Correlating Events Based on Receipt of Other Events Within a Specified
Time Interval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Example: Generating an Internal Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Example: Ignoring Events Based on Receipt of Other Events . . . . . . . . . . . . . . . . 92
Example: Limiting Event Script Output Based on a Specific Event Type . . . . . . . . 93
Example: Representing the Correlating Event in an Event Policy . . . . . . . . . . . . . . 94
Example: Retrying the File Upload Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Copyright © 2013, Juniper Networks, Inc.iv
Event Automation and Event Policy Developer Guide
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/
دانلود
فقط یک یادآوری دوستانه. می توانید سند را درست در اینجا مشاهده کنید. اما مهمتر از همه، هوش مصنوعی ما قبلاً آن را خوانده است. این می تواند موارد پیچیده را به زبان ساده توضیح دهد، به سوالات شما به هر زبانی پاسخ دهد و به شما کمک کند به سرعت حتی طولانی ترین یا پیچیده ترین اسناد را پیمایش کنید.
تبلیغات