def get_config_cisco_hp(host, log_file): (host_name, host_alias, host_address, plugin_output, host_filename) = host device = Device_cisco_hp(host_address.strip(), log_file) # Telnet fuer CSS Loadbalancer if plugin_output.find("sysDescr: Content Switch") != -1: device.set_prefer_telnet() device.logging("--- Hostname: " + host_name) # device.set_debug_mode(True) # device.set_demo_config_mode(True) tacacs_username = "******" tacacs_tpasswort = "test1" ips_dsl = ["192.168.121.1", "192.168.121.2"] if list_startswith(host_address, ips_dsl): device.logging("--- Anmeldedaten: DSL-Switche") device.connect(tacacs_username, tacacs_tpasswort, "test") else: device.logging("--- Anmeldedaten: TACACS only") device.connect(tacacs_username, tacacs_tpasswort) config = device.command("show running-config") write_memory_config(device, host) device.disconnect() return config
def get_HostByLivestatus(): all_server = [('10.3.3.3', 6557)] lql = "GET services\n" lql += "Columns: host_name host_alias host_address plugin_output host_filename\n" lql += "Filter: check_command = check_mk-snmp_info_v2\n" lql += "Filter: host_plugin_output !~ No IP packet received\n" lql += "OutputFormat: python\n" date = time.strftime("%Y-%m-%d_%H-%M-%S") path = "./" log_file = open(path + "CHANGELOG_" + date + ".log","w") for server in all_server: try: # Verbinden zum Server und LQL abfragen s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(server) s.send(lql) s.shutdown(socket.SHUT_WR) lql_answer = recv_timeout(s) lql_answer_python = eval(lql_answer) lql_answer_python_dopple = [] for host in lql_answer_python: lql_answer_python_dopple.append(host) lql_answer_python_dopple.append(host) for host in lql_answer_python: (host_name, host_alias, host_address, plugin_output, host_filename) = host print host if "cisco".lower() in plugin_output: device = Device_cisco_hp(host_address,log_file) device.logging("--- cmk_host_filname: "+ host_filename) device.connect('user','pass',"enable_pass") config = device.command("show running-config") print config #device.command("wr") device.disconnect() except Exception, e: print str(e)
def get_HostByLivestatus(): all_server = [('10.3.3.3', 6557)] lql = "GET services\n" lql += "Columns: host_name host_alias host_address plugin_output host_filename\n" lql += "Filter: check_command = check_mk-snmp_info_v2\n" lql += "Filter: host_plugin_output !~ No IP packet received\n" lql += "OutputFormat: python\n" date = time.strftime("%Y-%m-%d_%H-%M-%S") path = "./" log_file = open(path + "CHANGELOG_" + date + ".log", "w") for server in all_server: try: # Verbinden zum Server und LQL abfragen s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(server) s.send(lql) s.shutdown(socket.SHUT_WR) lql_answer = recv_timeout(s) lql_answer_python = eval(lql_answer) lql_answer_python_dopple = [] for host in lql_answer_python: lql_answer_python_dopple.append(host) lql_answer_python_dopple.append(host) for host in lql_answer_python: (host_name, host_alias, host_address, plugin_output, host_filename) = host print host if "cisco".lower() in plugin_output: device = Device_cisco_hp(host_address, log_file) device.logging("--- cmk_host_filname: " + host_filename) device.connect('user', 'pass', "enable_pass") config = device.command("show running-config") print config #device.command("wr") device.disconnect() except Exception, e: print str(e)
def get_HostByLivestatus(): all_server = [('10.33.3.3', 6557)] lql = "GET services\n" lql += "Columns: host_name host_alias host_address plugin_output host_filename\n" lql += "Filter: check_command = check_mk-snmp_info_v2\n" lql += "Filter: host_plugin_output !~ No IP packet received\n" lql += "OutputFormat: python\n" date = time.strftime("%Y-%m-%d_%H-%M-%S") path = "./" log_file = open(path + "UPDATELOG_" + date + ".log","w") for server in all_server: try: # Verbinden zum Server und LQL abfragen s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(server) s.send(lql) s.shutdown(socket.SHUT_WR) lql_answer = recv_timeout(s) lql_answer_python = eval(lql_answer) for host in lql_answer_python: (host_name, host_alias, host_address, plugin_output, host_filename) = host if "C2950-I6Q4L2-M" in plugin_output: device = Device_cisco_hp(host_address,log_file) device.connect('user','pass','enable_pass','enable_pass_backup') firmware_update(device) except Exception, e: print str(e)
def get_config_cisco_hp(host, log_file): (host_name, host_alias, host_address, plugin_output, host_filename) = host device = Device_cisco_hp(host_address.strip(),log_file) # Telnet fuer CSS Loadbalancer if plugin_output.find("sysDescr: Content Switch") != -1: device.set_prefer_telnet() device.logging("--- Hostname: " + host_name) #device.set_debug_mode(True) #device.set_demo_config_mode(True) tacacs_username = '******' tacacs_tpasswort = 'test1' ips_dsl = ["192.168.121.1", "192.168.121.2"] if list_startswith(host_address, ips_dsl ): device.logging("--- Anmeldedaten: DSL-Switche") device.connect(tacacs_username, tacacs_tpasswort, 'test') else: device.logging("--- Anmeldedaten: TACACS only") device.connect(tacacs_username, tacacs_tpasswort) config = device.command("show running-config") write_memory_config(device, host) device.disconnect() return config