grr/server/grr_response_server/databases/mysql_clients.py
def MultiReadClientFullInfo(self, client_ids, min_last_ping=None,
                              cursor=None):
    """Reads full client information for a list of clients."""
    query = (
        "SELECT "
        "c.client_id, c.fleetspeak_enabled, c.certificate, c.last_ping, "
        "c.last_clock, c.last_ip, c.last_foreman, c.first_seen, "
        "c.last_client_timestamp, c.last_crash_timestamp, "
        "c.last_startup_timestamp, h.client_snapshot, s.startup_info, "
        "s_last.startup_info, l.owner_username, l.label "
        "FROM clients as c "
        "LEFT JOIN client_snapshot_history as h ON ( "
        "c.client_id = h.client_id AND h.timestamp = c.last_client_timestamp) "
        "LEFT JOIN client_startup_history as s ON ( "
        "c.client_id = s.client_id AND s.timestamp = c.last_client_timestamp) "
        "LEFT JOIN client_startup_history as s_last ON ( "
        "c.client_id = s_last.client_id "
        "AND s_last.timestamp = c.last_startup_timestamp) "
        "LEFT JOIN client_labels AS l ON (c.client_id = l.client_id) ")

    query += "WHERE c.client_id IN (%s) " % ", ".join(["%s"] * len(client_ids))

    values = [mysql_utils.ClientIDToInt(cid) for cid in client_ids]
    if min_last_ping is not None:
      query += "AND c.last_ping >= %s"
      values.append(mysql_utils.RDFDatetimeToMysqlString(min_last_ping))

    cursor.execute(query, values)
    ret = {}
    for c_id, c_info in self._ResponseToClientsFullInfo(cursor.fetchall()):
      ret[c_id] = c_info

    return ret
Reads full client information for a list of clients.
Reads full client information for a list of clients.
Reads full client information for a list of clients .
def MultiReadClientFullInfo(self, client_ids, min_last_ping=None,
                              cursor=None):
    query = (
        "SELECT "
        "c.client_id, c.fleetspeak_enabled, c.certificate, c.last_ping, "
        "c.last_clock, c.last_ip, c.last_foreman, c.first_seen, "
        "c.last_client_timestamp, c.last_crash_timestamp, "
        "c.last_startup_timestamp, h.client_snapshot, s.startup_info, "
        "s_last.startup_info, l.owner_username, l.label "
        "FROM clients as c "
        "LEFT JOIN client_snapshot_history as h ON ( "
        "c.client_id = h.client_id AND h.timestamp = c.last_client_timestamp) "
        "LEFT JOIN client_startup_history as s ON ( "
        "c.client_id = s.client_id AND s.timestamp = c.last_client_timestamp) "
        "LEFT JOIN client_startup_history as s_last ON ( "
        "c.client_id = s_last.client_id "
        "AND s_last.timestamp = c.last_startup_timestamp) "
        "LEFT JOIN client_labels AS l ON (c.client_id = l.client_id) ")
    query += "WHERE c.client_id IN (%s) " % ", ".join(["%s"] * len(client_ids))
    values = [mysql_utils.ClientIDToInt(cid) for cid in client_ids]
    if min_last_ping is not None:
      query += "AND c.last_ping >= %s"
      values.append(mysql_utils.RDFDatetimeToMysqlString(min_last_ping))
    cursor.execute(query, values)
    ret = {}
    for c_id, c_info in self._ResponseToClientsFullInfo(cursor.fetchall()):
      ret[c_id] = c_info
    return ret
def MultiReadClientFullInfo ( self , client_ids , min_last_ping = None , cursor = None ) : query = ( "SELECT " "c.client_id, c.fleetspeak_enabled, c.certificate, c.last_ping, " "c.last_clock, c.last_ip, c.last_foreman, c.first_seen, " "c.last_client_timestamp, c.last_crash_timestamp, " "c.last_startup_timestamp, h.client_snapshot, s.startup_info, " "s_last.startup_info, l.owner_username, l.label " "FROM clients as c " "LEFT JOIN client_snapshot_history as h ON ( " "c.client_id = h.client_id AND h.timestamp = c.last_client_timestamp) " "LEFT JOIN client_startup_history as s ON ( " "c.client_id = s.client_id AND s.timestamp = c.last_client_timestamp) " "LEFT JOIN client_startup_history as s_last ON ( " "c.client_id = s_last.client_id " "AND s_last.timestamp = c.last_startup_timestamp) " "LEFT JOIN client_labels AS l ON (c.client_id = l.client_id) " ) query += "WHERE c.client_id IN (%s) " % ", " . join ( [ "%s" ] * len ( client_ids ) ) values = [ mysql_utils . ClientIDToInt ( cid ) for cid in client_ids ] if min_last_ping is not None : query += "AND c.last_ping >= %s" values . append ( mysql_utils . RDFDatetimeToMysqlString ( min_last_ping ) ) cursor . execute ( query , values ) ret = { } for c_id , c_info in self . _ResponseToClientsFullInfo ( cursor . fetchall ( ) ) : ret [ c_id ] = c_info return ret
Reads full client information for a list of clients.
Reads full client information for a list of clients .
"""Reads full client information for a list of clients."""
self
client_ids
min_last_ping
cursor