🔨 监控逻辑.
This commit is contained in:
95
orion-visor-ui/src/api/monitor/metrics.ts
Normal file
95
orion-visor-ui/src/api/monitor/metrics.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 监控指标创建请求
|
||||
*/
|
||||
export interface MetricsCreateRequest {
|
||||
name?: string;
|
||||
measurement?: string;
|
||||
value?: string;
|
||||
unit?: string;
|
||||
suffix?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控指标更新请求
|
||||
*/
|
||||
export interface MetricsUpdateRequest extends MetricsCreateRequest {
|
||||
id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控指标查询请求
|
||||
*/
|
||||
export interface MetricsQueryRequest extends Pagination, OrderDirection {
|
||||
searchValue?: string;
|
||||
id?: number;
|
||||
name?: string;
|
||||
measurement?: string;
|
||||
value?: string;
|
||||
unit?: string;
|
||||
suffix?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控指标查询响应
|
||||
*/
|
||||
export interface MetricsQueryResponse extends TableData {
|
||||
id: number;
|
||||
name: string;
|
||||
measurement: string;
|
||||
value: string;
|
||||
unit: string;
|
||||
suffix: string;
|
||||
description: string;
|
||||
createTime: number;
|
||||
updateTime: number;
|
||||
creator: string;
|
||||
updater: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建监控指标
|
||||
*/
|
||||
export function createMetrics(request: MetricsCreateRequest) {
|
||||
return axios.post<number>('/monitor/monitor-metrics/create', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新监控指标
|
||||
*/
|
||||
export function updateMetrics(request: MetricsUpdateRequest) {
|
||||
return axios.put<number>('/monitor/monitor-metrics/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询监控指标
|
||||
*/
|
||||
export function getMetrics(id: number) {
|
||||
return axios.get<MetricsQueryResponse>('/monitor/monitor-metrics/get', { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部监控指标
|
||||
*/
|
||||
export function getMetricsList() {
|
||||
return axios.get<Array<MetricsQueryResponse>>('/monitor/monitor-metrics/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询监控指标
|
||||
*/
|
||||
export function getMetricsPage(request: MetricsQueryRequest) {
|
||||
return axios.post<DataGrid<MetricsQueryResponse>>('/monitor/monitor-metrics/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监控指标
|
||||
*/
|
||||
export function deleteMetrics(id: number) {
|
||||
return axios.delete<number>('/monitor/monitor-metrics/delete', { params: { id } });
|
||||
}
|
||||
168
orion-visor-ui/src/api/monitor/monitor-host.ts
Normal file
168
orion-visor-ui/src/api/monitor/monitor-host.ts
Normal file
@@ -0,0 +1,168 @@
|
||||
import type { TableData } from '@arco-design/web-vue';
|
||||
import type { DataGrid, Pagination, TimeChartSeries } from '@/types/global';
|
||||
import type { HostAgentLogResponse } from '@/api/asset/host-agent';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 监控主机更新请求
|
||||
*/
|
||||
export interface MonitorHostUpdateRequest {
|
||||
id?: number;
|
||||
policyId?: number;
|
||||
alarmSwitch?: number;
|
||||
ownerUserId?: number;
|
||||
cpuName?: string;
|
||||
diskName?: string;
|
||||
networkName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控主机更新请求
|
||||
*/
|
||||
export interface MonitorHostSwitchUpdateRequest {
|
||||
id?: number;
|
||||
alarmSwitch?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控主机查询请求
|
||||
*/
|
||||
export interface MonitorHostQueryRequest extends Pagination {
|
||||
agentKeyList?: Array<string>;
|
||||
searchValue?: string;
|
||||
alarmSwitch?: number;
|
||||
policyId?: number;
|
||||
ownerUserId?: number;
|
||||
name?: string;
|
||||
code?: string;
|
||||
address?: string;
|
||||
agentKey?: string;
|
||||
agentInstallStatus?: number;
|
||||
agentOnlineStatus?: number;
|
||||
description?: string;
|
||||
tags?: Array<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控主机图表查询请求
|
||||
*/
|
||||
export interface MonitorHostChartRequest {
|
||||
agentKeys?: Array<string>;
|
||||
measurement?: string;
|
||||
fields?: Array<string>;
|
||||
window?: string;
|
||||
aggregate?: string;
|
||||
range?: string;
|
||||
start?: string;
|
||||
end?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控主机查询响应
|
||||
*/
|
||||
export interface MonitorHostQueryResponse extends TableData {
|
||||
id: number;
|
||||
hostId: number;
|
||||
policyId: number;
|
||||
policyName: string;
|
||||
osType: string;
|
||||
name: string;
|
||||
code: string;
|
||||
address: string;
|
||||
status: string;
|
||||
agentKey: string;
|
||||
agentVersion: string;
|
||||
latestVersion: string;
|
||||
agentInstallStatus: number;
|
||||
agentOnlineStatus: number;
|
||||
agentOnlineChangeTime: number;
|
||||
alarmSwitch: number;
|
||||
ownerUserId: number;
|
||||
ownerUsername: string;
|
||||
tags: Array<{ id: number, name: string }>;
|
||||
meta: MonitorHostMeta;
|
||||
config: MonitorHostConfig;
|
||||
metricsData: MonitorHostMetricsData;
|
||||
installLog: HostAgentLogResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控元数据
|
||||
*/
|
||||
export interface MonitorHostMeta {
|
||||
cpus: Array<string>;
|
||||
disks: Array<string>;
|
||||
nets: Array<string>;
|
||||
memoryBytes: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控配置
|
||||
*/
|
||||
export interface MonitorHostConfig {
|
||||
cpuName: string;
|
||||
diskName: string;
|
||||
networkName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控数据
|
||||
*/
|
||||
export interface MonitorHostMetricsData {
|
||||
agentKey: string;
|
||||
noData: boolean;
|
||||
timestamp: number;
|
||||
cpuName: string;
|
||||
diskName: string;
|
||||
networkName: string;
|
||||
cpuUsagePercent: number;
|
||||
memoryUsagePercent: number;
|
||||
memoryUsageBytes: number;
|
||||
load1: number;
|
||||
load5: number;
|
||||
load15: number;
|
||||
diskUsagePercent: number;
|
||||
diskUsageBytes: number;
|
||||
networkSentPreBytes: number;
|
||||
networkRecvPreBytes: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询监控主机指标
|
||||
*/
|
||||
export function getMonitorHostMetrics(agentKeyList: Array<string>) {
|
||||
return axios.post<Array<MonitorHostMetricsData>>('/monitor/monitor-host/metrics', {
|
||||
agentKeyList
|
||||
}, {
|
||||
promptBizErrorMessage: false,
|
||||
promptRequestErrorMessage: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询监控主机图表
|
||||
*/
|
||||
export function getMonitorHostChart(request: MonitorHostChartRequest) {
|
||||
return axios.post<Array<TimeChartSeries>>('/monitor/monitor-host/chart', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询监控主机
|
||||
*/
|
||||
export function getMonitorHostPage(request: MonitorHostQueryRequest) {
|
||||
return axios.post<DataGrid<MonitorHostQueryResponse>>('/monitor/monitor-host/query', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新监控主机
|
||||
*/
|
||||
export function updateMonitorHost(request: MonitorHostUpdateRequest) {
|
||||
return axios.put<number>('/monitor/monitor-host/update', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新监控主机告警开关
|
||||
*/
|
||||
export function updateMonitorHostAlarmSwitch(request: MonitorHostSwitchUpdateRequest) {
|
||||
return axios.put<number>('/monitor/monitor-host/update-switch', request);
|
||||
}
|
||||
Reference in New Issue
Block a user