Ejemplo n.º 1
0
def dashboard():
    rx = []
    tx = []

    list_switches = get_sw_list()
    #    list_switches=[1,3]
    if current_user.group != 'tec':
        post = []
        posts = current_user.posts
        for i in posts[::-1]:
            post.append(i)
        keys = (current_user.sw_id.encode('ascii'),
                current_user.sw_port.encode('ascii'))
        print(keys)
        rx, tx = speed(keys)
        print(rx, tx)

        return render_template('dashboard.html',
                               title='Dashboard',
                               posts=post,
                               rx=rx,
                               tx=tx)

    else:
        switches = []
        my_god = []
        switch = Switches.query.all()
        for i in switch[::]:
            switches.append(i.id)
        return render_template('tec_dashboard.html',
                               title='Dashboard',
                               switches=switches,
                               list_switches=list_switches)
Ejemplo n.º 2
0
def dashboard():
  rx=[]
  tx=[]

  list_switches = get_sw_list()
  #    list_switches=[1,3]    
  if current_user.group!='tec':
    post =[]
    posts =current_user.posts
    for i in posts[::-1]:
      post.append(i)        
    u=db.session.query(Banda).filter(Banda.sw_id==current_user.sw_id, Banda.porta==current_user.sw_port).order_by(Banda.time.desc()).limit(10)

    for i in u:
      #print i
      rx.append(float(i.rx_bytes))
      tx.append(float(i.tx_bytes))
    #print(rx , tx)  
    f_rx,f_tx = speed(rx,tx)
#    L.append([float(f_rx),now.strftime("%H:%M")])
    return render_template('dashboard.html', title='Dashboard', posts=post, rx=f_rx, tx=f_tx)

  else:
    
    switches=[]
    my_god=[]
    switch= Switches.query.all()
    for i in switch[::]:
      switches.append(i.id)
    u = db.session.query(Banda).order_by(Banda.time.desc()).limit(6)   

    for i in u:
            my_god.append([i.sw_id, i.porta,i.tx_bytes,i.rx_bytes]) 

    return render_template('tec_dashboard.html',title='Dashboard', switches=switches, list_switches=list_switches, sw_dados= my_god)
Ejemplo n.º 3
0
def dashboard():
  rx=[]
  tx=[]
  tempo= -1
  controller ='mysdncontroller.local'
  list_switches =None
  switches=[]
  my_god=[]
  try:
   try:
    list_switches = get_sw_list()
    controle = list_switches
    if controle!= []: 
     tempo=1
     controle= None
    else:
     tempo= tempo-1
   except:
    tempo= tempo -1
    print("ERRO TO GET SWITCHES") 
   if current_user.group!='tec':
    post =[]
    posts =current_user.posts
#    for i in posts[::-1]:
#     post.append(i)        
#    u=db.session.query(Banda).filter(Banda.sw_id==current_user.sw_id, Banda.porta==current_user.sw_port).order_by(Banda.time.desc()).limit(10)
#    #print(u)
#    for i in u:
#      #print i
#     tempo.append(str(i.time))
#     rx.append(float(i.rx_bytes))
#     tx.append(float(i.tx_bytes))
#    f_rx,f_tx = speed(rx,tx,tempo)
    return render_template('dashboard.html', title='Dashboard', posts=post, rx= rx, tx= tx)
   else:
    switch= Switches.query.all()
    for i in switch[::]:
     switches.append(i.sw_id)
     
    for sw_id in switches:
       resp= trafego_(sw_id)         
       for i in resp:
        if len(my_god) < 20:
         my_god.append([resp['dpid'],resp['port_no'],resp['tx_bytes'], resp['rx_bytes']])
        else: 
         my_god.pop(0)
         my_god.append([resp['dpid'],resp['port_no'],resp['tx_bytes'], resp['rx_bytes']])
    return render_template('tec_dashboard.html',title='Dashboard',controller=controller,sw_dados= my_god[::-1],tempo=tempo)
  except:
   return render_template('erro1.html',title='Dashboard')
Ejemplo n.º 4
0
def dashboard():
    rx = []
    tx = []

    list_switches = get_sw_list()
    #    list_switches=[1,3]
    if current_user.group != 'tec':
        post = []
        posts = current_user.posts
        for i in posts[::-1]:
            post.append(i)
        keys = (current_user.sw_id.encode('ascii'),
                current_user.sw_port.encode('ascii'))
        print(keys)
        rx, tx = speed(keys)
        print(rx, tx)

        #		u=db.session.query(Banda).filter(Banda.sw_id==current_user.sw_id, Banda.porta==current_user.sw_port).order_by(Banda.time.desc()).limit(10)
        #		for i in u:
        #print(i.rx_bytes , i.tx_bytes)
        #			rx.append(i.rx_bytes)
        #			tx.append(i.tx_bytes)
        #                #print(rx, tx)
        #		rx,tx = speed(rx,tx)
        return render_template('dashboard.html',
                               title='Dashboard',
                               posts=post,
                               rx=rx,
                               tx=tx)

    else:
        switches = []
        my_god = []
        switch = Switches.query.all()
        for i in switch[::]:
            switches.append(i.id)
        #u = db.session.query(Banda).order_by(Banda.time.desc()).limit(6)
        #for i in u:
        #    my_god.append([i.sw_id, i.porta,i.tx_bytes,i.rx_bytes])
        return render_template('tec_dashboard.html',
                               title='Dashboard',
                               switches=switches,
                               list_switches=list_switches)
Ejemplo n.º 5
0
def switch_tmp():
  list_switches = []
  switches=[]
  my_god=[]
  resp =[]
  try:
    list_switches = get_sw_list()
  except:
    pass
  my_god=[]
  switch= Switches.query.all()
  #print(switch)
  for i in switch[::]:
    switches.append(i.sw_id)
    for sw_id in switches:
      resp= trafego_(sw_id)  
      for i in resp:
        if len(my_god) < 20:
          my_god.append([resp['dpid'],resp['port_no'],resp['tx_bytes'], resp['rx_bytes']])
        else: 
          my_god.pop(0)
          my_god.append([resp['dpid'],resp['port_no'],resp['tx_bytes'], resp['rx_bytes']])
  return render_template('tec_dashboard_switches.html',title='Dashboard', switches=switches, list_switches=list_switches)