🔨 监控逻辑.
This commit is contained in:
102
orion-visor-ui/src/api/asset/host-agent.ts
Normal file
102
orion-visor-ui/src/api/asset/host-agent.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import axios from 'axios';
|
||||
import qs from 'query-string';
|
||||
|
||||
/**
|
||||
* 主机探针状态
|
||||
*/
|
||||
export interface HostAgentStatusResponse {
|
||||
id: number;
|
||||
agentVersion: string;
|
||||
latestVersion: string;
|
||||
agentInstallStatus: number;
|
||||
agentOnlineStatus: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 探针日志
|
||||
*/
|
||||
export interface HostAgentLogResponse {
|
||||
id: number;
|
||||
hostId: number;
|
||||
agentKey: string;
|
||||
type: string;
|
||||
status: string;
|
||||
message: string;
|
||||
createTime: number;
|
||||
updateTime: number;
|
||||
creator: string;
|
||||
updater: string;
|
||||
agentStatus: HostAgentStatusResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装探针请求
|
||||
*/
|
||||
export interface HostInstallAgentRequest {
|
||||
idList?: Array<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主机安装探针更新状态请求
|
||||
*/
|
||||
export interface HostAgentInstallStatusUpdateRequest {
|
||||
id?: number;
|
||||
status?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装主机探针
|
||||
*/
|
||||
export function installHostAgent(request: HostInstallAgentRequest) {
|
||||
return axios.post('/asset/host-agent/install', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改探针安装状态
|
||||
*/
|
||||
export function updateAgentInstallStatus(request: HostAgentInstallStatusUpdateRequest) {
|
||||
return axios.put('/asset/host-agent/update-install-status', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询主机探针状态
|
||||
*/
|
||||
export function getHostAgentStatus(idList: Array<number>) {
|
||||
return axios.get<Array<HostAgentStatusResponse>>('/asset/host-agent/status', {
|
||||
params: { idList },
|
||||
promptBizErrorMessage: false,
|
||||
promptRequestErrorMessage: false,
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询探针安装状态
|
||||
*/
|
||||
export function getAgentInstallLogStatus(idList: Array<number>) {
|
||||
return axios.get<Array<HostAgentLogResponse>>('/asset/host-agent/install-status', {
|
||||
params: { idList },
|
||||
promptBizErrorMessage: false,
|
||||
promptRequestErrorMessage: false,
|
||||
paramsSerializer: params => {
|
||||
return qs.stringify(params, { arrayFormat: 'comma' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传探针发布包
|
||||
*/
|
||||
export function uploadAgentRelease(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return axios.post<string>('/asset/host-agent/upload-agent-release', formData, {
|
||||
timeout: 120000,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -56,7 +56,6 @@ export interface HostVncConfig extends HostBaseConfig {
|
||||
identityId?: number;
|
||||
noUsername?: boolean;
|
||||
noPassword?: boolean;
|
||||
portForwardId?: number;
|
||||
timezone?: string;
|
||||
clipboardEncoding?: string;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export interface HostSpecExtraModel {
|
||||
outBandwidth: number;
|
||||
publicIpAddresses: Array<string>;
|
||||
privateIpAddresses: Array<string>;
|
||||
chargePerson: string;
|
||||
ownerPerson: string;
|
||||
createdTime: number;
|
||||
expiredTime: number;
|
||||
items: Array<{
|
||||
|
||||
@@ -69,6 +69,11 @@ export interface HostQueryBaseResponse {
|
||||
code: string;
|
||||
address: string;
|
||||
status: string;
|
||||
agentKey: string;
|
||||
agentVersion: string;
|
||||
agentInstallStatus: number;
|
||||
agentOnlineStatus: number;
|
||||
agentOnlineChangeTime: number;
|
||||
description: string;
|
||||
createTime: number;
|
||||
updateTime: number;
|
||||
@@ -143,8 +148,8 @@ export function updateHostSpec(request: Partial<HostExtraUpdateRequest>) {
|
||||
/**
|
||||
* 查询主机
|
||||
*/
|
||||
export function getHost(id: number) {
|
||||
return axios.get<HostQueryResponse>('/asset/host/get', { params: { id } });
|
||||
export function getHost(id: number, base = false) {
|
||||
return axios.get<HostQueryResponse>('/asset/host/get', { params: { id, base } });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getToken } from '@/utils/auth';
|
||||
import { httpBaseUrl } from '@/utils/env';
|
||||
import { reLoginTipsKey } from '@/types/symbol';
|
||||
|
||||
axios.defaults.timeout = 10000;
|
||||
axios.defaults.timeout = 15000;
|
||||
axios.defaults.setAuthorization = true;
|
||||
axios.defaults.promptBizErrorMessage = true;
|
||||
axios.defaults.promptRequestErrorMessage = true;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ export function setSftpFileContent(token: string, content: string) {
|
||||
formData.append('token', token);
|
||||
formData.append('file', new File([content], Date.now() + '', { type: 'text/plain' }));
|
||||
return axios.post<boolean>('/terminal/terminal-sftp/set-content', formData, {
|
||||
timeout: 60000,
|
||||
timeout: 120000,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user