Skip to content

Instantly share code, notes, and snippets.

View twr14152's full-sized avatar

Todd Riemenschneider twr14152

  • Columbus, Ohio
View GitHub Profile
@twr14152
twr14152 / ex_loop_and_func_go
Created September 22, 2019 11:53
Tour_go_exercises
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0
for i := 0; i < 10; i++ {
@twr14152
twr14152 / telnet_script_enable_mode.py
Created December 18, 2018 19:22
Telnet script with enable mode
#This is the telnet Library for Python3
#Make sure transport input telnet is enabled on router validate
#This scripts will run commands you choose on the remote devices using telnet as transport
#The results will be print to screen and captured in files named ("router_" + HOST)
#(c) 2017 Todd Riemenschneider
from getpass import getpass
import telnetlib
user = input("Username: ")
__author__ = "ToddR"
#
#
import paramiko
import time
import getpass
UN = raw_input("Username : ")
PW = getpass.getpass("Password : ")
@twr14152
twr14152 / commands_file.py
Last active August 29, 2015 14:27
Python ssh script for network devices
host_commands = []
f = open('show_commands.txt', 'r')
for line in f:
host_commands.append(line.strip())
f.close()
print host_commands
@twr14152
twr14152 / EEM Config-change-alert
Created June 17, 2015 17:52
EEM Cisco - config change Alert - with email and syslog capturing user name and config commands
archive
log config
logging enable
notify syslog contenttype plaintext
hidekeys
event manager applet Config_Change authorization bypass
event config
action 1.1 cli command "enable"
@twr14152
twr14152 / sample.pysnmp.ex1.py
Created May 12, 2015 02:34
Testing pysnmp out on All-in-one-VM
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
# Run through these hosts
IP = ['10.10.10.110', '10.10.10.120', '10.10.10.130']
#
#http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&translate=Translate&objectInput=1.3.6.1.2.1.1.1#oidContent
#
def main():
@twr14152
twr14152 / config_file.py
Last active December 31, 2022 19:08
python ssh script to automate gathering info and pushing configs to Cisco routers and switches
host_conf = ['show ip arp vlan 11', 'show ip arp vlan 12', 'show ip arp vlan 13', 'show ip arp vlan 32', 'show ip arp vlan 50', 'show ip arp vlan 102', 'show ip arp vlan 112', 'show ip arp vlan 145', 'show ip arp vlan 150', 'show ip arp vlan 155', 'show ip arp vlan 160', 'show ip arp vlan 161', 'show ip arp vlan 171', 'show ip arp vlan 172', 'show ip arp vlan 327', 'show ip arp vlan 328', 'show ip arp vlan 331', 'show ip arp vlan 332', 'show ip arp vlan 374', 'show ip arp vlan 380', 'show ip arp vlan 401', 'show ip arp vlan 409', 'show ip arp vlan 433', 'show ip arp vlan 434', 'show ip arp vlan 435', 'show ip arp vlan 436', 'show ip arp vlan 334', 'show ip arp vlan 343', 'show ip arp vlan 403', 'show ip arp vlan 404', 'show ip arp vlan 406', 'show ip arp vlan 447','exit']
# To implement config changes your config would be implemented in list format
# host_conf = ['config t', 'interface lo10', 'description TEST-CONFIG-SCRIPT-3', 'end', 'show run int loop 10']
@twr14152
twr14152 / nx_api_conf_script.py
Last active November 3, 2018 23:47
Test Python interaction with nx-api
### Target hosts for this script lives in nexus_host.py
import time
from nexus_hosts import network_devices
import requests
import json
import getpass
UN = raw_input("Username : ")
PW = getpass.getpass("Password : ")
@twr14152
twr14152 / host_config_file.py
Last active August 22, 2021 12:47
Using Python to script the configuration of Cisco devices
#
#
# add your configurations in a list format
#
host_conf = ['config t', 'interface lo10', 'description TEST-CONFIG-SCRIPT-3', 'end', 'show run int loop 10']
@twr14152
twr14152 / task - main.yml
Created February 2, 2015 21:23
Week 3 exercise 3
---
- name: Generate configuration files
template: src=access_switch3.j2 dest=/home/toddr/ANSIBLE/roles/access_switch/CFGS/{{item.hostname}}3.txt
with_items: switches
~