365ab73e7d
1. 新增 notification_config 模型,飞书配置存数据库(单行id=1) 2. feishu_service 改为从数据库读配置,支持热更新,Web保存即生效 3. alerts.py 新增接口: - GET /alerts/notify/feishu/config 读配置(secret只返回是否已设) - PUT /alerts/notify/feishu/config 保存配置+热更新 (status/test 同步改为走数据库配置) 4. 前端告警中心增加「飞书通知设置」弹窗: - 开关/Webhook/签名密钥/最低级别/类型白名单 - 保存配置、发送测试按钮 5. alert_service.create_alert 推送时按数据库配置判断 配置无需改文件/重启,前端界面直接保存即生效。
199 lines
4.6 KiB
JavaScript
199 lines
4.6 KiB
JavaScript
import api from '@/utils/api'
|
|
|
|
// 网段管理
|
|
export const networkApi = {
|
|
// 获取网段列表
|
|
getList(params) {
|
|
return api.get('/networks', { params })
|
|
},
|
|
// 获取网段详情
|
|
getById(id) {
|
|
return api.get(`/networks/${id}`)
|
|
},
|
|
// 获取网段统计
|
|
getStats(id) {
|
|
return api.get(`/networks/${id}/stats`)
|
|
},
|
|
// 获取所有网段统计
|
|
getAllStats() {
|
|
return api.get('/networks/stats')
|
|
},
|
|
// 创建网段
|
|
create(data) {
|
|
return api.post('/networks', data)
|
|
},
|
|
// 更新网段
|
|
update(id, data) {
|
|
return api.put(`/networks/${id}`, data)
|
|
},
|
|
// 删除网段
|
|
delete(id) {
|
|
return api.delete(`/networks/${id}`)
|
|
},
|
|
// 获取网段下的IP
|
|
getIPs(id, params) {
|
|
return api.get(`/networks/${id}/ips`, { params })
|
|
}
|
|
}
|
|
|
|
// IP地址管理
|
|
export const ipApi = {
|
|
// 获取IP列表
|
|
getList(params) {
|
|
return api.get('/ips', { params })
|
|
},
|
|
// 获取IP详情
|
|
getById(id) {
|
|
return api.get(`/ips/${id}`)
|
|
},
|
|
// 更新IP信息
|
|
update(id, data) {
|
|
return api.put(`/ips/${id}`, data)
|
|
},
|
|
// 根据IP地址查询
|
|
getByIP(ip) {
|
|
return api.get(`/ips/address/${ip}`)
|
|
}
|
|
}
|
|
|
|
// 扫描管理
|
|
export const scanApi = {
|
|
// Ping扫描网段
|
|
pingNetwork(id) {
|
|
return api.post(`/scan/ping/${id}`)
|
|
},
|
|
// 综合扫描网段
|
|
// options: { enable_ping, enable_arp, enable_dns, enable_netbios, timeout }
|
|
// 单次调用覆盖全局 30s 超时,因为 /24 网段扫描要数分钟
|
|
comprehensiveScan(id, options = {}) {
|
|
const {
|
|
enable_ping = true,
|
|
enable_arp = true,
|
|
enable_dns = true,
|
|
enable_netbios = true,
|
|
timeout = 2
|
|
} = options
|
|
return api.post(`/scan/comprehensive/${id}`, {}, {
|
|
params: { enable_ping, enable_arp, enable_dns, enable_netbios, timeout },
|
|
timeout: 600000 // 10 分钟,足以应付 /16 级别网段
|
|
})
|
|
},
|
|
// 批量补全厂商信息
|
|
batchFillVendor(params) {
|
|
return api.post('/scan/batch/vendor', {}, { params })
|
|
},
|
|
// 批量发现主机名
|
|
batchDiscoverHostname(params) {
|
|
return api.post('/scan/batch/hostname', {}, { params })
|
|
},
|
|
// 单个IP扫描
|
|
scanIP(ipAddress) {
|
|
return api.post(`/scan/comprehensive/ip/${ipAddress}`)
|
|
},
|
|
// 获取统计摘要
|
|
getSummary() {
|
|
return api.get('/scan/statistics/summary')
|
|
}
|
|
}
|
|
|
|
// 告警管理
|
|
export const alertApi = {
|
|
// 获取告警列表
|
|
getList(params) {
|
|
return api.get('/alerts', { params })
|
|
},
|
|
// 获取告警统计
|
|
getStats() {
|
|
return api.get('/alerts/statistics/summary')
|
|
},
|
|
// 运行所有检测
|
|
runDetection() {
|
|
return api.post('/alerts/detect/run')
|
|
},
|
|
// 确认告警
|
|
acknowledge(id) {
|
|
return api.post(`/alerts/${id}/acknowledge`)
|
|
},
|
|
// 解决告警
|
|
resolve(id, notes) {
|
|
return api.post(`/alerts/${id}/resolve`, {}, { params: { notes } })
|
|
},
|
|
// 忽略告警
|
|
ignore(id) {
|
|
return api.post(`/alerts/${id}/ignore`)
|
|
},
|
|
// MAC白名单
|
|
getWhitelist(params) {
|
|
return api.get('/alerts/whitelist/macs', { params })
|
|
},
|
|
addToWhitelist(data) {
|
|
return api.post('/alerts/whitelist/macs', {}, { params: data })
|
|
},
|
|
removeFromWhitelist(id) {
|
|
return api.delete(`/alerts/whitelist/macs/${id}`)
|
|
},
|
|
// 飞书通知配置
|
|
getFeishuConfig() {
|
|
return api.get('/alerts/notify/feishu/config')
|
|
},
|
|
saveFeishuConfig(data) {
|
|
return api.put('/alerts/notify/feishu/config', {}, { params: data })
|
|
},
|
|
getFeishuStatus() {
|
|
return api.get('/alerts/notify/feishu/status')
|
|
},
|
|
testFeishu() {
|
|
return api.post('/alerts/notify/feishu/test')
|
|
}
|
|
}
|
|
|
|
// SNMP管理
|
|
export const snmpApi = {
|
|
// 凭据管理
|
|
getCredentials() {
|
|
return api.get('/snmp/credentials')
|
|
},
|
|
createCredential(data) {
|
|
return api.post('/snmp/credentials', {}, { params: data })
|
|
},
|
|
updateCredential(id, data) {
|
|
return api.put(`/snmp/credentials/${id}`, {}, { params: data })
|
|
},
|
|
deleteCredential(id) {
|
|
return api.delete(`/snmp/credentials/${id}`)
|
|
},
|
|
|
|
// 设备管理
|
|
getDevices(params) {
|
|
return api.get('/snmp/devices', { params })
|
|
},
|
|
createDevice(data) {
|
|
return api.post('/snmp/devices', {}, { params: data })
|
|
},
|
|
updateDevice(id, data) {
|
|
return api.put(`/snmp/devices/${id}`, {}, { params: data })
|
|
},
|
|
deleteDevice(id) {
|
|
return api.delete(`/snmp/devices/${id}`)
|
|
},
|
|
|
|
// SNMP操作
|
|
testConnection(id) {
|
|
return api.post(`/snmp/devices/${id}/test`)
|
|
},
|
|
pollDevice(id) {
|
|
return api.post(`/snmp/devices/${id}/poll`)
|
|
},
|
|
getARPTable(id) {
|
|
return api.post(`/snmp/devices/${id}/arp`)
|
|
},
|
|
getInterfaces(id) {
|
|
return api.post(`/snmp/devices/${id}/interfaces`)
|
|
},
|
|
|
|
// 获取统计
|
|
getStats() {
|
|
return api.get('/snmp/statistics/summary')
|
|
}
|
|
}
|