(self, ipstart, ipend, rule_id, timestamp)
return None
Given a host (start/end ip) a rule_id, and a log time,
            check if there already exists an identical alert. Return that alert id or -1

        :param ipstart: The ip-range-start to search for in the alert DB
        :param ipend: The ip-range-end to search for in the alert DB
        :param rule_id: The rule to search for in the alert DB. Can be None
        :param timestamp: The log_time (as a datetime object, not number) to search for in the alert DB
        :return: The ID of the alert that matches the above criteria. Returns None if not found.
Given a host (start/end ip) a rule_id, and a log time,
            check if there already exists an identical alert. Return that alert id or -1
Given a host ( start / end ip ) a rule_id and a log time check if there already exists an identical alert . Return that alert id or - 1
def alert_already_exists(self, ipstart, ipend, rule_id, timestamp):
        """
            Given a host (start/end ip) a rule_id, and a log time,
            check if there already exists an identical alert. Return that alert id or -1

        :param ipstart: The ip-range-start to search for in the alert DB
        :param ipend: The ip-range-end to search for in the alert DB
        :param rule_id: The rule to search for in the alert DB. Can be None
        :param timestamp: The log_time (as a datetime object, not number) to search for in the alert DB
        :return: The ID of the alert that matches the above criteria. Returns None if not found.
        """
        qvars = {
            'ips': ipstart,
            'ipe': ipend,
            'log': int(time.mktime(timestamp.timetuple())),
            'rid': rule_id,
        }
        if rule_id:
            where = "ipstart=$ips AND ipend=$ipe AND log_time=$log AND rule_id=$rid"
        else:
            where = "ipstart=$ips AND ipend=$ipe AND log_time=$log AND rule_id IS NULL"

        rows = self.db.select(self.table, what='id', where=where, vars=qvars)
        row = rows.first()
        if row:
            return row['id']
        return None
def alert_already_exists ( self , ipstart , ipend , rule_id , timestamp ) : qvars = { 'ips' : ipstart , 'ipe' : ipend , 'log' : int ( time . mktime ( timestamp . timetuple ( ) ) ) , 'rid' : rule_id , } if rule_id : where = "ipstart=$ips AND ipend=$ipe AND log_time=$log AND rule_id=$rid" else : where = "ipstart=$ips AND ipend=$ipe AND log_time=$log AND rule_id IS NULL" rows = self . db . select ( self . table , what = 'id' , where = where , vars = qvars ) row = rows . first ( ) if row : return row [ 'id' ] return None