This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def print_dup_info(s): | |
#split config on ! characters | |
blocks = s.split('!') | |
stanza_list = [] | |
interface_dict = {} | |
for block in blocks: | |
#get rid of blank lines and split each stanza into a list of lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def int_to_ip(signed_int): | |
""" convert a 32-bit signed integer to an IP address""" | |
# do preventative type checking because I didn't want to check inputs | |
try: | |
if type(signed_int) == str or type(signed_int) == int: | |
signed_int = long(signed_int) | |
except ValueError: | |
return "err_ip" | |
# CUCM occasionally creates CDRs with an IP of '0'. Bug or feature? Beats me. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Uncipher Cisco type 7 ciphered passwords | |
Usage: python uncipher.py <pass> where <pass> is the text of the type 7 password | |
Example: | |
$ python uncipher.py 094F4F1D1A0403 | |
catcat | |
""" | |
import fileinput | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Uncipher Cisco type 7 ciphered passwords | |
Usage: python uncipher.py <pass> where <pass> is the text of the type 7 password | |
Example: | |
$ python uncipher.py 094F4F1D1A0403 | |
catcat | |
""" | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Idx: record { | |
hostname: string; | |
}; | |
export { | |
redef enum Notice::Type += { | |
DNS_ENTRY::Tracked_Hostname | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from getpass import getpass | |
""" | |
A more friendly, bug-fixed version of the Python sample included with | |
Solarwinds SDK v1.8 | |
Make sure to set a valid nodeID in line 50 before using! | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter,defaultdict | |
import re | |
import sys | |
""" | |
Counterpart to this blog post: | |
http://unroutable.blogspot.com/2014/07/simple-python-syslog-counter.html | |
Summarize counts of typical Cisco syslog messages. Most syslog servers produce lines that look something like this: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
from csv import DictReader | |
import gzip | |
from pprint import pprint | |
from sys import argv | |
FIELDNAMES = ['ts', 'uid', 'id.orig_h', 'id.orig_p', 'id.resp_h', 'id.resp_p', 'proto', 'trans_id', 'query', 'qclass', 'qclass_name', 'qtype', 'qtype_name', 'rcode', 'rcode_name', 'AA', 'TC', 'RD', 'RA', 'Z', 'answersTTLs', 'rejected'] | |
def ingest(files, delim='\t', qchar='"'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import namedtuple | |
def d2n(name,d): | |
""" convert dict to namedtuple """ | |
NewClass = namedtuple(name,d.keys()) | |
return NewClass(*d.values()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
def hash(s,a='md5'): | |
""" One-stop hex-digest of a string. Allows any algorithm supported by hashlib. """ | |
f = getattr(hashlib,a) | |
return f(s).hexdigest() | |
def fhash(fn,a='md5'): | |
""" Hash a file as a string. Not memory considerate. """ | |
with open(fn) as f: |
OlderNewer