Esempio n. 1
0
 def findbyid(self,backboneid):
     dbclass = querytrigger()
     sql = "SELECT backbone.id as id, backbone.ip as ip, bina.ad as binaad,bina.id as binaid FROM backbone INNER JOIN bina ON (backbone.binaid = bina.id) WHERE backbone.id = %s ORDER BY backbone.id ASC"
     records = dbclass.selectquery (sql, backboneid)
     if (len (records) > 0):
         for record in records:
             backbone = Backbone (str (record[0]), record[1], record[2], record[3])
     return backbone
Esempio n. 2
0
 def whichbackbone(self):
     dbclass = querytrigger()
     sql = "SELECT backbone.id as id, backbone.ip as ip, bina.ad as binaad FROM backbone INNER JOIN bina ON (backbone.binaid = bina.id) WHERE backbone.switchkontrol = 1 ORDER BY backbone.id ASC"
     records = dbclass.simpleselectquery (sql)
     backboneidlist = []
     soru1 = ""
     if (len (records) > 0):
         for record in records:
             soru1 = soru1 + str (record[0]) + ". " + record[2] + " - " + record[1] + "\n"
             backboneidlist.append (str (record[0]))
     soru1 = soru1 + "Q. Programdan çıkmak için."
     return soru1,backboneidlist
    def __init__(self,
                 snmpcmd="snmpwalk -v 2c",
                 username="******",
                 oid="1.3.6.1.2.1.43.5.1.1.17.1",
                 oid2="1.3.6.1.2.1.25.3.2.1.3.1"):
        self.snmpcmd = snmpcmd
        self.username = username
        self.oid = oid
        self.oid2 = oid2

        dbclass = querytrigger()
        sql = "SELECT ip FROM public.ipadresleri"

        records = dbclass.simpleselectquery(sql)

        iplist = []
        self.iplist = iplist

        for record in records:
            iplist.append(record[0])
    def execute(self, ip):
        stmt = os.popen(self.snmpcmd + " " + self.username + " " + ip + " " +
                        self.oid).read()
        #stmt2 = os.popen(self.snmpcmd + " " + self.username + " " + ip + " " + self.oid2).read()

        a = stmt.split('.')
        c = a[-1]
        d = c[c.find("\"") + 1:len(c) - 2]

        #a1 = stmt2.split('.')
        #print(a1)
        #c1 = a1[-3]
        #print(c1)
        #d1 = c1[c1.find("\"") + 1: len(c1)]
        #print(ip +" : "+d)

        qt = querytrigger()
        updatesql = "UPDATE public.ipadresleri SET serino=%s WHERE ip=%s"
        data = [d, ip]
        qt.insertdeletequery(updatesql, data)
        print("updated")
Esempio n. 5
0
from QueryExecuter import querytrigger

select = querytrigger()
insert = querytrigger()

print(insert.__str__())
print(select.__str__())

sql = "INSERT INTO public.users(id, ad, soyad) VALUES (%s, %s, %s)"
data = ('4', 'erdogan4', 'ozturk4')
records = insert.insertdeletequery(sql, data)

selectsql = "SELECT * FROM public.users LIMIT 100"
selectrecords = select.simpleselectquery(selectsql)
liste = []
for selectrecord in selectrecords:
    liste.append(selectrecord[0])
    print(selectrecord)
Esempio n. 6
0
from SnmpConnections import SnmpProtocol
from QueryExecuter import querytrigger
from Backbone import Backbone
from Switch import Switch
from Client import Client
from Helper import Helper


soru1 = "Bina Seçiniz:\n\n"
dbclass = querytrigger()

sql = "SELECT backbone.id as id, backbone.ip as ip, bina.ad as binaad,bina.id as binaid FROM backbone INNER JOIN bina ON (backbone.binaid = bina.id) WHERE backbone.switchkontrol = 1 ORDER BY backbone.id ASC"
records = dbclass.simpleselectquery(sql)
backboneidlist = []
if(len(records) > 0):
    for record in records:
        soru1 = soru1+str(record[0])+". "+record[2]+" - "+record[1]+"\n"
        backboneidlist.append(record[0])

    soru1 = soru1+"\nçıkmak için q"
    print(soru1)

while True:
    backboneid =input("Bina Seç")
    if(islem=="q"):
        print("program sonlanıyor")
        break
    elif (backboneid in backboneidlist)
        print("içinde")
    else:
        print("geçersiz")