Esempio n. 1
0
def main(argv):
   c_debug = 0

   try:
      opts, args = getopt.getopt(sys.argv[1:], "dh")
   except getopt.GetoptError:
      helptext()
      return

   for opt, arg in opts:
      if opt == '-h':
         helptext()
         return
      elif opt in ("-d"):
         c_debug=1

   if len(args) != 2:
      helptext()

   ip_address = args[0]
   port = args[1]

   xm    = XenaScriptTools(ip_address)

   if c_debug:
      xm.debugOn()
   xm.haltOn()

   xm.Logon("xena")

   cgs = xm.Send(port + " P4G_INDICES ?").split()[2:]
      
   print "\n==PACKET COUNTS====================="
   xm.PrintPortStatistics(port)
   prx = xm.Send(port + " P4_RX_ETH_COUNTERS ?")
   print prx
   ptx = xm.Send(port + " P4_TX_ETH_COUNTERS ?")
   print ptx
   print "\n==TCP GOODPUT======================="
   for cg in cgs:
      res = xm.Send(port + " P4G_TCP_TX_TOTAL_BYTES [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_TX_GOOD_BYTES [" + cg + "] ?")
      print res
   print "\n==PACKET SIZE DISTRIBUTION==========="
   res = xm.Send(port + " P4_RX_PACKET_SIZE ?")
   print res
   res = xm.Send(port + " P4_TX_PACKET_SIZE ?")
   print res
   print "\n==CONNECTION TIMES=================="
   for cg in cgs:
      res = xm.Send(port + " P4G_TCP_ESTABLISH_TIME [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_ESTABLISH_HIST [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_CLOSE_TIME [" + cg + "] ?")
      print res
      res = xm.Send(port + " P4G_TCP_CLOSE_HIST [" + cg + "] ?")
      print res
   print
Esempio n. 2
0
def main(argv):
    c_debug = 0
    c_res = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dhr")
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-d"):
            c_debug = 1
        elif opt in ("-r"):
            c_res = 1

    arglen = len(args)
    if arglen < 1 or (arglen > 1 and (arglen - 1) % 2 != 0):
        helptext()

    ip_address = args[0]
    if arglen > 1:
        portlist = args[1:]
    else:
        portlist = []

    xm = XenaScriptTools(ip_address)

    if c_debug:
        xm.debugOn()
    xm.haltOn()

    xm.Logon("xena")

    if arglen == 1:
        modules = xm.Send("c_remoteportcounts ?").split()

        for i in range(len(modules) - 1):
            ports = int(modules[i + 1])
            if ports != 0:
                for port in range(ports):
                    portlist.append(str(i) + "/" + str(port))

    if c_res:
        printReservations(xm, portlist)
    else:
        printPortStates(xm, portlist)
Esempio n. 3
0
def main(argv):
    c_debug = 0

    try:
        opts, args = getopt.getopt(sys.argv[1:], "dhn")
    except getopt.GetoptError:
        helptext()
        return

    for opt, arg in opts:
        if opt == '-h':
            helptext()
            return
        elif opt in ("-d"):
            c_debug = 1

    if len(args) != 1:
        helptext()

    ip_address = args[0]

    xm = XenaScriptTools(ip_address)

    if c_debug:
        xm.debugOn()
    xm.haltOn()

    xm.Logon("xena")

    # Start with CHASSIS
    s_serial = xm.Send("C_SERIALNO ?").split()[1]
    versionno = xm.Send("C_VERSIONNO ?").split()
    s_version1 = versionno[1]
    s_version2 = versionno[2]
    r_model = re.search('.*"(.*)"', xm.Send("C_MODEL ?"))
    s_model = r_model.group(1)

    # License stuff
    s_lic_pes = xm.Send("1 M4_LIC_PES ?").split()[2]
    s_lic_p1g = xm.Send("1 M4_LIC_PORTS_1G ?").split()[2]
    s_lic_p10g = xm.Send("1 M4_LIC_PORTS_10G ?").split()[2]
    s_lic_p40g = xm.Send("1 M4_LIC_PORTS_40G ?").split()[2]

    # proceed to MODULE
    r_m_status = re.search('.*"(.*)"', xm.Send(" 1 M4_SYSTEM_STATUS ?"))
    s_m_status = r_m_status.group(1)

    # if module is ok
    if (s_m_status == "OK"):
        s_m_serial = xm.Send("1 M_SERIALNO ?").split()[2]
        s_m_version = xm.Send("1 M_VERSIONNO ?").split()[2]

        r_m_version = re.search('.*"(.*) (.*)"', xm.Send("1 M4_VERSIONNO ?"))
        s_m_verstr = r_m_version.group(1)
        s_m_build = r_m_version.group(2)

        s_m_sysid = xm.Send(" 1 M4_SYSTEMID ?").split()[2]

    print
    print "Date:                   %s" % (datetime.datetime.today())
    print "Chassis ip address:     %s" % (ip_address)
    print "Chassis model:          %s" % (s_model)
    print "Chassis serial number:  %s (0x%08x)" % (s_serial, int(s_serial))

    print "Chassis server version: %s" % (s_version1)
    print "Chassis driver version: %s" % (s_version2)

    print "Module serial number:   %s (0x%08x)" % (s_m_serial, int(s_m_serial))
    print "Module version number:  %s" % (s_m_version)
    print "Module version string:  %s" % (s_m_verstr)
    print "Module status:          %s" % (s_m_status)
    print "Module system id:       %s" % (s_m_sysid)

    print "Licensed PE's:          %s" % (s_lic_pes)
    print "Licensed 1G ports:      %s" % (s_lic_p1g)
    print "Licensed 10G ports:     %s" % (s_lic_p10g)
    print "Licensed 40G ports:     %s" % (s_lic_p40g)
    print "Module build id:        %s" % (s_m_build)
    print

    return 0