def zte_cdn_omc(): cookie = 'ERROR' url = 'https://39.134.88.198:8443/frame/loginOut.action' cj = ww.get_cookie_without_form(url) # 这个函数默认输出结果 for item in cj: cookie = item.name + '=' + item.value print(cookie) # cookie = 'JSESSIONID=4CD5A39212EAA84F77E3BE9817B6AC09' # url = 'https://39.134.88.198:8443/authimg' # ww.get_validate_code(url, cookie) url = 'https://39.134.88.198:8443/frame/login.action' # pwd = input('输入验证码,谢谢') form = { 'authCodeable': 'false', 'password': '******', 'userName': '******', # 'validateCode': pwd } ww.post_web_page_ssl(url, form, cookie) return cookie
def zte_anyservice_uniportal_v2(): cookie = 'ERROR' url = 'https://117.135.56.61:8443/frame/loginOut.action' cj = ww.get_cookie_without_form(url) for item in cj: cookie = item.name + '=' + item.value # print(cookie) url = 'https://117.135.56.61:8443/frame/login.action' form = { 'authCodeable': 'false', 'password': '******', 'userName': '******' } ww.post_web_page_ssl(url, form, cookie) return cookie
def query_ottnode_zte(n, cookie): url = 'https://39.134.88.198:8443/stat/traffic_query.action' form = { 'offset': '8', 'beginDate': startTime + ' 00:00:00', 'endDate': endTime + ' 00:00:00', 'areaid': '', 'nodeid': NODE_DICT[n], 'deviceid': '', 'apptype': '', 'servicemode': '', 'cachetype': '', 'domaintype': '1', 'domain': '', } f = ww.post_web_page_ssl(url, form, cookie) # print(f) encodedjson = json.loads(f) # print(encodedjson.keys()) service_rate = list() for item in encodedjson['message']['linearray']: # print(item['servicevolume']) service_rate.append(item['servicevolume']) print(max(service_rate)) return round(max(service_rate) / 1000 / 1000 / 1000 / 300 * 8, 2)
def hit_ratio(): # 节点状态码 url = 'https://39.134.88.198:8443/stat/requesthit_query.action' form = { 'offset': '8', 'beginDate': begin + ' 00:00:00', 'endDate': end + ' 00:00:00', 'areaid': '', 'nodeid': 'SMALLcache', 'deviceid': '', 'apptype': '', 'servicemode': '', 'cachetype': '', 'inserttypeid': '', 'terminalid': '', 'domaintype': '1', 'domain': '', } f = ww.post_web_page_ssl(url, form, cookie) print(f) tmp_dict = json.loads(f) "EDIT SCRIPT FROM HERE" tmp_dict = tmp_dict['message'] hit = 0 miss = 0 for item in tmp_dict: hit += int(item['hitsnum']) miss += int(item['missnum']) return hit, miss, round(hit/(hit+miss)*100, 2)
def download_rate(s): # 下载速率 url = 'https://39.134.88.198:8443/stat/userdown_query.action' form = { 'offset': '8', 'beginDate': begin + ' 00:00:00', 'endDate': end + ' 00:00:00', 'areaid': '', 'nodeid': s, 'deviceid': '', 'servicemode': '', 'cachetype': '', 'inserttypeid': '', 'terminalid': '', 'ratetype': '', 'domain': '', } f = ww.post_web_page_ssl(url, form, cookie) tmp_dict = json.loads(f) "EDIT SCRIPT FROM HERE" download_rate = tmp_dict['message']['messageline'] userdownload = 0 for item in download_rate: userdownload += float(item['userdownload']) userdownload = userdownload / len(download_rate) / 1024 / 1024 return round(userdownload, 2)
def zte(): cookie_zte = wl.zte_anyservice_uniportal_v2() url_zte = 'https://117.135.56.61:8443/monitor/cpstat_query.action?t=1549951114288' form_zte = { 'starttime': startTime + ' 00:00:00', 'endtime': endTime + ' 00:00:00', 'cpid': '000000000000', 'servicetype': 'total' } f_zte = ww.post_web_page_ssl(url_zte, form_zte, cookie_zte) # print(f) zte_dict = json.loads(f_zte) online_user = zte_dict['onlineusers'] bandwidth = zte_dict['bandwidth'] max_rate_tmp = max(bandwidth) mean_rate = round(sum(bandwidth) / len(bandwidth), 2) max_rate = max(bandwidth) max_user = max(online_user) print('max user: '******'max rate: ', max_rate) print('mean rate: ', mean_rate) # 获取峰值时间段 iptv_time_tmp = str(zte_dict['xaxis'][bandwidth.index(max_rate_tmp)])[11:] # print(bandwidth.index(max_rate_tmp)) # print(iptv_time_tmp) h = iptv_time_tmp[0:2] m = iptv_time_tmp[3:5] # print(h, m) t = (2018, 12, 31, int(h) + 8, int(m), 0, 0, 0, 0) # 鬼知道中兴的研发在搞什么 timestamp_iptv = time.mktime(t) peak_period = timestamp_to_date(timestamp_iptv - 1800) + '-' + timestamp_to_date(timestamp_iptv + 1800) print('峰值时间段:', peak_period) return max_user, max_rate, mean_rate, peak_period
def query_ottnode_zte(n, cookie): url = 'https://117.135.56.61:8443/monitor/ottnode_query.action' form = { 'areaid': '# all#', 'nodeid': NODE_DICT[n], 'starttime': startTime + ' 00:00:00', 'endtime': endTime + ' 00:00:00' } f = ww.post_web_page_ssl(url, form, cookie) encodedjson = json.loads(f) # unit单位 upstreamband回源带宽 # print(encodedjson.keys()) # for item in encodedjson.keys(): # print(max(encodedjson[item])) # exit() upstreamband = max(encodedjson['upstreamband']) concurrent = max(encodedjson['concurrent']) # 并发用户数吗 bandwidth = max(encodedjson['bandwidth']) # date rate mean = sum(encodedjson['bandwidth']) / len(encodedjson['bandwidth']) # 数值小的时候 传过来的单位会变 if encodedjson['unit'] == 'Mbps': return round(float(bandwidth) / 1024, 2), round(mean / 1024, 2), concurrent else: return float(bandwidth), round(mean, 2), concurrent
def zte(n): startTime = (datetime.datetime.now() - datetime.timedelta(n + 1)).strftime('%Y-%m-%d') endTime = (datetime.datetime.now() - datetime.timedelta(n)).strftime('%Y-%m-%d') # print(startTime, endTime) cookie_zte = wl.zte_anyservice_uniportal_v2() url_zte = 'https://117.135.56.61:8443/monitor/ottnode_query.action' # form_zte = { # 'starttime': startTime + ' 00:00:00', # 'endtime': endTime + ' 00:00:00', # 'cpid': '000000000000', # 'servicetype': 'total' # } form_zte = { 'granularity': '5', 'starttime': startTime + ' 00:00:00', 'endtime': endTime + ' 00:00:00', # 'cpid': '000000000000', 'areaid': '#all#', 'nodeid': 'all' } f_zte = ww.post_web_page_ssl(url_zte, form_zte, cookie_zte) # print(f_zte) zte_dict = json.loads(f_zte) # 读json(str) => dict # print(zte_dict) # print(zte_dict.keys(), len(zte_dict)) online_user = zte_dict['concurrent'] bandwidth = zte_dict['bandwidth'] max_rate_tmp = max(bandwidth) mean_rate = round(sum(bandwidth) / len(bandwidth), 2) max_rate = max(bandwidth) max_user = max(online_user) print(startTime) print('max user: '******'max rate: ', max_rate) print('mean rate: ', mean_rate) # 获取峰值时间段 # iptv_time_tmp = str(zte_dict['xaxis'][bandwidth.index(max_rate_tmp)])[11:] # # print(bandwidth.index(max_rate_tmp)) # # print(iptv_time_tmp) # h = iptv_time_tmp[0:2] # m = iptv_time_tmp[3:5] # # print(h, m) # t = (2018, 12, 31, int(h) + 8, int(m), 0, 0, 0, 0) # 鬼知道中兴的研发在搞什么 # timestamp_iptv = time.mktime(t) # peak_period = timestamp_to_date(timestamp_iptv - 1800) + '-' + timestamp_to_date(timestamp_iptv + 1800) # print('峰值时间段:', peak_period) # return max_user, max_rate, mean_rate, peak_period return max_user, max_rate, mean_rate
def login_wangluoquanjingkeshihua(): cookie = 'ERROR' url = 'https://117.136.129.122/cmnet/index.htm' cj = ww.get_cookie_without_form(url) for item in cj: cookie = item.name + '=' + item.value print(cookie) # cookie = 'JSESSIONID=3276F5B76C95383468C71976890DF58C' date = int(time.time() * 1000) temp = myPackages.number_base_conversion.base_n(date, 36) url = 'https://117.136.129.122/cmnet/validateCode.htm?temp=' + temp ww.get_validate_code(url, cookie) url = 'https://117.136.129.122/cmnet/login.htm' pwd = input('输入验证码,谢谢') form = { 'username': r'Xw1OfZDqN27WleNrhSAYAQ==', 'password': r'gS4MY8BMAeRRfMVQswEVWA==', 'exPassword': pwd } ww.post_web_page_ssl(url, form, cookie) return cookie
def get_httpstatus(): # 节点状态码 url = 'https://39.134.88.198:8443/stat/nodestatuscode_query.action' form = { 'offset': '8', 'beginDate': begin + ' 00:00:00', 'endDate': end + ' 00:00:00', 'areaid': '', 'nodeid': 'SMALLcache', 'deviceid': '', 'servicemode': '', 'cachetype': '', 'inserttypeid': '', 'terminalid': '', 'ratetype': '', 'domain': '', } f = ww.post_web_page_ssl(url, form, cookie) tmp_dict = json.loads(f) "EDIT SCRIPT FROM HERE" tmp_dict = tmp_dict['message'] # print(len(tmp_dict)) # print(tmp_dict[0]['errormessage'][0]['errornum']) httpstatus = list() for i in range(5): httpstatus.append(0) for item in tmp_dict: if isinstance(item, dict): # print(item) for i in range(5): httpstatus[i] += int(item['errormessage'][i]['errornum']) httpstatus.append(round(httpstatus[1]/sum(httpstatus)*100, 2)) return httpstatus