@cryptotaxi247 / CoPilot / commits / 31c8351a

healthcheck docs (#39)

* healthcheck docs * precommit

taylor_socfortress committed Jul 17, 2023 at 09:20 UTC 31c8351a5a60ce41a5ee5ceef2844a6b924547f4
3 files changed +195
backend/app/services/Healthchecks/__init__.py
backend/docs/healthchecks.md new
+194
@@ -0,0 +1,194 @@
1 +## Healthchecks Overview
2 +
3 +### <span style="color:green">Healthchecks Routes</span>
4 +
5 +# Healthchecks Module
6 +
7 +The `healthchecks.py` module provides a set of HTTP endpoints for checking the health status of different agents in the system.
8 +
9 +## Endpoints
10 +
11 +### GET /healthcheck/agent/full
12 +
13 +This endpoint retrieves a list of all agents who have sent logs within the last 15 minutes. It also returns a list of agents who haven't sent logs within the same timeframe.
14 +
15 +#### Response
16 +
17 +A JSON response containing the list of all available agents along with their log existence status.
18 +
19 +---
20 +
21 +### GET /healthcheck/agent/{agent_id}/full
22 +
23 +This endpoint retrieves the log existence status of a specific agent.
24 +
25 +#### Parameters
26 +
27 +- `agent_id`: The ID of the agent.
28 +
29 +#### Response
30 +
31 +A JSON response containing the log existence status of the agent.
32 +
33 +---
34 +
35 +### GET /healthcheck/agent/wazuh
36 +
37 +This endpoint retrieves a list of all agents whose Wazuh-Agent is running. It also returns a list of agents whose Wazuh-Agent is not running.
38 +
39 +#### Response
40 +
41 +A JSON response containing the list of all available agents along with their Wazuh-Agent status.
42 +
43 +---
44 +
45 +### GET /healthcheck/agent/{agent_id}/wazuh
46 +
47 +This endpoint retrieves the Wazuh-Agent status of a specific agent.
48 +
49 +#### Parameters
50 +
51 +- `agent_id`: The ID of the agent.
52 +
53 +#### Response
54 +
55 +A JSON response containing the Wazuh-Agent status of the agent.
56 +
57 +---
58 +
59 +### GET /healthcheck/agent/velociraptor
60 +
61 +This endpoint retrieves a list of all agents whose Velociraptor service is running. It also returns a list of agents whose Velociraptor service is not running.
62 +
63 +#### Response
64 +
65 +A JSON response containing the list of all available agents along with their Velociraptor service status.
66 +
67 +---
68 +
69 +### GET /healthcheck/agent/{agent_id}/velociraptor
70 +
71 +This endpoint retrieves the Velociraptor service status of a specific agent.
72 +
73 +#### Parameters
74 +
75 +- `agent_id`: The ID of the agent.
76 +
77 +#### Response
78 +
79 +A JSON response containing the Velociraptor service status of the agent.
80 +
81 +::: app.routes.healthchecks
82 +<br>
83 +
84 +### <span style="color:red">Healthcheck Agent Services</span>
85 +
86 +# HealthcheckAgentsService Class
87 +
88 +The `HealthcheckAgentsService` class encapsulates the logic for CoPilot healthchecks. It provides several methods to perform healthchecks and related operations.
89 +
90 +## Methods
91 +
92 +### `__init__`
93 +
94 +The initializer method of the class. It initializes an instance of the `UniversalService` class.
95 +
96 +---
97 +
98 +### `convert_string_to_datetime(date_string: str) -> datetime`
99 +
100 +This method converts a string into a datetime object.
101 +
102 +#### Parameters
103 +
104 +- `date_string`: The date string to be converted.
105 +
106 +#### Returns
107 +
108 +- The converted datetime object.
109 +
110 +---
111 +
112 +### `is_agent_unhealthy(agent: Dict, current_time: datetime) -> bool`
113 +
114 +This method determines if an agent is unhealthy based on the last seen time of the agent and the current time.
115 +
116 +#### Parameters
117 +
118 +- `agent`: The agent data.
119 +- `current_time`: The current time.
120 +
121 +#### Returns
122 +
123 +- A boolean indicating if the agent is unhealthy.
124 +
125 +---
126 +
127 +### `get_indices() -> List[str]`
128 +
129 +This method returns a list of all indices in the Wazuh-Indexer.
130 +
131 +#### Returns
132 +
133 +- A list of all indices.
134 +
135 +---
136 +
137 +### `has_agent_recent_logs(agent: Dict, indices: List[str]) -> bool`
138 +
139 +This method checks if an agent has recent logs.
140 +
141 +#### Parameters
142 +
143 +- `agent`: The agent data.
144 +- `indices`: The indices to be checked.
145 +
146 +#### Returns
147 +
148 +- A boolean indicating if the agent has recent logs.
149 +
150 +---
151 +
152 +### `perform_healthcheck_full(agents: List[Dict], check_logs: bool = False) -> Dict`
153 +
154 +This method performs a full healthcheck on all agents.
155 +
156 +#### Parameters
157 +
158 +- `agents`: A list of all agents.
159 +- `check_logs`: Whether to check if agents have recent logs.
160 +
161 +#### Returns
162 +
163 +- A dictionary containing the healthcheck results for all agents.
164 +
165 +---
166 +
167 +### `perform_healthcheck_wazuh(agents: Union[List[Dict], Dict]) -> Dict`
168 +
169 +This method checks the health of Wazuh agents.
170 +
171 +#### Parameters
172 +
173 +- `agents`: Either a list of agents or a single agent.
174 +
175 +#### Returns
176 +
177 +- A dictionary containing the healthcheck results for Wazuh agents.
178 +
179 +---
180 +
181 +### `perform_healthcheck_velociraptor(agents: Union[List[Dict], Dict]) -> Dict`
182 +
183 +This method checks the health of Velociraptor clients.
184 +
185 +#### Parameters
186 +
187 +- `agents`: Either a list of agents or a single agent.
188 +
189 +#### Returns
190 +
191 +- A dictionary containing the healthcheck results for Velociraptor clients.
192 +
193 +::: app.services.Healthchecks.agents
194 +<br>
backend/mkdocs.yml
+1
@@ -43,6 +43,7 @@ nav:
43 - Shuffle: shuffle.md
44 - Sublime: sublime.md
45 - InfluxDB: influxdb.md
46 + - Healthcehcks: healthchecks.md
47 - SMTP: smtp.md
48
49 markdown_extensions: