Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # KittensPaw - NETWORK MANAGEMENT AND MONITOR TOOL - BETA V.0.1 PYTHON IMPL
- # KittensPaw - C++ RELEASE SHOULD BE USED WHEN POSSIBLE
- import platform
- import subprocess
- import os
- # plan - multiple threads running loading into global variables that can be accessed
- # web thread - thread that manages web interface such as graphs, maps, etc
- # system thread - pings and retrieves and manages info from routers and other devices SNMP too
- # classes
- class Router: # equipment class for routers and possible switches (note switches may get their own class)
- equipment_name = ""
- ip_address = ""
- # lat/long cords
- # parent maybe????
- def __init__(self, equipment_name, ip_address):
- self.equipment_name = equipment_name
- self.ip_address = ip_address
- # functions
- def ping(host): # pings host
- """
- Returns True if host (str) responds to a ping request.
- Remember that a host may not respond to a ping (ICMP) request even if the host name is valid.
- """
- # Option for the number of packets as a function of
- param = '-n' if platform.system().lower()=='windows' else '-c'
- # Building the command. Ex: "ping -c 1 google.com"
- command = ['ping', param, '1', host]
- return subprocess.call(command) == 0
- # main
- def main():
- print("Type router name...")
- name = input("Enter name: ")
- ip = input("Enter IP address: ")
- london = Router(name, ip)
- print ("Checking if " , london.equipment_name , " is online...")
- testing = ping(london.ip_address)
- if testing == True:
- print(london.equipment_name , " can ping!")
- else:
- print(london.equipment_name , " is offline!")
- if __name__== "__main__":
- main()
- # print("world hello!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement