Beispiel #1
0
	def statns(self, client) :
		try : 
			obj = ns_stats.get(client)
			for i in range(len(obj)) :
				print("statns result::req="+str(obj[i].httptotrxrequestbytes)+", res="+str(obj[i].httptotrxresponsebytes) +", tcpclient="+obj[i].tcpcurclientconn+ ", tcp_esta_client"+obj[i].tcpcurclientconnestablished)
		except nitro_exception as e :
			print("Exception::statns::errorcode="+str(e.errorcode)+",message="+ e.message)
		except Exception as e :
			print("Exception::statns::message="+str(e.args))
Beispiel #2
0
 def statns(self, client):
     try:
         obj = ns_stats.get(client)
         for i in range(len(obj)):
             print("statns result::req=" +
                   str(obj[i].httptotrxrequestbytes) + ", res=" +
                   str(obj[i].httptotrxresponsebytes) + ", tcpclient=" +
                   obj[i].tcpcurclientconn + ", tcp_esta_client" +
                   obj[i].tcpcurclientconnestablished)
     except nitro_exception as e:
         print("Exception::statns::errorcode=" + str(e.errorcode) +
               ",message=" + e.message)
     except Exception as e:
         print("Exception::statns::message=" + str(e.args))
 def getNsSystemsStats(self, client):
     try:
         ns_obj = ns_stats.get(client)
         for i in range(len(ns_obj)):
             print("System last started: "+str(ns_obj[i].starttime))
             print("HA Health State: "+str(ns_obj[i].hacurstate))
             print("HA Status: "+str(ns_obj[i].hacurmasterstate))
             print("Memory in use: "+str(ns_obj[i].memuseinmb)+" MBs")
             print("Flash storage usage: "+str(ns_obj[i].disk0perusage)+"%")
             print("Hard drive storage (/var) usage: "+str(ns_obj[i].disk1perusage)+"%")
             print("Average CPU usage: "+str(ns_obj[i].rescpuusage)+"%")
             # this number of cpus should be moved to the hardware stats function
             print("Number of CPUs: "+str(ns_obj[i].numcpus))
     except nitro_exception as e:
         print("Exception::getNsSystemStats::errorCode="+str(e.errorcode)+",message="+e.message)
     except Exception as e:
         print("Exception::getNsSystemStats::message"+str(e.args))
#	nitro = NSNitro(args.host, args.user, args.password, args.ssl)
    if args.ssl:
        nitro_session = nitro_service(args.host, "HTTPS")
        if args.nosslverify:
            nitro_session.certvalidation = False
            nitro_session.hostnameverification = False
    else:
        nitro_session = nitro_service(args.host, "HTTP")

    nitro_session.set_credential(args.user, args.password)
    nitro_session.timeout = 310

    try:
        nitro_session.login()
        try:
            obj = ns_stats.get(nitro_session)
            for i in range(len(obj)):
                if args.warning and args.critical:
                    if (float(obj[i].cpuusagepcnt) >= float(
                            args.critical)) or (float(obj[i].pktcpuusagepcnt)
                                                >= float(args.critical)):
                        print("CRITICAL: CPU " + str(obj[i].cpuusagepcnt) +
                              "%, PE CPU " + str(obj[i].pktcpuusagepcnt) +
                              "% | 'cpu'=" + str(obj[i].cpuusagepcnt) + "%;" +
                              args.warning + ";" + args.critical +
                              ";; 'pecpu'=" + str(obj[i].pktcpuusagepcnt) +
                              "%;" + args.warning + ";" + args.critical + ";;")
                        nitro_session.logout()
                        sys.exit(2)
                    elif (float(obj[i].cpuusagepcnt) >= float(
                            args.warning)) or (float(obj[i].pktcpuusagepcnt) >=
    # 	nitro = NSNitro(args.host, args.user, args.password, args.ssl)
    if args.ssl:
        nitro_session = nitro_service(args.host, "HTTPS")
        nitro_session.certvalidation = False
        nitro_session.hostnameverification = False
    else:
        nitro_session = nitro_service(args.host, "HTTP")

    nitro_session.set_credential(args.user, args.password)
    nitro_session.timeout = 310

    try:
        nitro_session.login()
        try:
            obj = ns_stats.get(nitro_session)
            for i in range(len(obj)):
                if args.warning and args.critical:
                    if (float(obj[i].disk0perusage) >= float(args.critical)) or (
                        float(obj[i].disk1perusage) >= float(args.critical)
                    ):
                        print(
                            "CRITICAL: /flash "
                            + str(obj[i].disk0perusage)
                            + "%, /var "
                            + str(obj[i].disk1perusage)
                            + "% | 'flash'="
                            + str(obj[i].disk0perusage)
                            + "%;"
                            + args.warning
                            + ";"