def __init__(self): self.host_ip = '192.168.1.1' self.username = '******' #telnet账户 self.password = '******' #telnet密码 self.flag = 0 self.crosswise = 0 self.vertical = 0 self.telnet_operation = telnet_main.TelnetClient() self.dataExcel = data_excel.DataWtExcel() self.dataExcel.run_data_excel(0, 0, '内存') self.dataExcel.run_data_excel(0, 1, 'CPU')
def __init__(self): self.host_ip = '192.168.1.1' self.username = '******' #telnet账户 self.password = '******' #telnet密码 self.su = 'su' self.su_pwd = '12345678LaYBc' self.flag = 0 self.crosswise = 0 self.vertical = 0 self.telnet_operation = telnet_main.TelnetClient() self.dataExcel = data_excel.DataWtExcel() self.dataExcel.run_data_excel(0, 0, '内存') self.dataExcel.run_data_excel(0, 1, 'CPU')
def __init__(self): self.host_ip = '192.168.1.1' #目的主机IP self.username = '******' #电信telnet登录账户 self.password = '******' #电信telnet登录密码 self.su = 'su' self.su_pwd = '1234567812345' self.flag = 0 #当前记录次数 self.crosswise = 0 #excel表格中行 self.vertical = 0 #excel表格中列 self.telnet_operation = telnet_main.TelnetClient() self.dataExcel = data_excel.DataWtExcel() self.dataExcel.run_data_excel(0, 0, '内存') self.dataExcel.run_data_excel(0, 1, 'CPU') self.dataExcel.run_data_excel(0, 2, 'odmv3')
def __init__(self): self.host_ip = '192.168.1.1' #目的主机IP # self.username='******' #telnet登录账户 # self.password='******' #telnet登录密码 self.username = '******' # telnet登录账户 self.password = '******' # telnet登录密码 self.su = 'su' # telnet登录账户 self.su_pwd = '1234567812345' # telnet登录密码 self.flag = 0 #当前记录次数 self.crosswise = 0 #excel表格中行 self.vertical = 0 #excel表格中列 self.telnet_operation = telnet_main.TelnetClient() self.dataExcel = data_excel.DataWtExcel() self.dataExcel.run_data_excel(0, 0, 'free_total') self.dataExcel.run_data_excel(0, 1, 'free_udevd') self.dataExcel.run_data_excel(0, 2, 'free_syslogd') self.dataExcel.run_data_excel(0, 3, 'free_klogd') self.dataExcel.run_data_excel(0, 4, 'free_wlancfg') self.dataExcel.run_data_excel(0, 5, 'free_loop') self.dataExcel.run_data_excel(0, 6, 'free_fhoam') self.dataExcel.run_data_excel(0, 7, 'free_remd') self.dataExcel.run_data_excel(0, 8, 'free_obox_pid') self.dataExcel.run_data_excel(0, 9, 'free_server') self.dataExcel.run_data_excel(0, 10, 'free_vswitchd') self.dataExcel.run_data_excel(0, 11, 'free_ram') self.dataExcel.run_data_excel(0, 12, 'free_cm') self.dataExcel.run_data_excel(0, 13, 'free_dm') self.dataExcel.run_data_excel(0, 14, 'free_inetd') self.dataExcel.run_data_excel(0, 15, 'free_rastatus6') self.dataExcel.run_data_excel(0, 16, 'free_voip_monitor') self.dataExcel.run_data_excel(0, 17, 'free_telnetd') self.dataExcel.run_data_excel(0, 18, 'free_udhcpd') self.dataExcel.run_data_excel(0, 19, 'free_udhcpc') self.dataExcel.run_data_excel(0, 20, 'free_arping') self.dataExcel.run_data_excel(0, 21, 'free_pppoe_start') self.dataExcel.run_data_excel(0, 22, 'free_pppd') self.dataExcel.run_data_excel(0, 23, 'free_hgcsip') self.dataExcel.run_data_excel(0, 24, 'free_dnsmasqx') self.dataExcel.run_data_excel(0, 25, 'cpu_idle')
return True else: print('账号密码错误') return False def import_content(self,content): self.telnet.write(content.encode('ascii')+b'\n') time.sleep(2) content_result=self.telnet.read_very_eager().decode('ascii') return content_result if __name__ == '__main__': host_ip='192.168.1.1' username='******' password='******' telnet_client=TelnetClient() if telnet_client.login_host(host_ip,username,password): free = str(telnet_client.import_content('free')).split()[17] cpu = str(telnet_client.import_content('top -n 1')).split()[19] data_excel = data_excel.DataWtExcel() data_excel.run_data_excel(crosswise=4,vertical=7,content=6)