Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4d2abd496 | ||
|
|
8f3edac281 | ||
|
|
fd9d265d23 | ||
|
|
0a90a30045 | ||
|
|
0f3c81c052 | ||
|
|
2d58facb97 | ||
|
|
57ceac0c24 | ||
|
|
a526bc5a3e | ||
|
|
fac4516353 | ||
|
|
4db13fb924 | ||
|
|
c97ee22e66 | ||
|
|
98737f92af | ||
|
|
74637f9d2a | ||
|
|
69dbc2fe7a | ||
|
|
d157e200f6 | ||
|
|
594540cff5 | ||
|
|
8e47e8cd3d | ||
|
|
c5d7625a06 | ||
|
|
7763c5e288 | ||
|
|
957988d977 | ||
|
|
0c04c06d4e | ||
|
|
a7ef014b92 | ||
|
|
3822d971cb | ||
|
|
7cb985116e | ||
|
|
2297494d21 | ||
|
|
19a61b6ce4 | ||
|
|
492aed200a | ||
|
|
be2f33b5d1 | ||
|
|
5d48cecee8 | ||
|
|
f0bfe1a152 | ||
|
|
d2ff386f97 | ||
|
|
42eaa75437 | ||
|
|
7fb4e75956 | ||
|
|
87c549960e | ||
|
|
4ac0f1e87f | ||
|
|
5465bee630 | ||
|
|
60a3d46e59 | ||
|
|
e100d54eed | ||
|
|
848d50ec43 | ||
|
|
a9a8686295 | ||
|
|
30a9309bd8 | ||
|
|
ab64cd192b | ||
|
|
5fc2c8c14b | ||
|
|
ea7ce450f1 | ||
|
|
ce77b43705 | ||
|
|
bd2ba804ee | ||
|
|
bd75f7b0fc | ||
|
|
32e4f7514d | ||
|
|
c9e1d35daf | ||
|
|
3be6ae91f2 | ||
|
|
931104fbcf | ||
|
|
1d5cec94a5 | ||
|
|
faeec01a6d | ||
|
|
b8db987579 | ||
|
|
1fad85d48d | ||
|
|
eb70c9f5f0 | ||
|
|
ce025df7b7 | ||
|
|
daf5797fed | ||
|
|
0baa7d9891 | ||
|
|
f6cd0f668f | ||
|
|
9ae83cc34d | ||
|
|
06ebb76948 | ||
|
|
3a8ba154b2 | ||
|
|
089801109e | ||
|
|
a8a4b5c2b4 | ||
|
|
089bda2de0 | ||
|
|
e18e2e26da | ||
|
|
104cf194ac | ||
|
|
de7cdb4aef | ||
|
|
6bdf9891e8 | ||
|
|
27d37ece7d | ||
|
|
b9afca3608 | ||
|
|
b796464241 | ||
|
|
8bf3875d9a | ||
|
|
3b22ce75db |
No files matched your search
@@ -88,3 +88,4 @@ jobs:
|
||||
docker compose down
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
docker system prune -af
|
||||
@@ -0,0 +1,993 @@
|
||||
# Checkmate Codebase Architecture - Docker Monitoring Integration Guide
|
||||
|
||||
## 1. PROJECT STRUCTURE
|
||||
|
||||
### Directory Layout
|
||||
```
|
||||
Checkmate/
|
||||
├── server/ # Backend Node.js/Express
|
||||
│ ├── src/
|
||||
│ │ ├── db/v1|v2/ # Database (MongoDB)
|
||||
│ │ ├── service/v1|v2/ # Business logic
|
||||
│ │ ├── routes/v1|v2/ # API routes
|
||||
│ │ ├── controllers/v1|v2/ # HTTP request handlers
|
||||
│ │ ├── middleware/v1/ # Express middleware
|
||||
│ │ ├── config/ # Service initialization
|
||||
│ │ ├── validation/ # Input validation
|
||||
│ │ └── utils/ # Helper functions
|
||||
│ └── package.json # Dependencies (Node >=20)
|
||||
├── client/ # Frontend React + TypeScript
|
||||
│ ├── src/
|
||||
│ │ ├── Components/v1|v2/ # UI Components
|
||||
│ │ ├── Pages/v1|v2/ # Page layouts
|
||||
│ │ ├── Hooks/ # React hooks (data fetching)
|
||||
│ │ ├── Features/ # Redux slices
|
||||
│ │ └── Utils/ # Utilities & API client
|
||||
│ └── package.json # React, Vite, MUI
|
||||
└── docker/ # Deployment configs
|
||||
```
|
||||
|
||||
### Technology Stack
|
||||
**Backend:**
|
||||
- Express 4.19 (HTTP server)
|
||||
- MongoDB 8.3 (database)
|
||||
- Mongoose (ODM)
|
||||
- BullMQ 5.41 (job queue) - V2 only
|
||||
- super-simple-scheduler 1.4 (job scheduling) - V1
|
||||
- Dockerode 4.0.6 (Docker API client)
|
||||
- JWT authentication
|
||||
- Winston (logging)
|
||||
|
||||
**Frontend:**
|
||||
- React 18.3 + TypeScript
|
||||
- Vite (build tool)
|
||||
- MUI v6 (Material-UI)
|
||||
- Redux Toolkit (state management)
|
||||
- Axios (HTTP client)
|
||||
- React Router (navigation)
|
||||
- i18next (internationalization)
|
||||
|
||||
**Architectures:**
|
||||
- V1: Simpler, SuperSimpleQueue-based job scheduling
|
||||
- V2: TypeScript-based, BullMQ, more structured (in development)
|
||||
|
||||
---
|
||||
|
||||
## 2. MONITOR TYPES & IMPLEMENTATION
|
||||
|
||||
### Supported Monitor Types
|
||||
Defined in `/server/src/db/v1/models/Monitor.js` line 46:
|
||||
```javascript
|
||||
type: {
|
||||
enum: ["http", "ping", "pagespeed", "hardware", "docker", "port", "game"],
|
||||
required: true
|
||||
}
|
||||
```
|
||||
|
||||
### How Monitor Types Are Handled
|
||||
|
||||
#### Request Dispatch (NetworkService)
|
||||
**Location:** `/server/src/service/v1/infrastructure/networkService.js` (580 lines)
|
||||
|
||||
Entry point: `requestStatus(monitor)` - Routes to type-specific handlers:
|
||||
```javascript
|
||||
async requestStatus(monitor) {
|
||||
switch(monitor.type) {
|
||||
case "ping": return await this.requestPing(monitor);
|
||||
case "http": return await this.requestHttp(monitor);
|
||||
case "pagespeed": return await this.requestPageSpeed(monitor);
|
||||
case "hardware": return await this.requestHardware(monitor);
|
||||
case "docker": return await this.requestDocker(monitor);
|
||||
case "port": return await this.requestPort(monitor);
|
||||
case "game": return await this.requestGame(monitor);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### DOCKER IMPLEMENTATION (Lines 289-383)
|
||||
```javascript
|
||||
async requestDocker(monitor) {
|
||||
// Uses Dockerode to connect to /var/run/docker.sock
|
||||
const docker = new this.Docker({
|
||||
socketPath: "/var/run/docker.sock",
|
||||
handleError: true,
|
||||
});
|
||||
|
||||
// Container matching (priority-based):
|
||||
// 1. Exact full ID match (64-char)
|
||||
// 2. Exact name match (case-insensitive)
|
||||
// 3. Partial ID match (backwards compatibility)
|
||||
|
||||
// Returns: { status: bool, code: int, message: string, responseTime: ms }
|
||||
}
|
||||
```
|
||||
|
||||
**Docker Monitor Storage:**
|
||||
- `monitor.url`: Container ID or name (e.g., "my-app" or "a1b2c3d4...")
|
||||
- `monitor.port`: Not used for Docker
|
||||
- Returns: Only status and response time (no detailed metrics)
|
||||
|
||||
#### HARDWARE IMPLEMENTATION (Lines 279-287)
|
||||
```javascript
|
||||
async requestHardware(monitor) {
|
||||
return await this.requestHttp(monitor); // Delegates to HTTP!
|
||||
}
|
||||
```
|
||||
Hardware monitors send HTTP requests to Capture API endpoint with secret authentication.
|
||||
|
||||
### Hardware/Docker Check Data Structure
|
||||
**Location:** `/server/src/db/v1/models/Check.js` (176 lines)
|
||||
|
||||
Check schema includes:
|
||||
```javascript
|
||||
// Common fields
|
||||
monitorId, teamId, type, status, responseTime, message
|
||||
|
||||
// Hardware/Docker specific (capture data):
|
||||
cpu: {
|
||||
physical_core, logical_core, frequency, temperature[],
|
||||
free_percent, usage_percent
|
||||
},
|
||||
memory: {
|
||||
total_bytes, available_bytes, used_bytes, usage_percent
|
||||
},
|
||||
disk: [{
|
||||
read_speed_bytes, write_speed_bytes,
|
||||
total_bytes, free_bytes, usage_percent
|
||||
}],
|
||||
host: { os, platform, kernel_version },
|
||||
errors: [{ metric[], err }],
|
||||
capture: { version, mode },
|
||||
net: [{ name, bytes_sent, bytes_recv, ... }]
|
||||
```
|
||||
|
||||
**TTL:** Auto-deletes after 30 days
|
||||
**Indexes:** monitorId, type, status, updatedAt (optimized for queries)
|
||||
|
||||
---
|
||||
|
||||
## 3. DATABASE SCHEMA
|
||||
|
||||
### Core Models
|
||||
|
||||
#### Monitor Model
|
||||
**File:** `/server/src/db/v1/models/Monitor.js` (208 lines)
|
||||
|
||||
```javascript
|
||||
{
|
||||
userId: ObjectId (immutable, required),
|
||||
teamId: ObjectId (immutable, required),
|
||||
name: String (required),
|
||||
description: String,
|
||||
type: String (enum: http|ping|pagespeed|hardware|docker|port|game),
|
||||
url: String (required) // container name/ID for docker
|
||||
port: Number,
|
||||
interval: Number (ms, default: 60000),
|
||||
isActive: Boolean (default: true),
|
||||
status: Boolean, // Current up/down
|
||||
statusWindow: [Boolean], // Last N checks
|
||||
statusWindowSize: Number (default: 5),
|
||||
statusWindowThreshold: Number (default: 60),
|
||||
|
||||
// Hardware/Docker thresholds
|
||||
thresholds: {
|
||||
usage_cpu: Number (0-1),
|
||||
usage_memory: Number (0-1),
|
||||
usage_disk: Number (0-1),
|
||||
usage_temperature: Number
|
||||
},
|
||||
|
||||
// Notification thresholds
|
||||
alertThreshold: Number (default: 5),
|
||||
cpuAlertThreshold, memoryAlertThreshold, diskAlertThreshold, tempAlertThreshold,
|
||||
|
||||
// Relationships
|
||||
notifications: [ObjectId], // refs to Notification model
|
||||
|
||||
// Advanced
|
||||
secret: String, // For Capture API auth
|
||||
ignoreTlsErrors: Boolean,
|
||||
jsonPath: String,
|
||||
expectedValue: String,
|
||||
matchMethod: String (equal|include|regex),
|
||||
gameId: String,
|
||||
group: String (max 50 chars),
|
||||
|
||||
// Computed
|
||||
uptimePercentage: Number,
|
||||
|
||||
timestamps: true // createdAt, updatedAt
|
||||
}
|
||||
|
||||
// Indexes
|
||||
MonitorSchema.index({ teamId: 1, type: 1 });
|
||||
|
||||
// Pre-hooks
|
||||
pre("findOneAndDelete"): Deletes checks, stats, removes from status pages
|
||||
pre("deleteMany"): Cascade deletes
|
||||
pre("save"): Syncs alertThresholds
|
||||
pre("findOneAndUpdate"): Updates thresholds
|
||||
```
|
||||
|
||||
#### Check Model
|
||||
**File:** `/server/src/db/v1/models/Check.js`
|
||||
|
||||
```javascript
|
||||
{
|
||||
monitorId: ObjectId (ref: Monitor, immutable, indexed),
|
||||
teamId: ObjectId (ref: Team, immutable, indexed),
|
||||
type: String (enum: http|ping|pagespeed|hardware|docker|port|game, indexed),
|
||||
status: Boolean (indexed),
|
||||
responseTime: Number,
|
||||
timings: Object,
|
||||
statusCode: Number,
|
||||
message: String,
|
||||
|
||||
// Acknowledgment
|
||||
ack: Boolean (default: false),
|
||||
ackAt: Date,
|
||||
|
||||
// Hardware fields (see above)
|
||||
cpu, memory, disk[], host, errors[], capture, net[]
|
||||
|
||||
// PageSpeed only
|
||||
accessibility, bestPractices, seo, performance, audits,
|
||||
|
||||
// Expiry
|
||||
expiry: Date (TTL index: 30 days),
|
||||
timestamps: true
|
||||
}
|
||||
|
||||
// Indexes
|
||||
CheckSchema.index({ updatedAt: 1 });
|
||||
CheckSchema.index({ monitorId: 1, updatedAt: 1 });
|
||||
CheckSchema.index({ monitorId: 1, updatedAt: -1 });
|
||||
CheckSchema.index({ teamId: 1, updatedAt: -1 });
|
||||
```
|
||||
|
||||
#### MonitorStats Model
|
||||
**File:** `/server/src/db/v1/models/MonitorStats.js`
|
||||
|
||||
```javascript
|
||||
{
|
||||
monitorId: ObjectId (ref: Monitor, immutable, indexed),
|
||||
avgResponseTime: Number,
|
||||
totalChecks: Number,
|
||||
totalUpChecks: Number,
|
||||
totalDownChecks: Number,
|
||||
uptimePercentage: Number,
|
||||
lastCheckTimestamp: Number,
|
||||
lastResponseTime: Number,
|
||||
timeOfLastFailure: Number,
|
||||
timestamps: true
|
||||
}
|
||||
```
|
||||
|
||||
### Database Access Layer
|
||||
**Location:** `/server/src/db/v1/modules/`
|
||||
|
||||
- `MonitorModule.js` (593 lines) - Monitor CRUD + aggregations
|
||||
- `CheckModule.js` - Check recording
|
||||
- `MonitorModuleQueries.js` - MongoDB aggregation pipelines
|
||||
|
||||
**Key Methods:**
|
||||
```javascript
|
||||
// Creation
|
||||
Monitor.createMonitor({ body, teamId, userId })
|
||||
Monitor.createBulkMonitors(monitors)
|
||||
|
||||
// Retrieval
|
||||
Monitor.getMonitorById(id)
|
||||
Monitor.getMonitorsByTeamId()
|
||||
Monitor.getMonitorStatsById()
|
||||
Monitor.getHardwareDetailsById()
|
||||
|
||||
// Updates
|
||||
Monitor.updateMonitor(id, updateData)
|
||||
|
||||
// Deletions
|
||||
Monitor.deleteMonitor(id)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. API PATTERNS
|
||||
|
||||
### REST Endpoint Structure
|
||||
**Base:** `/api/v1/`
|
||||
|
||||
#### Monitor Routes
|
||||
**File:** `/server/src/routes/v1/monitorRoute.js`
|
||||
|
||||
```
|
||||
GET /monitors getAllMonitors
|
||||
POST /monitors createMonitor
|
||||
DELETE /monitors deleteAllMonitors (superadmin)
|
||||
|
||||
GET /monitors/:monitorId getMonitorById
|
||||
PUT /monitors/:monitorId editMonitor (admin)
|
||||
DELETE /monitors/:monitorId deleteMonitor (admin)
|
||||
|
||||
GET /monitors/team getMonitorsByTeamId
|
||||
GET /monitors/team/with-checks getMonitorsWithChecksByTeamId
|
||||
GET /monitors/team/summary getMonitorsSummaryByTeamId
|
||||
GET /monitors/team/groups getGroupsByTeamId
|
||||
|
||||
GET /monitors/stats/:monitorId getMonitorStatsById
|
||||
GET /monitors/uptime/details/:monitorId getUptimeDetailsById
|
||||
GET /monitors/hardware/details/:monitorId getHardwareDetailsById
|
||||
|
||||
POST /monitors/pause/:monitorId pauseMonitor (admin)
|
||||
POST /monitors/demo addDemoMonitors
|
||||
POST /monitors/bulk createBulkMonitors (CSV upload)
|
||||
POST /monitors/test-email sendTestEmail
|
||||
|
||||
GET /monitors/games getAllGames
|
||||
GET /monitors/certificate/:monitorId fetchCertificate
|
||||
```
|
||||
|
||||
#### Check Routes
|
||||
**File:** `/server/src/routes/v1/checkRoute.js`
|
||||
|
||||
```
|
||||
GET /checks/:monitorId getChecksByMonitorId
|
||||
GET /checks/team/:teamId getChecksByTeamId
|
||||
GET /checks/:monitorId/:checkId getCheckById
|
||||
PUT /checks/:checkId updateCheck (ack)
|
||||
```
|
||||
|
||||
### Request/Response Pattern
|
||||
|
||||
**Create Monitor Request:**
|
||||
```javascript
|
||||
POST /api/v1/monitors
|
||||
Authorization: Bearer <JWT>
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
name: "My Docker Container",
|
||||
description: "Monitors app container",
|
||||
type: "docker",
|
||||
url: "my-app-container", // Container name
|
||||
interval: 60000, // 1 minute
|
||||
isActive: true,
|
||||
secret: "api-key-for-capture", // If using hardware monitoring
|
||||
notifications: ["notif-id-1"],
|
||||
thresholds: {
|
||||
usage_cpu: 0.8, // 80%
|
||||
usage_memory: 0.9, // 90%
|
||||
usage_disk: 0.95
|
||||
},
|
||||
alertThreshold: 5, // Consecutive failures
|
||||
statusWindowSize: 5, // Last 5 checks
|
||||
statusWindowThreshold: 60 // % threshold
|
||||
}
|
||||
|
||||
Response 200:
|
||||
{
|
||||
data: {
|
||||
_id: "monitor-id",
|
||||
name: "My Docker Container",
|
||||
type: "docker",
|
||||
status: true,
|
||||
interval: 60000,
|
||||
...
|
||||
},
|
||||
msg: "Monitor created successfully"
|
||||
}
|
||||
```
|
||||
|
||||
**Edit Monitor Request:**
|
||||
```javascript
|
||||
PUT /api/v1/monitors/:monitorId
|
||||
|
||||
{
|
||||
name: "Updated Name",
|
||||
interval: 120000,
|
||||
thresholds: { usage_cpu: 0.85 },
|
||||
// Partial updates allowed
|
||||
}
|
||||
```
|
||||
|
||||
### Authentication & Authorization
|
||||
|
||||
**JWT Middleware:** `/server/src/middleware/v1/verifyJWT.js`
|
||||
- Header: `Authorization: Bearer <token>`
|
||||
- Validates signature using `jwtSecret` from AppSettings
|
||||
- Extracts user info: `req.user = { userId, teamId, role, ... }`
|
||||
|
||||
**Role-Based Access:**
|
||||
```javascript
|
||||
// isAllowed middleware checks req.user.role
|
||||
router.post("/monitors", isAllowed(["admin", "superadmin"]), createMonitor);
|
||||
router.delete("/monitors/:monitorId", isAllowed(["admin", "superadmin"]), deleteMonitor);
|
||||
```
|
||||
|
||||
### Validation
|
||||
**File:** `/server/src/validation/joi.js`
|
||||
|
||||
```javascript
|
||||
const createMonitorBodyValidation = joi.object({
|
||||
name: joi.string().required(),
|
||||
description: joi.string().required(),
|
||||
type: joi.string().required(),
|
||||
url: joi.string().required(),
|
||||
interval: joi.number(),
|
||||
port: joi.number(),
|
||||
thresholds: joi.object().keys({
|
||||
usage_cpu: joi.number(),
|
||||
usage_memory: joi.number(),
|
||||
usage_disk: joi.number(),
|
||||
usage_temperature: joi.number(),
|
||||
}),
|
||||
notifications: joi.array().items(joi.string()),
|
||||
secret: joi.string(),
|
||||
// ... more fields
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. POLLING/JOBS IMPLEMENTATION
|
||||
|
||||
### Job Queue Architecture
|
||||
|
||||
#### V1: SuperSimpleScheduler (Production)
|
||||
**Files:**
|
||||
- `/server/src/service/v1/infrastructure/SuperSimpleQueue/SuperSimpleQueue.js`
|
||||
- `/server/src/service/v1/infrastructure/SuperSimpleQueue/SuperSimpleQueueHelper.js`
|
||||
|
||||
**Job Lifecycle:**
|
||||
|
||||
1. **Initialization** (on server startup):
|
||||
```javascript
|
||||
// Load all monitors from DB
|
||||
const monitors = await db.monitorModule.getAllMonitors();
|
||||
for (const monitor of monitors) {
|
||||
// Add job with random offset (0-100ms)
|
||||
this.addJob(monitor._id, monitor);
|
||||
}
|
||||
|
||||
// Register job template
|
||||
scheduler.addTemplate("monitor-job", this.helper.getMonitorJob());
|
||||
```
|
||||
|
||||
2. **Job Template** (executed per interval):
|
||||
```javascript
|
||||
getMonitorJob = () => {
|
||||
return async (monitor) => {
|
||||
// Check maintenance window
|
||||
if (await this.isInMaintenanceWindow(monitorId, teamId)) {
|
||||
return; // Skip
|
||||
}
|
||||
|
||||
// Execute monitor check
|
||||
const networkResponse = await this.networkService.requestStatus(monitor);
|
||||
|
||||
// Update monitor status
|
||||
const { monitor: updated, statusChanged } =
|
||||
await this.statusService.updateStatus(networkResponse);
|
||||
|
||||
// Send notifications if status changed
|
||||
if (statusChanged) {
|
||||
await this.notificationService.handleNotifications({
|
||||
...networkResponse,
|
||||
monitor: updated,
|
||||
prevStatus,
|
||||
statusChanged
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
3. **Job Control:**
|
||||
```javascript
|
||||
// Add job
|
||||
addJob(monitorId, monitor) {
|
||||
scheduler.addJob({
|
||||
id: monitorId.toString(),
|
||||
template: "monitor-job",
|
||||
repeat: monitor.interval, // Milliseconds
|
||||
active: monitor.isActive,
|
||||
data: monitor.toObject()
|
||||
});
|
||||
}
|
||||
|
||||
// Pause/Resume
|
||||
pauseJob(monitor) { scheduler.pauseJob(monitor._id); }
|
||||
resumeJob(monitor) { scheduler.resumeJob(monitor._id); }
|
||||
|
||||
// Update interval
|
||||
updateJob(monitor) {
|
||||
scheduler.updateJob(monitor._id, {
|
||||
repeat: monitor.interval,
|
||||
data: monitor.toObject()
|
||||
});
|
||||
}
|
||||
|
||||
// Delete
|
||||
deleteJob(monitor) { scheduler.removeJob(monitor._id); }
|
||||
```
|
||||
|
||||
#### V2: BullMQ (TypeScript, Planned)
|
||||
**Files:**
|
||||
- `/server/src/service/v2/infrastructure/JobQueue.ts`
|
||||
- `/server/src/service/v2/infrastructure/JobGenerator.ts`
|
||||
|
||||
**Key Differences:**
|
||||
- Uses Redis backing store
|
||||
- TypeScript interfaces (type safety)
|
||||
- More robust queue management
|
||||
- Cleanup jobs for orphaned checks
|
||||
|
||||
```typescript
|
||||
// Cleanup job runs every 24 hours
|
||||
scheduler.addJob({
|
||||
id: "cleanup-orphaned-checks",
|
||||
template: "cleanup-job",
|
||||
repeat: 24 * 60 * 60 * 1000,
|
||||
active: true
|
||||
});
|
||||
```
|
||||
|
||||
### Monitor Execution Flow
|
||||
|
||||
```
|
||||
Monitor Created/Updated
|
||||
↓
|
||||
MonitorService.createMonitor()
|
||||
↓
|
||||
jobQueue.addJob(monitor)
|
||||
↓
|
||||
Job scheduled at interval
|
||||
↓
|
||||
[Job Execution]
|
||||
├─ Check maintenance window
|
||||
├─ NetworkService.requestStatus(monitor)
|
||||
│ └─ Routes to type handler (requestDocker, requestHttp, etc)
|
||||
├─ Create Check record (database)
|
||||
├─ StatusService.updateMonitorStatus()
|
||||
│ └─ Updates Monitor.status field
|
||||
├─ MonitorStatsService.updateStats()
|
||||
├─ If status changed → NotificationService.handleNotifications()
|
||||
└─ Job completes / reschedules for next interval
|
||||
```
|
||||
|
||||
### Status Update Logic
|
||||
**Location:** `/server/src/service/v1/infrastructure/statusService.js`
|
||||
|
||||
```javascript
|
||||
async updateStatus(networkResponse) {
|
||||
// networkResponse = { monitorId, type, status, code, message, responseTime }
|
||||
|
||||
// 1. Create Check record
|
||||
const check = await Check.create({
|
||||
monitorId, teamId, type, status,
|
||||
responseTime, statusCode: code, message
|
||||
});
|
||||
|
||||
// 2. Get previous status
|
||||
const prevStatus = monitor.status;
|
||||
|
||||
// 3. Apply statusWindow logic (sliding window of checks)
|
||||
monitor.statusWindow.push(status);
|
||||
if (monitor.statusWindow.length > monitor.statusWindowSize) {
|
||||
monitor.statusWindow.shift();
|
||||
}
|
||||
|
||||
// 4. Determine if DOWN (majority of window is false)
|
||||
const downCount = monitor.statusWindow.filter(s => !s).length;
|
||||
const isDown = (downCount / monitor.statusWindowSize) >
|
||||
(monitor.statusWindowThreshold / 100);
|
||||
|
||||
monitor.status = isDown ? false : true;
|
||||
|
||||
// 5. Return status change info
|
||||
return {
|
||||
monitor: await monitor.save(),
|
||||
statusChanged: prevStatus !== monitor.status,
|
||||
prevStatus
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. FRONTEND COMPONENTS
|
||||
|
||||
### Monitor Management Pages
|
||||
|
||||
#### Infrastructure Monitors (Hardware/Docker)
|
||||
**Location:** `/client/src/Pages/v1/Infrastructure/`
|
||||
|
||||
```
|
||||
Infrastructure/
|
||||
├── Create/
|
||||
│ ├── index.jsx (Main form - 10K lines)
|
||||
│ ├── Components/
|
||||
│ │ ├── MonitorStatusHeader.jsx
|
||||
│ │ ├── MonitorActionButtons.jsx
|
||||
│ │ └── CustomAlertsSection.jsx
|
||||
│ └── hooks/
|
||||
│ ├── useInfrastructureMonitorForm.jsx
|
||||
│ ├── useValidateInfrastructureForm.jsx
|
||||
│ └── useInfrastructureSubmit.jsx
|
||||
├── Details/
|
||||
├── Monitors/
|
||||
│ └── Components/
|
||||
│ └── MonitorsTable.jsx
|
||||
```
|
||||
|
||||
#### Form Structure (useInfrastructureMonitorForm hook)
|
||||
```javascript
|
||||
const [infrastructureMonitor, setInfrastructureMonitor] = useState({
|
||||
url: "", // Container name/IP
|
||||
name: "", // Display name
|
||||
notifications: [], // Notification IDs
|
||||
interval: 0.25, // Minutes (0.25 = 15s, 1 = 60s)
|
||||
|
||||
// Threshold toggles
|
||||
cpu: false,
|
||||
usage_cpu: "", // Percentage
|
||||
memory: false,
|
||||
usage_memory: "",
|
||||
disk: false,
|
||||
usage_disk: "",
|
||||
temperature: false,
|
||||
usage_temperature: "",
|
||||
|
||||
secret: "", // Capture API secret
|
||||
statusWindowSize: 5,
|
||||
statusWindowThreshold: 60
|
||||
});
|
||||
```
|
||||
|
||||
**Frequency Options:**
|
||||
```javascript
|
||||
[
|
||||
{ _id: 0.25, name: "15 Seconds" },
|
||||
{ _id: 0.5, name: "30 Seconds" },
|
||||
{ _id: 1, name: "1 Minute" },
|
||||
{ _id: 2, name: "2 Minutes" },
|
||||
{ _id: 5, name: "5 Minutes" },
|
||||
{ _id: 10, name: "10 Minutes" }
|
||||
]
|
||||
```
|
||||
|
||||
#### Form Submission (useInfrastructureSubmit hook)
|
||||
```javascript
|
||||
// Converts frontend form → backend model
|
||||
const finalForm = {
|
||||
url: `http${https ? "s" : ""}://` + infrastructureMonitor.url,
|
||||
name: infrastructureMonitor.name || infrastructureMonitor.url,
|
||||
interval: infrastructureMonitor.interval * 60000, // Convert to ms
|
||||
type: "hardware", // Always "hardware" for infrastructure monitors
|
||||
|
||||
// Thresholds (convert % to decimal 0-1)
|
||||
thresholds: {
|
||||
...(cpu ? { usage_cpu: usage_cpu / 100 } : {}),
|
||||
...(memory ? { usage_memory: usage_memory / 100 } : {}),
|
||||
...(disk ? { usage_disk: usage_disk / 100 } : {}),
|
||||
...(temperature ? { usage_temperature: usage_temperature / 100 } : {})
|
||||
},
|
||||
|
||||
notifications: infrastructureMonitor.notifications
|
||||
};
|
||||
|
||||
// API call
|
||||
isCreate ?
|
||||
await createMonitor({ monitor: finalForm, redirect: "/infrastructure" }) :
|
||||
await updateMonitor({ monitor: finalForm, redirect: "/infrastructure" });
|
||||
```
|
||||
|
||||
### Monitor Display Components
|
||||
|
||||
#### Monitor Status Component
|
||||
**Location:** `/client/src/Components/v2/Monitors/MonitorStatus.tsx`
|
||||
|
||||
Displays:
|
||||
- Status indicator (up/down)
|
||||
- Response time
|
||||
- Last check time
|
||||
- Incident badges
|
||||
|
||||
#### Monitoring Hooks
|
||||
**Location:** `/client/src/Hooks/v1/monitorHooks.js`
|
||||
|
||||
```javascript
|
||||
// Fetch monitors
|
||||
useFetchMonitorsByTeamId({ types, limit, page, ... })
|
||||
useFetchMonitorsWithSummary({ types, monitorUpdateTrigger })
|
||||
useFetchMonitorsWithChecks({ types, limit, ... })
|
||||
|
||||
// Fetch individual monitor
|
||||
useFetchHardwareMonitorById({ monitorId, updateTrigger })
|
||||
useFetchStatsByMonitorId({ monitorId, dateRange, ... })
|
||||
|
||||
// Manage monitors
|
||||
useCreateMonitor() // POST /monitors
|
||||
useUpdateMonitor() // PUT /monitors/:id
|
||||
useDeleteMonitor() // DELETE /monitors/:id
|
||||
usePauseMonitor() // POST /monitors/pause/:id
|
||||
```
|
||||
|
||||
### Network Service (API Client)
|
||||
**Location:** `/client/src/Utils/NetworkService.js` (1157 lines)
|
||||
|
||||
```javascript
|
||||
// Constructor
|
||||
constructor(store, dispatch, navigate) {
|
||||
// Axios instance with:
|
||||
// - Bearer token injection
|
||||
// - Language header
|
||||
// - 401 redirect to login
|
||||
// - Network error handling
|
||||
}
|
||||
|
||||
// Monitor endpoints
|
||||
async createMonitor(config) {
|
||||
return this.axiosInstance.post(`/monitors`, config.monitor);
|
||||
}
|
||||
|
||||
async updateMonitor(config) {
|
||||
return this.axiosInstance.put(`/monitors/${config.monitorId}`, config.monitor);
|
||||
}
|
||||
|
||||
async getMonitorsByTeamId(config) {
|
||||
// Query params: limit, types[], page, rowsPerPage, filter, field, order
|
||||
return this.axiosInstance.get(`/monitors/team?...`);
|
||||
}
|
||||
|
||||
async getHardwareDetailsByMonitorId(config) {
|
||||
return this.axiosInstance.get(`/monitors/hardware/details/${config.monitorId}`);
|
||||
}
|
||||
|
||||
async getStatsByMonitorId(config) {
|
||||
// Query params: sortOrder, limit, dateRange, numToDisplay, normalize
|
||||
return this.axiosInstance.get(`/monitors/stats/${config.monitorId}?...`);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. AUTHENTICATION & API KEYS
|
||||
|
||||
### User Authentication (JWT)
|
||||
|
||||
**Registration/Login:**
|
||||
```javascript
|
||||
// POST /auth/register
|
||||
{
|
||||
firstName: "John",
|
||||
lastName: "Doe",
|
||||
email: "john@example.com",
|
||||
password: "SecurePass123!"
|
||||
}
|
||||
|
||||
Response:
|
||||
{
|
||||
user: { _id, email, role, teamId, ... },
|
||||
token: "eyJhbGciOiJIUzI1NiIs..." // JWT
|
||||
}
|
||||
```
|
||||
|
||||
**Token Storage:** Redux store (`Features/Auth/authSlice`)
|
||||
|
||||
**Token Injection:** Automatic by NetworkService
|
||||
```javascript
|
||||
config.headers.Authorization = `Bearer ${authToken}`;
|
||||
```
|
||||
|
||||
### Monitor-Specific Authentication
|
||||
|
||||
#### For Hardware/Docker Monitors via Capture API
|
||||
Monitors can have a `secret` field for authenticating requests to the Capture API:
|
||||
|
||||
```javascript
|
||||
{
|
||||
type: "hardware",
|
||||
url: "http://192.168.1.100:3000", // Capture endpoint
|
||||
secret: "api-key-12345", // Passed to Capture API
|
||||
thresholds: { ... }
|
||||
}
|
||||
```
|
||||
|
||||
**Implementation:** The secret is stored in the Monitor model and could be:
|
||||
1. Sent as HTTP header: `Authorization: Bearer <secret>`
|
||||
2. Sent as query param: `?secret=<secret>`
|
||||
3. Sent in request body for POST requests
|
||||
|
||||
---
|
||||
|
||||
## 8. CONFIGURATION & USER SETTINGS
|
||||
|
||||
### Global Settings
|
||||
**Model:** `/server/src/db/v1/models/AppSettings.js`
|
||||
|
||||
```javascript
|
||||
{
|
||||
jwtSecret: String, // For signing JWTs
|
||||
sslCertificate: String, // SSL cert content
|
||||
smtpConfig: Object, // Email settings
|
||||
globalThresholds: { // Default thresholds
|
||||
cpu: Number,
|
||||
memory: Number,
|
||||
disk: Number,
|
||||
temperature: Number
|
||||
},
|
||||
siteTitle: String,
|
||||
defaultLanguage: String,
|
||||
maintenanceMode: Boolean
|
||||
}
|
||||
```
|
||||
|
||||
**Fetching Settings:**
|
||||
```javascript
|
||||
// Frontend
|
||||
useFetchGlobalSettings()
|
||||
→ NetworkService.getGlobalSettings()
|
||||
→ GET /settings
|
||||
|
||||
// Backend
|
||||
SettingsService.loadSettings()
|
||||
→ Loads from AppSettings collection
|
||||
```
|
||||
|
||||
### Monitor Configuration UI Flow
|
||||
|
||||
1. **Create Page:** `/infrastructure/create`
|
||||
- Fetch global settings for default thresholds
|
||||
- Form includes:
|
||||
- Monitor name
|
||||
- URL/Container name
|
||||
- Interval (dropdown)
|
||||
- CPU/Memory/Disk/Temp thresholds (checkboxes + inputs)
|
||||
- Notification channels (multi-select)
|
||||
- Secret (if using Capture API)
|
||||
|
||||
2. **Edit Page:** `/infrastructure/configure/:monitorId`
|
||||
- Load existing monitor data
|
||||
- Update form fields
|
||||
- Save changes with PUT request
|
||||
|
||||
3. **Details Page:** `/infrastructure/:monitorId`
|
||||
- Display monitor stats
|
||||
- Show uptime graph
|
||||
- List recent checks
|
||||
- Status history
|
||||
|
||||
### Team-Based Isolation
|
||||
**Access Control:**
|
||||
```javascript
|
||||
// All queries filtered by teamId
|
||||
await Monitor.find({ teamId: req.user.teamId });
|
||||
|
||||
// verifyTeamAccess middleware
|
||||
await verifyTeamAccess(req.user.teamId, req.params.monitorId);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## KEY PATTERNS FOR DOCKER MONITORING INTEGRATION
|
||||
|
||||
### 1. Adding Docker Monitor Type
|
||||
Already supported! Located in:
|
||||
- `Monitor.schema` type enum ✓
|
||||
- `NetworkService.requestDocker()` ✓
|
||||
- `Check.schema` with type ✓
|
||||
|
||||
### 2. Docker-Specific Data Collection
|
||||
Currently: Only status + response time
|
||||
**To Add Detailed Metrics:**
|
||||
- Extend `Check.schema` with Docker stats fields
|
||||
- Modify `NetworkService.requestDocker()` to call `container.stats()`
|
||||
- Stream stats to `Check.docker` field
|
||||
|
||||
### 3. Capture API Integration (Hardware Monitoring)
|
||||
**Flow:**
|
||||
```
|
||||
Monitor with type="hardware" and url="http://capture-endpoint"
|
||||
↓
|
||||
NetworkService.requestHardware()
|
||||
↓ (delegates to)
|
||||
NetworkService.requestHttp()
|
||||
↓
|
||||
Expects JSON response: { cpu, memory, disk, net, ... }
|
||||
↓
|
||||
Check record stores full payload in hardware fields
|
||||
```
|
||||
|
||||
### 4. Database Queries
|
||||
**Get hardware checks:**
|
||||
```javascript
|
||||
Check.find({
|
||||
monitorId: id,
|
||||
type: "hardware",
|
||||
createdAt: { $gte: startDate, $lte: endDate }
|
||||
})
|
||||
.sort({ createdAt: -1 })
|
||||
.limit(100)
|
||||
```
|
||||
|
||||
### 5. UI Display
|
||||
- Stats dashboard: `/infrastructure/:monitorId`
|
||||
- Uptime details: `/monitor/uptime/details/:monitorId`
|
||||
- Hardware details: `/monitor/hardware/details/:monitorId`
|
||||
|
||||
---
|
||||
|
||||
## SERVICE ARCHITECTURE
|
||||
|
||||
### Service Registry Pattern
|
||||
**Location:** `/server/src/service/v1/system/serviceRegistry.js`
|
||||
|
||||
```javascript
|
||||
// Singleton pattern
|
||||
ServiceRegistry.set(serviceName, serviceInstance);
|
||||
const service = ServiceRegistry.get(serviceName);
|
||||
```
|
||||
|
||||
### Service Dependencies
|
||||
**Initialization:** `/server/src/config/services.js`
|
||||
|
||||
```javascript
|
||||
// Infrastructure services
|
||||
new NetworkService({
|
||||
axios, got, https, jmespath, GameDig, ping,
|
||||
logger, http, Docker, // ← Docker client injected
|
||||
net, stringService, settingsService
|
||||
})
|
||||
|
||||
// Business services
|
||||
new MonitorService({
|
||||
db, settingsService, jobQueue,
|
||||
stringService, emailService, logger
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## KEY FILES SUMMARY
|
||||
|
||||
| Component | File | Lines | Purpose |
|
||||
|-----------|------|-------|---------|
|
||||
| Monitor Model | `server/src/db/v1/models/Monitor.js` | 209 | Schema, hooks |
|
||||
| Check Model | `server/src/db/v1/models/Check.js` | 177 | Check records, TTL |
|
||||
| NetworkService | `server/src/service/v1/infrastructure/networkService.js` | 580 | Type handlers |
|
||||
| MonitorService | `server/src/service/v1/business/monitorService.js` | 277 | CRUD, validation |
|
||||
| MonitorModule | `server/src/db/v1/modules/monitorModule.js` | 593 | DB queries |
|
||||
| JobQueue | `server/src/service/v1/infrastructure/SuperSimpleQueue/SuperSimpleQueue.js` | 177 | Job scheduling |
|
||||
| MonitorController | `server/src/controllers/v1/monitorController.js` | 475 | HTTP handlers |
|
||||
| MonitorRoute | `server/src/routes/v1/monitorRoute.js` | 61 | Endpoint definitions |
|
||||
| Frontend Hooks | `client/src/Hooks/v1/monitorHooks.js` | 500+ | Data fetching |
|
||||
| NetworkService (FE) | `client/src/Utils/NetworkService.js` | 1157 | API client |
|
||||
| Form Hook | `client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx` | 97 | Form state |
|
||||
|
||||
---
|
||||
|
||||
## DEPLOYMENT & DOCKER INTEGRATION
|
||||
|
||||
### Docker-Compose Setup
|
||||
**Files:** `/docker/dev/docker-compose.yaml`, `/docker/prod/docker-compose.yaml`
|
||||
|
||||
**Volumes for Docker Monitoring:**
|
||||
```yaml
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock # Required for Dockerode
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
**Backend (.env):**
|
||||
```
|
||||
MONGODB_URI=mongodb://mongo:27017/checkmate
|
||||
JWT_SECRET=your-secret-key
|
||||
NODE_ENV=production|development
|
||||
PORT=5000
|
||||
```
|
||||
|
||||
**Frontend (.env):**
|
||||
```
|
||||
VITE_APP_API_BASE_URL=http://localhost:5000/api/v1
|
||||
```
|
||||
|
||||
+4
-4
@@ -66,7 +66,7 @@ cd Checkmate
|
||||
Navigate to the Docker dev directory:
|
||||
|
||||
```bash
|
||||
cd server/docker/dev
|
||||
cd docker/dev
|
||||
```
|
||||
|
||||
Build the Docker images:
|
||||
@@ -78,13 +78,13 @@ Build the Docker images:
|
||||
Run MongoDB container:
|
||||
|
||||
```bash
|
||||
docker run -d -p 27017:27017 -v $(pwd)/mongo/data:/data/db --name uptime_database_mongo uptime_database_mongo
|
||||
docker run -d -p 27017:27017 -v uptime_mongo_data:/data/db --name uptime_database_mongo mongo:6.0
|
||||
```
|
||||
|
||||
Navigate back to the root directory:
|
||||
|
||||
```bash
|
||||
cd ../../..
|
||||
cd ../..
|
||||
```
|
||||
|
||||
#### Step 3: Set Up the Backend (Server)
|
||||
@@ -161,7 +161,7 @@ Start the frontend:
|
||||
npm run dev
|
||||
```
|
||||
|
||||
The client will run at `http://localhost:5173`.
|
||||
The client will run at `http://localhost:5173`.
|
||||
|
||||
#### Step 5: Access the Application
|
||||
|
||||
|
||||
+11325
File diff suppressed because it is too large.
Load diff
@@ -52,7 +52,7 @@ Usage instructions can be found [here](https://docs.checkmate.so/checkmate-2.1).
|
||||
|
||||
See installation instructions in [Checkmate documentation portal](https://docs.checkmate.so/checkmate-2.1/users-guide/quickstart).
|
||||
|
||||
Alternatively, you can also use [Coolify](https://coolify.io/), [Elestio](https://elest.io/open-source/checkmate), [K8s](./charts/helm/checkmate/INSTALLATION.md), [Sive Host](https://sive.host) (South Africa) or [Pikapods](https://www.pikapods.com/) to quickly spin off a Checkmate instance. If you would like to monitor your server infrastructure, you'll need [Capture agent](https://github.com/bluewave-labs/capture). Capture repository also contains the installation instructions.
|
||||
Alternatively, you can also use [Elestio](https://elest.io/open-source/checkmate), [K8s](./charts/helm/checkmate/INSTALLATION.md), [Sive Host](https://sive.host) (South Africa) or [Pikapods](https://www.pikapods.com/) to quickly spin off a Checkmate instance. If you would like to monitor your server infrastructure, you'll need [Capture agent](https://github.com/bluewave-labs/capture). Capture repository also contains the installation instructions.
|
||||
|
||||
### Using a Custom CA
|
||||
|
||||
@@ -162,6 +162,7 @@ Here's how you can contribute:
|
||||
4. Open an issue if you believe you've encountered a bug.
|
||||
5. Check for good-first-issue's if you are a newcomer.
|
||||
6. Make a pull request to add new features/make quality-of-life improvements/fix bugs.
|
||||
7. Check out this interactive walkthrough of the `Checkmate` codebase on CodeCanvas [here](https://www.code-canvas.com/?session=unauthenticatedGithub&repo=Checkmate&owner=bluewave-labs&branch=develop&OnboardingTutorial=true). To refine existing dataflow simulation or create new ones, follow the quick tutorial [here](https://docs.code-canvas.com/updating-diagram).
|
||||
|
||||
<a href="https://github.com/bluewave-labs/checkmate/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=bluewave-labs/checkmate" />
|
||||
|
||||
@@ -21,6 +21,10 @@ cd checkmate/charts/helm/checkmate
|
||||
Edit `values.yaml` to update:
|
||||
- `client.ingress.host` and `server.ingress.host` with your domain names
|
||||
- `server.protocol` (usually http or https)
|
||||
- **If upgrading**: Migrate persistence settings from flat structure to nested:
|
||||
- Old: `persistence.mongodbSize` → New: `persistence.mongo.size`
|
||||
- Old: `persistence.redisSize` → New: `persistence.redis.size`
|
||||
- Add: `persistence.mongo.storageClass` and `persistence.redis.storageClass` (leave empty for default)
|
||||
- Secrets under the `secrets` section (`JWT_SECRET`, email credentials, API keys, etc.) — replace all change_me values
|
||||
|
||||
### 3. Deploy the Helm chart
|
||||
|
||||
@@ -37,8 +37,8 @@ spec:
|
||||
- metadata:
|
||||
name: checkmate-mongo-persistent-storage
|
||||
spec:
|
||||
storageClassName: "gp3"
|
||||
storageClassName: {{ .Values.persistence.mongo.storageClass | quote }}
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.mongodbSize }}
|
||||
storage: {{ .Values.persistence.mongo.size | default "5Gi" | quote }}
|
||||
@@ -25,9 +25,9 @@ spec:
|
||||
- metadata:
|
||||
name: checkmate-redis-persistent-storage
|
||||
spec:
|
||||
storageClassName: "gp3"
|
||||
storageClassName: {{ .Values.persistence.redis.storageClass | quote }}
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.redisSize }}
|
||||
storage: {{ .Values.persistence.redis.size | default "1Gi" | quote }}
|
||||
{{- end }}
|
||||
@@ -44,5 +44,9 @@ secrets:
|
||||
# REFRESH_TOKEN_TTL: 99d
|
||||
|
||||
persistence:
|
||||
mongodbSize: 5Gi
|
||||
redisSize: 1Gi
|
||||
mongo:
|
||||
size: 5Gi
|
||||
storageClass: ""
|
||||
redis:
|
||||
size: 1Gi
|
||||
storageClass: ""
|
||||
@@ -2,6 +2,7 @@ import { Stack, Typography } from "@mui/material";
|
||||
import PropTypes from "prop-types";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import Dot from "../Dot/index.jsx";
|
||||
import { StatusLabel } from "@/Components/v1/Label/index.jsx";
|
||||
/**
|
||||
* Host component.
|
||||
* This subcomponent receives a params object and displays the host details.
|
||||
@@ -14,7 +15,7 @@ import Dot from "../Dot/index.jsx";
|
||||
* @param {number} params.percentage - The percentage to display.
|
||||
* @returns {React.ElementType} Returns a div element with the host details.
|
||||
*/
|
||||
const Host = ({ url, title, percentageColor, percentage, showURL }) => {
|
||||
const Host = ({ url, title, percentageColor, percentage, showURL, status }) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Stack>
|
||||
@@ -22,21 +23,36 @@ const Host = ({ url, title, percentageColor, percentage, showURL }) => {
|
||||
direction="row"
|
||||
position="relative"
|
||||
alignItems="center"
|
||||
gap={theme.spacing(4)}
|
||||
gap={theme.spacing(5)}
|
||||
>
|
||||
{title}
|
||||
<Typography
|
||||
variant="h6"
|
||||
sx={{
|
||||
fontWeight: 600,
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</Typography>
|
||||
|
||||
{percentageColor && percentage && (
|
||||
<>
|
||||
<Dot />
|
||||
<Typography
|
||||
component="span"
|
||||
variant="h6"
|
||||
sx={{
|
||||
fontWeight: 600,
|
||||
color: percentageColor,
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{percentage}%
|
||||
</Typography>
|
||||
{status && (
|
||||
<StatusLabel
|
||||
status={status}
|
||||
text={status}
|
||||
customStyles={{ textTransform: "capitalize" }}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
@@ -51,6 +67,7 @@ Host.propTypes = {
|
||||
percentage: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
showURL: PropTypes.bool,
|
||||
status: PropTypes.string,
|
||||
};
|
||||
|
||||
export default Host;
|
||||
@@ -147,11 +147,9 @@ const StatusLabel = ({ status, text, customStyles }) => {
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
width={7}
|
||||
height={7}
|
||||
bgcolor={theme.palette[themeColor].lowContrast}
|
||||
borderRadius="50%"
|
||||
marginRight="5px"
|
||||
borderRadius="0%"
|
||||
marginRight="1px"
|
||||
/>
|
||||
</BaseLabel>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import Box from "@mui/material/Box";
|
||||
import { BaseBox } from "@/Components/v2/DesignElements";
|
||||
import type { MonitorStatus } from "@/Types/Monitor";
|
||||
|
||||
import { getStatusPalette } from "@/Utils/MonitorUtils";
|
||||
import { getStatusPalette } from "@/Utils/v2/MonitorUtils";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
|
||||
export const StatusLabel = ({
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Select from "@mui/material/Select";
|
||||
import { Typography, Select } from "@mui/material";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import type { SelectProps } from "@mui/material/Select";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||
|
||||
export const SelectInput: React.FC<SelectProps> = ({ ...props }) => {
|
||||
const theme = useTheme();
|
||||
@@ -20,3 +22,67 @@ export const SelectInput: React.FC<SelectProps> = ({ ...props }) => {
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
type ItemTypes = string | number;
|
||||
interface SelectItem {
|
||||
_id: ItemTypes;
|
||||
name: string;
|
||||
}
|
||||
export type CustomSelectProps = SelectProps & {
|
||||
items: SelectItem[];
|
||||
placeholder?: string;
|
||||
isHidden?: boolean;
|
||||
hasError?: boolean;
|
||||
};
|
||||
|
||||
export const SelectFromItems: React.FC<CustomSelectProps> = ({
|
||||
items,
|
||||
placeholder,
|
||||
isHidden = false,
|
||||
hasError = false,
|
||||
...props
|
||||
}) => {
|
||||
return (
|
||||
<SelectInput
|
||||
error={hasError}
|
||||
IconComponent={KeyboardArrowDownIcon}
|
||||
displayEmpty
|
||||
MenuProps={{ disableScrollLock: true }}
|
||||
renderValue={(selected) => {
|
||||
if (!selected) {
|
||||
return (
|
||||
<Typography
|
||||
noWrap
|
||||
color="text.secondary"
|
||||
>
|
||||
{placeholder ?? ""}
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
const selectedItem = items.find((item) => item._id === selected);
|
||||
const displayName = selectedItem ? selectedItem.name : placeholder;
|
||||
return (
|
||||
<Typography
|
||||
noWrap
|
||||
title={displayName}
|
||||
>
|
||||
{displayName}
|
||||
</Typography>
|
||||
);
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
{items.map((item) => (
|
||||
<MenuItem
|
||||
key={item._id}
|
||||
value={item._id}
|
||||
>
|
||||
{item.name}
|
||||
</MenuItem>
|
||||
))}
|
||||
</SelectInput>
|
||||
);
|
||||
};
|
||||
|
||||
SelectInput.displayName = "SelectInput";
|
||||
SelectFromItems.displayName = "SelectFromItems";
|
||||
@@ -4,7 +4,7 @@ import Typography from "@mui/material/Typography";
|
||||
import AverageResponseIcon from "@/assets/icons/average-response-icon.svg?react";
|
||||
import { Cell, RadialBarChart, RadialBar, ResponsiveContainer } from "recharts";
|
||||
|
||||
import { getResponseTimeColor } from "@/Utils/MonitorUtils";
|
||||
import { getResponseTimeColor } from "@/Utils/v2/MonitorUtils";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
|
||||
export const ChartAvgResponse = ({ avg, max }: { avg: number; max: number }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BaseChart } from "./HistogramStatus";
|
||||
import { BaseBox } from "../DesignElements";
|
||||
import ResponseTimeIcon from "@/assets/icons/response-time-icon.svg?react";
|
||||
import { normalizeResponseTimes } from "@/Utils/DataUtils";
|
||||
import { normalizeResponseTimes } from "@/Utils/v2/DataUtils";
|
||||
import {
|
||||
AreaChart,
|
||||
Area,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
formatDateWithTz,
|
||||
tickDateFormatLookup,
|
||||
tooltipDateFormatLookup,
|
||||
} from "@/Utils/TimeUtils";
|
||||
} from "@/Utils/v2/TimeUtils";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import type { GroupedCheck } from "@/Types/Check";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
@@ -3,7 +3,7 @@ import Box from "@mui/material/Box";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import type { Check } from "@/Types/Check";
|
||||
import { HistogramResponseTimeTooltip } from "@/Components/v2/Monitors/HistogramResponseTimeTooltip";
|
||||
import { normalizeResponseTimes } from "@/Utils/DataUtils";
|
||||
import { normalizeResponseTimes } from "@/Utils/v2/DataUtils";
|
||||
|
||||
export const HistogramResponseTime = ({ checks }: { checks: Check[] }) => {
|
||||
const normalChecks = normalizeResponseTimes(checks, "responseTime");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||
import { formatDateWithTz } from "@/Utils/v2/TimeUtils";
|
||||
import { useSelector } from "react-redux";
|
||||
import type { LatestCheck } from "@/Types/Check";
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ import IncidentsIcon from "@/assets/icons/incidents.svg?react";
|
||||
import type { GroupedCheck } from "@/Types/Check";
|
||||
import type { MonitorStatus } from "@/Types/Monitor";
|
||||
|
||||
import { normalizeResponseTimes } from "@/Utils/DataUtils";
|
||||
import { normalizeResponseTimes } from "@/Utils/v2/DataUtils";
|
||||
import { useState } from "react";
|
||||
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||
import { formatDateWithTz } from "@/Utils/v2/TimeUtils";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { getResponseTimeColor } from "@/Utils/MonitorUtils";
|
||||
import { getResponseTimeColor } from "@/Utils/v2/MonitorUtils";
|
||||
|
||||
const XLabel = ({
|
||||
p1,
|
||||
|
||||
@@ -3,7 +3,7 @@ import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { PulseDot } from "@/Components/v2/DesignElements/PulseDot";
|
||||
import { Dot } from "@/Components/v2/DesignElements/Dot";
|
||||
import { getStatusColor, formatUrl } from "@/Utils/MonitorUtils";
|
||||
import { getStatusColor, formatUrl } from "@/Utils/v2/MonitorUtils";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import prettyMilliseconds from "pretty-ms";
|
||||
import { typographyLevels } from "@/Utils/Theme/v2/palette";
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
||||
import useSWR from "swr";
|
||||
import type { SWRConfiguration } from "swr";
|
||||
import type { AxiosRequestConfig } from "axios";
|
||||
import { get, post, patch } from "@/Utils/ApiClient"; // your axios wrapper
|
||||
import { get, post, patch } from "@/Utils/v2/ApiClient"; // your axios wrapper
|
||||
|
||||
export type ApiResponse = {
|
||||
message: string;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { monitorSchema } from "@/Validation/v2/zod";
|
||||
import { z } from "zod";
|
||||
export const useInitForm = ({
|
||||
initialData,
|
||||
}: {
|
||||
initialData: Partial<z.infer<typeof monitorSchema>> | undefined;
|
||||
}) => {
|
||||
const defaults: z.infer<typeof monitorSchema> = {
|
||||
type: initialData?.type || "http",
|
||||
url: initialData?.url || "",
|
||||
n: initialData?.n || 3,
|
||||
notificationChannels: initialData?.notificationChannels || [],
|
||||
name: initialData?.name || "",
|
||||
interval: initialData?.interval || "1 minute",
|
||||
};
|
||||
return { defaults };
|
||||
};
|
||||
@@ -31,14 +31,17 @@ const useInfrastructureMonitorForm = () => {
|
||||
[event.target.name]: event.target.checked,
|
||||
});
|
||||
};
|
||||
const initializeInfrastructureMonitorForCreate = useCallback((globalSettings) => {
|
||||
const initializeInfrastructureMonitorForCreate = useCallback((globalSettings, monitorType = "hardware") => {
|
||||
const gt = globalSettings?.data?.settings?.globalThresholds || {};
|
||||
// Docker monitors default to 30 seconds (0.5 minutes), hardware to 15 seconds (0.25 minutes)
|
||||
const defaultInterval = monitorType === "docker" ? 0.5 : 0.25;
|
||||
|
||||
setInfrastructureMonitor((prev) => ({
|
||||
...prev,
|
||||
url: "",
|
||||
name: "",
|
||||
notifications: [],
|
||||
interval: 0.25,
|
||||
interval: defaultInterval,
|
||||
cpu: gt.cpu !== undefined,
|
||||
usage_cpu: gt.cpu !== undefined ? gt.cpu.toString() : "",
|
||||
memory: gt.memory !== undefined,
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
const useInfrastructureSubmit = () => {
|
||||
const [createMonitor, isCreating] = useCreateMonitor();
|
||||
const [updateMonitor, isUpdating] = useUpdateMonitor();
|
||||
const buildForm = (infrastructureMonitor, https) => {
|
||||
const buildForm = (infrastructureMonitor, https, monitorType = "hardware") => {
|
||||
const MS_PER_MINUTE = 60000;
|
||||
|
||||
let form = {
|
||||
@@ -17,31 +17,37 @@ const useInfrastructureSubmit = () => {
|
||||
interval: infrastructureMonitor.interval * MS_PER_MINUTE,
|
||||
statusWindowSize: infrastructureMonitor.statusWindowSize,
|
||||
statusWindowThreshold: infrastructureMonitor.statusWindowThreshold,
|
||||
cpu: infrastructureMonitor.cpu,
|
||||
...(infrastructureMonitor.cpu
|
||||
? { usage_cpu: infrastructureMonitor.usage_cpu }
|
||||
: {}),
|
||||
memory: infrastructureMonitor.memory,
|
||||
...(infrastructureMonitor.memory
|
||||
? { usage_memory: infrastructureMonitor.usage_memory }
|
||||
: {}),
|
||||
disk: infrastructureMonitor.disk,
|
||||
...(infrastructureMonitor.disk
|
||||
? { usage_disk: infrastructureMonitor.usage_disk }
|
||||
: {}),
|
||||
temperature: infrastructureMonitor.temperature,
|
||||
...(infrastructureMonitor.temperature
|
||||
? { usage_temperature: infrastructureMonitor.usage_temperature }
|
||||
: {}),
|
||||
secret: infrastructureMonitor.secret,
|
||||
};
|
||||
|
||||
// Only add hardware-specific thresholds for hardware monitors
|
||||
if (monitorType === "hardware") {
|
||||
form.cpu = infrastructureMonitor.cpu;
|
||||
if (infrastructureMonitor.cpu) {
|
||||
form.usage_cpu = infrastructureMonitor.usage_cpu;
|
||||
}
|
||||
form.memory = infrastructureMonitor.memory;
|
||||
if (infrastructureMonitor.memory) {
|
||||
form.usage_memory = infrastructureMonitor.usage_memory;
|
||||
}
|
||||
form.disk = infrastructureMonitor.disk;
|
||||
if (infrastructureMonitor.disk) {
|
||||
form.usage_disk = infrastructureMonitor.usage_disk;
|
||||
}
|
||||
form.temperature = infrastructureMonitor.temperature;
|
||||
if (infrastructureMonitor.temperature) {
|
||||
form.usage_temperature = infrastructureMonitor.usage_temperature;
|
||||
}
|
||||
}
|
||||
|
||||
return form;
|
||||
};
|
||||
const submitInfrastructureForm = async (
|
||||
infrastructureMonitor,
|
||||
form,
|
||||
isCreate,
|
||||
monitorId
|
||||
monitorId,
|
||||
monitorType = "hardware"
|
||||
) => {
|
||||
const {
|
||||
cpu,
|
||||
@@ -55,20 +61,24 @@ const useInfrastructureSubmit = () => {
|
||||
...rest
|
||||
} = form;
|
||||
|
||||
const thresholds = {
|
||||
...(cpu ? { usage_cpu: usage_cpu / 100 } : {}),
|
||||
...(memory ? { usage_memory: usage_memory / 100 } : {}),
|
||||
...(disk ? { usage_disk: usage_disk / 100 } : {}),
|
||||
...(temperature ? { usage_temperature: usage_temperature / 100 } : {}),
|
||||
};
|
||||
// Only build thresholds for hardware monitors
|
||||
const thresholds =
|
||||
monitorType === "hardware"
|
||||
? {
|
||||
...(cpu ? { usage_cpu: usage_cpu / 100 } : {}),
|
||||
...(memory ? { usage_memory: usage_memory / 100 } : {}),
|
||||
...(disk ? { usage_disk: usage_disk / 100 } : {}),
|
||||
...(temperature ? { usage_temperature: usage_temperature / 100 } : {}),
|
||||
}
|
||||
: {};
|
||||
|
||||
const finalForm = {
|
||||
...(isCreate ? {} : { _id: monitorId }),
|
||||
...rest,
|
||||
description: form.name,
|
||||
type: "hardware",
|
||||
type: monitorType,
|
||||
notifications: infrastructureMonitor.notifications,
|
||||
thresholds,
|
||||
...(Object.keys(thresholds).length > 0 ? { thresholds } : {}),
|
||||
};
|
||||
// Handle create or update
|
||||
isCreate
|
||||
|
||||
@@ -13,7 +13,7 @@ import CustomAlertsSection from "./Components/CustomAlertsSection.jsx";
|
||||
// Utils
|
||||
import NotificationsConfig from "@/Components/v1/NotificationConfig/index.jsx";
|
||||
import { useGetNotificationsByTeamId } from "../../../../Hooks/v1/useNotifications.js";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useParams, useSearchParams } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -29,6 +29,7 @@ import useInfrastructureSubmit from "./hooks/useInfrastructureSubmit.jsx";
|
||||
|
||||
const CreateInfrastructureMonitor = () => {
|
||||
const { monitorId } = useParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
const isCreate = typeof monitorId === "undefined";
|
||||
|
||||
const theme = useTheme();
|
||||
@@ -43,6 +44,11 @@ const CreateInfrastructureMonitor = () => {
|
||||
monitorId,
|
||||
updateTrigger,
|
||||
});
|
||||
|
||||
// Determine monitor type: from query params when creating, from monitor object when editing
|
||||
const monitorType = isCreate
|
||||
? (searchParams.get("type") || "hardware")
|
||||
: (monitor?.type || "hardware");
|
||||
const [deleteMonitor, isDeleting] = useDeleteMonitor();
|
||||
const [globalSettings, globalSettingsLoading] = useFetchGlobalSettings();
|
||||
const [notifications, notificationsAreLoading] = useGetNotificationsByTeamId();
|
||||
@@ -59,7 +65,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
const { buildForm, submitInfrastructureForm, isCreating, isUpdating } =
|
||||
useInfrastructureSubmit();
|
||||
|
||||
const FREQUENCIES = [
|
||||
const ALL_FREQUENCIES = [
|
||||
{ _id: 0.25, name: t("time.fifteenSeconds") },
|
||||
{ _id: 0.5, name: t("time.thirtySeconds") },
|
||||
{ _id: 1, name: t("time.oneMinute") },
|
||||
@@ -67,6 +73,12 @@ const CreateInfrastructureMonitor = () => {
|
||||
{ _id: 5, name: t("time.fiveMinutes") },
|
||||
{ _id: 10, name: t("time.tenMinutes") },
|
||||
];
|
||||
|
||||
// Docker monitors require minimum 30 second interval
|
||||
const FREQUENCIES =
|
||||
monitorType === "docker"
|
||||
? ALL_FREQUENCIES.filter((f) => f._id >= 0.5)
|
||||
: ALL_FREQUENCIES;
|
||||
const CRUMBS = [
|
||||
{ name: "Infrastructure monitors", path: "/infrastructure" },
|
||||
...(isCreate
|
||||
@@ -81,7 +93,8 @@ const CreateInfrastructureMonitor = () => {
|
||||
if (isCreate) {
|
||||
if (globalSettingsLoading) return;
|
||||
setHttps(false);
|
||||
initializeInfrastructureMonitorForCreate(globalSettings);
|
||||
const typeFromQuery = searchParams.get("type") || "hardware";
|
||||
initializeInfrastructureMonitorForCreate(globalSettings, typeFromQuery);
|
||||
} else if (monitor) {
|
||||
setHttps(monitor.url.startsWith("https"));
|
||||
initializeInfrastructureMonitorForUpdate(monitor);
|
||||
@@ -91,6 +104,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
monitor,
|
||||
globalSettings,
|
||||
globalSettingsLoading,
|
||||
searchParams,
|
||||
initializeInfrastructureMonitorForCreate,
|
||||
initializeInfrastructureMonitorForUpdate,
|
||||
]);
|
||||
@@ -98,12 +112,12 @@ const CreateInfrastructureMonitor = () => {
|
||||
// Handlers
|
||||
const onSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
const form = buildForm(infrastructureMonitor, https);
|
||||
const form = buildForm(infrastructureMonitor, https, monitorType);
|
||||
const error = validateForm(form);
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
submitInfrastructureForm(infrastructureMonitor, form, isCreate, monitorId);
|
||||
submitInfrastructureForm(infrastructureMonitor, form, isCreate, monitorId, monitorType);
|
||||
};
|
||||
|
||||
const triggerUpdate = () => {
|
||||
@@ -200,15 +214,25 @@ const CreateInfrastructureMonitor = () => {
|
||||
{t("settingsGeneralSettings")}
|
||||
</Typography>
|
||||
<Typography component="p">
|
||||
{t("infrastructureCreateGeneralSettingsDescription")}
|
||||
{monitorType === "docker"
|
||||
? "Configure your Capture server to monitor Docker containers."
|
||||
: t("infrastructureCreateGeneralSettingsDescription")}
|
||||
</Typography>
|
||||
<Typography component="p">
|
||||
{t("infrastructureServerRequirement")}{" "}
|
||||
<Link
|
||||
level="primary"
|
||||
url="https://github.com/bluewave-labs/checkmate-agent"
|
||||
label={t("common.monitoringAgentName")}
|
||||
/>
|
||||
{monitorType === "docker" ? (
|
||||
<>
|
||||
Capture server endpoint: <code>/api/v1/metrics/docker</code>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{t("infrastructureServerRequirement")}{" "}
|
||||
<Link
|
||||
level="primary"
|
||||
url="https://github.com/bluewave-labs/checkmate-agent"
|
||||
label={t("common.monitoringAgentName")}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Stack gap={theme.spacing(8)}>
|
||||
@@ -217,8 +241,16 @@ const CreateInfrastructureMonitor = () => {
|
||||
id="url"
|
||||
name="url"
|
||||
startAdornment={<HttpAdornment https={https} />}
|
||||
placeholder={"localhost:59232/api/v1/metrics"}
|
||||
label={t("infrastructureServerUrlLabel")}
|
||||
placeholder={
|
||||
monitorType === "docker"
|
||||
? "192.168.1.100:59232"
|
||||
: "localhost:59232/api/v1/metrics"
|
||||
}
|
||||
label={
|
||||
monitorType === "docker"
|
||||
? "Capture Server URL"
|
||||
: t("infrastructureServerUrlLabel")
|
||||
}
|
||||
https={https}
|
||||
value={infrastructureMonitor.url}
|
||||
onChange={onChange}
|
||||
@@ -264,7 +296,12 @@ const CreateInfrastructureMonitor = () => {
|
||||
type="text"
|
||||
id="secret"
|
||||
name="secret"
|
||||
label={t("infrastructureAuthorizationSecretLabel")}
|
||||
label={
|
||||
monitorType === "docker"
|
||||
? "Capture API Secret"
|
||||
: t("infrastructureAuthorizationSecretLabel")
|
||||
}
|
||||
placeholder={monitorType === "docker" ? "Bearer token for Capture API" : ""}
|
||||
value={infrastructureMonitor.secret}
|
||||
onChange={onChange}
|
||||
error={errors["secret"] ? true : false}
|
||||
@@ -321,12 +358,14 @@ const CreateInfrastructureMonitor = () => {
|
||||
/>
|
||||
</Stack>
|
||||
</ConfigBox>
|
||||
<CustomAlertsSection
|
||||
errors={errors}
|
||||
onChange={onChange}
|
||||
infrastructureMonitor={infrastructureMonitor}
|
||||
handleCheckboxChange={handleCheckboxChange}
|
||||
/>
|
||||
{monitorType === "hardware" && (
|
||||
<CustomAlertsSection
|
||||
errors={errors}
|
||||
onChange={onChange}
|
||||
infrastructureMonitor={infrastructureMonitor}
|
||||
handleCheckboxChange={handleCheckboxChange}
|
||||
/>
|
||||
)}
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
<Typography
|
||||
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import PropTypes from "prop-types";
|
||||
import DataTable from "@/Components/v1/Table/index.jsx";
|
||||
import { StatusLabel } from "@/Components/v1/Label/index.jsx";
|
||||
|
||||
const DockerContainersTable = ({ containers = [], errors = [], captureVersion }) => {
|
||||
const theme = useTheme();
|
||||
|
||||
// Helper to format uptime
|
||||
const formatUptime = (startedAt, finishedAt, running) => {
|
||||
if (!running && finishedAt > 0) {
|
||||
const stoppedAgo = Math.floor(Date.now() / 1000) - finishedAt;
|
||||
return formatDuration(stoppedAgo) + " ago";
|
||||
}
|
||||
if (running && startedAt > 0) {
|
||||
const uptimeSeconds = Math.floor(Date.now() / 1000) - startedAt;
|
||||
return formatDuration(uptimeSeconds);
|
||||
}
|
||||
return "N/A";
|
||||
};
|
||||
|
||||
// Helper to format duration
|
||||
const formatDuration = (seconds) => {
|
||||
const days = Math.floor(seconds / 86400);
|
||||
const hours = Math.floor((seconds % 86400) / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
|
||||
if (days > 0) return `${days}d ${hours}h`;
|
||||
if (hours > 0) return `${hours}h ${minutes}m`;
|
||||
if (minutes > 0) return `${minutes}m`;
|
||||
return `${seconds}s`;
|
||||
};
|
||||
|
||||
// Helper to get status color
|
||||
const getStatusColor = (status, running, healthy) => {
|
||||
if (status === "running" && healthy) return "success";
|
||||
if (status === "running" && !healthy) return "warning";
|
||||
if (status === "exited") return "error";
|
||||
if (status === "paused") return "warning";
|
||||
if (status === "restarting") return "warning";
|
||||
return "default";
|
||||
};
|
||||
|
||||
const headers = [
|
||||
{
|
||||
id: "name",
|
||||
content: "Container Name",
|
||||
render: (row) => (
|
||||
<Box>
|
||||
<Typography
|
||||
variant="body2"
|
||||
fontWeight={600}
|
||||
>
|
||||
{row.container_name || "Unnamed"}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
color={theme.palette.primary.contrastTextTertiary}
|
||||
>
|
||||
{row.container_id ? row.container_id.substring(0, 12) : "N/A"}
|
||||
</Typography>
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "status",
|
||||
content: "Status",
|
||||
render: (row) => (
|
||||
<StatusLabel
|
||||
status={getStatusColor(row.status, row.running, row.health?.healthy)}
|
||||
text={row.status || "unknown"}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "health",
|
||||
content: "Health",
|
||||
render: (row) => (
|
||||
<Box>
|
||||
<Typography
|
||||
variant="body2"
|
||||
color={row.health?.healthy ? theme.palette.success.main : theme.palette.error.main}
|
||||
>
|
||||
{row.health?.healthy ? "Healthy" : "Unhealthy"}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
color={theme.palette.primary.contrastTextTertiary}
|
||||
>
|
||||
{row.health?.source === "container_health_check" ? "HEALTHCHECK" : "State-based"}
|
||||
</Typography>
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "image",
|
||||
content: "Image",
|
||||
render: (row) => (
|
||||
<Typography variant="body2">{row.base_image || "N/A"}</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "uptime",
|
||||
content: "Uptime",
|
||||
render: (row) => (
|
||||
<Typography variant="body2">
|
||||
{formatUptime(row.started_at, row.finished_at, row.running)}
|
||||
</Typography>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "ports",
|
||||
content: "Ports",
|
||||
render: (row) => (
|
||||
<Box>
|
||||
{row.exposed_ports && row.exposed_ports.length > 0 ? (
|
||||
row.exposed_ports.map((port, idx) => (
|
||||
<Typography
|
||||
key={`${port.port}-${port.protocol}-${idx}`}
|
||||
variant="caption"
|
||||
sx={{ display: "block" }}
|
||||
>
|
||||
{port.port}/{port.protocol}
|
||||
</Typography>
|
||||
))
|
||||
) : (
|
||||
<Typography
|
||||
variant="caption"
|
||||
color={theme.palette.primary.contrastTextTertiary}
|
||||
>
|
||||
None
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
// Check if there are critical errors (Docker daemon down)
|
||||
const dockerClientError = errors.find((e) => e.metric && e.metric.includes("docker.client"));
|
||||
|
||||
if (!containers || containers.length === 0) {
|
||||
// Determine the message based on error type
|
||||
let message = "No containers found";
|
||||
let errorDetails = null;
|
||||
|
||||
if (dockerClientError) {
|
||||
message = "Docker daemon unavailable";
|
||||
errorDetails = dockerClientError.err;
|
||||
} else if (errors && errors.length > 0) {
|
||||
message = "Partial data available";
|
||||
errorDetails = "Some containers could not be inspected";
|
||||
}
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
padding: theme.spacing(12),
|
||||
textAlign: "center",
|
||||
border: dockerClientError
|
||||
? `2px solid ${theme.palette.error.main}`
|
||||
: `1px solid ${theme.palette.divider}`,
|
||||
borderRadius: theme.spacing(2),
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="body1"
|
||||
color={dockerClientError ? theme.palette.error.main : theme.palette.primary.contrastTextTertiary}
|
||||
fontWeight={600}
|
||||
mb={errorDetails ? theme.spacing(2) : 0}
|
||||
>
|
||||
{message}
|
||||
</Typography>
|
||||
{errorDetails && (
|
||||
<Typography
|
||||
variant="body2"
|
||||
color={theme.palette.primary.contrastTextSecondary}
|
||||
>
|
||||
{errorDetails}
|
||||
</Typography>
|
||||
)}
|
||||
{captureVersion && (
|
||||
<Typography
|
||||
variant="caption"
|
||||
color={theme.palette.primary.contrastTextTertiary}
|
||||
sx={{ display: "block", marginTop: theme.spacing(4) }}
|
||||
>
|
||||
Capture version: {captureVersion}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack gap={theme.spacing(4)}>
|
||||
<Box>
|
||||
<Typography
|
||||
variant="h3"
|
||||
fontWeight={600}
|
||||
>
|
||||
Docker Containers ({containers.length})
|
||||
</Typography>
|
||||
{errors && errors.length > 0 && (
|
||||
<Typography
|
||||
variant="caption"
|
||||
color={theme.palette.warning.main}
|
||||
sx={{ display: "block", marginTop: theme.spacing(1) }}
|
||||
>
|
||||
⚠ {errors.length} error(s) encountered while fetching container data
|
||||
</Typography>
|
||||
)}
|
||||
{captureVersion && (
|
||||
<Typography
|
||||
variant="caption"
|
||||
color={theme.palette.primary.contrastTextTertiary}
|
||||
sx={{ display: "block", marginTop: theme.spacing(1) }}
|
||||
>
|
||||
Capture version: {captureVersion}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
<DataTable
|
||||
headers={headers}
|
||||
data={containers}
|
||||
config={{
|
||||
emptyView: "No containers found",
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
DockerContainersTable.propTypes = {
|
||||
containers: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
container_id: PropTypes.string,
|
||||
container_name: PropTypes.string,
|
||||
status: PropTypes.string,
|
||||
health: PropTypes.shape({
|
||||
healthy: PropTypes.bool,
|
||||
source: PropTypes.string,
|
||||
message: PropTypes.string,
|
||||
}),
|
||||
running: PropTypes.bool,
|
||||
base_image: PropTypes.string,
|
||||
exposed_ports: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
port: PropTypes.string,
|
||||
protocol: PropTypes.string,
|
||||
})
|
||||
),
|
||||
started_at: PropTypes.number,
|
||||
finished_at: PropTypes.number,
|
||||
})
|
||||
),
|
||||
errors: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
metric: PropTypes.arrayOf(PropTypes.string),
|
||||
err: PropTypes.string,
|
||||
})
|
||||
),
|
||||
captureVersion: PropTypes.string,
|
||||
};
|
||||
|
||||
export default DockerContainersTable;
|
||||
@@ -8,6 +8,7 @@ import GaugeBoxes from "./Components/GaugeBoxes/index.jsx";
|
||||
import AreaChartBoxes from "./Components/AreaChartBoxes/index.jsx";
|
||||
import GenericFallback from "@/Components/v1/GenericFallback/index.jsx";
|
||||
import NetworkStats from "./Components/NetworkStats/index.jsx";
|
||||
import DockerContainersTable from "./Components/DockerContainersTable/index.jsx";
|
||||
import CustomTabList from "@/Components/v1/Tab/index.jsx";
|
||||
import TabContext from "@mui/lab/TabContext";
|
||||
|
||||
@@ -98,12 +99,27 @@ const InfrastructureDetails = () => {
|
||||
label={t("details")}
|
||||
value="details"
|
||||
/>
|
||||
<Tab
|
||||
label={t("network")}
|
||||
value="network"
|
||||
/>
|
||||
{monitor?.type !== "docker" && (
|
||||
<Tab
|
||||
label={t("network")}
|
||||
value="network"
|
||||
/>
|
||||
)}
|
||||
</CustomTabList>
|
||||
{tab === "details" && (
|
||||
{tab === "details" && monitor?.type === "docker" && (
|
||||
<>
|
||||
<StatusBoxes
|
||||
shouldRender={!isLoading}
|
||||
monitor={monitor}
|
||||
/>
|
||||
<DockerContainersTable
|
||||
containers={monitor?.stats?.aggregateData?.latestCheck?.docker || []}
|
||||
errors={monitor?.stats?.aggregateData?.latestCheck?.errors || []}
|
||||
captureVersion={monitor?.stats?.aggregateData?.latestCheck?.capture?.version}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{tab === "details" && monitor?.type !== "docker" && (
|
||||
<>
|
||||
<StatusBoxes
|
||||
shouldRender={!isLoading}
|
||||
@@ -125,7 +141,7 @@ const InfrastructureDetails = () => {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{tab === "network" && (
|
||||
{tab === "network" && monitor?.type !== "docker" && (
|
||||
<NetworkStats
|
||||
net={monitor?.stats?.aggregateData?.latestCheck?.net || []}
|
||||
isLoading={isLoading}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Components
|
||||
import { Stack } from "@mui/material";
|
||||
import { Stack, Tab } from "@mui/material";
|
||||
import { TabContext, TabPanel } from "@mui/lab";
|
||||
import Breadcrumbs from "@/Components/v1/Breadcrumbs/index.jsx";
|
||||
import MonitorCountHeader from "@/Components/v1/MonitorCountHeader/index.jsx";
|
||||
import MonitorCreateHeader from "@/Components/v1/MonitorCreateHeader/index.jsx";
|
||||
@@ -8,6 +9,7 @@ import Pagination from "@/Components/v1/Table/TablePagination/index.jsx";
|
||||
import PageStateWrapper from "@/Components/v1/PageStateWrapper/index.jsx";
|
||||
import Filter from "./Components/Filters/index.jsx";
|
||||
import SearchComponent from "../../Uptime/Monitors/Components/SearchComponent/index.jsx";
|
||||
import CustomTabList from "@/Components/v1/Tab/index.jsx";
|
||||
// Utils
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { useEffect, useState } from "react";
|
||||
@@ -17,7 +19,6 @@ import { useFetchMonitorsByTeamId } from "../../../../Hooks/v1/monitorHooks.js";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { setRowsPerPage } from "../../../../Features/UI/uiSlice.js";
|
||||
// Constants
|
||||
const TYPES = ["hardware"];
|
||||
const BREADCRUMBS = [{ name: `infrastructure`, path: "/infrastructure" }];
|
||||
|
||||
const InfrastructureMonitors = () => {
|
||||
@@ -26,6 +27,7 @@ const InfrastructureMonitors = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
// Local state
|
||||
const [tab, setTab] = useState("hardware");
|
||||
const [page, setPage] = useState(0);
|
||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||
const [selectedStatus, setSelectedStatus] = useState(undefined);
|
||||
@@ -39,6 +41,14 @@ const InfrastructureMonitors = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Handlers
|
||||
const handleTabChange = (event, newTab) => {
|
||||
setTab(newTab);
|
||||
setPage(0); // Reset to first page when changing tabs
|
||||
setSearch(undefined); // Clear search
|
||||
setSelectedStatus(undefined); // Clear filters
|
||||
setToFilterStatus(undefined);
|
||||
};
|
||||
|
||||
const handleActionMenuDelete = () => {
|
||||
setUpdateTrigger(!updateTrigger);
|
||||
};
|
||||
@@ -70,9 +80,12 @@ const InfrastructureMonitors = () => {
|
||||
|
||||
const field = toFilterStatus !== undefined ? "status" : undefined;
|
||||
|
||||
// Determine monitor types based on active tab
|
||||
const types = tab === "hardware" ? ["hardware"] : ["docker"];
|
||||
|
||||
const [monitors, summary, isLoading, networkError] = useFetchMonitorsByTeamId({
|
||||
limit: 1,
|
||||
types: TYPES,
|
||||
types: types,
|
||||
page,
|
||||
field: field,
|
||||
filter: toFilterStatus ?? search,
|
||||
@@ -82,55 +95,113 @@ const InfrastructureMonitors = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageStateWrapper
|
||||
networkError={networkError}
|
||||
isLoading={isLoading}
|
||||
items={monitors}
|
||||
type="infrastructureMonitor"
|
||||
fallbackLink="/infrastructure/create"
|
||||
>
|
||||
<Stack gap={theme.spacing(10)}>
|
||||
<Breadcrumbs list={BREADCRUMBS} />
|
||||
<MonitorCreateHeader
|
||||
isAdmin={isAdmin}
|
||||
isLoading={isLoading}
|
||||
path="/infrastructure/create"
|
||||
/>
|
||||
<Stack direction={"row"}>
|
||||
<MonitorCountHeader
|
||||
isLoading={isLoading}
|
||||
monitorCount={summary?.totalMonitors ?? 0}
|
||||
/>
|
||||
<Filter
|
||||
selectedStatus={selectedStatus}
|
||||
setSelectedStatus={setSelectedStatus}
|
||||
setToFilterStatus={setToFilterStatus}
|
||||
handleReset={handleReset}
|
||||
/>
|
||||
<SearchComponent
|
||||
monitors={monitors}
|
||||
onSearchChange={setSearch}
|
||||
setIsSearching={setIsSearching}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack gap={theme.spacing(10)}>
|
||||
<Breadcrumbs list={BREADCRUMBS} />
|
||||
<MonitorCreateHeader
|
||||
isAdmin={isAdmin}
|
||||
isLoading={isLoading}
|
||||
path={tab === "docker" ? "/infrastructure/create?type=docker" : "/infrastructure/create?type=hardware"}
|
||||
/>
|
||||
|
||||
<MonitorsTable
|
||||
isLoading={isLoading}
|
||||
monitors={monitors}
|
||||
isAdmin={isAdmin}
|
||||
handleActionMenuDelete={handleActionMenuDelete}
|
||||
isSearching={isSearching}
|
||||
/>
|
||||
<Pagination
|
||||
itemCount={summary?.totalMonitors}
|
||||
paginationLabel={t("monitors")}
|
||||
page={page}
|
||||
rowsPerPage={rowsPerPage}
|
||||
handleChangePage={handleChangePage}
|
||||
handleChangeRowsPerPage={handleChangeRowsPerPage}
|
||||
/>
|
||||
</Stack>
|
||||
</PageStateWrapper>
|
||||
<TabContext value={tab}>
|
||||
<CustomTabList value={tab} onChange={handleTabChange}>
|
||||
<Tab label="Hardware" value="hardware" />
|
||||
<Tab label="Docker Monitoring" value="docker" />
|
||||
</CustomTabList>
|
||||
|
||||
<TabPanel value="hardware" sx={{ padding: 0 }}>
|
||||
<PageStateWrapper
|
||||
networkError={networkError}
|
||||
isLoading={isLoading}
|
||||
items={monitors}
|
||||
type="infrastructureMonitor"
|
||||
fallbackLink="/infrastructure/create?type=hardware"
|
||||
>
|
||||
<Stack gap={theme.spacing(10)}>
|
||||
<Stack direction={"row"}>
|
||||
<MonitorCountHeader
|
||||
isLoading={isLoading}
|
||||
monitorCount={summary?.totalMonitors ?? 0}
|
||||
/>
|
||||
<Filter
|
||||
selectedStatus={selectedStatus}
|
||||
setSelectedStatus={setSelectedStatus}
|
||||
setToFilterStatus={setToFilterStatus}
|
||||
handleReset={handleReset}
|
||||
/>
|
||||
<SearchComponent
|
||||
monitors={monitors}
|
||||
onSearchChange={setSearch}
|
||||
setIsSearching={setIsSearching}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<MonitorsTable
|
||||
isLoading={isLoading}
|
||||
monitors={monitors}
|
||||
isAdmin={isAdmin}
|
||||
handleActionMenuDelete={handleActionMenuDelete}
|
||||
isSearching={isSearching}
|
||||
/>
|
||||
<Pagination
|
||||
itemCount={summary?.totalMonitors}
|
||||
paginationLabel={t("monitors")}
|
||||
page={page}
|
||||
rowsPerPage={rowsPerPage}
|
||||
handleChangePage={handleChangePage}
|
||||
handleChangeRowsPerPage={handleChangeRowsPerPage}
|
||||
/>
|
||||
</Stack>
|
||||
</PageStateWrapper>
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel value="docker" sx={{ padding: 0 }}>
|
||||
<PageStateWrapper
|
||||
networkError={networkError}
|
||||
isLoading={isLoading}
|
||||
items={monitors}
|
||||
type="infrastructureMonitor"
|
||||
fallbackLink="/infrastructure/create?type=docker"
|
||||
>
|
||||
<Stack gap={theme.spacing(10)}>
|
||||
<Stack direction={"row"}>
|
||||
<MonitorCountHeader
|
||||
isLoading={isLoading}
|
||||
monitorCount={summary?.totalMonitors ?? 0}
|
||||
/>
|
||||
<Filter
|
||||
selectedStatus={selectedStatus}
|
||||
setSelectedStatus={setSelectedStatus}
|
||||
setToFilterStatus={setToFilterStatus}
|
||||
handleReset={handleReset}
|
||||
/>
|
||||
<SearchComponent
|
||||
monitors={monitors}
|
||||
onSearchChange={setSearch}
|
||||
setIsSearching={setIsSearching}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<MonitorsTable
|
||||
isLoading={isLoading}
|
||||
monitors={monitors}
|
||||
isAdmin={isAdmin}
|
||||
handleActionMenuDelete={handleActionMenuDelete}
|
||||
isSearching={isSearching}
|
||||
/>
|
||||
<Pagination
|
||||
itemCount={summary?.totalMonitors}
|
||||
paginationLabel={t("monitors")}
|
||||
page={page}
|
||||
rowsPerPage={rowsPerPage}
|
||||
handleChangePage={handleChangePage}
|
||||
handleChangeRowsPerPage={handleChangeRowsPerPage}
|
||||
/>
|
||||
</Stack>
|
||||
</PageStateWrapper>
|
||||
</TabPanel>
|
||||
</TabContext>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -223,18 +223,54 @@ const CreateNotifications = () => {
|
||||
<Typography component="p">{t(DESCRIPTION_MAP[type])}</Typography>
|
||||
</Box>
|
||||
<Stack gap={theme.spacing(12)}>
|
||||
<TextInput
|
||||
label={t(LABEL_MAP[type])}
|
||||
name="address"
|
||||
placeholder={t(PLACEHOLDER_MAP[type])}
|
||||
value={notification.address}
|
||||
onChange={onChange}
|
||||
error={Boolean(errors.address)}
|
||||
helperText={errors["address"]}
|
||||
/>
|
||||
{type === "matrix" ? (
|
||||
<>
|
||||
<TextInput
|
||||
label={t("createNotifications.matrixSettings.homeserverLabel")}
|
||||
name="homeserverUrl"
|
||||
placeholder={t(
|
||||
"createNotifications.matrixSettings.homeserverPlaceholder"
|
||||
)}
|
||||
value={notification.homeserverUrl || ""}
|
||||
onChange={onChange}
|
||||
error={Boolean(errors.homeserverUrl)}
|
||||
helperText={errors["homeserverUrl"]}
|
||||
/>
|
||||
<TextInput
|
||||
label={t("createNotifications.matrixSettings.roomIdLabel")}
|
||||
name="roomId"
|
||||
placeholder={t("createNotifications.matrixSettings.roomIdPlaceholder")}
|
||||
value={notification.roomId || ""}
|
||||
onChange={onChange}
|
||||
error={Boolean(errors.roomId)}
|
||||
helperText={errors["roomId"]}
|
||||
/>
|
||||
<TextInput
|
||||
label={t("createNotifications.matrixSettings.accessTokenLabel")}
|
||||
name="accessToken"
|
||||
type="password"
|
||||
placeholder={t(
|
||||
"createNotifications.matrixSettings.accessTokenPlaceholder"
|
||||
)}
|
||||
value={notification.accessToken || ""}
|
||||
onChange={onChange}
|
||||
error={Boolean(errors.accessToken)}
|
||||
helperText={errors["accessToken"]}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<TextInput
|
||||
label={t(LABEL_MAP[type])}
|
||||
name="address"
|
||||
placeholder={t(PLACEHOLDER_MAP[type])}
|
||||
value={notification.address}
|
||||
onChange={onChange}
|
||||
error={Boolean(errors.address)}
|
||||
helperText={errors["address"]}
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
</ConfigBox>
|
||||
|
||||
</ConfigBox>{" "}
|
||||
<Stack
|
||||
direction="row"
|
||||
justifyContent="flex-end"
|
||||
|
||||
@@ -4,6 +4,7 @@ export const NOTIFICATION_TYPES = [
|
||||
{ _id: 3, name: "PagerDuty", value: "pager_duty" },
|
||||
{ _id: 4, name: "Webhook", value: "webhook" },
|
||||
{ _id: 5, name: "Discord", value: "discord" },
|
||||
{ _id: 6, name: "Matrix", value: "matrix" },
|
||||
];
|
||||
|
||||
export const TITLE_MAP = {
|
||||
@@ -12,6 +13,7 @@ export const TITLE_MAP = {
|
||||
pager_duty: "createNotifications.pagerdutySettings.title",
|
||||
webhook: "createNotifications.webhookSettings.title",
|
||||
discord: "createNotifications.discordSettings.title",
|
||||
matrix: "createNotifications.matrixSettings.title",
|
||||
};
|
||||
|
||||
export const DESCRIPTION_MAP = {
|
||||
@@ -20,6 +22,7 @@ export const DESCRIPTION_MAP = {
|
||||
pager_duty: "createNotifications.pagerdutySettings.description",
|
||||
webhook: "createNotifications.webhookSettings.description",
|
||||
discord: "createNotifications.discordSettings.description",
|
||||
matrix: "createNotifications.matrixSettings.description",
|
||||
};
|
||||
|
||||
export const LABEL_MAP = {
|
||||
@@ -28,6 +31,7 @@ export const LABEL_MAP = {
|
||||
pager_duty: "createNotifications.pagerdutySettings.integrationKeyLabel",
|
||||
webhook: "createNotifications.webhookSettings.webhookLabel",
|
||||
discord: "createNotifications.discordSettings.webhookLabel",
|
||||
matrix: "createNotifications.matrixSettings.homeserverLabel",
|
||||
};
|
||||
|
||||
export const PLACEHOLDER_MAP = {
|
||||
@@ -36,4 +40,5 @@ export const PLACEHOLDER_MAP = {
|
||||
pager_duty: "createNotifications.pagerdutySettings.integrationKeyPlaceholder",
|
||||
webhook: "createNotifications.webhookSettings.webhookPlaceholder",
|
||||
discord: "createNotifications.discordSettings.webhookPlaceholder",
|
||||
matrix: "createNotifications.matrixSettings.homeserverPlaceholder",
|
||||
};
|
||||
@@ -14,7 +14,7 @@ const useMonitorsFetch = () => {
|
||||
try {
|
||||
const response = await networkService.getMonitorsByTeamId({
|
||||
limit: null, // donot return any checks for the monitors
|
||||
types: ["http", "ping", "port"], // status page is available for uptime, ping, and port monitors
|
||||
types: ["http", "ping", "port", "game"], // include game servers in status page monitor selection
|
||||
});
|
||||
setMonitors(response.data.data.monitors);
|
||||
} catch (error) {
|
||||
|
||||
@@ -30,7 +30,9 @@ const MonitorsList = ({
|
||||
<Stack
|
||||
key={monitor._id}
|
||||
width="100%"
|
||||
gap={theme.spacing(2)}
|
||||
gap={theme.spacing(10)}
|
||||
margin="0 auto"
|
||||
maxWidth="95%"
|
||||
>
|
||||
<Host
|
||||
key={monitor._id}
|
||||
@@ -39,24 +41,18 @@ const MonitorsList = ({
|
||||
percentageColor={monitor.percentageColor}
|
||||
percentage={monitor.percentage}
|
||||
showURL={showURL}
|
||||
status={status}
|
||||
/>
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
gap={theme.spacing(20)}
|
||||
gap={theme.spacing(1)}
|
||||
>
|
||||
{statusPage.showCharts !== false && (
|
||||
<Box flex={9}>
|
||||
<StatusPageBarChart checks={monitor?.checks?.slice().reverse()} />
|
||||
</Box>
|
||||
)}
|
||||
<Box flex={statusPage.showCharts !== false ? 1 : 10}>
|
||||
<StatusLabel
|
||||
status={status}
|
||||
text={status}
|
||||
customStyles={{ textTransform: "capitalize" }}
|
||||
/>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -7,6 +7,80 @@ import { StatusLabel } from "@/Components/v1/Label/index.jsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { formatDateWithTz } from "../../../../../../Utils/timeUtils.js";
|
||||
import SkeletonLayout from "./skeleton.jsx";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import Box from "@mui/material/Box";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import { lighten, useTheme } from "@mui/material";
|
||||
|
||||
/**
|
||||
* Creates tooltip content with detailed timing breakdown
|
||||
* Following the pattern from IncidentTable's GetTooltip function
|
||||
* @param {Object} timings - Timing object (guaranteed to have phases by caller)
|
||||
* @param {Object} theme - MUI theme object
|
||||
* @param {Function} t - Translation function
|
||||
* @returns {JSX.Element} Tooltip content
|
||||
*/
|
||||
const GetTooltip = (timings, theme, t) => {
|
||||
const phases = timings.phases;
|
||||
const timingDetails = [
|
||||
{ label: t("dnsLookup"), value: phases.dns },
|
||||
{ label: t("tcpConnection"), value: phases.tcp },
|
||||
{ label: t("tlsHandshake"), value: phases.tls },
|
||||
{ label: t("waitTime"), value: phases.wait },
|
||||
{ label: t("timeToFirstByte"), value: phases.firstByte },
|
||||
{ label: t("download"), value: phases.download },
|
||||
{ label: t("total"), value: phases.total },
|
||||
].filter((item) => item.value > 0);
|
||||
|
||||
return (
|
||||
<Stack
|
||||
sx={{
|
||||
py: theme.spacing(2),
|
||||
px: theme.spacing(4),
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
fontWeight: 600,
|
||||
marginBottom: theme.spacing(1),
|
||||
color: theme.palette.primary.contrastText,
|
||||
}}
|
||||
>
|
||||
{t("responseTimeBreakdown")}
|
||||
</Typography>
|
||||
{timingDetails.map((detail, index, array) => (
|
||||
<Box
|
||||
key={index}
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
gap: theme.spacing(4),
|
||||
marginBottom: index < array.length - 1 ? theme.spacing(0.5) : 0,
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{ color: theme.palette.primary.contrastText }}
|
||||
>
|
||||
{detail.label}:
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
fontWeight: index === array.length - 1 ? 600 : 400,
|
||||
color: theme.palette.primary.contrastText,
|
||||
}}
|
||||
>
|
||||
{Math.round(detail.value)} ms
|
||||
</Typography>
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
const ResponseTable = ({
|
||||
isLoading = false,
|
||||
checks = [],
|
||||
@@ -18,6 +92,8 @@ const ResponseTable = ({
|
||||
setRowsPerPage,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
|
||||
if (isLoading) {
|
||||
return <SkeletonLayout />;
|
||||
}
|
||||
@@ -54,6 +130,56 @@ const ResponseTable = ({
|
||||
content: t("message"),
|
||||
render: (row) => row.message,
|
||||
},
|
||||
{
|
||||
id: "responseTime",
|
||||
content: t("responseTime"),
|
||||
render: (row) => {
|
||||
const hasTimings = row.timings && row.timings.phases;
|
||||
const responseTime = row.responseTime;
|
||||
const responseTimeDisplay =
|
||||
responseTime !== null && responseTime !== undefined
|
||||
? `${Math.round(responseTime)} ms`
|
||||
: "N/A";
|
||||
|
||||
if (!hasTimings) {
|
||||
return responseTimeDisplay;
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
title={GetTooltip(row.timings, theme, t)}
|
||||
placement="top"
|
||||
arrow
|
||||
enterDelay={300}
|
||||
enterNextDelay={300}
|
||||
slotProps={{
|
||||
tooltip: {
|
||||
sx: {
|
||||
backgroundColor: lighten(theme.palette.primary.main, 0.1),
|
||||
border: `1px solid ${theme.palette.primary.lowContrast}`,
|
||||
borderRadius: theme.shape.borderRadius,
|
||||
"& .MuiTooltip-arrow": {
|
||||
color: lighten(theme.palette.primary.main, 0.1),
|
||||
"&::before": {
|
||||
border: `1px solid ${theme.palette.primary.lowContrast}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
cursor: "help",
|
||||
display: "inline-block",
|
||||
}}
|
||||
>
|
||||
{responseTimeDisplay}
|
||||
</Box>
|
||||
</Tooltip>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { MonitorStatus } from "@/Types/Monitor";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useGet } from "@/Hooks/v2/UseApi";
|
||||
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||
import { formatDateWithTz } from "@/Utils/v2/TimeUtils";
|
||||
import { useSelector } from "react-redux";
|
||||
const getHeaders = (t: Function, uiTimezone: string) => {
|
||||
const headers: Header<Check>[] = [
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { monitorSchema } from "@/Validation/v2/zod";
|
||||
import { useGet, usePost } from "@/Hooks/v2/UseApi";
|
||||
import { UptimeForm } from "@/Pages/v2/Uptime/UptimeForm";
|
||||
|
||||
import { useParams } from "react-router";
|
||||
import type { ApiResponse } from "@/Hooks/v2/UseApi";
|
||||
import humanInterval from "human-interval";
|
||||
import { z } from "zod";
|
||||
|
||||
export const UptimeConfigurePage = () => {
|
||||
type FormValues = z.infer<typeof monitorSchema>;
|
||||
type SubmitValues = Omit<FormValues, "interval"> & { interval: number | undefined };
|
||||
|
||||
const { id } = useParams();
|
||||
const { response } = useGet<ApiResponse>("/notification-channels");
|
||||
const { response: monitorResponse } = useGet<ApiResponse>(`/monitors/${id}`);
|
||||
const monitor = monitorResponse?.data || null;
|
||||
const notificationOptions = response?.data ?? [];
|
||||
|
||||
const { post, loading, error } = usePost<SubmitValues, ApiResponse>();
|
||||
|
||||
const onSubmit = async (data: FormValues) => {
|
||||
let interval = humanInterval(data.interval);
|
||||
if (!interval) interval = 60000;
|
||||
const submitData = { ...data, interval };
|
||||
const result = await post("/monitors", submitData);
|
||||
if (result) {
|
||||
console.log(result);
|
||||
} else {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<UptimeForm
|
||||
initialData={{
|
||||
...monitor,
|
||||
}}
|
||||
onSubmit={onSubmit}
|
||||
notificationOptions={notificationOptions}
|
||||
loading={loading}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -14,7 +14,7 @@ import { useTheme } from "@mui/material/styles";
|
||||
import { useParams } from "react-router";
|
||||
import { useGet, usePatch, type ApiResponse } from "@/Hooks/v2/UseApi";
|
||||
import { useState } from "react";
|
||||
import { getStatusPalette } from "@/Utils/MonitorUtils";
|
||||
import { getStatusPalette } from "@/Utils/v2/MonitorUtils";
|
||||
import prettyMilliseconds from "pretty-ms";
|
||||
|
||||
const UptimeDetailsPage = () => {
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
import Stack from "@mui/material/Stack";
|
||||
import { TextInput } from "@/Components/v2/Inputs/TextInput";
|
||||
import { AutoCompleteInput } from "@/Components/v2/Inputs/AutoComplete";
|
||||
import { ConfigBox, BasePage } from "@/Components/v2/DesignElements";
|
||||
import RadioGroup from "@mui/material/RadioGroup";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import { RadioWithDescription } from "@/Components/v2/Inputs/RadioInput";
|
||||
import { Button } from "@/Components/v2/Inputs";
|
||||
import DeleteOutlineRoundedIcon from "@mui/icons-material/DeleteOutlineRounded";
|
||||
import { Typography } from "@mui/material";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { monitorSchema } from "@/Validation/v2/zod";
|
||||
import { z } from "zod";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useForm, Controller, useWatch, type SubmitHandler } from "react-hook-form";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { useInitForm } from "@/Hooks/v2/useInitMonitorForm";
|
||||
|
||||
type FormValues = z.infer<typeof monitorSchema>;
|
||||
|
||||
export const UptimeForm = ({
|
||||
initialData,
|
||||
onSubmit,
|
||||
notificationOptions,
|
||||
loading,
|
||||
}: {
|
||||
initialData?: Partial<FormValues>;
|
||||
onSubmit: SubmitHandler<FormValues>;
|
||||
notificationOptions: any[];
|
||||
loading: boolean;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const { defaults } = useInitForm({ initialData: initialData });
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
setValue,
|
||||
formState: { errors },
|
||||
} = useForm<FormValues>({
|
||||
resolver: zodResolver(monitorSchema) as any,
|
||||
defaultValues: defaults,
|
||||
mode: "onChange",
|
||||
});
|
||||
|
||||
const selectedType = useWatch({
|
||||
control,
|
||||
name: "type",
|
||||
});
|
||||
const notificationChannels = useWatch({
|
||||
control,
|
||||
name: "notificationChannels",
|
||||
});
|
||||
|
||||
return (
|
||||
<BasePage
|
||||
component={"form"}
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
>
|
||||
<ConfigBox
|
||||
title={t("distributedUptimeCreateChecks")}
|
||||
subtitle={t("distributedUptimeCreateChecksDescription")}
|
||||
rightContent={
|
||||
<Controller
|
||||
name="type"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<FormControl error={!!errors.type}>
|
||||
<RadioGroup
|
||||
{...field}
|
||||
sx={{ gap: theme.spacing(6) }}
|
||||
>
|
||||
<RadioWithDescription
|
||||
value="http"
|
||||
label={"HTTP"}
|
||||
description={"Use HTTP to monitor your website or API endpoint."}
|
||||
/>
|
||||
<RadioWithDescription
|
||||
value="https"
|
||||
label="HTTPS"
|
||||
description="Use HTTPS to monitor your website or API endpoint.
|
||||
"
|
||||
/>
|
||||
<RadioWithDescription
|
||||
value="ping"
|
||||
label={t("pingMonitoring")}
|
||||
description={t("pingMonitoringDescription")}
|
||||
/>
|
||||
</RadioGroup>
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<ConfigBox
|
||||
title={t("settingsGeneralSettings")}
|
||||
subtitle={t(`uptimeGeneralInstructions.${selectedType}`)}
|
||||
rightContent={
|
||||
<Stack gap={theme.spacing(8)}>
|
||||
<Controller
|
||||
name="url"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextInput
|
||||
{...field}
|
||||
type="text"
|
||||
label={t("url")}
|
||||
fullWidth
|
||||
error={!!errors.url}
|
||||
helperText={errors.url ? errors.url.message : ""}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="name"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextInput
|
||||
{...field}
|
||||
type="text"
|
||||
label={t("displayName")}
|
||||
fullWidth
|
||||
error={!!errors.name}
|
||||
helperText={errors.name ? errors.name.message : ""}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
<ConfigBox
|
||||
title={t("createMonitorPage.incidentConfigTitle")}
|
||||
subtitle={t("createMonitorPage.incidentConfigDescriptionV2")}
|
||||
rightContent={
|
||||
<Controller
|
||||
name="n"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextInput
|
||||
{...field}
|
||||
type="number"
|
||||
label={t("createMonitorPage.incidentConfigStatusCheckNumber")}
|
||||
fullWidth
|
||||
error={!!errors.n}
|
||||
helperText={errors.n ? errors.n.message : ""}
|
||||
onChange={(e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
field.onChange(target.valueAsNumber);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<ConfigBox
|
||||
title={t("notificationConfig.title")}
|
||||
subtitle={t("notificationConfig.description")}
|
||||
rightContent={
|
||||
<Stack>
|
||||
<Controller
|
||||
name="notificationChannels"
|
||||
control={control}
|
||||
defaultValue={[]} // important!
|
||||
render={({ field }) => (
|
||||
<AutoCompleteInput
|
||||
multiple
|
||||
options={notificationOptions}
|
||||
getOptionLabel={(option) => option.name}
|
||||
value={notificationOptions.filter((o: any) =>
|
||||
(field.value || []).includes(o._id)
|
||||
)}
|
||||
onChange={(_, newValue) => {
|
||||
field.onChange(newValue.map((o: any) => o._id));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Stack
|
||||
gap={theme.spacing(2)}
|
||||
mt={theme.spacing(2)}
|
||||
>
|
||||
{notificationChannels.map((notificationId) => {
|
||||
const option = notificationOptions.find(
|
||||
(o: any) => o._id === notificationId
|
||||
);
|
||||
if (!option) return null;
|
||||
return (
|
||||
<Stack
|
||||
width={"100%"}
|
||||
justifyContent={"space-between"}
|
||||
direction="row"
|
||||
key={notificationId}
|
||||
>
|
||||
<Typography>{option.name}</Typography>
|
||||
<DeleteOutlineRoundedIcon
|
||||
onClick={() => {
|
||||
const updated = notificationChannels.filter(
|
||||
(id) => id !== notificationId
|
||||
);
|
||||
setValue("notificationChannels", updated);
|
||||
}}
|
||||
sx={{ cursor: "pointer" }}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
})}
|
||||
</Stack>
|
||||
</Stack>
|
||||
}
|
||||
/>
|
||||
<ConfigBox
|
||||
title={t("createMonitorPage.intervalTitle")}
|
||||
subtitle="How often to check the URL"
|
||||
rightContent={
|
||||
<Controller
|
||||
name="interval"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<TextInput
|
||||
{...field}
|
||||
type="text"
|
||||
label={t("createMonitorPage.intervalDescription")}
|
||||
fullWidth
|
||||
error={!!errors.interval}
|
||||
helperText={errors.interval ? errors.interval.message : ""}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Stack
|
||||
direction="row"
|
||||
justifyContent="flex-end"
|
||||
>
|
||||
<Button
|
||||
loading={loading}
|
||||
type="submit"
|
||||
variant="contained"
|
||||
color="accent"
|
||||
>
|
||||
{t("settingsSave")}
|
||||
</Button>
|
||||
</Stack>
|
||||
</BasePage>
|
||||
);
|
||||
};
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
|
||||
import type { MonitorStatus } from "@/Types/Monitor";
|
||||
import type { PaletteKey } from "./Theme/v2/theme";
|
||||
import type { PaletteKey } from "@/Utils/Theme/v2/theme";
|
||||
export const getStatusPalette = (status: MonitorStatus): PaletteKey => {
|
||||
const paletteMap: Record<MonitorStatus, PaletteKey> = {
|
||||
up: "success",
|
||||
File renamed without changes.
@@ -458,7 +458,7 @@ const notificationValidation = joi.object({
|
||||
|
||||
type: joi
|
||||
.string()
|
||||
.valid("email", "webhook", "slack", "discord", "pager_duty")
|
||||
.valid("email", "webhook", "slack", "discord", "pager_duty", "matrix")
|
||||
.required()
|
||||
.messages({
|
||||
"string.empty": "Notification type is required",
|
||||
@@ -495,8 +495,40 @@ const notificationValidation = joi.object({
|
||||
"string.uri": "Please enter a valid Webhook URL",
|
||||
}),
|
||||
},
|
||||
{
|
||||
is: "matrix",
|
||||
then: joi.string().allow("").optional(),
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
homeserverUrl: joi.when("type", {
|
||||
is: "matrix",
|
||||
then: joi.string().uri().required().messages({
|
||||
"string.empty": "Homeserver URL cannot be empty",
|
||||
"any.required": "Homeserver URL is required",
|
||||
"string.uri": "Please enter a valid Homeserver URL",
|
||||
}),
|
||||
otherwise: joi.string().allow("").optional(),
|
||||
}),
|
||||
|
||||
roomId: joi.when("type", {
|
||||
is: "matrix",
|
||||
then: joi.string().required().messages({
|
||||
"string.empty": "Room ID cannot be empty",
|
||||
"any.required": "Room ID is required",
|
||||
}),
|
||||
otherwise: joi.string().allow("").optional(),
|
||||
}),
|
||||
|
||||
accessToken: joi.when("type", {
|
||||
is: "matrix",
|
||||
then: joi.string().required().messages({
|
||||
"string.empty": "Access Token cannot be empty",
|
||||
"any.required": "Access Token is required",
|
||||
}),
|
||||
otherwise: joi.string().allow("").optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
const editUserValidation = joi.object({
|
||||
|
||||
@@ -15,15 +15,11 @@ html {
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
/* Generalized Stylings */
|
||||
--env-var-radius-1: 4px;
|
||||
--env-var-radius-2: 8px;
|
||||
|
||||
--env-var-width-1: 100vw;
|
||||
--env-var-width-2: 360px;
|
||||
--env-var-width-3: 250px;
|
||||
--env-var-width-4: 100px;
|
||||
|
||||
--env-var-height-1: 100vh;
|
||||
--env-var-height-2: 34px;
|
||||
|
||||
--env-var-nav-bar-height: 70px;
|
||||
@@ -35,9 +31,6 @@ html {
|
||||
--env-var-spacing-1-plus: 16px;
|
||||
--env-var-spacing-1-minus: 10px;
|
||||
--env-var-spacing-2: 24px;
|
||||
--env-var-spacing-3: 32px;
|
||||
--env-var-spacing-4: 40px;
|
||||
--env-var-spacing-5: 65px;
|
||||
|
||||
--env-var-font-size-small: 11px;
|
||||
--env-var-font-size-small-plus: 12px;
|
||||
@@ -46,16 +39,6 @@ html {
|
||||
--env-var-font-size-large: 16px;
|
||||
--env-var-font-size-large-plus: 22px;
|
||||
--env-var-font-size-xlarge: 30px;
|
||||
|
||||
--env-var-img-width-1: 20px;
|
||||
--env-var-img-width-2: 16px;
|
||||
--env-var-img-width-3: 12px;
|
||||
|
||||
--env-var-default-1: 24px;
|
||||
--env-var-default-2: 40px;
|
||||
|
||||
--env-var-shadow-1:
|
||||
0px 4px 24px -4px rgba(16, 24, 40, 0.08), 0px 3px 3px -3px rgba(16, 24, 40, 0.03);
|
||||
}
|
||||
|
||||
.MuiInputBase-root.Mui-disabled input {
|
||||
|
||||
@@ -421,7 +421,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "",
|
||||
@@ -483,7 +489,8 @@
|
||||
"ping": "",
|
||||
"docker": "",
|
||||
"port": "",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "",
|
||||
@@ -1071,7 +1078,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -421,7 +421,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "",
|
||||
@@ -483,7 +489,8 @@
|
||||
"ping": "",
|
||||
"docker": "",
|
||||
"port": "",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1071,7 +1078,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
+94
-83
@@ -382,50 +382,56 @@
|
||||
"created": "Angelegt"
|
||||
},
|
||||
"addTeamMember": {
|
||||
"addMemberMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"addButton": ""
|
||||
"addMemberMenu": "Teammitglied hinzufügen",
|
||||
"title": "Neues Teammitglied registrieren",
|
||||
"description": "Einen neuen Benutzer anlegen und Zugangsdaten mit ihm teilen. Diese Methode gibt dem Mitglied direkt Zugriff auf alle Überwachungen.",
|
||||
"addButton": "Mitglied hinzufügen"
|
||||
},
|
||||
"register": "",
|
||||
"register": "Teammitglied registrieren",
|
||||
"registerToast": {
|
||||
"success": "",
|
||||
"dbUserExists": "",
|
||||
"unknownError": ""
|
||||
"success": "Benutzer erstellt, Zugangsdaten auf sichere Weise weitergeben.",
|
||||
"dbUserExists": "Der Benutzer existiert bereits.",
|
||||
"unknownError": "Unbekannter Fehler aufgetreten."
|
||||
},
|
||||
"registerTeamMember": {
|
||||
"title": "",
|
||||
"title": "Teammitglied registrieren",
|
||||
"auth": {
|
||||
"common": {
|
||||
"inputs": {
|
||||
"firstName": {
|
||||
"errors": {
|
||||
"empty": "",
|
||||
"pattern": ""
|
||||
"empty": "Bitte einen Namen eingeben",
|
||||
"pattern": "Der Name darf nur Buchstaben, Leerzeichen, Apostrophe oder Bindestriche enthalten"
|
||||
}
|
||||
},
|
||||
"lastName": {
|
||||
"errors": {
|
||||
"empty": "",
|
||||
"pattern": ""
|
||||
"empty": "Bitte einen Vornamen eingeben",
|
||||
"pattern": "Der Vorname darf nur Buchstaben, Leerzeichen, Apostrophe oder Bindestriche enthalten"
|
||||
}
|
||||
},
|
||||
"email": {
|
||||
"errors": {
|
||||
"empty": "",
|
||||
"invalid": ""
|
||||
"empty": "Zum Fortsetzen bitte eine E-Mail-Adresse eingeben",
|
||||
"invalid": "Bitte die Gültigkeit der E-Mail-Adresse erneut prüfen"
|
||||
}
|
||||
},
|
||||
"role": {
|
||||
"errors": {
|
||||
"empty": ""
|
||||
"empty": "Eine Rolle wird benötigt"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "Rolle",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "Passwort zurücksetzen",
|
||||
"title": "Passwort des Teammitgliedes zurücksetzen",
|
||||
"description": "Neues Passwort für dieses Teammitglied erstellen. Es muss auf einem Sicheren weg zur Verfügung gestellt werden.",
|
||||
"success": "Passwort erfolgreich zurückgesetzt. Bitte sicherstellen, dass die Zugangsdaten auf sichere Weise weitergegeben werden."
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "Pausiert",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "Geben Sie die IP-Adresse oder den Hostnamen ein, der angepingt werden soll (z. B. 192.168.1.100 oder example.com), und fügen Sie einen eindeutigen Anzeigenamen hinzu, der auf dem Dashboard angezeigt wird.",
|
||||
"docker": "Geben Sie die Docker-ID Ihres Containers ein. Docker-IDs müssen die vollständige 64-Zeichen-ID sein. Sie können docker inspect <short_id> ausführen, um die vollständige Container-ID abzurufen.",
|
||||
"port": "Geben Sie die URL oder IP des Servers, die Portnummer und einen eindeutigen Anzeigenamen ein, der auf dem Dashboard angezeigt wird.",
|
||||
"game": ""
|
||||
"game": "IP Adresse oder Hostnamen und Port für Ping eingeben (z.B. 192.168.1.100 oder beispiel.de) und Spieletyp auswählen.",
|
||||
"https": "Zu überwachende Adresse oder IP (z.B. https://beispiel.de/ oder 192.168.1.100) eingeben und einen klaren Anzeigenamen, der im Dashboard erscheint."
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -607,7 +614,7 @@
|
||||
"forgotPassword": "Passwort vergessen?",
|
||||
"register": "Noch keinen Account?",
|
||||
"forgotPasswordLink": "Passwort zurücksetzen",
|
||||
"registerLink": "Hier resistrieren"
|
||||
"registerLink": "Hier registrieren"
|
||||
},
|
||||
"toasts": {
|
||||
"success": "Willkommen zurück. Erfolgreich angemeldet.",
|
||||
@@ -618,7 +625,7 @@
|
||||
"incorrect": "Das Passwort stimmt nicht mit dem gespeicherten überein"
|
||||
}
|
||||
},
|
||||
"welcome": ""
|
||||
"welcome": "Willkommen zurück bei Checkmate!"
|
||||
},
|
||||
"registration": {
|
||||
"heading": {
|
||||
@@ -645,7 +652,7 @@
|
||||
"toasts": {
|
||||
"success": "Willkommen! Benutzer erfolgreich angelegt"
|
||||
},
|
||||
"welcome": ""
|
||||
"welcome": "Willkommen bei Checkmate!"
|
||||
},
|
||||
"forgotPassword": {
|
||||
"heading": "Passwort vergessen?",
|
||||
@@ -746,8 +753,8 @@
|
||||
"monitorStatus": {
|
||||
"checkingEvery": "Überprüfung alle {{interval}}",
|
||||
"withCaptureAgent": "mit Capture-Agent {{version}}",
|
||||
"up": "hoch",
|
||||
"down": "runter",
|
||||
"up": "Online",
|
||||
"down": "Offline",
|
||||
"paused": "pausiert"
|
||||
},
|
||||
"advancedMatching": "Erweiterter Abgleich",
|
||||
@@ -792,7 +799,7 @@
|
||||
"lastRunHeader": "Letzter Lauf um",
|
||||
"lastFinishedAtHeader": "Zuletzt abgeschlossen um",
|
||||
"lastRunTookHeader": "Letzter Lauf dauerte",
|
||||
"intervalHeader": ""
|
||||
"intervalHeader": "Invervall"
|
||||
},
|
||||
"metricsTable": {
|
||||
"title": "Warteschlangenmetriken",
|
||||
@@ -900,8 +907,8 @@
|
||||
"title": "Überwachen Sie IP/URL auf der Statusseite"
|
||||
},
|
||||
"globalThresholds": {
|
||||
"title": "",
|
||||
"description": ""
|
||||
"title": "Globale Schwellenwerte",
|
||||
"description": "Globale CPU-, Speicher-, Festplatten- und Temperaturschwellenwerte festlegen. Wenn ein Wert angegeben ist, wird er automatisch für die Überwachung genutzt."
|
||||
}
|
||||
},
|
||||
"statusPageCreate": {
|
||||
@@ -975,11 +982,11 @@
|
||||
"oneHour": "1 Stunde",
|
||||
"oneDay": "1 Tag",
|
||||
"oneWeek": "1 Woche",
|
||||
"fourMinutes": "",
|
||||
"oneMinute": "",
|
||||
"twoMinutes": "",
|
||||
"fifteenSeconds": "",
|
||||
"thirtySeconds": ""
|
||||
"fourMinutes": "4 Minuten",
|
||||
"oneMinute": "Eine Minute",
|
||||
"twoMinutes": "Zwei Minuten",
|
||||
"fifteenSeconds": "15 Sekunden",
|
||||
"thirtySeconds": "30 Sekunden"
|
||||
},
|
||||
"general": {
|
||||
"noOptionsFound": "Keine {{unit}} gefunden"
|
||||
@@ -1050,73 +1057,77 @@
|
||||
"incidentsPageActionResolveMonitor": "Monitor-Vorfälle beheben",
|
||||
"incidentsPageActionResolveAll": "Alle Vorfälle lösen",
|
||||
"matchMethodOptions": {
|
||||
"equal": "",
|
||||
"equalPlaceholder": "",
|
||||
"include": "",
|
||||
"includePlaceholder": "",
|
||||
"regex": "",
|
||||
"regexPlaceholder": "",
|
||||
"text": ""
|
||||
"equal": "Gleich",
|
||||
"equalPlaceholder": "Erfolg",
|
||||
"include": "Enthält",
|
||||
"includePlaceholder": "OK",
|
||||
"regex": "Regex",
|
||||
"regexPlaceholder": "^(success|ok)$",
|
||||
"text": "Übereinstummungsmethode"
|
||||
},
|
||||
"monitorType": {
|
||||
"docker": {
|
||||
"label": "",
|
||||
"namePlaceholder": "",
|
||||
"placeholder": ""
|
||||
"label": "Container Name/ID",
|
||||
"namePlaceholder": "Mein Container",
|
||||
"placeholder": "Meine-App"
|
||||
},
|
||||
"http": {
|
||||
"label": "",
|
||||
"namePlaceholder": "",
|
||||
"placeholder": ""
|
||||
"label": "Zu überwachende URL",
|
||||
"namePlaceholder": "Google",
|
||||
"placeholder": "google.de"
|
||||
},
|
||||
"ping": {
|
||||
"label": "",
|
||||
"namePlaceholder": "",
|
||||
"placeholder": ""
|
||||
"label": "Zu überwachende IP-Adresse",
|
||||
"namePlaceholder": "Google",
|
||||
"placeholder": "1.1.1.1"
|
||||
},
|
||||
"port": {
|
||||
"label": "",
|
||||
"namePlaceholder": "",
|
||||
"placeholder": ""
|
||||
"label": "Zu überwachende URL",
|
||||
"namePlaceholder": "localhost:5173",
|
||||
"placeholder": "localhost"
|
||||
},
|
||||
"game": {
|
||||
"label": "",
|
||||
"namePlaceholder": "",
|
||||
"placeholder": ""
|
||||
"label": "Zu überwachende URL",
|
||||
"namePlaceholder": "localhost:5173",
|
||||
"placeholder": "localhost"
|
||||
}
|
||||
},
|
||||
"uptimeAdvancedMatching": {
|
||||
"jsonPath": ""
|
||||
"jsonPath": "JSON Pfad"
|
||||
},
|
||||
"bytesPerSecond": "",
|
||||
"bytesReceived": "",
|
||||
"bytesSent": "",
|
||||
"chooseGame": "",
|
||||
"bytesPerSecond": "Bytes pro Sekunde",
|
||||
"bytesReceived": "Empfangene Bytes",
|
||||
"bytesSent": "Gesendete Bytes",
|
||||
"chooseGame": "Spiel auswählen",
|
||||
"createMonitorPage": {
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigDescription": "Mithilfe eines gleitenden Fensters wird ermittelt, wann ein Monitor ausfällt. Der Status eines Monitors ändert sich nur, wenn der Prozentsatz der Prüfungen im gleitenden Fenster den angegebenen Wert erreicht.",
|
||||
"incidentConfigStatusWindowLabel": "Wie viele Prüfungen sollen im gleitenden Fenster ausgeführt werden?",
|
||||
"incidentConfigStatusWindowThresholdLabel": "Wie viel Prozent der Prüfungen im gleitenden Fenster sollen fehlschlagen/erfolgreich sein, bevor sich der Status ändert?",
|
||||
"incidentConfigTitle": "Vorfälle",
|
||||
"incidentConfigDescriptionV2": "Anzahl der aufeinanderfolgenden Prüfungen, die zum Ändern des Monitorstatus erforderlich sind. Maximal 25",
|
||||
"incidentConfigStatusCheckNumber": "Anzahl der Prüfungen bevor sich er Status ändert",
|
||||
"intervalTitle": "Prüfintervall",
|
||||
"intervalDescription": "Wie oft soll die Überwachung geprüft werden."
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
"dataSent": "",
|
||||
"details": "",
|
||||
"drops": "",
|
||||
"errors": "",
|
||||
"errorsIn": "",
|
||||
"errorsOut": "",
|
||||
"gameServerMonitoring": "",
|
||||
"gameServerMonitoringDescription": "",
|
||||
"network": "",
|
||||
"networkDrops": "",
|
||||
"networkErrors": "",
|
||||
"networkInterface": "",
|
||||
"noNetworkStatsAvailable": "",
|
||||
"packetsPerSecond": "",
|
||||
"packetsReceived": "",
|
||||
"packetsReceivedRate": "",
|
||||
"packetsSent": "",
|
||||
"rate": "",
|
||||
"selectInterface": ""
|
||||
"dataRate": "Datenrate",
|
||||
"dataReceived": "Empfangene Daten",
|
||||
"dataSent": "Gesendete Daten",
|
||||
"details": "Details",
|
||||
"drops": "verloren",
|
||||
"errors": "Fehler",
|
||||
"errorsIn": "Fehler eingehend",
|
||||
"errorsOut": "Fehler ausgehend",
|
||||
"gameServerMonitoring": "Spiele Server Überwachung",
|
||||
"gameServerMonitoringDescription": "Prüfen ob der Spiele-Server läuft oder nicht",
|
||||
"network": "Netzwerk",
|
||||
"networkDrops": "Netzwerkabbrüche",
|
||||
"networkErrors": "Netzwerkfehler",
|
||||
"networkInterface": "Netzwerkschnittstelle",
|
||||
"noNetworkStatsAvailable": "Keine Netzwerkstatistiken verfügbar.",
|
||||
"packetsPerSecond": "Pakete pro Sekunde",
|
||||
"packetsReceived": "Empfangene Pakete",
|
||||
"packetsReceivedRate": "Rate empfangener Pakete",
|
||||
"packetsSent": "Gesendete Pakete",
|
||||
"rate": "Rate",
|
||||
"selectInterface": "Schnittstelle auswählen"
|
||||
}
|
||||
@@ -20,6 +20,13 @@
|
||||
"delete": "Delete",
|
||||
"configure": "Configure",
|
||||
"responseTime": "Response time",
|
||||
"responseTimeBreakdown": "Response time breakdown",
|
||||
"dnsLookup": "DNS lookup",
|
||||
"tcpConnection": "TCP connection",
|
||||
"tlsHandshake": "TLS handshake",
|
||||
"waitTime": "Wait time",
|
||||
"timeToFirstByte": "Time to first byte",
|
||||
"download": "Download",
|
||||
"ms": "ms",
|
||||
"bar": "Bar",
|
||||
"area": "Area",
|
||||
@@ -490,11 +497,11 @@
|
||||
},
|
||||
"uptimeGeneralInstructions": {
|
||||
"http": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard.",
|
||||
"https": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard.",
|
||||
"ping": "Enter the IP address or hostname to ping (e.g., 192.168.1.100 or example.com) and add a clear display name that appears on the dashboard.",
|
||||
"docker": "Enter the Docker container name or ID. You can use either the container name (e.g., my-app) or the container ID (full 64-char ID or short ID).",
|
||||
"port": "Enter the URL or IP of the server, the port number and a clear display name that appears on the dashboard.",
|
||||
"game": "Enter the IP address or hostname and the port number to ping (e.g., 192.168.1.100 or example.com) and choose game type."
|
||||
"game": "Enter the IP address or hostname and the port number to ping (e.g., 192.168.1.100 or example.com) and choose game type.",
|
||||
"https": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard."
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1101,11 +1108,11 @@
|
||||
"chooseGame": "Choose game",
|
||||
"createMonitorPage": {
|
||||
"incidentConfigDescription": "A sliding window is used to determine when a monitor goes down. The status of a monitor will only change when the percentage of checks in the sliding window meet the specified value.",
|
||||
"incidentConfigDescriptionV2": "Number of consecutive checks needed to change monitor status. Maximum 25",
|
||||
"incidentConfigStatusWindowLabel": "How many checks should be in the sliding window?",
|
||||
"incidentConfigStatusCheckNumber": "How many checks before status change?",
|
||||
"incidentConfigStatusWindowThresholdLabel": "What percentage of checks in the sliding window fail/succeed before monitor status changes?",
|
||||
"incidentConfigTitle": "Incidents",
|
||||
"incidentConfigDescriptionV2": "Number of consecutive checks needed to change monitor status. Maximum 25",
|
||||
"incidentConfigStatusCheckNumber": "How many checks before status change?",
|
||||
"intervalTitle": "Check interval",
|
||||
"intervalDescription": "How often the monitor should be checked."
|
||||
},
|
||||
|
||||
+47
-36
@@ -129,32 +129,32 @@
|
||||
"distributedUptimeStatusPublishedLabel": "",
|
||||
"distributedUptimeStatusCompanyNameLabel": "",
|
||||
"distributedUptimeStatusPageAddressLabel": "",
|
||||
"distributedUptimeStatus30Days": "",
|
||||
"distributedUptimeStatus60Days": "",
|
||||
"distributedUptimeStatus90Days": "",
|
||||
"distributedUptimeStatus30Days": "30 dias",
|
||||
"distributedUptimeStatus60Days": "60 días",
|
||||
"distributedUptimeStatus90Days": "90 dias",
|
||||
"distributedUptimeStatusPageNotSetUp": "",
|
||||
"distributedUptimeStatusContactAdmin": "",
|
||||
"distributedUptimeStatusPageNotPublic": "",
|
||||
"distributedUptimeStatusPageDeleteDialog": "",
|
||||
"distributedUptimeStatusPageDeleteConfirm": "",
|
||||
"distributedUptimeStatusPageDeleteDescription": "",
|
||||
"distributedUptimeStatusDevices": "",
|
||||
"distributedUptimeStatusDevices": "Dispositivos",
|
||||
"distributedUptimeStatusUpt": "",
|
||||
"distributedUptimeStatusUptBurned": "",
|
||||
"distributedUptimeStatusUptLogo": "",
|
||||
"incidentsTableNoIncidents": "",
|
||||
"incidentsTablePaginationLabel": "",
|
||||
"incidentsTablePaginationLabel": "Incidentes",
|
||||
"incidentsTableMonitorName": "",
|
||||
"incidentsTableStatus": "",
|
||||
"incidentsTableStatus": "Estado",
|
||||
"incidentsTableDateTime": "",
|
||||
"incidentsTableStatusCode": "",
|
||||
"incidentsTableMessage": "",
|
||||
"incidentsTableMessage": "Mensaje",
|
||||
"incidentsOptionsHeader": "",
|
||||
"incidentsOptionsHeaderFilterBy": "",
|
||||
"incidentsOptionsHeaderFilterAll": "",
|
||||
"incidentsOptionsHeaderFilterAll": "Todo",
|
||||
"incidentsOptionsHeaderFilterDown": "",
|
||||
"incidentsOptionsHeaderFilterCannotResolve": "",
|
||||
"incidentsOptionsHeaderShow": "",
|
||||
"incidentsOptionsHeaderShow": "Mostrar:",
|
||||
"incidentsOptionsHeaderLastHour": "",
|
||||
"incidentsOptionsHeaderLastDay": "",
|
||||
"incidentsOptionsHeaderLastWeek": "",
|
||||
@@ -165,22 +165,22 @@
|
||||
"infrastructureCustomizeAlerts": "",
|
||||
"infrastructureAlertNotificationDescription": "",
|
||||
"infrastructureCreateMonitor": "",
|
||||
"infrastructureProtocol": "",
|
||||
"infrastructureProtocol": "Protocolo",
|
||||
"infrastructureServerUrlLabel": "",
|
||||
"infrastructureDisplayNameLabel": "",
|
||||
"infrastructureAuthorizationSecretLabel": "",
|
||||
"gb": "",
|
||||
"mb": "",
|
||||
"mem": "",
|
||||
"gb": "GB",
|
||||
"mb": "MB",
|
||||
"mem": "Mem",
|
||||
"memoryUsage": "",
|
||||
"cpu": "",
|
||||
"cpu": "CPU",
|
||||
"cpuUsage": "",
|
||||
"cpuTemperature": "",
|
||||
"diskUsage": "",
|
||||
"used": "",
|
||||
"total": "",
|
||||
"cores": "",
|
||||
"frequency": "",
|
||||
"total": "Total",
|
||||
"cores": "Nucleos",
|
||||
"frequency": "Frecuencia",
|
||||
"status": "",
|
||||
"cpuPhysical": "",
|
||||
"cpuLogical": "",
|
||||
@@ -189,25 +189,25 @@
|
||||
"memory": "",
|
||||
"disk": "",
|
||||
"uptime": "",
|
||||
"os": "",
|
||||
"os": "SO",
|
||||
"host": "",
|
||||
"actions": "",
|
||||
"integrations": "",
|
||||
"integrationsPrism": "",
|
||||
"integrationsSlack": "",
|
||||
"integrationsSlack": "Slack",
|
||||
"integrationsSlackInfo": "",
|
||||
"integrationsDiscord": "",
|
||||
"integrationsDiscord": "Discord",
|
||||
"integrationsDiscordInfo": "",
|
||||
"integrationsZapier": "",
|
||||
"integrationsZapier": "Zapier",
|
||||
"integrationsZapierInfo": "",
|
||||
"commonSave": "",
|
||||
"commonSave": "Guardar",
|
||||
"createYour": "",
|
||||
"createMonitor": "",
|
||||
"pause": "",
|
||||
"resume": "",
|
||||
"editing": "",
|
||||
"url": "",
|
||||
"access": "",
|
||||
"pause": "Pausar",
|
||||
"resume": "Resumir",
|
||||
"editing": "Editando...",
|
||||
"url": "URL",
|
||||
"access": "Acceso",
|
||||
"timezone": "",
|
||||
"features": "",
|
||||
"administrator": "",
|
||||
@@ -231,13 +231,13 @@
|
||||
"friendlyNamePlaceholder": "",
|
||||
"maintenanceRepeat": "",
|
||||
"maintenance": "",
|
||||
"duration": "",
|
||||
"duration": "Duración",
|
||||
"addMonitors": "",
|
||||
"window": "",
|
||||
"cancel": "",
|
||||
"message": "",
|
||||
"low": "",
|
||||
"high": "",
|
||||
"window": "ventana",
|
||||
"cancel": "Cancelar",
|
||||
"message": "Mensaje",
|
||||
"low": "bajo",
|
||||
"high": "alto",
|
||||
"statusCode": "",
|
||||
"date&Time": "",
|
||||
"type": "",
|
||||
@@ -421,7 +421,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "",
|
||||
@@ -483,7 +489,8 @@
|
||||
"ping": "",
|
||||
"docker": "",
|
||||
"port": "",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "",
|
||||
@@ -1071,7 +1078,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -421,7 +421,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "Tauota",
|
||||
@@ -483,7 +489,8 @@
|
||||
"ping": "",
|
||||
"docker": "",
|
||||
"port": "",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "",
|
||||
@@ -1071,7 +1078,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -425,7 +425,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "Pause",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "Entrez l'adresse IP ou le nom d'hôte à tester (par exemple, 192.168.1.100 ou exemple.fr) et ajoutez un nom familier qui apparaîtra sur le tableau de bord.",
|
||||
"docker": "Entrer l'ID Docker du container. Les identifiants Docker doivent être les 64 caractères de l'ID Docker. Vous pouvez utiliser la commande docker inspect <short_id> pour avoir l'ID complet.",
|
||||
"port": "Entrez l'URL ou l'adresse IP du serveur, le numéro de port et un nom d'affichage familier qui apparaîtra sur le tableau de bord.",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1096,7 +1103,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -425,7 +425,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "一時停止",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "pingするIPアドレスまたはホスト名を入力(例: 192.168.1.100 または example.com)し、ダッシュボードに表示される明確な表示名を追加。",
|
||||
"docker": "コンテナのDocker IDを入力。Docker IDは64文字のフルDocker IDである必要があります。docker inspect <short_id>を実行してフルコンテナIDを取得できます。",
|
||||
"port": "サーバーのURLまたはIP、ポート番号、ダッシュボードに表示される明確な表示名を入力。",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1075,7 +1082,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -425,7 +425,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "Pausado",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "Insira o endereço IP ou nome de domínio para ping (ex. 192.168.1.100 ou exemplo.com.br) e adicione uma descrição que aparecerá na dashboard.",
|
||||
"docker": "Insira o Docker Id do seu container. Docker Ids devem ser todos os 64 caracteres. Você pode executar docker inspect <short_id> para descobrir o Id completo.",
|
||||
"port": "Insira a URL ou o IP do servidor, aporta e uma descrição que aparecerá na dashboard.",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1096,7 +1103,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
+387
-351
File diff suppressed because it is too large.
Load diff
@@ -425,7 +425,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": "บทบาท"
|
||||
"role": "บทบาท",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "หยุดชั่วคราว",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "กรอกที่อยู่ IP หรือชื่อโฮสต์ที่ต้องการ ping (เช่น 192.168.1.100 หรือ example.com) และตั้งชื่อที่ชัดเจนให้แสดงบนแดชบอร์ด",
|
||||
"docker": "กรอกชื่อหรือ ID ของคอนเทนเนอร์ Docker คุณสามารถใช้ชื่อคอนเทนเนอร์ (เช่น my-app) หรือ ID ของคอนเทนเนอร์ (ID เต็ม 64 ตัวอักษร หรือ ID สั้น)",
|
||||
"port": "กรอก URL หรือ IP ของเซิร์ฟเวอร์ หมายเลขพอร์ต และตั้งชื่อที่ชัดเจนให้แสดงบนแดชบอร์ด",
|
||||
"game": "กรอกที่อยู่ IP หรือชื่อโฮสต์และหมายเลขพอร์ตเพื่อทำการ ping (เช่น 192.168.1.100 หรือ example.com) และเลือกประเภทเกม"
|
||||
"game": "กรอกที่อยู่ IP หรือชื่อโฮสต์และหมายเลขพอร์ตเพื่อทำการ ping (เช่น 192.168.1.100 หรือ example.com) และเลือกประเภทเกม",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1096,7 +1103,11 @@
|
||||
"incidentConfigDescription": "การใช้หน้าต่างเลื่อนจะช่วยกำหนดเวลาที่ตัวตรวจสอบล้มเหลว สถานะของตัวตรวจสอบจะเปลี่ยนก็ต่อเมื่อเปอร์เซ็นต์ของการตรวจสอบในหน้าต่างเลื่อนตรงตามค่าที่กำหนด",
|
||||
"incidentConfigStatusWindowLabel": "ต้องมีการตรวจสอบกี่ครั้งในหน้าต่างเลื่อน?",
|
||||
"incidentConfigStatusWindowThresholdLabel": "ต้องการให้กี่เปอร์เซ็นต์ของการตรวจสอบในหน้าต่างเลื่อนล้มเหลว/สำเร็จ ก่อนที่จะเปลี่ยนสถานะของตัวตรวจสอบ?",
|
||||
"incidentConfigTitle": "เหตุการณ์"
|
||||
"incidentConfigTitle": "เหตุการณ์",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "อัตราการส่งข้อมูล",
|
||||
"dataReceived": "ข้อมูลที่รับ",
|
||||
|
||||
@@ -421,7 +421,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "Durduruldu",
|
||||
@@ -483,7 +489,8 @@
|
||||
"ping": "",
|
||||
"docker": "",
|
||||
"port": "",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1071,7 +1078,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -425,7 +425,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": "角色"
|
||||
"role": "角色",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "暂停",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "输入要 ping 的 IP 地址或主机名(例如.. 192.168.1.100 或 example.com),并添加显示在仪表板上的清晰显示名称。",
|
||||
"docker": "码输入 Docker 容器名称或 ID。您可以使用容器名称(例如.. my-app)或容器 ID(完整的 64 字符 ID 或短 ID)。",
|
||||
"port": "输入服务器的 URL 或 IP、端口号和仪表板上显示的清晰显示名称。",
|
||||
"game": "输入要 ping 的 IP 地址或主机名和端口号(例如.. 192.168.1.100 或 example.com)并选择游戏类型。"
|
||||
"game": "输入要 ping 的 IP 地址或主机名和端口号(例如.. 192.168.1.100 或 example.com)并选择游戏类型。",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1088,7 +1095,11 @@
|
||||
"incidentConfigDescription": "滑动窗口用于确定监视器何时发生故障。仅当滑动窗口中的检查百分比满足指定值时,监视器的状态才会改变。",
|
||||
"incidentConfigStatusWindowLabel": "在滑动窗口中应包含多少次检测?",
|
||||
"incidentConfigStatusWindowThresholdLabel": "在监视器状态改变之前,滑动窗口中的检查失败/成功的百分比是多少?",
|
||||
"incidentConfigTitle": "事件"
|
||||
"incidentConfigTitle": "事件",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "数据速率",
|
||||
"dataReceived": "已接收数据",
|
||||
|
||||
@@ -425,7 +425,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"role": ""
|
||||
"role": "",
|
||||
"changeTeamPassword": {
|
||||
"changePasswordMenu": "",
|
||||
"title": "",
|
||||
"description": "",
|
||||
"success": ""
|
||||
}
|
||||
},
|
||||
"monitorState": {
|
||||
"paused": "",
|
||||
@@ -487,7 +493,8 @@
|
||||
"ping": "",
|
||||
"docker": "",
|
||||
"port": "",
|
||||
"game": ""
|
||||
"game": "",
|
||||
"https": ""
|
||||
},
|
||||
"common": {
|
||||
"appName": "Checkmate",
|
||||
@@ -1075,7 +1082,11 @@
|
||||
"incidentConfigDescription": "",
|
||||
"incidentConfigStatusWindowLabel": "",
|
||||
"incidentConfigStatusWindowThresholdLabel": "",
|
||||
"incidentConfigTitle": ""
|
||||
"incidentConfigTitle": "",
|
||||
"incidentConfigDescriptionV2": "",
|
||||
"incidentConfigStatusCheckNumber": "",
|
||||
"intervalTitle": "",
|
||||
"intervalDescription": ""
|
||||
},
|
||||
"dataRate": "",
|
||||
"dataReceived": "",
|
||||
|
||||
@@ -7,7 +7,7 @@ const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
export default defineConfig(({}) => {
|
||||
let version = "3.2.0";
|
||||
let version = "3.2.1";
|
||||
|
||||
return {
|
||||
base: "/",
|
||||
|
||||
Generated
+1267
-1146
File diff suppressed because it is too large.
Load diff
+7
-4
@@ -6,8 +6,8 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "c8 mocha",
|
||||
"dev": "nodemon --exec tsx src/index.js",
|
||||
"start": "nodemon ./dist/index.js",
|
||||
"dev": "tsx watch src/index.js",
|
||||
"start": "node --watch ./dist/index.js",
|
||||
"build": "tsc",
|
||||
"lint": "eslint .",
|
||||
"lint-fix": "eslint --fix .",
|
||||
@@ -17,11 +17,15 @@
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pulsecron/pulse": "1.6.8",
|
||||
"axios": "^1.7.2",
|
||||
"bcryptjs": "3.0.2",
|
||||
"bullmq": "5.41.2",
|
||||
"cacheable-lookup": "7.0.0",
|
||||
"compression": "1.8.1",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"cors": "^2.8.5",
|
||||
@@ -48,7 +52,7 @@
|
||||
"ping": "0.4.4",
|
||||
"sharp": "0.33.5",
|
||||
"ssl-checker": "2.0.10",
|
||||
"super-simple-scheduler": "1.4.1",
|
||||
"super-simple-scheduler": "1.4.5",
|
||||
"swagger-ui-express": "5.0.1",
|
||||
"winston": "^3.13.0"
|
||||
},
|
||||
@@ -65,7 +69,6 @@
|
||||
"esm": "3.2.25",
|
||||
"globals": "^15.14.0",
|
||||
"mocha": "11.1.0",
|
||||
"nodemon": "3.1.9",
|
||||
"prettier": "^3.3.3",
|
||||
"sinon": "19.0.2",
|
||||
"tsx": "4.20.5",
|
||||
|
||||
@@ -452,6 +452,24 @@ class MonitorController extends BaseController {
|
||||
SERVICE_NAME,
|
||||
"getAllGames"
|
||||
);
|
||||
|
||||
getGroupsByTeamId = this.asyncHandler(
|
||||
async (req, res) => {
|
||||
const teamId = req?.user?.teamId;
|
||||
if (!teamId) {
|
||||
throw this.errorService.createBadRequestError("Team ID is required");
|
||||
}
|
||||
|
||||
const groups = await this.monitorService.getGroupsByTeamId({ teamId });
|
||||
|
||||
return res.success({
|
||||
msg: "OK",
|
||||
data: groups,
|
||||
});
|
||||
},
|
||||
SERVICE_NAME,
|
||||
"getGroupsByTeamId"
|
||||
);
|
||||
}
|
||||
|
||||
export default MonitorController;
|
||||
@@ -54,6 +54,35 @@ const networkInterfaceSchema = mongoose.Schema({
|
||||
fifo_out: { type: Number, default: 0 },
|
||||
});
|
||||
|
||||
const portSchema = mongoose.Schema({
|
||||
port: { type: String },
|
||||
protocol: { type: String },
|
||||
});
|
||||
|
||||
const healthSchema = mongoose.Schema({
|
||||
healthy: { type: Boolean, default: false },
|
||||
source: { type: String, default: "" },
|
||||
message: { type: String, default: "" },
|
||||
});
|
||||
|
||||
const containerSchema = mongoose.Schema({
|
||||
container_id: { type: String, default: "" },
|
||||
container_name: { type: String, default: "" },
|
||||
status: { type: String, default: "" },
|
||||
health: {
|
||||
type: healthSchema,
|
||||
default: () => ({}),
|
||||
},
|
||||
running: { type: Boolean, default: false },
|
||||
base_image: { type: String, default: "" },
|
||||
exposed_ports: {
|
||||
type: [portSchema],
|
||||
default: () => [],
|
||||
},
|
||||
started_at: { type: Number, default: 0 },
|
||||
finished_at: { type: Number, default: 0 },
|
||||
});
|
||||
|
||||
const CheckSchema = new mongoose.Schema(
|
||||
{
|
||||
// Common fields
|
||||
@@ -148,6 +177,12 @@ const CheckSchema = new mongoose.Schema(
|
||||
default: () => [],
|
||||
},
|
||||
|
||||
// Docker fields
|
||||
docker: {
|
||||
type: [containerSchema],
|
||||
default: () => [],
|
||||
},
|
||||
|
||||
// PageSpeed fields
|
||||
accessibility: {
|
||||
type: Number,
|
||||
|
||||
@@ -128,6 +128,15 @@ const MonitorSchema = mongoose.Schema(
|
||||
gameId: {
|
||||
type: String,
|
||||
},
|
||||
group: {
|
||||
type: String,
|
||||
trim: true,
|
||||
maxLength: 50,
|
||||
default: null,
|
||||
set: function (value) {
|
||||
return value && value.trim() ? value.trim() : null;
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
|
||||
@@ -16,7 +16,7 @@ const NotificationSchema = mongoose.Schema(
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
enum: ["email", "slack", "discord", "webhook", "pager_duty"],
|
||||
enum: ["email", "slack", "discord", "webhook", "pager_duty", "matrix"],
|
||||
},
|
||||
notificationName: {
|
||||
type: String,
|
||||
@@ -28,6 +28,16 @@ const NotificationSchema = mongoose.Schema(
|
||||
phone: {
|
||||
type: String,
|
||||
},
|
||||
// Matrix-specific fields
|
||||
homeserverUrl: {
|
||||
type: String,
|
||||
},
|
||||
roomId: {
|
||||
type: String,
|
||||
},
|
||||
accessToken: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
|
||||
@@ -573,6 +573,21 @@ class MonitorModule {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
getGroupsByTeamId = async ({ teamId }) => {
|
||||
try {
|
||||
const groups = await this.Monitor.distinct("group", {
|
||||
teamId: new this.ObjectId(teamId),
|
||||
group: { $ne: null, $ne: "" },
|
||||
});
|
||||
|
||||
return groups.filter(Boolean).sort();
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "getGroupsByTeamId";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default MonitorModule;
|
||||
@@ -175,7 +175,7 @@
|
||||
"checkmate": "Checkmate",
|
||||
"url": "URL",
|
||||
"unknown": "Unknown",
|
||||
"uptimeAlert": "Uptime Alert: One of your monitors is back online",
|
||||
"downtimeAlert": "Downtime Alert: One of your monitors went offline"
|
||||
"uptimeAlert": "Uptime Alert: Your monitor {monitorName} is back online",
|
||||
"downtimeAlert": "Downtime Alert: Your monitor {monitorName} went offline"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Router } from "express";
|
||||
import MaintenanceWindow from "../../db/v1/models/MaintenanceWindow.js";
|
||||
|
||||
class MaintenanceWindowRoutes {
|
||||
constructor(maintenanceWindowController) {
|
||||
this.router = Router();
|
||||
|
||||
@@ -18,6 +18,7 @@ class MonitorRoutes {
|
||||
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
|
||||
this.router.get("/team/with-checks", this.monitorController.getMonitorsWithChecksByTeamId);
|
||||
this.router.get("/team/summary", this.monitorController.getMonitorsAndSummaryByTeamId);
|
||||
this.router.get("/team/groups", this.monitorController.getGroupsByTeamId);
|
||||
|
||||
// Uptime routes
|
||||
this.router.get("/uptime/details/:monitorId", this.monitorController.getUptimeDetailsById);
|
||||
|
||||
@@ -267,6 +267,11 @@ class MonitorService {
|
||||
getAllGames = () => {
|
||||
return this.games;
|
||||
};
|
||||
|
||||
getGroupsByTeamId = async ({ teamId }) => {
|
||||
const groups = await this.db.monitorModule.getGroupsByTeamId({ teamId });
|
||||
return groups;
|
||||
};
|
||||
}
|
||||
|
||||
export default MonitorService;
|
||||
@@ -35,8 +35,12 @@ class SuperSimpleQueue {
|
||||
this.scheduler.addTemplate("monitor-job", this.helper.getMonitorJob());
|
||||
const monitors = await this.db.monitorModule.getAllMonitors();
|
||||
for (const monitor of monitors) {
|
||||
await this.addJob(monitor._id, monitor);
|
||||
const randomOffset = Math.floor(Math.random() * 100);
|
||||
setTimeout(() => {
|
||||
this.addJob(monitor._id, monitor);
|
||||
}, randomOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.logger.error({
|
||||
|
||||
@@ -46,7 +46,7 @@ class EmailService {
|
||||
*/
|
||||
this.loadTemplate = (templateName) => {
|
||||
try {
|
||||
const templatePath = this.path.join(__dirname, `../../templates/${templateName}.mjml`);
|
||||
const templatePath = this.path.join(__dirname, `../../../templates/${templateName}.mjml`);
|
||||
const templateContent = this.fs.readFileSync(templatePath, "utf8");
|
||||
return this.compile(templateContent);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import CacheableLookup from "cacheable-lookup";
|
||||
const SERVICE_NAME = "NetworkService";
|
||||
|
||||
class NetworkService {
|
||||
@@ -15,7 +16,6 @@ class NetworkService {
|
||||
this.NETWORK_ERROR = 5000;
|
||||
this.PING_ERROR = 5001;
|
||||
this.axios = axios;
|
||||
this.got = got;
|
||||
this.https = https;
|
||||
this.jmespath = jmespath;
|
||||
this.GameDig = GameDig;
|
||||
@@ -26,6 +26,16 @@ class NetworkService {
|
||||
this.net = net;
|
||||
this.stringService = stringService;
|
||||
this.settingsService = settingsService;
|
||||
|
||||
const cacheable = new CacheableLookup();
|
||||
|
||||
this.got = got.extend({
|
||||
dnsCache: cacheable,
|
||||
timeout: {
|
||||
request: 30000,
|
||||
},
|
||||
retry: { limit: 1 },
|
||||
});
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
@@ -276,7 +286,7 @@ class NetworkService {
|
||||
}
|
||||
}
|
||||
|
||||
async requestDocker(monitor) {
|
||||
async requestLocalDocker(monitor) {
|
||||
try {
|
||||
if (!monitor.url) {
|
||||
throw new Error("Monitor URL is required");
|
||||
@@ -320,7 +330,7 @@ class NetworkService {
|
||||
this.logger.warn({
|
||||
message: `No container found for "${monitor.url}".`,
|
||||
service: this.SERVICE_NAME,
|
||||
method: "requestDocker",
|
||||
method: "requestLocalDocker",
|
||||
details: { url: monitor.url },
|
||||
});
|
||||
|
||||
@@ -340,7 +350,7 @@ class NetworkService {
|
||||
this.logger.warn({
|
||||
message: `Ambiguous container match for "${monitor.url}". Matched by: ${matchTypes.join(", ")}. Using ${exactIdMatch ? "exact ID" : exactNameMatch ? "exact name" : "partial ID"} match.`,
|
||||
service: this.SERVICE_NAME,
|
||||
method: "requestDocker",
|
||||
method: "requestLocalDocker",
|
||||
details: { url: monitor.url },
|
||||
});
|
||||
dockerResponse.status = 404;
|
||||
@@ -365,6 +375,112 @@ class NetworkService {
|
||||
}
|
||||
|
||||
return dockerResponse;
|
||||
} catch (err) {
|
||||
err.service = this.SERVICE_NAME;
|
||||
err.method = "requestLocalDocker";
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async requestCaptureDocker(monitor) {
|
||||
try {
|
||||
if (!monitor.url) {
|
||||
throw new Error("Monitor URL is required");
|
||||
}
|
||||
|
||||
const dockerResponse = {
|
||||
monitorId: monitor._id,
|
||||
teamId: monitor.teamId,
|
||||
type: monitor.type,
|
||||
};
|
||||
|
||||
// Build Capture API URL
|
||||
const captureUrl = new URL(monitor.url);
|
||||
const apiUrl = `${captureUrl.protocol}//${captureUrl.host}/api/v1/metrics/docker`;
|
||||
|
||||
// Make request to Capture API
|
||||
const { response, responseTime, error } = await this.timeRequest(async () => {
|
||||
return await this.got(apiUrl, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${monitor.secret || ""}`,
|
||||
},
|
||||
timeout: { request: 10000 },
|
||||
responseType: "json",
|
||||
});
|
||||
});
|
||||
|
||||
dockerResponse.responseTime = responseTime;
|
||||
|
||||
// Handle errors
|
||||
if (error) {
|
||||
const statusCode = error.response?.statusCode || this.NETWORK_ERROR;
|
||||
dockerResponse.status = false;
|
||||
dockerResponse.code = statusCode;
|
||||
|
||||
if (statusCode === 401) {
|
||||
dockerResponse.message = "Invalid API secret for Capture server";
|
||||
} else if (statusCode === 404) {
|
||||
dockerResponse.message = "Docker monitoring not available (Capture version too old or endpoint not found)";
|
||||
} else if (statusCode === 500) {
|
||||
dockerResponse.message = "Docker daemon unavailable on Capture server";
|
||||
} else {
|
||||
dockerResponse.message = error.message || "Failed to fetch Docker metrics from Capture";
|
||||
}
|
||||
|
||||
return dockerResponse;
|
||||
}
|
||||
|
||||
// Parse response
|
||||
const payload = response.body || response;
|
||||
const { data, capture, errors } = payload;
|
||||
|
||||
// Check for errors array
|
||||
if (errors && errors.length > 0) {
|
||||
// Check if it's a critical error (docker.client)
|
||||
const dockerClientError = errors.find((e) => e.metric && e.metric.includes("docker.client"));
|
||||
if (dockerClientError) {
|
||||
dockerResponse.status = false;
|
||||
dockerResponse.code = 500;
|
||||
dockerResponse.message = dockerClientError.err || "Docker daemon unavailable";
|
||||
return dockerResponse;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have container data
|
||||
if (!data || !Array.isArray(data) || data.length === 0) {
|
||||
dockerResponse.status = false;
|
||||
dockerResponse.code = 404;
|
||||
dockerResponse.message = "No containers found on Capture server";
|
||||
dockerResponse.payload = { data: [], capture, errors: errors || [] };
|
||||
return dockerResponse;
|
||||
}
|
||||
|
||||
// Successful response - store all containers
|
||||
dockerResponse.status = true;
|
||||
dockerResponse.code = 200;
|
||||
dockerResponse.message = `Found ${data.length} container(s) on Capture server`;
|
||||
dockerResponse.payload = { data, capture, errors: errors || [] };
|
||||
|
||||
return dockerResponse;
|
||||
} catch (err) {
|
||||
err.service = this.SERVICE_NAME;
|
||||
err.method = "requestCaptureDocker";
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async requestDocker(monitor) {
|
||||
try {
|
||||
if (!monitor.url) {
|
||||
throw new Error("Monitor URL is required");
|
||||
}
|
||||
|
||||
// Check if URL is HTTP/HTTPS (Capture API) or container name/ID (local)
|
||||
if (monitor.url.startsWith("http://") || monitor.url.startsWith("https://")) {
|
||||
return await this.requestCaptureDocker(monitor);
|
||||
} else {
|
||||
return await this.requestLocalDocker(monitor);
|
||||
}
|
||||
} catch (err) {
|
||||
err.service = this.SERVICE_NAME;
|
||||
err.method = "requestDocker";
|
||||
@@ -529,6 +645,42 @@ class NetworkService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async requestMatrix({ homeserverUrl, accessToken, roomId, message }) {
|
||||
try {
|
||||
const url = `${homeserverUrl}/_matrix/client/v3/rooms/${roomId}/send/m.room.message?access_token=${accessToken}`;
|
||||
const body = {
|
||||
msgtype: "m.text",
|
||||
body: message,
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: message,
|
||||
};
|
||||
const response = await this.axios.post(url, body, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
status: true,
|
||||
code: response.status,
|
||||
message: "Successfully sent Matrix notification",
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.warn({
|
||||
message: error.message,
|
||||
service: this.SERVICE_NAME,
|
||||
method: "requestMatrix",
|
||||
});
|
||||
|
||||
return {
|
||||
status: false,
|
||||
code: error.response?.status || this.NETWORK_ERROR,
|
||||
message: "Failed to send Matrix notification",
|
||||
payload: error.response?.data,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default NetworkService;
|
||||
@@ -0,0 +1,34 @@
|
||||
const SERVICE_NAME = "Matrix";
|
||||
|
||||
class Matrix {
|
||||
static SERVICE_NAME = SERVICE_NAME;
|
||||
|
||||
constructor({ networkService, logger }) {
|
||||
this.networkService = networkService;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
get serviceName() {
|
||||
return Matrix.SERVICE_NAME;
|
||||
}
|
||||
|
||||
async send({ friendlyName, homeserverUrl, accessToken, roomId, message, monitorName }) {
|
||||
const title = `Checkmate status for ${monitorName}`;
|
||||
const formattedMessage = `## ${title}\n${message}`;
|
||||
try {
|
||||
await this.networkService.requestMatrix({
|
||||
homeserverUrl,
|
||||
accessToken,
|
||||
roomId,
|
||||
message: formattedMessage,
|
||||
});
|
||||
this.logger.info(`Successfully sent Matrix notification for ${friendlyName}`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to send Matrix notification for ${friendlyName}: ${error.message}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Matrix;
|
||||
@@ -1,4 +1,5 @@
|
||||
const SERVICE_NAME = "NotificationService";
|
||||
import Matrix from "./notificationProviders/matrix.js";
|
||||
|
||||
class NotificationService {
|
||||
static SERVICE_NAME = SERVICE_NAME;
|
||||
@@ -46,6 +47,14 @@ class NotificationService {
|
||||
|
||||
return response;
|
||||
}
|
||||
if (type === "matrix") {
|
||||
const { friendlyName, homeserverUrl, accessToken, roomId } = notification;
|
||||
const monitorName = subject;
|
||||
const message = content;
|
||||
const matrix = new Matrix({ networkService: this.networkService, logger: this.logger });
|
||||
const success = await matrix.send({ friendlyName, homeserverUrl, accessToken, roomId, message, monitorName });
|
||||
return success;
|
||||
}
|
||||
};
|
||||
|
||||
async handleNotifications(networkResponse) {
|
||||
|
||||
@@ -74,7 +74,9 @@ class NotificationUtils {
|
||||
let discordMessageText = {
|
||||
embeds: [
|
||||
{
|
||||
title: status ? dn.uptimeAlert : dn.downtimeAlert,
|
||||
title: status
|
||||
? dn.uptimeAlert.replace("{monitorName}", monitor?.name ?? dn.unknown)
|
||||
: dn.downtimeAlert.replace("{monitorName}", monitor?.name ?? dn.unknown),
|
||||
color: status ? 5763719 : 15548997,
|
||||
|
||||
fields: [
|
||||
|
||||
@@ -275,6 +275,13 @@ class StatusService {
|
||||
check.capture = payload?.capture ?? {};
|
||||
check.net = net ?? {};
|
||||
}
|
||||
|
||||
if (type === "docker") {
|
||||
const { data, capture, errors } = payload ?? {};
|
||||
check.docker = data ?? [];
|
||||
check.errors = errors ?? [];
|
||||
check.capture = capture ?? {};
|
||||
}
|
||||
return check;
|
||||
};
|
||||
|
||||
|
||||
@@ -381,7 +381,7 @@ class MonitorService implements IMonitorService {
|
||||
// Get monitor stats
|
||||
const monitorStats = await MonitorStats.findOne({
|
||||
monitorId: monitor._id,
|
||||
}).lean();
|
||||
});
|
||||
|
||||
if (!monitorStats) {
|
||||
throw new ApiError("Monitor stats not found", 404);
|
||||
|
||||
@@ -174,6 +174,7 @@ const createMonitorBodyValidation = joi.object({
|
||||
expectedValue: joi.string().allow(""),
|
||||
matchMethod: joi.string(),
|
||||
gameId: joi.string().allow(""),
|
||||
group: joi.string().max(50).trim().allow(null, "").optional(),
|
||||
});
|
||||
|
||||
const createMonitorsBodyValidation = joi.array().items(
|
||||
@@ -203,6 +204,7 @@ const editMonitorBodyValidation = joi.object({
|
||||
usage_temperature: joi.number(),
|
||||
}),
|
||||
gameId: joi.string(),
|
||||
group: joi.string().max(50).trim().allow(null, "").optional(),
|
||||
});
|
||||
|
||||
const pauseMonitorParamValidation = joi.object({
|
||||
@@ -573,10 +575,10 @@ const createNotificationBodyValidation = joi.object({
|
||||
"any.required": "Notification name is required",
|
||||
}),
|
||||
|
||||
type: joi.string().valid("email", "webhook", "slack", "discord", "pager_duty").required().messages({
|
||||
type: joi.string().valid("email", "webhook", "slack", "discord", "pager_duty", "matrix").required().messages({
|
||||
"string.empty": "Notification type is required",
|
||||
"any.required": "Notification type is required",
|
||||
"any.only": "Notification type must be email, webhook, or pager_duty",
|
||||
"any.only": "Notification type must be email, webhook, slack, discord, pager_duty, or matrix",
|
||||
}),
|
||||
|
||||
address: joi.when("type", {
|
||||
@@ -604,8 +606,40 @@ const createNotificationBodyValidation = joi.object({
|
||||
"string.uri": "Please enter a valid Webhook URL",
|
||||
}),
|
||||
},
|
||||
{
|
||||
is: "matrix",
|
||||
then: joi.string().allow("").optional(),
|
||||
},
|
||||
],
|
||||
}),
|
||||
|
||||
homeserverUrl: joi.when("type", {
|
||||
is: "matrix",
|
||||
then: joi.string().uri().required().messages({
|
||||
"string.empty": "Homeserver URL cannot be empty",
|
||||
"any.required": "Homeserver URL is required",
|
||||
"string.uri": "Please enter a valid Homeserver URL",
|
||||
}),
|
||||
otherwise: joi.string().allow("").optional(),
|
||||
}),
|
||||
|
||||
roomId: joi.when("type", {
|
||||
is: "matrix",
|
||||
then: joi.string().required().messages({
|
||||
"string.empty": "Room ID cannot be empty",
|
||||
"any.required": "Room ID is required",
|
||||
}),
|
||||
otherwise: joi.string().allow("").optional(),
|
||||
}),
|
||||
|
||||
accessToken: joi.when("type", {
|
||||
is: "matrix",
|
||||
then: joi.string().required().messages({
|
||||
"string.empty": "Access Token cannot be empty",
|
||||
"any.required": "Access Token is required",
|
||||
}),
|
||||
otherwise: joi.string().allow("").optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
//****************************************
|
||||
|
||||
Reference in new issue
Block a user