Skip to content

Instantly share code, notes, and snippets.

View tyler-8's full-sized avatar

Tyler Bigler tyler-8

View GitHub Profile
@tyler-8
tyler-8 / ping.py
Last active January 17, 2017 18:57
Simple function for pinging an IP/hostname (Linux/Mac Only)
import re
import subprocess
def ping(host):
""" Ping the address/hostname and return True if packet loss is less than
60%. All other results return False or print and error."""
exp = re.compile(r"\s(\d{1,3})\%\s")
try:
test = subprocess.Popen(["ping", "-c 5", "-W 2", host],
@tyler-8
tyler-8 / mp_netmiko.py
Last active January 16, 2017 20:58
Multiprocessing with Netmiko for Plaid Speed
from __future__ import print_function
import logging
import time
from datetime import datetime
from multiprocessing import Pool, cpu_count, current_process
from netmiko import ConnectHandler
from netmiko.ssh_exception import NetMikoTimeoutException, NetMikoAuthenticationException