move docker types to docker domain
This commit is contained in:
1 parent
77974682fb
commit
efcc7829d4
7 files changed
+73
-69
No files matched your search
@@ -13,7 +13,7 @@ import {
|
|||||||
ProxyModes,
|
ProxyModes,
|
||||||
} from "@/domain/monitors/monitor.type.js";
|
} from "@/domain/monitors/monitor.type.js";
|
||||||
import { DateRanges, SortOrders } from "@/types/query.js";
|
import { DateRanges, SortOrders } from "@/types/query.js";
|
||||||
import { DockerContainerStates, DockerHealthStatuses, DockerPortProtocols } from "@/types/network.js";
|
import { DockerContainerStates, DockerHealthStatuses, DockerPortProtocols } from "@/domain/docker/docker.type.js";
|
||||||
|
|
||||||
const httpStatusCode = z.number().refine((code) => HttpStatusCodeSet.has(code), { message: "Must be a valid HTTP status code" });
|
const httpStatusCode = z.number().refine((code) => HttpStatusCodeSet.has(code), { message: "Must be a valid HTTP status code" });
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
DockerContainerSummary,
|
DockerContainerSummary,
|
||||||
DockerHealthStatuses,
|
DockerHealthStatuses,
|
||||||
DockerPortProtocols,
|
DockerPortProtocols,
|
||||||
} from "@/types/network.js";
|
} from "@/domain/docker/docker.type.js";
|
||||||
|
|
||||||
type CheckMetadataDocument = Omit<CheckMetadata, "monitorId" | "teamId"> & {
|
type CheckMetadataDocument = Omit<CheckMetadata, "monitorId" | "teamId"> & {
|
||||||
monitorId: Types.ObjectId;
|
monitorId: Types.ObjectId;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import type {
|
|||||||
SnapshotHostInfo,
|
SnapshotHostInfo,
|
||||||
SnapshotMemoryInfo,
|
SnapshotMemoryInfo,
|
||||||
} from "@/domain/checks/check.type.js";
|
} from "@/domain/checks/check.type.js";
|
||||||
import { DockerContainerSummary } from "@/types/network.js";
|
import { DockerContainerSummary } from "@/domain/docker/docker.type.js";
|
||||||
import { toDateString } from "@/utils/mongoMappers.js";
|
import { toDateString } from "@/utils/mongoMappers.js";
|
||||||
|
|
||||||
export type CheckSnapshotSource = Pick<
|
export type CheckSnapshotSource = Pick<
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { MonitorType } from "@/domain/monitors/monitor.type.js";
|
import type { MonitorType } from "@/domain/monitors/monitor.type.js";
|
||||||
import { DockerContainerInfo, DockerContainerSummary } from "@/types/network.js";
|
import { DockerContainerInfo, DockerContainerSummary } from "@/domain/docker/docker.type.js";
|
||||||
import type { Response } from "got";
|
import type { Response } from "got";
|
||||||
|
|
||||||
export const CHECK_TTL_SENTINEL = 366;
|
export const CHECK_TTL_SENTINEL = 366;
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
export const DockerContainerStates = ["created", "running", "paused", "restarting", "removing", "exited", "dead"] as const;
|
||||||
|
export type DockerContainerState = (typeof DockerContainerStates)[number];
|
||||||
|
|
||||||
|
export const DockerHealthStatuses = ["healthy", "unhealthy", "starting", "none"] as const;
|
||||||
|
export type DockerHealthStatus = (typeof DockerHealthStatuses)[number];
|
||||||
|
|
||||||
|
export const DockerPortProtocols = ["tcp", "udp", "sctp"] as const;
|
||||||
|
export type DockerPortProtocol = (typeof DockerPortProtocols)[number];
|
||||||
|
|
||||||
|
export const DockerLogStreams = ["stdout", "stderr"] as const;
|
||||||
|
export type DockerLogStream = (typeof DockerLogStreams)[number];
|
||||||
|
|
||||||
|
export const DOCKER_LOG_TAIL_LINES = 200;
|
||||||
|
|
||||||
|
export interface DockerLogLine {
|
||||||
|
ts: string;
|
||||||
|
stream: DockerLogStream;
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockerContainerLogs {
|
||||||
|
containerId: string;
|
||||||
|
containerName: string;
|
||||||
|
lines: DockerLogLine[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockerContainerPort {
|
||||||
|
privatePort: number;
|
||||||
|
protocol: DockerPortProtocol;
|
||||||
|
publicPort?: number;
|
||||||
|
hostIp?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockerContainerMount {
|
||||||
|
type: string; // open set: bind, volume, tmpfs, image, npipe, cluster, …
|
||||||
|
name?: string;
|
||||||
|
source: string;
|
||||||
|
destination: string;
|
||||||
|
mode: string;
|
||||||
|
rw: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockerContainerInfo {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
image: string;
|
||||||
|
state: DockerContainerState;
|
||||||
|
status: string;
|
||||||
|
health: DockerHealthStatus;
|
||||||
|
cpuPct?: number; // fraction of one core (docker stats convention / 100); exceeds 1 when using multiple cores
|
||||||
|
memoryUsedBytes?: number;
|
||||||
|
memoryLimitBytes?: number;
|
||||||
|
memoryPct?: number; // 0-1 fraction of the memory limit
|
||||||
|
restartCount?: number;
|
||||||
|
startedAt?: string; // ISO date
|
||||||
|
ports?: DockerContainerPort[];
|
||||||
|
mounts?: DockerContainerMount[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockerContainerSummary {
|
||||||
|
total: number;
|
||||||
|
running: number;
|
||||||
|
stopped: number;
|
||||||
|
unhealthy: number;
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { IStatusProvider } from "@/service/network/IStatusProvider.js";
|
import { IStatusProvider } from "@/service/network/IStatusProvider.js";
|
||||||
|
import { DockerStatusPayload, MonitorStatusResponse } from "@/types/network.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DockerContainerInfo,
|
DockerContainerInfo,
|
||||||
DockerContainerMount,
|
DockerContainerMount,
|
||||||
@@ -10,9 +12,7 @@ import {
|
|||||||
DockerHealthStatuses,
|
DockerHealthStatuses,
|
||||||
DockerPortProtocol,
|
DockerPortProtocol,
|
||||||
DockerPortProtocols,
|
DockerPortProtocols,
|
||||||
DockerStatusPayload,
|
} from "@/domain/docker/docker.type.js";
|
||||||
MonitorStatusResponse,
|
|
||||||
} from "@/types/network.js";
|
|
||||||
import { Monitor, MonitorType } from "@/domain/monitors/monitor.type.js";
|
import { Monitor, MonitorType } from "@/domain/monitors/monitor.type.js";
|
||||||
import { ILogger } from "@/utils/logger.js";
|
import { ILogger } from "@/utils/logger.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import type {
|
|||||||
GotTimings,
|
GotTimings,
|
||||||
ILighthouseAudit,
|
ILighthouseAudit,
|
||||||
} from "@/domain/checks/check.type.js";
|
} from "@/domain/checks/check.type.js";
|
||||||
|
import { DockerContainerInfo, DockerContainerLogs, DockerContainerSummary } from "@/domain/docker/docker.type.js";
|
||||||
import type { DnsRecordType, Monitor, MonitorMatchMethod, MonitorStatus, MonitorType } from "@/domain/monitors/monitor.type.js";
|
import type { DnsRecordType, Monitor, MonitorMatchMethod, MonitorStatus, MonitorType } from "@/domain/monitors/monitor.type.js";
|
||||||
|
|
||||||
import type { QueryResult } from "gamedig";
|
import type { QueryResult } from "gamedig";
|
||||||
@@ -97,68 +98,6 @@ export interface HardwareStatusPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Docker host monitoring
|
// Docker host monitoring
|
||||||
export const DockerContainerStates = ["created", "running", "paused", "restarting", "removing", "exited", "dead"] as const;
|
|
||||||
export type DockerContainerState = (typeof DockerContainerStates)[number];
|
|
||||||
|
|
||||||
export const DockerHealthStatuses = ["healthy", "unhealthy", "starting", "none"] as const;
|
|
||||||
export type DockerHealthStatus = (typeof DockerHealthStatuses)[number];
|
|
||||||
|
|
||||||
export const DockerLogStreams = ["stdout", "stderr"] as const;
|
|
||||||
export type DockerLogStream = (typeof DockerLogStreams)[number];
|
|
||||||
export interface DockerLogLine {
|
|
||||||
ts: string;
|
|
||||||
stream: DockerLogStream;
|
|
||||||
text: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DockerContainerLogs {
|
|
||||||
containerId: string;
|
|
||||||
containerName: string;
|
|
||||||
lines: DockerLogLine[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DockerContainerSummary {
|
|
||||||
total: number;
|
|
||||||
running: number;
|
|
||||||
stopped: number;
|
|
||||||
unhealthy: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DockerContainerInfo {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
image: string;
|
|
||||||
state: DockerContainerState;
|
|
||||||
status: string;
|
|
||||||
health: DockerHealthStatus;
|
|
||||||
cpuPct?: number; // fraction of one core (docker stats convention / 100); exceeds 1 when using multiple cores
|
|
||||||
memoryUsedBytes?: number;
|
|
||||||
memoryLimitBytes?: number;
|
|
||||||
memoryPct?: number; // 0-1 fraction of the memory limit
|
|
||||||
restartCount?: number;
|
|
||||||
startedAt?: string; // ISO date
|
|
||||||
ports?: DockerContainerPort[];
|
|
||||||
mounts?: DockerContainerMount[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DockerPortProtocols = ["tcp", "udp", "sctp"] as const;
|
|
||||||
export type DockerPortProtocol = (typeof DockerPortProtocols)[number];
|
|
||||||
|
|
||||||
export interface DockerContainerPort {
|
|
||||||
privatePort: number;
|
|
||||||
protocol: DockerPortProtocol;
|
|
||||||
publicPort?: number;
|
|
||||||
hostIp?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DockerContainerMount {
|
|
||||||
type: string; // open set: bind, volume, tmpfs, image, npipe, cluster, …
|
|
||||||
name?: string;
|
|
||||||
source: string;
|
|
||||||
destination: string;
|
|
||||||
mode: string;
|
|
||||||
rw: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DockerStatusPayload {
|
export interface DockerStatusPayload {
|
||||||
containers: DockerContainerInfo[];
|
containers: DockerContainerInfo[];
|
||||||
|
|||||||
Reference in new issue
Block a user