@@ -855,6 +855,8 @@ def upsert_host_heartbeat(
855855 ip_address : str ,
856856 service_name : str ,
857857 last_command_id : Optional [str ] = None ,
858+ received_command_ids : Optional [List [str ]] = None ,
859+ executed_command_ids : Optional [List [str ]] = None ,
858860 status : str = "active" ,
859861 heartbeat_timestamp : Optional [datetime ] = None ,
860862 ) -> bool :
@@ -865,16 +867,21 @@ def upsert_host_heartbeat(
865867 query = """
866868 INSERT INTO HostHeartbeats (
867869 hostname, ip_address, service_name, last_command_id,
870+ received_command_ids, executed_command_ids,
868871 status, heartbeat_timestamp, created_at, updated_at
869872 ) VALUES (
870873 %(hostname)s, %(ip_address)s::inet, %(service_name)s,
871- %(last_command_id)s::uuid, %(status)s::HostStatus,
874+ %(last_command_id)s::uuid, %(received_command_ids)s::uuid[],
875+ %(executed_command_ids)s::uuid[],
876+ %(status)s::HostStatus,
872877 %(heartbeat_timestamp)s, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
873878 )
874879 ON CONFLICT (hostname, service_name)
875880 DO UPDATE SET
876881 ip_address = EXCLUDED.ip_address,
877882 last_command_id = EXCLUDED.last_command_id,
883+ received_command_ids = EXCLUDED.received_command_ids,
884+ executed_command_ids = EXCLUDED.executed_command_ids,
878885 status = EXCLUDED.status,
879886 heartbeat_timestamp = EXCLUDED.heartbeat_timestamp,
880887 updated_at = CURRENT_TIMESTAMP
@@ -885,6 +892,8 @@ def upsert_host_heartbeat(
885892 "ip_address" : ip_address ,
886893 "service_name" : service_name ,
887894 "last_command_id" : last_command_id ,
895+ "received_command_ids" : received_command_ids ,
896+ "executed_command_ids" : executed_command_ids ,
888897 "status" : status ,
889898 "heartbeat_timestamp" : heartbeat_timestamp ,
890899 }
@@ -897,6 +906,7 @@ def get_host_heartbeat(self, hostname: str) -> Optional[Dict]:
897906 query = """
898907 SELECT
899908 hostname, ip_address, service_name, last_command_id,
909+ received_command_ids, executed_command_ids,
900910 status, heartbeat_timestamp, created_at, updated_at
901911 FROM HostHeartbeats
902912 WHERE hostname = %(hostname)s
@@ -911,6 +921,7 @@ def get_active_hosts(self, service_name: Optional[str] = None) -> List[Dict]:
911921 query = """
912922 SELECT
913923 hostname, ip_address, service_name, last_command_id,
924+ received_command_ids, executed_command_ids,
914925 status, heartbeat_timestamp
915926 FROM HostHeartbeats
916927 WHERE status = 'active'
@@ -995,6 +1006,7 @@ def get_all_host_heartbeats(self, limit: Optional[int] = None, offset: Optional[
9951006 query = """
9961007 SELECT
9971008 ID, hostname, ip_address, service_name, last_command_id,
1009+ received_command_ids, executed_command_ids,
9981010 status, heartbeat_timestamp, created_at, updated_at
9991011 FROM HostHeartbeats
10001012 ORDER BY heartbeat_timestamp DESC
@@ -1024,6 +1036,7 @@ def get_host_heartbeats_by_service(self, service_name: str, limit: Optional[int]
10241036 query = f"""
10251037 SELECT
10261038 ID, hostname, ip_address, service_name, last_command_id,
1039+ received_command_ids, executed_command_ids,
10271040 status, heartbeat_timestamp, created_at, updated_at
10281041 FROM HostHeartbeats
10291042 { where_clause }
@@ -1042,6 +1055,7 @@ def get_host_heartbeats_by_status(self, status: str, limit: Optional[int] = None
10421055 query = """
10431056 SELECT
10441057 ID, hostname, ip_address, service_name, last_command_id,
1058+ received_command_ids, executed_command_ids,
10451059 status, heartbeat_timestamp, created_at, updated_at
10461060 FROM HostHeartbeats
10471061 WHERE status = %(status)s
0 commit comments