NetOps Coding 101 building your first robot!

Similar documents
Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Python INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython.

GIS 4653/5653: Spatial Programming and GIS. More Python: Statements, Types, Functions, Modules, Classes

Topic 7: Lists, Dictionaries and Strings

Python Training. Complete Practical & Real-time Trainings. A Unit of SequelGate Innovative Technologies Pvt. Ltd.

CS108 Lecture 19: The Python DBAPI

Webgurukul Programming Language Course

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

Iterators & Generators

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

JSON Support for Junos OS

[301] JSON. Tyler Caraza-Harter

STATS Data Analysis using Python. Lecture 8: Hadoop and the mrjob package Some slides adapted from C. Budak

Ch.1 Introduction. Why Machine Learning (ML)?

APIs and API Design with Python

Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Introduction to Bioinformatics

Ceng 111 Fall 2015 Week 8a

PYTHON TRAINING COURSE CONTENT

About Python. Python Duration. Training Objectives. Training Pre - Requisites & Who Should Learn Python

Python Basics. Lecture and Lab 5 Day Course. Python Basics

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

15-388/688 - Practical Data Science: Data collection and scraping. J. Zico Kolter Carnegie Mellon University Spring 2017

Ch.1 Introduction. Why Machine Learning (ML)? manual designing of rules requires knowing how humans do it.

Python Working with files. May 4, 2017

Python Intro GIS Week 1. Jake K. Carr

Level 3 Computing Year 2 Lecturer: Phil Smith

CS2304: Python for Java Programmers. CS2304: Sequences and Collections

Data type built into Python. Dictionaries are sometimes found in other languages as associative memories or associative arrays.

JME Language Reference Manual

LING115 Lecture Note Session #7: Regular Expressions

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

The Pyth Language. Administrivia

Part III Appendices 165

Computer and Programming: Lab 1

Script language: Python Data structures

Mastering Modern Linux by Paul S. Wang Appendix: Pattern Processing with awk

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

Table of Contents EVALUATION COPY

Python: Short Overview and Recap

Computational Programming with Python

Playlist Builder 1.5 Manual

CMSC 201 Fall 2015 Lab 12 Tuples and Dictionaries

Basics of Stata, Statistics 220 Last modified December 10, 1999.

S206E Lecture 19, 5/24/2016, Python an overview

Basic Scripting, Syntax, and Data Types in Python. Mteor 227 Fall 2017

Defining Functions. CSc 372. Comparative Programming Languages. 5 : Haskell Function Definitions. Department of Computer Science University of Arizona

Python Class-Lesson1 Instructor: Yao

Java+- Language Reference Manual

Comp Exam 1 Overview.

Human-Computer Interaction Design

Dictionaries. Looking up English words in the dictionary. Python sequences and collections. Properties of sequences and collections

Python - Variable Types. John R. Woodward

Configuring the Embedded Event Manager

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman

Chapter 4. Unix Tutorial. Unix Shell

Play with Python: An intro to Data Science

TUPLES AND RECURSIVE LISTS 5

pylatexenc Documentation

CS1110 Lab 1 (Jan 27-28, 2015)

Python I. Some material adapted from Upenn cmpe391 slides and other sources

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

MUTABLE LISTS AND DICTIONARIES 4

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

CS 11 python track: lecture 3. n Today: Useful coding idioms

LING/C SC/PSYC 438/538. Lecture 3 Sandiway Fong

[CHAPTER] 1 INTRODUCTION 1

Exceptions & a Taste of Declarative Programming in SQL

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

GNU ccscript Scripting Guide IV

1 of 7 7/24/2014 8:16 PM

Python for ArcGIS. Lab 1.

Part IV. More on Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

Exercise: The basics - variables and types

MITOCW watch?v=rvrkt-jxvko

Advanced Algorithms and Computational Models (module A)

Data Acquisition and Processing

CorreLog. SQL Table Monitor Adapter Users Manual

Visualize ComplexCities

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

IT 374 C# and Applications/ IT695 C# Data Structures

CMSC201 Computer Science I for Majors

Contrail Sandbox Tutorial Script

Introduction to Python Part 1. Brian Gregor Research Computing Services Information Services & Technology

This class is about understanding how programs work

Programming in Python 3

PLOG Proposal: A programming language for graph operations

Using Python for shell scripts

LISTS WITH PYTHON. José M. Garrido Department of Computer Science. May College of Computing and Software Engineering Kennesaw State University

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala

N-grams in Python. L445/L515 Autumn 2010

COMP-520 GoLite Tutorial

Python. Objects. Geog 271 Geographic Data Analysis Fall 2010

CSC148H Week 3. Sadia Sharmin. May 24, /20

Data! CS 133: Databases. Goals for Today. So, what is a database? What is a database anyway? From the textbook:

CS Summer 2013

SQLite vs. MongoDB for Big Data

Topics to Learn. Important concepts. Tree-based index. Hash-based index

PyROOT: Seamless Melting of C++ and Python. Pere MATO, Danilo PIPARO on behalf of the ROOT Team

Transcription:

NetOps Coding 101 building your first robot! NANOG 66 david swafford 02.09.2016

what we ll accomplish 2

automating 3

the remediation of network faults 4

using the examples of link flaps & line card failures 5

based on parsing of syslog messages 6

focusing today 7

coding in Python 8

interacting with network devices through software 9

regular expressions 10

keeping track of what happened 11

12

how it works 13

system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 14

system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 15

system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 16

system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 17

live demo! 18

19

20

21

22

23

24

25

26

syslog message problem identified solution suggested 27

28

the lab environment 29

a virtual machine of Ubuntu desktop 30

customized with ipython! and extras Python 2.7.11 & 3.5.1 MySQL server & Python libs 31

importing the virtual appliance 32

download it from netengcode.com! 33

34

35

36

37

TERMINAL log-in details user: demo pass: demo 38

keyboard shortcuts to break out of the VM f enter or leave full-screen 39

40

introducing IPython! http://ipython.org/ipython-doc/3/install/install.html 41

42

43

simple prototyping 44

simple prototyping 45

scrolling back 46

scrolling back 47

leaving 48

a few Python basics 49

the basic data structures 50

the basic data structures strings lists tuples dictionaries 51

strings in Python any sequence of characters enclosed by single or double-quotes https://docs.python.org/3/tutorial/introduction.html#strings 52

lists in Python comma-separated values (items) between square brackets" https://docs.python.org/3/tutorial/introduction.html#lists 53

tuples in Python comma-separated values https://docs.python.org/3/library/stdtypes.html#tuples 54

lists vs tuples? 55

lists vs tuples the contents of a list may be changed the contents of a tuple may not be changed 56

quick caveat! "...it is actually the comma which makes a tuple, not the parentheses." https://docs.python.org/3/library/stdtypes.html#tuple 57

dictionaries ( hash tables ) 58

dictionaries in Python an unordered set of key: value pairs keys must be unique https://docs.python.org/3/tutorial/datastructures.html#dictionaries 59

dictionaries in Python 66 is the key and San Diego the value https://docs.python.org/3/tutorial/datastructures.html#dictionaries 60

dictionaries in Python values are accessed using the notation of [key] https://docs.python.org/3/tutorial/datastructures.html#dictionaries 61

try it out! 62

try it out! create a variable with your neighbor's name create a list of your adjacent neighbor's names create a dictionary mapping those last names to first names 63

try it out! create a variable with your neighbor's name name = '' create a list of your adjacent neighbor's names names = [] create a dictionary mapping those last names to first names names = {'last': 'first'} 64

questions? 65

66

working with modules 67

what is a module? 68

imports, or makes available, the re module part of the standard library https://docs.python.org/3/reference/simple_stmts.html#import 69

re is the module s namespace 70

as imports the module under a different namespace 71

methods from a module are accessed by namespace.method() 72

we will be using re.match() 73

using re.match() two inputs a regex and thing to match against 74

using re.match() it returns None or a match object 75

try it out! 76

try it out! import the "re" module type help(re) type re.match('eth', 'ethernet') 77

questions? 78

79

reading syslog messages 80

reading in a file assigning the file path to a variable 81

reading in a file opening a file handle 82

reading in a file using.readlines() to get a list of lines 83

reading in a file 84

try it out! 85

try it out! open the file "syslog.txt" try out ".readlines()" 86

questions? 87

88

parsing syslog messages 89

a syslog message 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 90

looking with an abstract lens 2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 91

looking with an abstract lens DATESTAMP 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 92

looking with an abstract lens DATESTAMP 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 93

looking with an abstract lens DATESTAMP TIMESTAMP switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 94

looking with an abstract lens DATESTAMP TIMESTAMP DEVICE %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 95

looking with an abstract lens DATESTAMP TIMESTAMP DEVICE %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 96

looking with an abstract lens DATESTAMP TIMESTAMP DEVICE ERROR_CODE: Interface Ethernet5/1 is down (Interface removed) 97

looking with an abstract lens DATESTAMP TIMESTAMP DEVICE ERROR_CODE: Interface Ethernet5/1 is down (Interface removed) 98

looking with an abstract lens DATESTAMP TIMESTAMP DEVICE ERROR_CODE: ERROR_MESSAGE 99

from log message to structured data 100

structured data LOG MESSAGE DATESTAMP TIMESTAMP DEVICE ERROR CODE ERROR MESSAGE 101

102

regular expressions! 103

a way to ask does this pattern exist in a given block of text? https://docs.python.org/3/howto/regex.html 104

where this pattern is created by you 105

specifying the pattern is often called building a regex 106

an example with BGP ip as-path access-list 1 permit "^$" 107

"^$" beginning of line followed by end of line (an empty line!) 108

getting started with regular expressions in Python 109

try it out! 110

try it out! a raw string, with an opening grouping symbol 111

try it out! \ to indicate that a pattern-matching character follows 112

try it out! d to match one digit (integer) http://www.merriam-webster.com/dictionary/digit 113

try it out! instead of pattern-matching, we could put exact text too -- "2015" for example 114

try it out! + to indicate one or more (of the previous thing) 115

try it out! \d+ will match 2015 116

try it out! \s will match one space 117

try it out! \w+ will match one or more characters (Jun) 118

try it out! assigning the return of re.match() to a variable (matched) 119

try it out! a match object was returned (it matched) 120

try it out! accessing the matched data using.group() 121

questions? 122

123

parsing syslog 124

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' one or \d+ more digits 125

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' one or \s+ more spaces 126

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' one or \w+ more characters 127

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DEVICE_NAME_RE = r'(\s+)' one or more \S+ non-space characters 128

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) ERROR_CODE_RE = r'%(\s+):' one or more \S+ non-space characters 129

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) ERROR_MESSAGE_RE = r'(\.*)' one or more \.* non-newline characters 130

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' TIMESTAMP_RE = r'(\d+:\d+:\d+)' DEVICE_NAME_RE = r'(\s+)' ERROR_CODE_RE = r'%(\s+):' ERROR_MESSAGE_RE = r'(\.*)' COLUMN_DELIMITER_RE = r'(\s+)' 131

132

using the re module to match 133

using the re module to match 134

using the re module to match 135

using the re module to match continue skip this log line and go to the next https://docs.python.org/3/reference/simple_stmts.html#continue 136

using the re module to match 137

start of group 1 end of group 1 DATESTAMP_RE = r'(\d+\s+\w+\s+\d+)' TIMESTAMP_RE = r'(\d+:\d+:\d+)' DEVICE_NAME_RE = r'(\s+)' ERROR_CODE_RE = r'%(\s+):' ERROR_MESSAGE_RE = r'(\.*)' 138

try it out! 139

try it out! 140

try it out! note - SYSLOG_RE is already staged 141

try it out! 142

try it out! 143

try it out! 144

try it out! 145

questions? 146

147

building our first remediation 148

first remediation a linecard failure 149

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 150

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 151

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 152

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 153

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 154

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) Did the interface regex find a match? 155

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) Group "1" is the data matched by the first set of ( ) 156

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 157

2015 Apr 2 14:25:06 switch1 %ETHPORT-5- IF_DOWN_INTERFACE_REMOVED: Interface Ethernet5/1 is down (Interface removed) 158

try it out! 159

try it out! parse out only the module number from: Ethernet5/1 populate that value into the string: show module {module} 160

sending commands over SSH 161

sending commands over SSH 162

sending commands over SSH a wrapper around Paramiko (Python SSH client) included with our demo code http://docs.paramiko.org/ 163

no paramiko? http://docs.paramiko.org/ 164

installing paramiko 165

installing paramiko 166

sending commands over ssh commands over ssh 167

sending commands over ssh commands over ssh 168

sending commands over ssh commands over ssh Connection opened! 169

sending commands over ssh 170

sending commands over ssh 171

sending commands over ssh 172

try it out! 173

try it out! open a dummy ssh connection using: import ssh_helper ssh = ssh_helper.sshsession('switch1') inspect the output from: show module 5 174

inspecting the output output is a list [0:5] is a slice of the first 5 lines https://docs.python.org/3/tutorial/introduction.html 175

inspecting the output 176

inspecting the output checking if one string is present in another string 177

inspecting the output ignoring case using.lower() 178

inspecting the output 179

inspecting the output 180

reacting to the output using on-device filtering with egrep 181

reacting to the output 182

reacting to the output idea! parse the uptime and react based on the value 183

reacting to the output 184

questions? 185

186

next remediation link flaps & light level checking 187

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 188

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 189

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 190

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 191

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 192

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 193

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 194

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 195

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 196

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 197

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 198

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 199

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 200

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 201

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 202

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 203

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 204

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 205

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 206

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 207

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 208

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 209

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) "show transceiver details" 210

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power -8.84 dbm...' 211

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power -8.84 dbm...' 212

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power -8.84 dbm...' 213

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power -8.84 dbm...' 214

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power -8.84 dbm...' 215

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) example output: ' Rx Power -8.84 dbm...' 216

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) converting a string to a float for mathematical comparison 217

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) 218

2015 May 18 12:43:15 switch2 %ETHPORT-5- IF_DOWN_LINK_FAILURE: Interface Ethernet1/4 is down (Link failure) send_email() 219

questions? 220

keeping track of what happened 221

options in memory (lists, dictionaries, etc) on disk (as a file) in a database 222

comparing a few database options sqlite mysql 223

an event as a database table EVENT ID DATESTAMP DEVICE ERROR CODE ERROR MESSAGE RESULT 224

getting started with sqlite 225

building the database 226

building the database 227

creating events the safe way to handle string substitution 228

creating events auto-generated by the database 229

updating events 230

updating events 231

questions? 232

opportunities for improvement 233

scoping globally scoped code is a bad design use functions, classes, and modules to keep things organized 234

scoping globally scoped code and code inside large functions are both hard to test concise functions are easier to test testability saves much pain and suffering later 235

organization remediation and system code together - it can be quite a lot to digest. "sparse is better than dense" - use smaller concise files and split logically. 236

scaling it's not a real-time system, but would need to be. for log parsing, continuous parsing with some intelligence re: new vs old events. 237

stability persistence is key! a restart to the parsing script should not re-run previously handled events / remediations. 238

perf one by one processing is okay for a demo... in real life though, this should break up the load within the script, or as separate scripts/instances. 239

system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 240

system design device 1 sends message 4 remediates syslog server 2 tails 3 messages runs parser remediation 241

appendix 242

separating backend code from remediation logic 243

separating the backend from remediations a dictionary where the values are functions! 244

separating the backend from remediations 245

separating the backend from remediations a function 246

running a function who s name is not defined in this block of code 247

248

249

250

#netengcode NANOG 66 david swafford 02.09.2016