示例#1
0
def a():
	df = file_to_pd('/Users/jpatel/Documents/Techdocs/mip_reg_vip')
	df['physregion'] = df['physregion'].str.replace(',','')
	df.set_index(['physregion'], inplace = True)
	tempdf = df.ix['20087']
	tempdf.drop_duplicates(subset='machineIP',inplace = True)
	for i in tempdf['machineIP']:
		cmd = 'nsh ' + i + ' grep --range ' + 'start' + '-' + 'end' + " '" + "abcd" + "' /ghostcache/logs/" + 'iked.log'
示例#2
0
def populate_sets():
	df = file_to_pd('/Users/jpatel/Desktop/allnevep')
	df['custID'] = df['custID'].str.replace(',','') 
	df['epID'] = df['epID'].str.replace(',','') 
	df['slot'] = df['slot'].str.replace(',','') 
	df['gwReg'] = df['gwReg'].str.replace(',','') 
	custID_list = df['custID'].unique().tolist()
	slot_list = df['slot'].unique().tolist()
	version_list = df['version'].unique().tolist()
	gwCity_list = df['gwCity'].unique().tolist()
	gwCntry_list = df['gwCntry'].unique().tolist()
	gwCont_list = df['gwCont'].unique().tolist()
	return(custID_list, slot_list, version_list, gwCity_list, gwCntry_list, gwCont_list)
示例#3
0
def findcpe(request):

  if request.method == 'POST':
    d = FindcpeForm(request.POST)
    if d.is_valid():
      cd = d.cleaned_data
      # LOGIC FOR DATA COLLECTED
      nonnull_cd ={}
      for k,v in cd.items():
      	if v != None and v != '':
      		nonnull_cd[k] = v
      df = file_to_pd('/Users/jpatel/Desktop/allnevep')
      df['custID'] = df['custID'].str.replace(',','') 
      df['epID'] = df['epID'].str.replace(',','').astype(int)
      df['slot'] = df['slot'].str.replace(',','') 
      df['gwReg'] = df['gwReg'].str.replace(',','') .astype(int)

      for k2,v2 in nonnull_cd.items():
      	df = df[df[k2] == v2]

      file_age = (time.time() - os.path.getmtime('/Users/jpatel/Desktop/allnevep'))//60
      
      context = {
			"op": df.to_html(classes="table table-striped", index=False),
      "file_age" : file_age               
			}
      return render(request, 'findcpe_result.html', context)
    else:
      context = {
                   "form" : d
                   }
      return render(request, 'findcpe_form.html',context)
  else:
    d = FindcpeForm()
    context = {
             "form" : d,
             }
    return render(request, 'findcpe_form.html', context)
示例#4
0
	# edge_vip = input("Edge VIP: ")
	print('\nPlease make sure mip_reg_vip and region_info files are up-to-date in Techdocs.')
	# Jay VPN:
	edge_vip = '63.217.233.117'
	endpoint_id = '*****@*****.**'

	# Jay SAAS
	# edge_vip = '23.75.23.253'
	# endpoint_id = '*****@*****.**'

	# OBS
	# edge_vip = '81.171.120.175'
	# endpoint_id = '*****@*****.**'

	print('\n========================================================')
	df1 = file_to_pd('/Users/jpatel/Documents/Techdocs/mip_reg_vip')
	df1.set_index(['vip'], inplace = True)
	df1['physregion'] = df1['physregion'].str.replace(',','')
	# # print(df1[df1['vip'] == '120.29.145.227'])  # Works if index is not set
	# print (df1.ix['120.29.145.227'])  # works if index is set
	# print(df1.loc['120.29.145.227'])  # works if index is set	
	tempdf1 = df1.ix[edge_vip]
	print('Machines behind the VIP: \n', tempdf1)
	edge_reg_str = str(tempdf1.iloc[0][1])
	reg_df1 = region_info(edge_reg_str)
	print('\nEdge Region:  ',edge_reg_str, reg_df1['city'], reg_df1['country'])

	print('\n========================================================')
	# print(tempdf1.iloc[0][0])
	cmd1 = 'gwsh -i /Users/jpatel/.ssh/deployed/2016-04-18 -l testgrp ' + tempdf1.iloc[0][0] + '  /a/bin/qed /ipsecd_endpoint w9=' + endpoint_id 
	print('Running on first machine in above list: ', cmd1)
示例#5
0
#! /usr/bin/env python3
import pandas as pd
from jfunc import run_cmd_print, file_to_pd
import multiprocessing

if __name__ == "__main__":
    edge_vip = input("Edge VIP: ")
    start_time = input("Start time (MM/DD/YY/HH:MM): ")
    end_time = input("End time (MM/DD/YY/HH:MM): ")
    search_keyword = input("Keyword to search: ")
    df = file_to_pd("/Users/jpatel/Documents/Techdocs/mip_reg_vip")
    # print(df)
    df.set_index(["vip"], inplace=True)
    df["physregion"] = df["physregion"].str.replace(",", "")
    # # print(df[df['vip'] == '120.29.145.227'])  # Works if index is not set
    # print (df.ix['120.29.145.227'])  # works if index is set
    # print(df.loc['120.29.145.227'])  # works if index is set
    tempdf = df.ix[edge_vip]
    for i in tempdf["machineIP"]:
        cmd = (
            "nsh "
            + i
            + " grep --range "
            + start_time
            + "-"
            + end_time
            + " "
            + search_keyword
            + " /ghostcache/logs/sripd.log"
        )
        p = multiprocessing.Process(target=run_cmd_print, args=(cmd,))