MCPcopy
hub / github.com/OneUptime/oneuptime / getPostgresStats

Function getPostgresStats

App/API/AdminHealth.ts:118–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116}
117
118async function getPostgresStats(): Promise<JSONObject> {
119 const result: JSONObject = {
120 connected: false,
121 databaseSizeInBytes: null,
122 };
123
124 try {
125 const dataSource: ReturnType<typeof PostgresAppInstance.getDataSource> =
126 PostgresAppInstance.getDataSource();
127
128 if (!dataSource) {
129 return result;
130 }
131
132 const rows: Array<{ size: string }> = await dataSource.query(
133 "SELECT pg_database_size(current_database()) AS size",
134 );
135
136 result["connected"] = true;
137 result["databaseSizeInBytes"] = toNumberOrNull(rows?.[0]?.size);
138 } catch (err) {
139 logger.error("AdminHealth: failed to read Postgres stats");
140 logger.error(err);
141 }
142
143 return result;
144}
145
146async function getClickhouseStats(): Promise<JSONObject> {
147 const result: JSONObject = {

Callers 1

AdminHealth.tsFile · 0.85

Calls 4

toNumberOrNullFunction · 0.70
getDataSourceMethod · 0.45
queryMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected