예제 #1
0
 def insert_hostlist_in_db(self, hostlist):
     """
     Update of the table containing the hosts. Inserts each host in 'hostlist'.
     """
     db = MysqlHandler(self.db_username, self.db_passwd, self.db_dbname)
     for host in hostlist:
         db.update_datas_in_table(
             "ip_monitor",
             {"mac_addr": host._MacAddr},
             {
                 "last_update": str(time.time()).split(".")[0],
                 "ip_addr": host._IpAddr,
                 "hostname": host._Hostname.split(".")[0],
             },
         )
     db.updatedb()
     db.close()
예제 #2
0
    def insert_hostlist_in_db(self, hostlist):
        """
        Update of the table containing the hosts. Inserts each host in 'hostlist'.
        """
        db = MysqlHandler(self.db_username, self.db_passwd, self.db_dbname);
        for host in hostlist:
            db.update_datas_in_table('ip_monitor',
                                     {"mac_addr": host._MacAddr},
                                     {"last_update": str(time.time()).split('.')[0],
                                      "ip_addr": host._IpAddr,
                                      "hostname": host._Hostname.split('.')[0]});
        db.personnal_query("DELETE FROM ip_monitor WHERE last_update<"+str(time.time()-7200).split('.')[0]);
        
        db.updatedb();

        query =  "UPDATE room_device ";
        query += "JOIN ip_monitor ON plus4=mac_addr ";
        query += "SET addr=ip_addr ";
        query += "WHERE protocol_id=6 AND plus4 != '' AND ip_addr != addr";
        self.mysql_handler_personnal_query(query);
        
        db.updatedb();
        
        db.close();