Esempio n. 1
0
def read_zyxel_ping_rxtx (name_well,ip_well,ip_poz,ip_obrab,name_base):
	# echooff=' > /dev/null 2>&1'
	# err = '/usr/local/bin/telegram-send "SUCK 916"'+echooff


	r = pyping.ping(ip_well, count=1)
	if (r.ret_code!=0):
		r = pyping.ping(ip_well, count=1)
	if (r.ret_code!=0):
		r = pyping.ping(ip_well, count=1)


	#Mlcache
	out1=mlcache.mlcacheOn(ip_obrab)
	if (len(out1)==1):
		ml=2
	else:
		ml=-1


	if (len(out1)==5):
		ml=1.8

	average=-100
	
		#average=r.avg_rtt
		#Speed zyxel
	tx,rx=zyxel.speed_zyxel(ip_poz,"5188",10)
		#rx,tx= tellnet.speed(ip_poz,"5188",int(c))
		
	
#		ml=-1
		#subprocess.Popen(err, shell = True)
	# #Speed zyxel
	# tx,rx=zyxel.speed_zyxel(ip_poz,"5188",int(c))
	# ml = -1
	#Текущее время
	if (r.ret_code==0):
		average=r.avg_rtt
	
	timestamp = int(time.time())+60*60*4

	db_name=name_base
	db = MySQLdb.connect(host="127.0.0.1", user="******", passwd="goodman1978", db="pozitron", charset='utf8')
	cursor = db.cursor()
	sql = "INSERT INTO "+db_name+"(date, value, rx, tx, ml) VALUE ("+str(timestamp)+","+str(average)+","+str(rx)+","+str(tx)+","+str(ml)+")"
	cursor.execute(sql)
	db.commit()
Esempio n. 2
0
def read_zyxel_ping_rxtx (poz_type, name_well,ip_well,ip_poz,ip_obrab,name_base,ippoz_modem,ip_signal,ip_dvr, ip_cam1, ip_cam2, ip_cam3, ip_cam4, ip_ub1, ip_ub2, ip_sbor):
	r = pyping.ping(ip_well, count=1)
	if (r.ret_code!=0):
		r = pyping.ping(ip_well, count=1)
	if (r.ret_code!=0):
		r = pyping.ping(ip_well, count=1)


	#Mlcache
	out1=mlcache.mlcacheOn(ip_obrab)
	if (len(out1)==1):
		ml=2
	else:
		ml=-1
	if (len(out1)==5):
		ml=1.8
	average=-100
	
	if (poz_type):
		#Speed poz_br0
		rx,tx= tellnet.speed(ip_poz,"5188",int(c))
	else:
		#Speed zyxel
		tx,rx=zyxel.speed_zyxel(ip_poz,"5188",int(c))
	
	#Speed poz_modem
	mrx, mtx = pozmodem.speed(ippoz_modem,"5188",int(c))
	
	#Signal level
	signal = pozmodemsignal.signal(ip_signal,"5188",int(c))

	#Текущее время
	if (r.ret_code==0):
		average=r.avg_rtt
	#dvr
	r1 = pyping.ping(ip_dvr, count=1)
	if (r1.ret_code!=0):
		r1 = pyping.ping(ip_dvr, count=1)
	if (r1.ret_code!=0):
		r1 = pyping.ping(ip_dvr, count=1)		
	if (r1.ret_code==0):
		dvr=r1.avg_rtt
	#cams
	r2 = pyping.ping(ip_cam1, count=1)
	if (r2.ret_code!=0):
		r2 = pyping.ping(ip_cam1, count=1)
	if (r2.ret_code!=0):
		r2 = pyping.ping(ip_cam1, count=1)		
	if (r2.ret_code==0):
		cam1=r2.avg_rtt
	r3 = pyping.ping(ip_cam2, count=1)
	if (r3.ret_code!=0):
		r3 = pyping.ping(ip_cam2, count=1)
	if (r3.ret_code!=0):
		r3 = pyping.ping(ip_cam2, count=1)		
	if (r3.ret_code==0):
		cam2=r3.avg_rtt
	r4 = pyping.ping(ip_cam3, count=1)
	if (r4.ret_code!=0):
		r4 = pyping.ping(ip_cam3, count=1)
	if (r4.ret_code!=0):
		r4 = pyping.ping(ip_cam3, count=1)		
	if (r4.ret_code==0):
		cam3=r4.avg_rtt
	r5 = pyping.ping(ip_cam4, count=1)
	if (r5.ret_code!=0):
		r5 = pyping.ping(ip_cam4, count=1)
	if (r5.ret_code!=0):
		r5 = pyping.ping(ip_cam4, count=1)		
	if (r5.ret_code==0):
		cam4=r5.avg_rtt
	
	#Ubi1_Ap
	r6 = pyping.ping(ip_ub1, count=1)
	if (r6.ret_code!=0):
		r6 = pyping.ping(ip_ub1, count=1)
	if (r6.ret_code!=0):
		r6 = pyping.ping(ip_ub1, count=1)		
	if (r6.ret_code==0):
		ub1=r6.avg_rtt
		
	#Ubi2_Client
	r7 = pyping.ping(ip_ub2, count=1)
	if (r7.ret_code!=0):
		r7 = pyping.ping(ip_ub2, count=1)
	if (r7.ret_code!=0):
		r7 = pyping.ping(ip_ub2, count=1)		
	if (r7.ret_code==0):
		ub2=r7.avg_rtt
		
	#Sbor
	r8 = pyping.ping(ip_sbor, count=1)
	if (r8.ret_code!=0):
		r8 = pyping.ping(ip_sbor, count=1)
	if (r8.ret_code!=0):
		r8 = pyping.ping(ip_sbor, count=1)		
	if (r8.ret_code==0):
		sbor=r8.avg_rtt
	
	timestamp = int(time.time())+60*60*4

	db_name=name_base
	db = MySQLdb.connect(host="127.0.0.1", user="******", passwd="goodman1978", db="pozitron", charset='utf8')
	cursor = db.cursor()
	sql = "INSERT INTO "+db_name+"(date, value, rx, tx, ml, mrx, mtx, sigpoz, dvr, cam1, cam2, cam3, cam4, ub1, ub2, sbor) VALUE ("+str(timestamp)+","+str(average)+","+str(rx)+","+str(tx)+","+str(ml)+","+str(mrx)+","+str(mtx)+","+str(signal)+","+str(dvr)+","+str(cam1)+","+str(cam2)+","+str(cam3)+","+str(cam4)+","+str(ub1)+","+str(ub2)+","+str(sbor)+")"
	cursor.execute(sql)
	db.commit()
	db.close()
Esempio n. 3
0
def read_zyxel_ping_rxtx(poz_type, name_well, ip_well, ip_poz, ip_obrab,
                         name_base, ippoz_modem, ip_signal, ip_dvr, ip_cam1,
                         ip_cam2, ip_cam3, ip_cam4, ip_ub1, ip_ub2, ip_sbor,
                         analogdvr, ubi_ver):
    #Speed Время измерения
    c = 5
    average, ml, rx, tx, mrx, mtx, signal, dvr, cam1, cam2, cam3, cam4, ub1, ub2, sbor, ub1amc, ub1amq, ub1signal, ub2amc, ub2amq, ub2signal, mlrx, mltx = -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -100.0, -1.0, -1.0, -100.0, -1.0, -1.0, -1.0, -1.0
    #pools={ip_well,ip_dvr,ip_ub1,ip_ub2,ip_sbor,ip_cam1,ip_cam2,ip_cam3,ip_cam4}
    #Mlcache
    out1 = mlcache.mlcacheOn(ip_obrab)
    if (len(out1) == 1 or len(out1) == 2):
        ml = 2
    else:
        ml = -1
    if (len(out1) == 5):
        ml = 1.8
    average = -1
    print "mlcache\n"

    if (poz_type):
        #Speed poz_br0
        rx, tx = tellnet.speed(ip_poz, "5188", int(c))
    else:
        #Speed zyxel
        # if (name_well == "604"):
        # tx,rx = zyxel_wan_all.speed_zyxel(ip_poz,"5188",int(c), "213.80.235.178")
        # else:
        # tx,rx=zyxel.speed_zyxel(ip_poz,"5188",int(c))
        tx, rx = zyxel_wan_all.speed_zyxel(ip_poz, "5188", int(c),
                                           "213.80.235.178")
        mlrx, mltx = zyxel_sngs_port2206.speed_zyxel(ip_poz, "5188", int(c),
                                                     "213.80.235.178")
        #tx,rx=-1,-1
    print "speed zyxel/poz\n"

    #Speed poz_modem
    mrx, mtx = pozmodem.speed(ippoz_modem, "5188", int(c))
    print "speed poz\n"

    #Signal level
    signal = pozmodemsignal.signal(ip_signal, "5188", int(c))
    print "signal poz\n"

    #Signal Ubi1 ubisignal how connect!
    ub1signal, ub1amq, ub1amc = ubisignal_ap.ubisignal(ip_ub1, "22", 5, 2,
                                                       True, ubi_ver)
    print "ubi1\n"

    #Signal Ubi2
    ub2signal, ub2amq, ub2amc = ubisignal_ap.ubisignal(ip_ub2, "22", 5, 2,
                                                       False, ubi_ver)
    print "ubi2\n"

    threadLock.acquire()
    #pings
    #white adrr
    # average,dvr,ub1,ub2,sbor,cam1,cam2,cam3,cam4 = megamultiping.ping(pools)
    average = verbose_ping(ip_well)
    print "ping well\n"
    #average = megamultiping.ping(ip_well)
    #ip_well,ip_dvr,ip_ub1,ip_ub2,ip_sbor,ip_cam1,ip_cam2,ip_cam3,ip_cam4)
    #dvr
    dvr = verbose_ping(ip_dvr)
    print "ping dvr\n"
    #dvr = megamultiping.ping(ip_dvr)
    #Ubi1_Ap
    ub1 = verbose_ping(ip_ub1)
    print "ping ubi1\n"
    #ub1 = megamultiping.ping (ip_ub1)
    #Ubi2_Client
    ub2 = verbose_ping(ip_ub2)
    print "ping ubi2\n"
    #ub2 = megamultiping.ping (ip_ub2)
    #Sbor
    sbor = verbose_ping(ip_sbor)
    print "ping sbor\n"
    #sbor = megamultiping.ping (ip_sbor)

    #cams
    if (analogdvr != True):
        cam1 = verbose_ping(ip_cam1)
        cam2 = verbose_ping(ip_cam2)
        cam3 = verbose_ping(ip_cam3)
        cam4 = verbose_ping(ip_cam4)
        print "ping cams\n"
        # cam1 = megamultiping.ping (ip_cam1)
        # cam2 = megamultiping.ping (ip_cam2)
        # cam3 = megamultiping.ping (ip_cam3)
        # cam4 = megamultiping.ping (ip_cam4)
    else:
        if (dvr > 0):
            #DO TEST ANALOG CAMS!
            cam1 = badanalogcam.check_crash_cam("/var/www/html/mon/poz/" +
                                                name_well + "_1.jpg")
            cam2 = badanalogcam.check_crash_cam("/var/www/html/mon/poz/" +
                                                name_well + "_2.jpg")
            cam3 = badanalogcam.check_crash_cam("/var/www/html/mon/poz/" +
                                                name_well + "_3.jpg")
            cam4 = badanalogcam.check_crash_cam("/var/www/html/mon/poz/" +
                                                name_well + "_4.jpg")

            # cam1=1
            # cam2=1
            # cam3=1
            # cam4=1

    threadLock.release()

    # #Текущее время
    timestamp = int(time.time()) + 60 * 60 * 4

    db_name = name_base
    db = MySQLdb.connect(host="127.0.0.1",
                         user="******",
                         passwd="goodman1978",
                         db="pozitron",
                         charset='utf8')
    cursor = db.cursor()
    sql = "INSERT INTO " + db_name + "(date, value, rx, tx, ml, mrx, mtx, sigpoz, dvr, cam1, cam2, cam3, cam4, ub1, ub2, sbor, ub1amc, ub1amq, ub1sig, ub2amc, ub2amq, ub2sig, mlrx, mltx) VALUE (" + str(
        timestamp) + "," + str(average) + "," + str(rx) + "," + str(
            tx) + "," + str(ml) + "," + str(mrx) + "," + str(mtx) + "," + str(
                signal) + "," + str(dvr) + "," + str(cam1) + "," + str(
                    cam2) + "," + str(cam3) + "," + str(cam4) + "," + str(
                        ub1) + "," + str(ub2) + "," + str(sbor) + "," + str(
                            ub1amc) + "," + str(ub1amq) + "," + str(
                                ub1signal) + "," + str(ub2amc) + "," + str(
                                    ub2amq) + "," + str(ub2signal) + "," + str(
                                        mlrx) + "," + str(mltx) + ")"
    print sql
    cursor.execute(sql)
    db.commit()
    db.close()
Esempio n. 4
0
def read_zyxel_ping_rxtx(poz_type, name_well, ip_well, ip_poz, ip_obrab,
                         name_base, ippoz_modem, ip_signal, ip_dvr, ip_cam1,
                         ip_cam2, ip_cam3, ip_cam4, ip_ub1, ip_ub2, ip_sbor,
                         analogdvr):
    #Speed Время измерения
    c = 10
    rx, tx, mrx, mtx, signal, dvr, cam1, cam2, cam3, cam4, ub1, ub2, sbor = -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0

    #Mlcache
    out1 = mlcache.mlcacheOn(ip_obrab)
    if (len(out1) == 1):
        ml = 2
    else:
        ml = -1
    if (len(out1) == 5):
        ml = 1.8
    average = -100

    if (poz_type):
        #Speed poz_br0
        rx, tx = tellnet.speed(ip_poz, "5188", int(c))
    else:
        #Speed zyxel
        tx, rx = zyxel.speed_zyxel(ip_poz, "5188", int(c))

    #Speed poz_modem
    mrx, mtx = pozmodem.speed(ippoz_modem, "5188", int(c))

    #Signal level
    signal = pozmodemsignal.signal(ip_signal, "5188", int(c))

    #white adrr
    average = verbose_ping(ip_well)
    #dvr
    dvr = verbose_ping(ip_dvr)

    #cams
    if (analogdvr != True):
        cam1 = verbose_ping(ip_cam1)
        cam2 = verbose_ping(ip_cam2)
        cam3 = verbose_ping(ip_cam3)
        cam4 = verbose_ping(ip_cam4)
    else:
        if (dvr > 0):
            #DO TEST ANALOG CAMS!
            cam1 = 1
            cam2 = 1
            cam3 = 1
            cam4 = 1

    #Ubi1_Ap
    ub1 = verbose_ping(ip_ub1)

    #Ubi2_Client
    ub2 = verbose_ping(ip_ub2)

    #Sbor
    sbor = verbose_ping(ip_sbor)

    # #Текущее время
    timestamp = int(time.time()) + 60 * 60 * 4

    db_name = name_base
    db = MySQLdb.connect(host="127.0.0.1",
                         user="******",
                         passwd="goodman1978",
                         db="pozitron",
                         charset='utf8')
    cursor = db.cursor()
    sql = "INSERT INTO " + db_name + "(date, value, rx, tx, ml, mrx, mtx, sigpoz, dvr, cam1, cam2, cam3, cam4, ub1, ub2, sbor) VALUE (" + str(
        timestamp) + "," + str(average) + "," + str(rx) + "," + str(
            tx) + "," + str(ml) + "," + str(mrx) + "," + str(mtx) + "," + str(
                signal) + "," + str(dvr) + "," + str(cam1) + "," + str(
                    cam2) + "," + str(cam3) + "," + str(cam4) + "," + str(
                        ub1) + "," + str(ub2) + "," + str(sbor) + ")"
    cursor.execute(sql)
    db.commit()