diff --git a/frontend/src/mocks/data.ts b/frontend/src/mocks/data.ts deleted file mode 100644 index 6c6c5c2..0000000 --- a/frontend/src/mocks/data.ts +++ /dev/null @@ -1,76 +0,0 @@ -// Mock data barrel - re-exports all mock data from modules -export * from './modules/servers'; -export * from './modules/cloud'; -export * from './modules/k8s'; -export * from './modules/alerts'; -export * from './modules/dashboard'; -export * from './modules/cicd'; -export * from './modules/automation'; -export * from './modules/system'; -export * from './modules/approval'; -export * from './modules/monitor'; -export * from './modules/misc'; - -// Aggregate mockData object (cross-module references) -import { resourceModels, modelInstances } from './modules/misc'; -import { ansiblePlaybooks, ansibleJobs, ansibleInventories, cronJobsList, cronJobExecutions, scripts } from './modules/automation'; -import { logMonitorEntries, logSources, traces, serviceMetrics, traceSpans, grafanaDashboards, datasources } from './modules/monitor'; -import { alertCenterAlerts, alertCenterRules, notificationChannels, recentAlerts, alertEvents } from './modules/alerts'; -import { pipelines, pipelineExecutions, releases, appReleases } from './modules/cicd'; -import { servers, serverMetrics } from './modules/servers'; -import { k8sClusters, k8sNodes, k8sPods, k8sDeployments, k8sServices, k8sIngresses } from './modules/k8s'; -import { dashboardStats, topCPU, topMemory, topDisk } from './modules/dashboard'; -import { costStats, certExpiry, cloudProvidersList, cloudAccountsList, cloudRegionsList, domainsList } from './modules/cloud'; -import { pendingApprovals, currentUser, users } from './modules/system'; -import { tickets, approvalFlows, approvalInstances } from './modules/approval'; - -export const mockData = { - resourceModels, - modelInstances, - ansiblePlaybooks, - ansibleJobs, - ansibleInventories, - logEntries: logMonitorEntries, - logSources, - alerts: alertCenterAlerts, - alertRules: alertCenterRules, - notificationChannels, - traces, - serviceMetrics, - spans: traceSpans, - grafanaDashboards, - datasources, - pipelines, - pipelineExecutions, - releases, - cronJobs: cronJobsList, - cronJobExecutions, - scripts, - servers, - k8sClusters, - k8sNodes, - k8sPods, - k8sDeployments, - k8sServices, - k8sIngresses, - dashboardStats, - recentAlerts, - topCPU, - topMemory, - topDisk, - costStats, - certExpiry, - serverMetrics, - cloudProviders: cloudProvidersList, - cloudAccounts: cloudAccountsList, - cloudRegions: cloudRegionsList, - domains: domainsList, - pendingApprovals, - currentUser, - users, - tickets, - appReleases, - approvalFlows, - approvalInstances, - alertEvents, -}; diff --git a/frontend/src/mocks/modules/alerts.ts b/frontend/src/mocks/modules/alerts.ts deleted file mode 100644 index 35cd0c0..0000000 --- a/frontend/src/mocks/modules/alerts.ts +++ /dev/null @@ -1,200 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const alertRules: AlertRule[] = [ - { - id: 'rule-001', - name: 'CPU使用率过高', - metric: 'cpu_usage_percent', - operator: '>', - threshold: 80, - duration: 300, - severity: 'warning', - enabled: true, - description: '服务器CPU使用率超过80%持续5分钟', - notifyChannels: ['email', 'dingtalk'], - }, - { - id: 'rule-002', - name: 'CPU使用率严重过高', - metric: 'cpu_usage_percent', - operator: '>', - threshold: 95, - duration: 180, - severity: 'critical', - enabled: true, - description: '服务器CPU使用率超过95%持续3分钟', - notifyChannels: ['email', 'sms', 'dingtalk'], - }, - { - id: 'rule-003', - name: '内存使用率过高', - metric: 'memory_usage_percent', - operator: '>', - threshold: 85, - duration: 300, - severity: 'warning', - enabled: true, - description: '服务器内存使用率超过85%持续5分钟', - notifyChannels: ['email', 'dingtalk'], - }, - { - id: 'rule-004', - name: '磁盘空间不足', - metric: 'disk_usage_percent', - operator: '>', - threshold: 90, - duration: 60, - severity: 'critical', - enabled: true, - description: '服务器磁盘使用率超过90%', - notifyChannels: ['email', 'sms', 'dingtalk'], - }, - { - id: 'rule-005', - name: '服务不可用', - metric: 'service_up', - operator: '==', - threshold: 0, - duration: 60, - severity: 'critical', - enabled: true, - description: '服务健康检查失败', - notifyChannels: ['email', 'sms', 'dingtalk', 'wechat'], - }, - { - id: 'rule-006', - name: '网络延迟过高', - metric: 'network_latency_ms', - operator: '>', - threshold: 100, - duration: 180, - severity: 'warning', - enabled: true, - description: '网络延迟超过100ms持续3分钟', - notifyChannels: ['email'], - }, -]; - -// 告警事件数据 -export const alertEvents: AlertEvent[] = [ - { - id: 'alert-001', - ruleId: 'rule-002', - ruleName: 'CPU使用率严重过高', - severity: 'critical', - status: 'firing', - value: 97.5, - threshold: 95, - target: 'app-server-01 (192.168.1.103)', - message: '服务器CPU使用率97.5%,超过阈值95%', - startedAt: '2025-03-30T09:45:00Z', - }, - { - id: 'alert-002', - ruleId: 'rule-003', - ruleName: '内存使用率过高', - severity: 'warning', - status: 'firing', - value: 89.2, - threshold: 85, - target: 'k8s-worker-02 (192.168.1.212)', - message: '服务器内存使用率89.2%,超过阈值85%', - startedAt: '2025-03-30T09:30:00Z', - }, - { - id: 'alert-003', - ruleId: 'rule-004', - ruleName: '磁盘空间不足', - severity: 'critical', - status: 'firing', - value: 94.8, - threshold: 90, - target: 'db-server-01 (192.168.1.105)', - message: '服务器磁盘使用率94.8%,超过阈值90%', - startedAt: '2025-03-30T08:00:00Z', - }, - { - id: 'alert-004', - ruleId: 'rule-001', - ruleName: 'CPU使用率过高', - severity: 'warning', - status: 'resolved', - value: 75.2, - threshold: 80, - target: 'web-server-01 (192.168.1.101)', - message: '服务器CPU使用率已恢复正常', - startedAt: '2025-03-30T07:00:00Z', - resolvedAt: '2025-03-30T08:30:00Z', - }, - { - id: 'alert-005', - ruleId: 'rule-005', - ruleName: '服务不可用', - severity: 'critical', - status: 'firing', - value: 0, - threshold: 0, - target: 'test-server-01 (192.168.2.101)', - message: '服务健康检查失败,服务可能已停止', - startedAt: '2025-03-29T18:00:00Z', - }, -]; - -// 工单数据 -export const alertCenterAlerts = [ - { id: 'alert-001', title: '数据库连接池耗尽', description: '生产环境数据库连接池使用率超过95%', severity: 'critical', status: 'firing', source: 'Prometheus', service: 'order-service', metric: 'db_connection_pool_usage', value: 98.5, threshold: 95, startedAt: '2025-04-14 10:15:00', labels: { env: 'production' }, annotations: {} }, - { id: 'alert-002', title: 'API响应时间过高', description: '用户服务API P99响应时间超过500ms', severity: 'warning', status: 'firing', source: 'SkyWalking', service: 'user-service', metric: 'http_request_duration_p99', value: 750, threshold: 500, startedAt: '2025-04-14 09:30:00', labels: {}, annotations: {} }, - { id: 'alert-003', title: '磁盘空间不足', description: '数据库服务器磁盘使用率超过90%', severity: 'critical', status: 'acknowledged', source: 'Zabbix', service: 'db-server-01', metric: 'disk_usage_percent', value: 94.2, threshold: 90, startedAt: '2025-04-14 08:00:00', acknowledgedBy: '李运维', acknowledgedAt: '2025-04-14 08:15:00', labels: {}, annotations: {} }, - { id: 'alert-004', title: '内存使用率过高', description: '应用服务器内存使用率超过85%', severity: 'warning', status: 'resolved', source: 'Prometheus', service: 'app-server-02', metric: 'memory_usage_percent', value: 72.5, threshold: 85, startedAt: '2025-04-14 07:00:00', resolvedAt: '2025-04-14 08:30:00', labels: {}, annotations: {} }, - { id: 'alert-005', title: '服务健康检查失败', description: '支付服务健康检查连续3次失败', severity: 'critical', status: 'firing', source: 'Kubernetes', service: 'payment-service', metric: 'health_check_status', value: 0, threshold: 1, startedAt: '2025-04-14 10:25:00', labels: {}, annotations: {} } -]; - -export const alertCenterRules = [ - { id: 'arule-001', name: '数据库连接池使用率', description: '监控数据库连接池使用率', enabled: true, severity: 'critical', query: 'db_connection_pool_usage > 95', duration: '5m', threshold: 95, labels: ['database'], notificationChannels: ['email', 'slack'], lastEvaluated: '2025-04-14 10:30:00' }, - { id: 'arule-002', name: 'API响应时间P99', description: '监控API P99响应时间', enabled: true, severity: 'warning', query: 'http_request_duration_p99 > 500', duration: '3m', threshold: 500, labels: ['api'], notificationChannels: ['slack'], lastEvaluated: '2025-04-14 10:30:00' }, - { id: 'arule-003', name: '磁盘空间使用率', description: '监控服务器磁盘使用率', enabled: true, severity: 'critical', query: 'disk_usage_percent > 90', duration: '1m', threshold: 90, labels: ['disk'], notificationChannels: ['email', 'sms'], lastEvaluated: '2025-04-14 10:30:00' }, - { id: 'arule-004', name: '服务健康检查', description: '监控服务健康检查状态', enabled: true, severity: 'critical', query: 'health_check_status == 0', duration: '1m', threshold: 0, labels: ['health'], notificationChannels: ['email', 'pagerduty'], lastEvaluated: '2025-04-14 10:30:00' } -]; - -export const notificationChannels = [ - { id: 'ch-001', name: '运维邮箱组', type: 'email', enabled: true, config: { recipients: 'ops@company.com' } }, - { id: 'ch-002', name: '告警Slack频道', type: 'slack', enabled: true, config: { webhook: 'https://hooks.slack.com/xxx' } }, - { id: 'ch-003', name: '值班手机', type: 'sms', enabled: true, config: { phone: '13800138000' } }, - { id: 'ch-004', name: 'PagerDuty', type: 'pagerduty', enabled: false, config: { service_key: 'xxx' } }, - { id: 'ch-005', name: '企业微信', type: 'webhook', enabled: true, config: { url: 'https://qyapi.weixin.qq.com/xxx' } } -]; - -// ============ 链路追踪数据 ============ -export const recentAlerts = [ - { id: 'a-001', title: 'CPU使用率过高', severity: 'critical', service: 'app-server-01', time: '5分钟前' }, - { id: 'a-002', title: '内存使用率警告', severity: 'warning', service: 'k8s-worker-02', time: '15分钟前' }, - { id: 'a-003', title: '磁盘空间不足', severity: 'critical', service: 'db-server-01', time: '30分钟前' } -]; - diff --git a/frontend/src/mocks/modules/approval.ts b/frontend/src/mocks/modules/approval.ts deleted file mode 100644 index 66cbc09..0000000 --- a/frontend/src/mocks/modules/approval.ts +++ /dev/null @@ -1,173 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const approvalFlows: ApprovalFlow[] = [ - { - id: 'flow-001', - name: '服务器资源申请审批', - description: '申请新服务器或扩容资源的审批流程', - enabled: true, - createdAt: '2024-01-01T00:00:00Z', - nodes: [ - { id: 'start', name: '开始', type: 'start', nextNodes: ['dept-approval'] }, - { id: 'dept-approval', name: '部门审批', type: 'approval', approvers: ['dept-manager'], nextNodes: ['it-approval'] }, - { id: 'it-approval', name: 'IT审批', type: 'approval', approvers: ['it-manager'], nextNodes: ['finance-approval'] }, - { id: 'finance-approval', name: '财务审批', type: 'approval', approvers: ['finance-manager'], nextNodes: ['end'] }, - { id: 'end', name: '结束', type: 'end', nextNodes: [] }, - ], - }, - { - id: 'flow-002', - name: '生产环境变更审批', - description: '生产环境配置变更、发布等操作的审批流程', - enabled: true, - createdAt: '2024-01-01T00:00:00Z', - nodes: [ - { id: 'start', name: '开始', type: 'start', nextNodes: ['tech-approval'] }, - { id: 'tech-approval', name: '技术负责人审批', type: 'approval', approvers: ['tech-lead'], nextNodes: ['ops-approval'] }, - { id: 'ops-approval', name: '运维负责人审批', type: 'approval', approvers: ['ops-lead'], nextNodes: ['end'] }, - { id: 'end', name: '结束', type: 'end', nextNodes: [] }, - ], - }, -]; - -// 审批实例数据 -export const approvalInstances: ApprovalInstance[] = [ - { - id: 'instance-001', - flowId: 'flow-001', - flowName: '服务器资源申请审批', - applicant: 'user-004', - applicantName: '王开发', - status: 'pending', - currentNode: 'it-approval', - createdAt: '2025-03-30T09:00:00Z', - }, - { - id: 'instance-002', - flowId: 'flow-002', - flowName: '生产环境变更审批', - applicant: 'user-002', - applicantName: '李运维', - status: 'pending', - currentNode: 'tech-approval', - createdAt: '2025-03-29T16:00:00Z', - }, - { - id: 'instance-003', - flowId: 'flow-001', - flowName: '服务器资源申请审批', - applicant: 'user-005', - applicantName: '赵开发', - status: 'approved', - currentNode: 'end', - createdAt: '2025-03-28T10:00:00Z', - completedAt: '2025-03-28T15:00:00Z', - }, -]; - -// 应用发布数据 -export const tickets: Ticket[] = [ - { - id: 'TICKET-2025-001', - title: '生产环境数据库性能优化', - type: 'incident', - priority: 'high', - status: 'in_progress', - assignee: 'user-003', - assigneeName: '张工程师', - creator: 'user-001', - creatorName: '管理员', - description: '生产环境数据库响应缓慢,需要紧急优化', - createdAt: '2025-03-30T08:00:00Z', - updatedAt: '2025-03-30T09:30:00Z', - dueDate: '2025-03-30T18:00:00Z', - }, - { - id: 'TICKET-2025-002', - title: '申请开通测试服务器访问权限', - type: 'request', - priority: 'medium', - status: 'open', - assignee: 'user-002', - assigneeName: '李运维', - creator: 'user-004', - creatorName: '王开发', - description: '新员工需要访问测试环境服务器进行开发调试', - createdAt: '2025-03-29T14:00:00Z', - updatedAt: '2025-03-29T14:00:00Z', - dueDate: '2025-04-01T18:00:00Z', - }, - { - id: 'TICKET-2025-003', - title: 'Kubernetes集群版本升级', - type: 'change', - priority: 'high', - status: 'open', - assignee: 'user-002', - assigneeName: '李运维', - creator: 'user-001', - creatorName: '管理员', - description: '计划将生产K8s集群从v1.28.5升级到v1.29.0', - createdAt: '2025-03-28T10:00:00Z', - updatedAt: '2025-03-28T10:00:00Z', - dueDate: '2025-04-05T20:00:00Z', - }, - { - id: 'TICKET-2025-004', - title: '磁盘空间清理', - type: 'incident', - priority: 'medium', - status: 'resolved', - assignee: 'user-003', - assigneeName: '张工程师', - creator: 'user-001', - creatorName: '管理员', - description: '日志服务器磁盘空间不足,需要清理旧日志', - createdAt: '2025-03-27T09:00:00Z', - updatedAt: '2025-03-27T16:00:00Z', - dueDate: '2025-03-27T18:00:00Z', - }, - { - id: 'TICKET-2025-005', - title: '新增监控告警规则', - type: 'request', - priority: 'low', - status: 'closed', - assignee: 'user-002', - assigneeName: '李运维', - creator: 'user-005', - creatorName: '赵开发', - description: '为新上线的微服务添加监控告警', - createdAt: '2025-03-26T11:00:00Z', - updatedAt: '2025-03-26T15:00:00Z', - }, -]; - -// 审批流程数据 diff --git a/frontend/src/mocks/modules/automation.ts b/frontend/src/mocks/modules/automation.ts deleted file mode 100644 index 88e52db..0000000 --- a/frontend/src/mocks/modules/automation.ts +++ /dev/null @@ -1,258 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const cronJobs: CronJob[] = [ - { - id: 'job-001', - name: '日志清理任务', - description: '清理7天前的应用日志', - cron: '0 2 * * *', - command: '/opt/scripts/cleanup_logs.sh', - status: 'running', - lastRunAt: '2025-03-30T02:00:00Z', - nextRunAt: '2025-03-31T02:00:00Z', - successCount: 365, - failCount: 2, - }, - { - id: 'job-002', - name: '数据库备份', - description: '每日数据库全量备份', - cron: '0 3 * * *', - command: '/opt/scripts/backup_db.sh', - status: 'running', - lastRunAt: '2025-03-30T03:00:00Z', - nextRunAt: '2025-03-31T03:00:00Z', - successCount: 365, - failCount: 0, - }, - { - id: 'job-003', - name: '健康检查', - description: '系统健康状态检查', - cron: '*/5 * * * *', - command: '/opt/scripts/health_check.sh', - status: 'running', - lastRunAt: '2025-03-30T10:25:00Z', - nextRunAt: '2025-03-30T10:30:00Z', - successCount: 105120, - failCount: 10, - }, - { - id: 'job-004', - name: '临时数据清理', - description: '清理临时目录数据', - cron: '0 1 * * 0', - command: '/opt/scripts/cleanup_temp.sh', - status: 'paused', - successCount: 52, - failCount: 0, - }, -]; - -// 脚本数据 -export const cronJobsList = [ - { id: 'cron-001', name: '数据库备份', description: '每日凌晨执行数据库全量备份', schedule: '0 2 * * *', command: '/scripts/backup-db.sh', enabled: true, lastRun: '2025-04-14 02:00:00', nextRun: '2025-04-15 02:00:00', createdAt: '2025-01-01', createdBy: '李运维' }, - { id: 'cron-002', name: '日志清理', description: '清理7天前的应用日志', schedule: '0 3 * * *', command: '/scripts/cleanup-logs.sh', enabled: true, lastRun: '2025-04-14 03:00:00', nextRun: '2025-04-15 03:00:00', createdAt: '2025-01-01', createdBy: '张工程师' }, - { id: 'cron-003', name: '数据同步', description: '每小时同步订单数据到数据仓库', schedule: '0 * * * *', command: '/scripts/sync-data.sh', enabled: false, lastRun: '2025-04-13 23:00:00', nextRun: '-', createdAt: '2025-02-01', createdBy: '王开发' } -]; - -export const cronJobExecutions = [ - { id: 'exec-cron-001', jobId: 'cron-001', jobName: '数据库备份', status: 'success', startedAt: '2025-04-14 02:00:00', duration: 1200, output: 'Backup completed. Size: 2.5GB' }, - { id: 'exec-cron-002', jobId: 'cron-001', jobName: '数据库备份', status: 'success', startedAt: '2025-04-13 02:00:00', duration: 1150, output: 'Backup completed. Size: 2.4GB' }, - { id: 'exec-cron-003', jobId: 'cron-002', jobName: '日志清理', status: 'success', startedAt: '2025-04-14 03:00:00', duration: 45, output: 'Cleaned 150 log files' }, - { id: 'exec-cron-004', jobId: 'cron-003', jobName: '数据同步', status: 'failed', startedAt: '2025-04-13 23:00:00', duration: 300, output: 'Error: Connection timeout' } -]; - -// ============ 仪表盘统计数据 ============ -export const scripts: Script[] = [ - { - id: 'script-001', - name: '重启Nginx服务', - description: '安全重启Nginx服务', - language: 'bash', - content: '#!/bin/bash\necho "正在重启Nginx服务..."\nsystemctl reload nginx\necho "Nginx服务重启完成"', - params: [], - createdAt: '2024-01-01T00:00:00Z', - updatedAt: '2024-01-01T00:00:00Z', - }, - { - id: 'script-002', - name: '清理Docker镜像', - description: '清理未使用的Docker镜像', - language: 'bash', - content: '#!/bin/bash\necho "清理未使用的Docker镜像..."\ndocker image prune -af\necho "清理完成"', - params: [ - { name: 'dry_run', type: 'boolean', required: false, default: 'false', description: '仅预览,不实际删除' }, - ], - createdAt: '2024-01-15T00:00:00Z', - updatedAt: '2024-02-01T00:00:00Z', - }, - { - id: 'script-003', - name: '查看端口占用', - description: '查看指定端口的占用情况', - language: 'bash', - content: '#!/bin/bash\nPORT=${1:-8080}\necho "查看端口 $PORT 的占用情况..."\nnetstat -tlnp | grep :$PORT', - params: [ - { name: 'port', type: 'number', required: true, description: '端口号' }, - ], - createdAt: '2024-02-15T00:00:00Z', - updatedAt: '2024-02-15T00:00:00Z', - }, -]; - -// ==================== CMDB资源模型数据 ==================== - -export const ansiblePlaybooks = [ - { - id: 'pb-001', - name: '部署Nginx服务', - description: '在目标主机上安装和配置Nginx服务', - content: '---\n- name: Deploy Nginx\n hosts: web_servers\n become: yes\n tasks:\n - name: Install Nginx\n apt:\n name: nginx\n state: present\n - name: Start Nginx\n service:\n name: nginx\n state: started\n enabled: yes', - tags: ['nginx', 'web', 'deployment'], - category: 'deployment', - createdAt: '2025-04-01', - updatedAt: '2025-04-10', - createdBy: '张工程师', - variables: [ - { name: 'nginx_version', defaultValue: 'latest', description: 'Nginx版本', required: false }, - { name: 'listen_port', defaultValue: '80', description: '监听端口', required: false } - ] - }, - { - id: 'pb-002', - name: '系统安全加固', - description: '执行系统安全加固配置', - content: '---\n- name: System Hardening\n hosts: all\n become: yes\n tasks:\n - name: Update packages\n apt:\n update_cache: yes\n upgrade: dist\n - name: Configure firewall\n ufw:\n state: enabled\n policy: deny', - tags: ['security', 'hardening', 'system'], - category: 'security', - createdAt: '2025-03-15', - updatedAt: '2025-03-20', - createdBy: '李运维', - variables: [] - }, - { - id: 'pb-003', - name: 'Docker环境安装', - description: '安装Docker和Docker Compose', - content: '---\n- name: Install Docker\n hosts: docker_hosts\n become: yes\n tasks:\n - name: Install Docker\n apt:\n name: docker.io\n state: present\n - name: Install Docker Compose\n pip:\n name: docker-compose\n state: present', - tags: ['docker', 'container', 'installation'], - category: 'configuration', - createdAt: '2025-04-05', - updatedAt: '2025-04-05', - createdBy: '王开发', - variables: [{ name: 'docker_version', defaultValue: 'latest', description: 'Docker版本', required: false }] - }, - { - id: 'pb-004', - name: 'MySQL备份', - description: '执行MySQL数据库备份', - content: '---\n- name: MySQL Backup\n hosts: db_servers\n become: yes\n tasks:\n - name: Create backup\n mysql_db:\n state: dump\n name: all\n target: /backup/mysql_{{ ansible_date_time.date }}.sql', - tags: ['mysql', 'backup', 'database'], - category: 'backup', - createdAt: '2025-03-20', - updatedAt: '2025-04-01', - createdBy: '张工程师', - variables: [ - { name: 'backup_path', defaultValue: '/backup', description: '备份路径', required: true }, - { name: 'retention_days', defaultValue: '7', description: '保留天数', required: false } - ] - } -]; - -export const ansibleJobs = [ - { - id: 'job-001', - playbookId: 'pb-001', - playbookName: '部署Nginx服务', - status: 'success', - targetHosts: ['web-server-01', 'web-server-02'], - variables: { nginx_version: '1.25.3', listen_port: '80' }, - startedAt: '2025-04-14 10:00:00', - completedAt: '2025-04-14 10:05:30', - duration: 330000, - output: 'PLAY [Deploy Nginx] ***\nTASK [Install Nginx] ***\nchanged: [web-server-01]\nchanged: [web-server-02]', - triggeredBy: '张工程师' - }, - { - id: 'job-002', - playbookId: 'pb-002', - playbookName: '系统安全加固', - status: 'running', - targetHosts: ['app-server-01', 'app-server-02'], - variables: {}, - startedAt: '2025-04-14 11:00:00', - output: 'PLAY [System Hardening] ***\nTASK [Update packages] ***\nRunning...', - triggeredBy: '李运维' - }, - { - id: 'job-003', - playbookId: 'pb-003', - playbookName: 'Docker环境安装', - status: 'failed', - targetHosts: ['test-server-01'], - variables: { docker_version: 'latest' }, - startedAt: '2025-04-14 09:00:00', - completedAt: '2025-04-14 09:02:15', - duration: 135000, - output: 'PLAY [Install Docker] ***\nfatal: [test-server-01]: FAILED!', - triggeredBy: '王开发' - } -]; - -export const ansibleInventories = [ - { - id: 'inv-001', - name: '生产环境主机', - hosts: [ - { id: 'h-001', name: 'web-server-01', ip: '192.168.1.101', port: 22, user: 'ansible', os: 'CentOS 7' }, - { id: 'h-002', name: 'web-server-02', ip: '192.168.1.102', port: 22, user: 'ansible', os: 'CentOS 7' }, - { id: 'h-003', name: 'app-server-01', ip: '192.168.1.103', port: 22, user: 'ansible', os: 'Ubuntu 22.04' }, - { id: 'h-004', name: 'app-server-02', ip: '192.168.1.104', port: 22, user: 'ansible', os: 'Ubuntu 22.04' }, - { id: 'h-005', name: 'db-server-01', ip: '192.168.1.105', port: 22, user: 'ansible', os: 'CentOS 8' } - ], - groups: [ - { id: 'g-001', name: 'web_servers', hosts: ['h-001', 'h-002'] }, - { id: 'g-002', name: 'app_servers', hosts: ['h-003', 'h-004'] }, - { id: 'g-003', name: 'db_servers', hosts: ['h-005'] } - ] - }, - { - id: 'inv-002', - name: '测试环境主机', - hosts: [ - { id: 'h-006', name: 'test-server-01', ip: '192.168.2.101', port: 22, user: 'ansible', os: 'Ubuntu 22.04' }, - { id: 'h-007', name: 'test-server-02', ip: '192.168.2.102', port: 22, user: 'ansible', os: 'Ubuntu 22.04' } - ], - groups: [{ id: 'g-004', name: 'test_servers', hosts: ['h-006', 'h-007'] }] - } -]; - -// ============ 日志数据 ============ diff --git a/frontend/src/mocks/modules/cicd.ts b/frontend/src/mocks/modules/cicd.ts deleted file mode 100644 index abc36bc..0000000 --- a/frontend/src/mocks/modules/cicd.ts +++ /dev/null @@ -1,118 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const pipelines = [ - { id: 'pipe-001', name: 'user-service-pipeline', description: '用户服务CI/CD流水线', template: 'nodejs', stages: [{ name: '检出代码', status: 'success', duration: 15 }, { name: '构建', status: 'success', duration: 120 }, { name: '单元测试', status: 'success', duration: 60 }], createdAt: '2025-03-01', lastRun: '2025-04-14 10:00:00' }, - { id: 'pipe-002', name: 'order-service-pipeline', description: '订单服务CI/CD流水线', template: 'java', stages: [{ name: '检出代码', status: 'success', duration: 12 }, { name: '编译', status: 'success', duration: 180 }, { name: '集成测试', status: 'running', duration: 0 }], createdAt: '2025-03-05', lastRun: '2025-04-14 11:00:00' } -]; - -export const pipelineExecutions = [ - { id: 'exec-001', pipelineId: 'pipe-001', pipelineName: 'user-service-pipeline', status: 'success', branch: 'main', commitId: 'a1b2c3d', triggeredBy: '张工程师', startedAt: '2025-04-14 10:00:00', duration: 510 }, - { id: 'exec-002', pipelineId: 'pipe-001', pipelineName: 'user-service-pipeline', status: 'failed', branch: 'feature/new-ui', commitId: 'e4f5g6h', triggeredBy: '王开发', startedAt: '2025-04-14 09:00:00', duration: 245 }, - { id: 'exec-003', pipelineId: 'pipe-002', pipelineName: 'order-service-pipeline', status: 'running', branch: 'main', commitId: 'i7j8k9l', triggeredBy: '李运维', startedAt: '2025-04-14 11:00:00', duration: 0 } -]; - -// ============ 发布数据 ============ -export const appReleases: AppRelease[] = [ - { - id: 'release-001', - appName: '用户中心服务', - version: 'v2.5.1', - environment: 'prod', - status: 'success', - pipeline: 'user-service-pipeline', - commitId: 'a1b2c3d', - branch: 'main', - deployer: 'user-002', - startedAt: '2025-03-30T06:00:00Z', - completedAt: '2025-03-30T06:15:00Z', - duration: 900, - }, - { - id: 'release-002', - appName: '订单服务', - version: 'v3.2.0', - environment: 'staging', - status: 'deploying', - pipeline: 'order-service-pipeline', - commitId: 'e4f5g6h', - branch: 'release/v3.2.0', - deployer: 'user-002', - startedAt: '2025-03-30T10:00:00Z', - }, - { - id: 'release-003', - appName: '支付网关', - version: 'v1.8.5', - environment: 'prod', - status: 'failed', - pipeline: 'payment-gateway-pipeline', - commitId: 'i7j8k9l', - branch: 'hotfix/payment-bug', - deployer: 'user-003', - startedAt: '2025-03-29T20:00:00Z', - completedAt: '2025-03-29T20:05:00Z', - duration: 300, - }, - { - id: 'release-004', - appName: '消息推送服务', - version: 'v2.1.0', - environment: 'prod', - status: 'rolled_back', - pipeline: 'notification-service-pipeline', - commitId: 'm0n1o2p', - branch: 'main', - deployer: 'user-002', - startedAt: '2025-03-28T14:00:00Z', - completedAt: '2025-03-28T14:30:00Z', - duration: 1800, - }, - { - id: 'release-005', - appName: '数据分析平台', - version: 'v4.0.0-beta', - environment: 'test', - status: 'building', - pipeline: 'analytics-platform-pipeline', - commitId: 'q3r4s5t', - branch: 'feature/new-dashboard', - deployer: 'user-004', - startedAt: '2025-03-30T09:30:00Z', - }, -]; - -// 用户数据 -export const releases = [ - { id: 'rel-001', appName: '用户中心服务', version: 'v2.5.1', environment: 'prod', status: 'success', pipeline: 'user-service-pipeline', commitId: 'a1b2c3d', branch: 'main', deployer: '张工程师', startedAt: '2025-04-14 06:00:00', completedAt: '2025-04-14 06:15:00', duration: 900 }, - { id: 'rel-002', appName: '订单服务', version: 'v3.2.0', environment: 'staging', status: 'deploying', pipeline: 'order-service-pipeline', commitId: 'e4f5g6h', branch: 'release/v3.2.0', deployer: '李运维', startedAt: '2025-04-14 10:00:00' }, - { id: 'rel-003', appName: '支付网关', version: 'v1.8.5', environment: 'prod', status: 'failed', pipeline: 'payment-gateway-pipeline', commitId: 'i7j8k9l', branch: 'hotfix/payment-bug', deployer: '张工程师', startedAt: '2025-04-13 20:00:00', completedAt: '2025-04-13 20:05:00', duration: 300 } -]; - -// ============ 定时任务数据 ============ diff --git a/frontend/src/mocks/modules/cloud.ts b/frontend/src/mocks/modules/cloud.ts deleted file mode 100644 index 9fc0a8d..0000000 --- a/frontend/src/mocks/modules/cloud.ts +++ /dev/null @@ -1,330 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const cloudAccounts = [ - { - id: 'acc-001', - name: 'AWS生产账号', - provider: 'aws', - accessKey: 'AKIAIOSFODNN7EXAMPLE', - status: 'active' as const, - regionCount: 4, - serverCount: 56, - createdAt: '2024-01-10T08:00:00Z', - lastSync: '2025-03-30T10:00:00Z', - }, - { - id: 'acc-002', - name: '阿里云主账号', - provider: 'aliyun', - accessKey: 'LTAI5t8Z3y8Y7Z7Z7Z7Z7Z7Z', - status: 'active' as const, - regionCount: 3, - serverCount: 42, - createdAt: '2024-02-15T09:00:00Z', - lastSync: '2025-03-30T09:30:00Z', - }, - { - id: 'acc-003', - name: '腾讯云账号', - provider: 'tencent', - accessKey: 'AKIDz8krbsJ5yKBZQpn74WFkmLPx3EXAMPLE', - status: 'active' as const, - regionCount: 2, - serverCount: 28, - createdAt: '2024-03-01T10:00:00Z', - lastSync: '2025-03-30T09:45:00Z', - }, - { - id: 'acc-004', - name: '华为云测试账号', - provider: 'huawei', - accessKey: 'QK9Y7Y7Y7Y7Y7Y7Y7Y7Y', - status: 'error' as const, - regionCount: 1, - serverCount: 5, - createdAt: '2024-06-20T11:00:00Z', - lastSync: '2025-03-29T08:00:00Z', - }, - { - id: 'acc-005', - name: 'Azure国际版', - provider: 'azure', - accessKey: '7e8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e', - status: 'inactive' as const, - regionCount: 2, - serverCount: 12, - createdAt: '2024-08-10T12:00:00Z', - lastSync: '2025-03-15T10:00:00Z', - }, -]; - -// ==================== 域名数据 ==================== - -export const domains = [ - { - id: 'domain-001', - name: 'example.com', - registrar: '阿里云', - status: 'active' as const, - expireDate: '2026-05-15', - dnsProvider: '阿里云DNS', - recordCount: 12, - sslEnabled: true, - sslExpireDate: '2025-09-15', - }, - { - id: 'domain-002', - name: 'myapp.io', - registrar: 'GoDaddy', - status: 'active' as const, - expireDate: '2025-12-20', - dnsProvider: 'Cloudflare', - recordCount: 8, - sslEnabled: true, - sslExpireDate: '2025-11-20', - }, - { - id: 'domain-003', - name: 'test-site.cn', - registrar: '腾讯云', - status: 'active' as const, - expireDate: '2025-08-30', - dnsProvider: 'DNSPod', - recordCount: 5, - sslEnabled: false, - }, - { - id: 'domain-004', - name: 'old-project.com', - registrar: 'Namecheap', - status: 'expired' as const, - expireDate: '2025-01-10', - dnsProvider: 'Cloudflare', - recordCount: 3, - sslEnabled: false, - }, - { - id: 'domain-005', - name: 'new-service.dev', - registrar: 'AWS Route53', - status: 'pending' as const, - expireDate: '2026-03-25', - dnsProvider: 'Route53', - recordCount: 2, - sslEnabled: true, - sslExpireDate: '2025-10-25', - }, -]; - -// ==================== 区域数据 ==================== - -export const regions = [ - { - id: 'region-001', - name: '华北-北京', - code: 'cn-north-1', - provider: 'aliyun', - location: '中国北京', - status: 'active' as const, - serverCount: 45, - vpcCount: 8, - endpoint: 'ecs.cn-north-1.aliyuncs.com', - }, - { - id: 'region-002', - name: '华东-上海', - code: 'cn-shanghai', - provider: 'aliyun', - location: '中国上海', - status: 'active' as const, - serverCount: 32, - vpcCount: 5, - endpoint: 'ecs.cn-shanghai.aliyuncs.com', - }, - { - id: 'region-003', - name: '美国东部-弗吉尼亚', - code: 'us-east-1', - provider: 'aws', - location: '美国弗吉尼亚', - status: 'active' as const, - serverCount: 28, - vpcCount: 6, - endpoint: 'ec2.us-east-1.amazonaws.com', - }, - { - id: 'region-004', - name: '亚太地区-新加坡', - code: 'ap-southeast-1', - provider: 'aws', - location: '新加坡', - status: 'active' as const, - serverCount: 18, - vpcCount: 3, - endpoint: 'ec2.ap-southeast-1.amazonaws.com', - }, - { - id: 'region-005', - name: '华南-广州', - code: 'ap-guangzhou', - provider: 'tencent', - location: '中国广州', - status: 'active' as const, - serverCount: 22, - vpcCount: 4, - endpoint: 'cvm.tencentcloudapi.com', - }, - { - id: 'region-006', - name: '华东-南京', - code: 'cn-east-2', - provider: 'huawei', - location: '中国南京', - status: 'inactive' as const, - serverCount: 5, - vpcCount: 1, - endpoint: 'ecs.cn-east-2.myhuaweicloud.com', - }, -]; - -// ==================== 云平台数据 ==================== - -export const platforms = [ - { - id: 'platform-001', - name: '阿里云', - code: 'aliyun', - type: 'public' as const, - status: 'active' as const, - accountCount: 2, - regionCount: 8, - serverCount: 87, - website: 'https://www.aliyun.com', - description: '阿里巴巴集团旗下的云计算服务平台', - }, - { - id: 'platform-002', - name: 'AWS', - code: 'aws', - type: 'public' as const, - status: 'active' as const, - accountCount: 1, - regionCount: 25, - serverCount: 56, - website: 'https://aws.amazon.com', - description: 'Amazon Web Services,全球领先的云服务平台', - }, - { - id: 'platform-003', - name: '腾讯云', - code: 'tencent', - type: 'public' as const, - status: 'active' as const, - accountCount: 1, - regionCount: 6, - serverCount: 28, - website: 'https://cloud.tencent.com', - description: '腾讯公司旗下的云计算服务平台', - }, - { - id: 'platform-004', - name: '华为云', - code: 'huawei', - type: 'public' as const, - status: 'active' as const, - accountCount: 1, - regionCount: 5, - serverCount: 15, - website: 'https://www.huaweicloud.com', - description: '华为公司旗下的云计算服务平台', - }, - { - id: 'platform-005', - name: '私有云-OpenStack', - code: 'private-openstack', - type: 'private' as const, - status: 'active' as const, - accountCount: 1, - regionCount: 1, - serverCount: 32, - website: 'https://www.openstack.org', - description: '自建OpenStack私有云平台', - }, -]; - -// ==================== 云平台/账号/区域/域名数据 ==================== - -export const cloudProvidersList = [ - { id: 'aliyun', name: '阿里云', icon: 'aliyun', regions: ['cn-beijing', 'cn-shanghai'] }, - { id: 'tencent', name: '腾讯云', icon: 'tencent', regions: ['ap-beijing', 'ap-shanghai'] }, - { id: 'aws', name: 'AWS', icon: 'aws', regions: ['us-east-1', 'us-west-2'] }, - { id: 'huawei', name: '华为云', icon: 'huawei', regions: ['cn-north-1', 'cn-east-2'] } -]; - -export const cloudAccountsList = [ - { id: 'acc-001', provider: 'aliyun', name: '生产账号', accountId: '123456789', status: 'active' }, - { id: 'acc-002', provider: 'aliyun', name: '测试账号', accountId: '987654321', status: 'active' }, - { id: 'acc-003', provider: 'tencent', name: '主账号', accountId: 'Tencent-001', status: 'active' }, - { id: 'acc-004', provider: 'aws', name: 'Global账号', accountId: 'aws-123456', status: 'inactive' } -]; - -export const cloudRegionsList = [ - { id: 'cn-beijing', name: '华北2(北京)', provider: 'aliyun', vpcCount: 5, instanceCount: 45 }, - { id: 'cn-shanghai', name: '华东2(上海)', provider: 'aliyun', vpcCount: 3, instanceCount: 32 }, - { id: 'ap-beijing', name: '北京', provider: 'tencent', vpcCount: 4, instanceCount: 28 }, - { id: 'ap-shanghai', name: '上海', provider: 'tencent', vpcCount: 2, instanceCount: 15 } -]; - -export const domainsList = [ - { id: 'domain-001', name: 'company.com', registrar: 'aliyun', expiryDate: '2026-03-15', status: 'active' }, - { id: 'domain-002', name: 'company.cn', registrar: 'tencent', expiryDate: '2026-06-20', status: 'active' }, - { id: 'domain-003', name: 'company-api.com', registrar: 'aws', expiryDate: '2025-12-01', status: 'active' } -]; - -// ============ 审批数据 ============ -export const costStats = { - total: 125000, - byProvider: [ - { name: '阿里云', value: 65000 }, { name: '腾讯云', value: 35000 }, - { name: 'AWS', value: 20000 }, { name: '华为云', value: 5000 } - ], - trend: [ - { month: '2025-01', value: 110000 }, { month: '2025-02', value: 115000 }, - { month: '2025-03', value: 120000 }, { month: '2025-04', value: 125000 } - ] -}; - -export const certExpiry = [ - { domain: 'api.company.com', expiryDate: '2025-05-15', daysLeft: 31 }, - { domain: 'app.company.com', expiryDate: '2025-06-01', daysLeft: 48 }, - { domain: 'admin.company.com', expiryDate: '2025-04-20', daysLeft: 6 }, - { domain: '*.company.com', expiryDate: '2025-07-15', daysLeft: 92 } -]; - diff --git a/frontend/src/mocks/modules/dashboard.ts b/frontend/src/mocks/modules/dashboard.ts deleted file mode 100644 index 5745604..0000000 --- a/frontend/src/mocks/modules/dashboard.ts +++ /dev/null @@ -1,98 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const dashboardData: DashboardData = { - serverCount: 156, - runningServers: 142, - alertCount: 23, - criticalAlerts: 5, - k8sClusters: 8, - healthyClusters: 7, - pendingTickets: 18, - todayReleases: 12, - cpuUsage: 67.5, - memoryUsage: 78.2, - diskUsage: 45.8, - networkUsage: 34.6, -}; - -// 服务器资产数据 -export const dashboardStats = { - serverCount: 156, runningServers: 142, alertCount: 23, criticalAlerts: 5, - k8sClusters: 8, healthyClusters: 7, pendingTickets: 18, todayReleases: 12, - cpuUsage: 67.5, memoryUsage: 78.2, diskUsage: 45.8, networkUsage: 34.6 -}; - -export const topCPU = [ - { name: 'app-server-01', value: 95.2 }, { name: 'k8s-worker-02', value: 89.5 }, - { name: 'app-server-02', value: 82.1 }, { name: 'db-server-01', value: 78.6 }, - { name: 'k8s-worker-01', value: 75.3 } -]; - -export const topMemory = [ - { name: 'db-server-01', value: 92.5 }, { name: 'k8s-worker-02', value: 88.2 }, - { name: 'app-server-02', value: 85.6 }, { name: 'app-server-01', value: 81.3 }, - { name: 'k8s-worker-01', value: 78.9 } -]; - -export const topDisk = [ - { name: 'db-server-01', value: 94.8 }, { name: 'log-server-01', value: 87.5 }, - { name: 'backup-server-01', value: 82.3 }, { name: 'app-server-01', value: 68.5 }, - { name: 'app-server-02', value: 62.1 } -]; - -export const metricData: MetricData[] = [ - { timestamp: 1711800000, metric: 'cpu_usage', value: 45.2, labels: { host: 'web-server-01' } }, - { timestamp: 1711800060, metric: 'cpu_usage', value: 48.5, labels: { host: 'web-server-01' } }, - { timestamp: 1711800120, metric: 'cpu_usage', value: 52.1, labels: { host: 'web-server-01' } }, - { timestamp: 1711800180, metric: 'cpu_usage', value: 49.8, labels: { host: 'web-server-01' } }, - { timestamp: 1711800240, metric: 'cpu_usage', value: 46.3, labels: { host: 'web-server-01' } }, - { timestamp: 1711800300, metric: 'cpu_usage', value: 44.7, labels: { host: 'web-server-01' } }, -]; - -// ==================== 日志数据 ==================== - -export function generateMetricsData(points: number = 24): { time: string; cpu: number; memory: number; disk: number; network: number }[] { - const data = []; - const now = new Date(); - for (let i = points - 1; i >= 0; i--) { - const time = new Date(now.getTime() - i * 60 * 60 * 1000); - data.push({ - time: time.getHours().toString().padStart(2, '0') + ':00', - cpu: 40 + Math.random() * 40, - memory: 50 + Math.random() * 30, - disk: 45 + Math.random() * 10, - network: 20 + Math.random() * 50, - }); - } - return data; -} - -// ==================== 云账号数据 ==================== - diff --git a/frontend/src/mocks/modules/k8s.ts b/frontend/src/mocks/modules/k8s.ts deleted file mode 100644 index 93d3ef5..0000000 --- a/frontend/src/mocks/modules/k8s.ts +++ /dev/null @@ -1,471 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const k8sClusters: K8sCluster[] = [ - { - id: 'k8s-001', - name: 'production-cluster', - version: 'v1.28.5', - nodes: 12, - pods: 156, - services: 45, - deployments: 78, - status: 'healthy', - cpuUsage: 68.5, - memoryUsage: 75.2, - createdAt: '2024-01-20T08:00:00Z', - namespace: 'default', - }, - { - id: 'k8s-002', - name: 'staging-cluster', - version: 'v1.28.5', - nodes: 6, - pods: 89, - services: 28, - deployments: 42, - status: 'healthy', - cpuUsage: 45.3, - memoryUsage: 52.8, - createdAt: '2024-02-15T09:00:00Z', - namespace: 'default', - }, - { - id: 'k8s-003', - name: 'development-cluster', - version: 'v1.27.8', - nodes: 4, - pods: 56, - services: 18, - deployments: 25, - status: 'healthy', - cpuUsage: 32.1, - memoryUsage: 38.5, - createdAt: '2024-03-01T10:00:00Z', - namespace: 'default', - }, - { - id: 'k8s-004', - name: 'test-cluster', - version: 'v1.27.8', - nodes: 3, - pods: 34, - services: 12, - deployments: 15, - status: 'warning', - cpuUsage: 85.6, - memoryUsage: 92.3, - createdAt: '2024-04-10T11:00:00Z', - namespace: 'default', - }, - { - id: 'k8s-005', - name: 'ai-training-cluster', - version: 'v1.29.0', - nodes: 8, - pods: 67, - services: 15, - deployments: 32, - status: 'healthy', - cpuUsage: 78.9, - memoryUsage: 88.5, - createdAt: '2024-05-20T12:00:00Z', - namespace: 'default', - }, -]; - -// K8s节点数据 -export const k8sNodes: K8sNode[] = [ - { - id: 'node-001', - name: 'k8s-master-01', - clusterId: 'k8s-001', - role: 'master', - status: 'ready', - cpu: 16, - memory: 64, - cpuUsage: 25.6, - memoryUsage: 42.3, - pods: 25, - os: 'CentOS Linux 7 (Core)', - kernel: '5.4.210-1.el7.elrepo.x86_64', - createdAt: '2024-01-20T08:00:00Z', - }, - { - id: 'node-002', - name: 'k8s-worker-01', - clusterId: 'k8s-001', - role: 'worker', - status: 'ready', - cpu: 32, - memory: 128, - cpuUsage: 68.4, - memoryUsage: 82.1, - pods: 35, - os: 'CentOS Linux 7 (Core)', - kernel: '5.4.210-1.el7.elrepo.x86_64', - createdAt: '2024-01-20T08:30:00Z', - }, - { - id: 'node-003', - name: 'k8s-worker-02', - clusterId: 'k8s-001', - role: 'worker', - status: 'ready', - cpu: 32, - memory: 128, - cpuUsage: 72.5, - memoryUsage: 78.9, - pods: 38, - os: 'CentOS Linux 7 (Core)', - kernel: '5.4.210-1.el7.elrepo.x86_64', - createdAt: '2024-01-20T08:35:00Z', - }, - { - id: 'node-004', - name: 'k8s-worker-03', - clusterId: 'k8s-001', - role: 'worker', - status: 'ready', - cpu: 32, - memory: 128, - cpuUsage: 65.2, - memoryUsage: 71.5, - pods: 32, - os: 'CentOS Linux 7 (Core)', - kernel: '5.4.210-1.el7.elrepo.x86_64', - createdAt: '2024-01-20T08:40:00Z', - }, - { - id: 'node-005', - name: 'k8s-master-01', - clusterId: 'k8s-002', - role: 'master', - status: 'ready', - cpu: 8, - memory: 32, - cpuUsage: 18.5, - memoryUsage: 35.2, - pods: 15, - os: 'Ubuntu 22.04.3 LTS', - kernel: '5.15.0-88-generic', - createdAt: '2024-02-15T09:00:00Z', - }, -]; - -// K8s Pod数据 -export const k8sPods: K8sPod[] = [ - { - id: 'pod-001', - name: 'nginx-deployment-7c4c8b8f5-x2k9m', - namespace: 'default', - clusterId: 'k8s-001', - status: 'running', - restarts: 0, - cpu: '500m', - memory: '512Mi', - node: 'k8s-worker-01', - createdAt: '2025-03-30T08:00:00Z', - labels: { app: 'nginx', 'pod-template-hash': '7c4c8b8f5' }, - }, - { - id: 'pod-002', - name: 'nginx-deployment-7c4c8b8f5-a3b7c', - namespace: 'default', - clusterId: 'k8s-001', - status: 'running', - restarts: 0, - cpu: '500m', - memory: '512Mi', - node: 'k8s-worker-02', - createdAt: '2025-03-30T08:00:00Z', - labels: { app: 'nginx', 'pod-template-hash': '7c4c8b8f5' }, - }, - { - id: 'pod-003', - name: 'redis-master-0', - namespace: 'default', - clusterId: 'k8s-001', - status: 'running', - restarts: 1, - cpu: '1000m', - memory: '2Gi', - node: 'k8s-worker-01', - createdAt: '2025-03-29T10:00:00Z', - labels: { app: 'redis', 'statefulset.kubernetes.io/pod-name': 'redis-master-0' }, - }, - { - id: 'pod-004', - name: 'mysql-0', - namespace: 'database', - clusterId: 'k8s-001', - status: 'running', - restarts: 0, - cpu: '2000m', - memory: '4Gi', - node: 'k8s-worker-03', - createdAt: '2025-03-28T14:00:00Z', - labels: { app: 'mysql', 'statefulset.kubernetes.io/pod-name': 'mysql-0' }, - }, - { - id: 'pod-005', - name: 'app-backend-5d8f7c6b4f-x9k2m', - namespace: 'production', - clusterId: 'k8s-001', - status: 'pending', - restarts: 0, - cpu: '1000m', - memory: '2Gi', - node: 'Pending', - createdAt: '2025-03-30T09:30:00Z', - labels: { app: 'backend', 'pod-template-hash': '5d8f7c6b4f' }, - }, -]; - -// K8s Deployment数据 -export const k8sDeployments = [ - { - id: 'deploy-001', - name: 'nginx-deployment', - namespace: 'default', - clusterId: 'k8s-001', - replicas: 3, - availableReplicas: 3, - image: 'nginx:1.25.3', - createdAt: '2025-03-28T10:00:00Z', - }, - { - id: 'deploy-002', - name: 'app-backend', - namespace: 'production', - clusterId: 'k8s-001', - replicas: 5, - availableReplicas: 4, - image: 'myapp/backend:v2.3.1', - createdAt: '2025-03-29T14:00:00Z', - }, - { - id: 'deploy-003', - name: 'app-frontend', - namespace: 'production', - clusterId: 'k8s-001', - replicas: 2, - availableReplicas: 2, - image: 'myapp/frontend:v1.8.0', - createdAt: '2025-03-25T09:00:00Z', - }, - { - id: 'deploy-004', - name: 'redis-master', - namespace: 'default', - clusterId: 'k8s-001', - replicas: 1, - availableReplicas: 1, - image: 'redis:7.0.12', - createdAt: '2025-03-20T08:00:00Z', - }, - { - id: 'deploy-005', - name: 'api-gateway', - namespace: 'infrastructure', - clusterId: 'k8s-001', - replicas: 2, - availableReplicas: 2, - image: 'kong:3.4.0', - createdAt: '2025-03-15T10:00:00Z', - }, -]; - -// K8s Service数据 -export const k8sServices = [ - { - id: 'svc-001', - name: 'nginx-service', - namespace: 'default', - clusterId: 'k8s-001', - type: 'ClusterIP', - clusterIP: '10.96.123.45', - ports: '80:8080/TCP', - selector: 'app=nginx', - }, - { - id: 'svc-002', - name: 'backend-service', - namespace: 'production', - clusterId: 'k8s-001', - type: 'ClusterIP', - clusterIP: '10.96.234.56', - ports: '8080:8080/TCP', - selector: 'app=backend', - }, - { - id: 'svc-003', - name: 'frontend-service', - namespace: 'production', - clusterId: 'k8s-001', - type: 'NodePort', - clusterIP: '10.96.345.67', - ports: '80:30080/TCP', - selector: 'app=frontend', - }, - { - id: 'svc-004', - name: 'redis-service', - namespace: 'default', - clusterId: 'k8s-001', - type: 'ClusterIP', - clusterIP: '10.96.456.78', - ports: '6379:6379/TCP', - selector: 'app=redis', - }, - { - id: 'svc-005', - name: 'mysql-service', - namespace: 'database', - clusterId: 'k8s-001', - type: 'ClusterIP', - clusterIP: '10.96.567.89', - ports: '3306:3306/TCP', - selector: 'app=mysql', - }, - { - id: 'svc-006', - name: 'api-gateway', - namespace: 'infrastructure', - clusterId: 'k8s-001', - type: 'LoadBalancer', - clusterIP: '10.96.678.90', - ports: '80:80/TCP,443:443/TCP', - selector: 'app=api-gateway', - }, -]; - -// K8s Ingress数据 -export const k8sIngresses = [ - { - id: 'ing-001', - name: 'app-ingress', - namespace: 'production', - clusterId: 'k8s-001', - hosts: 'app.company.com', - backend: 'frontend-service:80', - tls: true, - }, - { - id: 'ing-002', - name: 'api-ingress', - namespace: 'production', - clusterId: 'k8s-001', - hosts: 'api.company.com', - backend: 'backend-service:8080', - tls: true, - }, - { - id: 'ing-003', - name: 'grafana-ingress', - namespace: 'monitoring', - clusterId: 'k8s-001', - hosts: 'grafana.company.com', - backend: 'grafana-service:3000', - tls: true, - }, - { - id: 'ing-004', - name: 'kibana-ingress', - namespace: 'logging', - clusterId: 'k8s-001', - hosts: 'kibana.company.com', - backend: 'kibana-service:5601', - tls: false, - }, -]; - -// 告警规则数据 -export const topologyNodes: TopologyNode[] = [ - { - id: 'node-001', - name: '负载均衡', - type: 'loadbalancer', - x: 400, - y: 50, - data: { ip: '192.168.1.1', vendor: 'F5' }, - }, - { - id: 'node-002', - name: 'Web集群', - type: 'cluster', - x: 200, - y: 150, - data: { instanceCount: 3 }, - }, - { - id: 'node-003', - name: 'App集群', - type: 'cluster', - x: 600, - y: 150, - data: { instanceCount: 3 }, - }, - { - id: 'node-004', - name: '数据库主库', - type: 'database', - x: 400, - y: 300, - data: { type: 'MySQL', role: 'master' }, - }, - { - id: 'node-005', - name: '数据库从库', - type: 'database', - x: 600, - y: 300, - data: { type: 'MySQL', role: 'slave' }, - }, - { - id: 'node-006', - name: 'Redis缓存', - type: 'cache', - x: 200, - y: 300, - data: { type: 'Redis', mode: 'cluster' }, - }, -]; - -export const topologyEdges: TopologyEdge[] = [ - { id: 'edge-001', source: 'node-001', target: 'node-002', label: 'HTTP' }, - { id: 'edge-002', source: 'node-001', target: 'node-003', label: 'HTTP' }, - { id: 'edge-003', source: 'node-002', target: 'node-003', label: 'RPC' }, - { id: 'edge-004', source: 'node-002', target: 'node-006', label: 'Redis' }, - { id: 'edge-005', source: 'node-003', target: 'node-004', label: 'SQL' }, - { id: 'edge-006', source: 'node-004', target: 'node-005', label: 'Replication' }, -]; - -// ==================== 监控指标数据 ==================== - diff --git a/frontend/src/mocks/modules/misc.ts b/frontend/src/mocks/modules/misc.ts deleted file mode 100644 index 1f0967d..0000000 --- a/frontend/src/mocks/modules/misc.ts +++ /dev/null @@ -1,137 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const resourceModels: ResourceModel[] = [ - { - id: 'model-001', - name: '服务器', - code: 'server', - description: '物理服务器和虚拟机', - type: 'normal', - attributes: [ - { id: 'attr-001', name: '主机名', code: 'hostname', type: 'string', required: true, unique: true }, - { id: 'attr-002', name: 'IP地址', code: 'ip', type: 'string', required: true, unique: true }, - { id: 'attr-003', name: '操作系统', code: 'os', type: 'string', required: false }, - { id: 'attr-004', name: 'CPU核数', code: 'cpu', type: 'number', required: false }, - { id: 'attr-005', name: '内存大小', code: 'memory', type: 'number', required: false }, - { id: 'attr-006', name: '磁盘容量', code: 'disk', type: 'number', required: false }, - ], - instanceCount: 156, - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'model-002', - name: '网络设备', - code: 'network_device', - description: '交换机、路由器等网络设备', - type: 'normal', - attributes: [ - { id: 'attr-007', name: '设备名称', code: 'name', type: 'string', required: true, unique: true }, - { id: 'attr-008', name: '管理IP', code: 'mgmt_ip', type: 'string', required: true }, - { id: 'attr-009', name: '设备类型', code: 'device_type', type: 'enum', required: true }, - { id: 'attr-010', name: '厂商', code: 'vendor', type: 'string', required: false }, - { id: 'attr-011', name: '型号', code: 'model', type: 'string', required: false }, - ], - instanceCount: 48, - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'model-003', - name: '硬件设备', - code: 'hardware', - description: '所有硬件设备的父模型', - type: 'parent', - attributes: [ - { id: 'attr-012', name: '资产编号', code: 'asset_no', type: 'string', required: true, unique: true }, - { id: 'attr-013', name: '序列号', code: 'sn', type: 'string', required: false }, - { id: 'attr-014', name: '厂商', code: 'vendor', type: 'string', required: false }, - { id: 'attr-015', name: '购买日期', code: 'purchase_date', type: 'date', required: false }, - { id: 'attr-016', name: '保修期', code: 'warranty', type: 'number', required: false }, - ], - instanceCount: 0, - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'model-004', - name: '应用系统', - code: 'application', - description: '业务应用系统', - type: 'normal', - attributes: [ - { id: 'attr-017', name: '应用名称', code: 'name', type: 'string', required: true, unique: true }, - { id: 'attr-018', name: '应用代码', code: 'code', type: 'string', required: true, unique: true }, - { id: 'attr-019', name: '负责人', code: 'owner', type: 'string', required: true }, - { id: 'attr-020', name: '所属部门', code: 'department', type: 'string', required: false }, - ], - instanceCount: 32, - createdAt: '2024-01-01T00:00:00Z', - }, -]; - -// 模型实例数据 -export const modelInstances: ModelInstance[] = [ - { - id: 'inst-001', - modelId: 'model-001', - name: 'web-server-01', - data: { - hostname: 'web-server-01', - ip: '192.168.1.101', - os: 'CentOS 7.9', - cpu: 16, - memory: 64, - disk: 500, - }, - relations: [ - { targetModelId: 'model-004', targetInstanceId: 'inst-101', relationType: 'runs' }, - ], - createdAt: '2024-01-15T08:30:00Z', - updatedAt: '2025-03-30T10:25:00Z', - }, - { - id: 'inst-002', - modelId: 'model-001', - name: 'db-server-01', - data: { - hostname: 'db-server-01', - ip: '192.168.1.105', - os: 'CentOS 8.5', - cpu: 64, - memory: 256, - disk: 2000, - }, - relations: [], - createdAt: '2024-01-10T07:00:00Z', - updatedAt: '2025-03-30T10:25:00Z', - }, -]; - -// ============ Ansible数据 ============ -// mockData aggregate moved to data.ts barrel (references cross-module exports) - diff --git a/frontend/src/mocks/modules/monitor.ts b/frontend/src/mocks/modules/monitor.ts deleted file mode 100644 index 91141d7..0000000 --- a/frontend/src/mocks/modules/monitor.ts +++ /dev/null @@ -1,162 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const logEntries: LogEntry[] = [ - { - id: 'log-001', - timestamp: '2025-03-30T10:25:00Z', - level: 'INFO', - source: 'nginx', - message: '192.168.1.100 - - [30/Mar/2025:10:25:00 +0800] "GET /api/users HTTP/1.1" 200 1234', - host: 'web-server-01', - }, - { - id: 'log-002', - timestamp: '2025-03-30T10:24:55Z', - level: 'WARN', - source: 'app', - message: 'Database connection pool reaching limit: 45/50', - host: 'app-server-01', - }, - { - id: 'log-003', - timestamp: '2025-03-30T10:24:50Z', - level: 'ERROR', - source: 'mysql', - message: 'Connection timeout after 30000ms', - host: 'db-server-01', - }, - { - id: 'log-004', - timestamp: '2025-03-30T10:24:45Z', - level: 'INFO', - source: 'k8s', - message: 'Pod nginx-deployment-xxx created successfully', - host: 'k8s-master-01', - }, - { - id: 'log-005', - timestamp: '2025-03-30T10:24:40Z', - level: 'DEBUG', - source: 'cache', - message: 'Cache hit ratio: 0.85', - host: 'cache-server-01', - }, -]; - -// 生成监控数据 -export const logMonitorEntries = [ - { id: 'log-001', timestamp: '2025-04-14 10:30:15.234', level: 'error', service: 'order-service', host: 'app-server-01', message: 'Database connection timeout', traceId: 'trace-abc123', metadata: { error_code: 'DB_TIMEOUT' }, raw: 'ERROR [order-service] Database connection timeout' }, - { id: 'log-002', timestamp: '2025-04-14 10:30:14.123', level: 'info', service: 'user-service', host: 'app-server-01', message: 'User login successful', traceId: 'trace-ghi789', metadata: { user_id: '12345' }, raw: 'INFO [user-service] User login successful' }, - { id: 'log-003', timestamp: '2025-04-14 10:30:12.456', level: 'warn', service: 'payment-service', host: 'app-server-02', message: 'Payment processing slow', traceId: 'trace-mno345', metadata: { duration_ms: 2500 }, raw: 'WARN [payment-service] Payment processing slow' }, - { id: 'log-004', timestamp: '2025-04-14 10:30:10.789', level: 'debug', service: 'inventory-service', host: 'app-server-01', message: 'Cache hit', metadata: {}, raw: 'DEBUG [inventory-service] Cache hit' }, - { id: 'log-005', timestamp: '2025-04-14 10:30:08.321', level: 'fatal', service: 'notification-service', host: 'app-server-02', message: 'OutOfMemoryError', traceId: 'trace-stu901', metadata: {}, raw: 'FATAL [notification-service] OutOfMemoryError' } -]; - -export const logSources = [ - { id: 'src-001', name: '应用日志', type: 'application', status: 'connected', lastSeen: '2025-04-14 10:30:00', logCount: 1523456 }, - { id: 'src-002', name: '系统日志', type: 'syslog', status: 'connected', lastSeen: '2025-04-14 10:30:00', logCount: 892345 }, - { id: 'src-003', name: 'Docker容器日志', type: 'docker', status: 'connected', lastSeen: '2025-04-14 10:29:55', logCount: 567890 }, - { id: 'src-004', name: 'Kubernetes日志', type: 'kubernetes', status: 'connected', lastSeen: '2025-04-14 10:30:00', logCount: 1234567 }, - { id: 'src-005', name: 'Nginx访问日志', type: 'file', status: 'error', lastSeen: '2025-04-14 09:00:00', logCount: 2345678 } -]; - -// ============ 告警中心数据 ============ -export const traces = [ - { id: 'trace-001', traceId: 'abc123def456ghi789', serviceName: 'api-gateway', operationName: 'POST /api/orders', startTime: '2025-04-14 10:30:15.234', duration: 1250, status: 'success', spanCount: 12, tags: { http_method: 'POST' } }, - { id: 'trace-002', traceId: 'jkl012mno345pqr678', serviceName: 'user-service', operationName: 'GET /api/users/profile', startTime: '2025-04-14 10:30:14.123', duration: 45, status: 'success', spanCount: 5, tags: {} }, - { id: 'trace-003', traceId: 'stu901vwx234yza567', serviceName: 'payment-service', operationName: 'POST /api/payments', startTime: '2025-04-14 10:30:12.456', duration: 2500, status: 'error', spanCount: 8, tags: { error: 'timeout' } }, - { id: 'trace-004', traceId: 'bcd234efg567hij890', serviceName: 'inventory-service', operationName: 'GET /api/inventory/check', startTime: '2025-04-14 10:30:10.789', duration: 15, status: 'success', spanCount: 3, tags: {} } -]; - -export const serviceMetrics = [ - { serviceName: 'api-gateway', requestCount: 152345, errorRate: 0.5, avgDuration: 45, p95Duration: 120, p99Duration: 250 }, - { serviceName: 'user-service', requestCount: 89345, errorRate: 0.2, avgDuration: 25, p95Duration: 60, p99Duration: 120 }, - { serviceName: 'order-service', requestCount: 67890, errorRate: 1.2, avgDuration: 150, p95Duration: 350, p99Duration: 800 }, - { serviceName: 'payment-service', requestCount: 45678, errorRate: 2.5, avgDuration: 200, p95Duration: 500, p99Duration: 1200 }, - { serviceName: 'inventory-service', requestCount: 123456, errorRate: 0.1, avgDuration: 15, p95Duration: 35, p99Duration: 80 }, - { serviceName: 'notification-service', requestCount: 34567, errorRate: 0.8, avgDuration: 80, p95Duration: 200, p99Duration: 450 } -]; - -export const traceSpans = [ - { id: 'span-001', spanId: 'span-abc123', serviceName: 'api-gateway', operationName: 'POST /api/orders', startTime: '2025-04-14 10:30:15.234', duration: 1250, status: 'success', kind: 'server', tags: {}, logs: [], children: [ - { id: 'span-002', spanId: 'span-def456', parentSpanId: 'span-abc123', serviceName: 'order-service', operationName: 'CreateOrder', startTime: '2025-04-14 10:30:15.250', duration: 800, status: 'success', kind: 'client', tags: {}, logs: [], children: [ - { id: 'span-003', spanId: 'span-ghi789', parentSpanId: 'span-def456', serviceName: 'order-service', operationName: 'INSERT orders', startTime: '2025-04-14 10:30:15.300', duration: 150, status: 'success', kind: 'internal', tags: {}, logs: [], children: [] } - ] }, - { id: 'span-004', spanId: 'span-jkl012', parentSpanId: 'span-abc123', serviceName: 'inventory-service', operationName: 'CheckInventory', startTime: '2025-04-14 10:30:15.280', duration: 50, status: 'success', kind: 'client', tags: {}, logs: [], children: [] } - ] } -]; - -// ============ Grafana大屏数据 ============ -export const grafanaDashboards = [ - { - id: 'dash-001', - name: '系统监控大盘', - description: '整体系统资源使用情况监控', - datasource: 'prometheus', - datasourceUrl: 'http://prometheus:9090', - panels: [ - { id: 'p-001', title: 'CPU使用率', type: 'gauge', query: 'avg(cpu_usage_percent)', datasource: 'prometheus', width: 3, height: 4, x: 0, y: 0, options: { unit: '%', min: 0, max: 100 } }, - { id: 'p-002', title: '内存使用率', type: 'gauge', query: 'avg(memory_usage_percent)', datasource: 'prometheus', width: 3, height: 4, x: 3, y: 0, options: { unit: '%', min: 0, max: 100 } }, - { id: 'p-003', title: '磁盘使用率', type: 'gauge', query: 'avg(disk_usage_percent)', datasource: 'prometheus', width: 3, height: 4, x: 6, y: 0, options: { unit: '%', min: 0, max: 100 } }, - { id: 'p-004', title: '网络流量', type: 'graph', query: 'rate(network_bytes_total[5m])', datasource: 'prometheus', width: 6, height: 6, x: 0, y: 4, options: { unit: 'B/s' } }, - { id: 'p-005', title: '请求QPS', type: 'stat', query: 'sum(rate(http_requests_total[1m]))', datasource: 'prometheus', width: 3, height: 4, x: 9, y: 0, options: { unit: 'req/s' } } - ], - createdAt: '2025-03-01', - updatedAt: '2025-04-10', - createdBy: '张工程师', - isDefault: true - }, - { - id: 'dash-002', - name: '应用性能监控', - description: '应用层性能指标监控', - datasource: 'skywalking', - datasourceUrl: 'http://skywalking-oap:12800', - panels: [ - { id: 'p-006', title: 'P99响应时间', type: 'graph', query: 'service_resp_time_p99', datasource: 'skywalking', width: 6, height: 6, x: 0, y: 0, options: { unit: 'ms' } }, - { id: 'p-007', title: '错误率', type: 'graph', query: 'service_sla', datasource: 'skywalking', width: 6, height: 6, x: 6, y: 0, options: { unit: '%' } }, - { id: 'p-008', title: '吞吐量', type: 'stat', query: 'service_cpm', datasource: 'skywalking', width: 4, height: 4, x: 0, y: 6, options: { unit: 'calls/min' } } - ], - createdAt: '2025-03-15', - updatedAt: '2025-04-05', - createdBy: '李运维', - isDefault: false - } -]; - -export const datasources = [ - { id: 'ds-001', name: 'Prometheus生产', type: 'prometheus', url: 'http://prometheus-prod:9090', status: 'connected' }, - { id: 'ds-002', name: 'Prometheus测试', type: 'prometheus', url: 'http://prometheus-test:9090', status: 'connected' }, - { id: 'ds-003', name: 'Zabbix监控', type: 'zabbix', url: 'http://zabbix-server/api_jsonrpc.php', status: 'connected' }, - { id: 'ds-004', name: 'SkyWalking APM', type: 'skywalking', url: 'http://skywalking-oap:12800', status: 'error' }, - { id: 'ds-005', name: 'InfluxDB时序', type: 'influxdb', url: 'http://influxdb:8086', status: 'connected' } -]; - -// ============ 流水线数据 ============ diff --git a/frontend/src/mocks/modules/servers.ts b/frontend/src/mocks/modules/servers.ts deleted file mode 100644 index 663d635..0000000 --- a/frontend/src/mocks/modules/servers.ts +++ /dev/null @@ -1,327 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const servers: Server[] = [ - { - id: 'srv-001', - hostname: 'web-server-01', - ip: '192.168.1.101', - os: 'CentOS 7.9', - cpu: 16, - memory: 64, - disk: 500, - status: 'running', - tags: ['web', 'production', 'frontend'], - region: '华北-北京', - createdAt: '2024-01-15T08:30:00Z', - lastSeen: '2025-03-30T10:25:00Z', - cpuUsage: 45.2, - memoryUsage: 62.8, - diskUsage: 38.5, - }, - { - id: 'srv-002', - hostname: 'web-server-02', - ip: '192.168.1.102', - os: 'CentOS 7.9', - cpu: 16, - memory: 64, - disk: 500, - status: 'running', - tags: ['web', 'production', 'frontend'], - region: '华北-北京', - createdAt: '2024-01-15T08:35:00Z', - lastSeen: '2025-03-30T10:25:00Z', - cpuUsage: 38.7, - memoryUsage: 55.3, - diskUsage: 42.1, - }, - { - id: 'srv-003', - hostname: 'app-server-01', - ip: '192.168.1.103', - os: 'Ubuntu 22.04 LTS', - cpu: 32, - memory: 128, - disk: 1000, - status: 'running', - tags: ['app', 'production', 'backend'], - region: '华东-上海', - createdAt: '2024-02-20T09:00:00Z', - lastSeen: '2025-03-30T10:24:00Z', - cpuUsage: 72.5, - memoryUsage: 85.6, - diskUsage: 67.8, - }, - { - id: 'srv-004', - hostname: 'app-server-02', - ip: '192.168.1.104', - os: 'Ubuntu 22.04 LTS', - cpu: 32, - memory: 128, - disk: 1000, - status: 'running', - tags: ['app', 'production', 'backend'], - region: '华东-上海', - createdAt: '2024-02-20T09:05:00Z', - lastSeen: '2025-03-30T10:24:00Z', - cpuUsage: 65.3, - memoryUsage: 78.9, - diskUsage: 58.2, - }, - { - id: 'srv-005', - hostname: 'db-server-01', - ip: '192.168.1.105', - os: 'CentOS 8.5', - cpu: 64, - memory: 256, - disk: 2000, - status: 'running', - tags: ['database', 'production', 'mysql'], - region: '华北-北京', - createdAt: '2024-01-10T07:00:00Z', - lastSeen: '2025-03-30T10:25:00Z', - cpuUsage: 58.9, - memoryUsage: 72.4, - diskUsage: 81.5, - }, - { - id: 'srv-006', - hostname: 'db-server-02', - ip: '192.168.1.106', - os: 'CentOS 8.5', - cpu: 64, - memory: 256, - disk: 2000, - status: 'maintenance', - tags: ['database', 'production', 'mysql', 'slave'], - region: '华北-北京', - createdAt: '2024-01-10T07:05:00Z', - lastSeen: '2025-03-30T09:30:00Z', - cpuUsage: 0, - memoryUsage: 0, - diskUsage: 76.3, - }, - { - id: 'srv-007', - hostname: 'cache-server-01', - ip: '192.168.1.107', - os: 'Ubuntu 20.04 LTS', - cpu: 16, - memory: 64, - disk: 200, - status: 'running', - tags: ['cache', 'production', 'redis'], - region: '华南-广州', - createdAt: '2024-03-01T10:00:00Z', - lastSeen: '2025-03-30T10:25:00Z', - cpuUsage: 32.1, - memoryUsage: 48.7, - diskUsage: 25.4, - }, - { - id: 'srv-008', - hostname: 'test-server-01', - ip: '192.168.2.101', - os: 'Ubuntu 22.04 LTS', - cpu: 8, - memory: 16, - disk: 200, - status: 'stopped', - tags: ['test', 'development'], - region: '华东-上海', - createdAt: '2024-06-15T14:00:00Z', - lastSeen: '2025-03-29T18:00:00Z', - cpuUsage: 0, - memoryUsage: 0, - diskUsage: 45.2, - }, - { - id: 'srv-009', - hostname: 'k8s-master-01', - ip: '192.168.1.201', - os: 'CentOS 7.9', - cpu: 16, - memory: 64, - disk: 500, - status: 'running', - tags: ['kubernetes', 'master', 'production'], - region: '华北-北京', - createdAt: '2024-01-20T08:00:00Z', - lastSeen: '2025-03-30T10:25:00Z', - cpuUsage: 25.6, - memoryUsage: 42.3, - diskUsage: 35.8, - }, - { - id: 'srv-010', - hostname: 'k8s-worker-01', - ip: '192.168.1.211', - os: 'CentOS 7.9', - cpu: 32, - memory: 128, - disk: 1000, - status: 'running', - tags: ['kubernetes', 'worker', 'production'], - region: '华北-北京', - createdAt: '2024-01-20T08:30:00Z', - lastSeen: '2025-03-30T10:25:00Z', - cpuUsage: 68.4, - memoryUsage: 82.1, - diskUsage: 58.9, - }, -]; - -// K8s集群数据 -export const cabinets: Cabinet[] = [ - { - id: 'cab-001', - name: 'A01-01', - room: '机房A', - row: 1, - column: 1, - totalU: 42, - usedU: 28, - status: 'active', - powerCapacity: 10, - powerUsed: 6.5, - }, - { - id: 'cab-002', - name: 'A01-02', - room: '机房A', - row: 1, - column: 2, - totalU: 42, - usedU: 35, - status: 'active', - powerCapacity: 10, - powerUsed: 8.2, - }, - { - id: 'cab-003', - name: 'A01-03', - room: '机房A', - row: 1, - column: 3, - totalU: 42, - usedU: 18, - status: 'active', - powerCapacity: 10, - powerUsed: 4.1, - }, - { - id: 'cab-004', - name: 'A02-01', - room: '机房A', - row: 2, - column: 1, - totalU: 42, - usedU: 0, - status: 'empty', - powerCapacity: 10, - powerUsed: 0, - }, - { - id: 'cab-005', - name: 'B01-01', - room: '机房B', - row: 1, - column: 1, - totalU: 42, - usedU: 40, - status: 'active', - powerCapacity: 10, - powerUsed: 9.5, - }, -]; - -export const devices: Device[] = [ - { - id: 'dev-001', - name: 'web-server-01', - type: 'server', - cabinetId: 'cab-001', - startU: 1, - sizeU: 2, - status: 'online', - ip: '192.168.1.101', - sn: 'SN123456789', - assetNo: 'ASSET-001', - }, - { - id: 'dev-002', - name: 'app-server-01', - type: 'server', - cabinetId: 'cab-001', - startU: 4, - sizeU: 2, - status: 'online', - ip: '192.168.1.103', - sn: 'SN123456790', - assetNo: 'ASSET-002', - }, - { - id: 'dev-003', - name: 'switch-core-01', - type: 'switch', - cabinetId: 'cab-001', - startU: 40, - sizeU: 1, - status: 'online', - ip: '192.168.1.2', - sn: 'SN987654321', - assetNo: 'ASSET-003', - }, - { - id: 'dev-004', - name: 'db-server-01', - type: 'server', - cabinetId: 'cab-002', - startU: 1, - sizeU: 4, - status: 'online', - ip: '192.168.1.105', - sn: 'SN123456791', - assetNo: 'ASSET-004', - }, -]; - -// ==================== 拓扑架构数据 ==================== - -export const serverMetrics = { - cpu: { usage: 67.5, cores: 16, load: [1.2, 1.5, 1.8] }, - memory: { usage: 78.2, total: 64, used: 50.0 }, - disk: { usage: 45.8, total: 500, used: 229 }, - network: { in: 12.5, out: 8.3 } -}; - -// ============ 云平台数据 ============ diff --git a/frontend/src/mocks/modules/system.ts b/frontend/src/mocks/modules/system.ts deleted file mode 100644 index 3c5969e..0000000 --- a/frontend/src/mocks/modules/system.ts +++ /dev/null @@ -1,178 +0,0 @@ -import type { - Server, - K8sCluster, - K8sNode, - K8sPod, - AlertRule, - AlertEvent, - Ticket, - ApprovalFlow, - ApprovalInstance, - AppRelease, - User, - Role, - OperationLog, - CronJob, - Script, - DashboardData, - ResourceModel, - ModelInstance, - Cabinet, - Device, - TopologyNode, - TopologyEdge, - MetricData, - LogEntry, -} from '@/types'; - -// 仪表盘数据 - -export const users: User[] = [ - { - id: 'user-001', - username: 'admin', - nickname: '管理员', - email: 'admin@company.com', - phone: '13800138000', - roles: ['admin'], - status: 'active', - lastLoginAt: '2025-03-30T08:00:00Z', - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'user-002', - username: 'liyunwei', - nickname: '李运维', - email: 'liyunwei@company.com', - phone: '13800138001', - roles: ['ops'], - status: 'active', - lastLoginAt: '2025-03-30T09:00:00Z', - createdAt: '2024-01-15T00:00:00Z', - }, - { - id: 'user-003', - username: 'zhanggongcheng', - nickname: '张工程师', - email: 'zhanggongcheng@company.com', - phone: '13800138002', - roles: ['engineer'], - status: 'active', - lastLoginAt: '2025-03-29T18:00:00Z', - createdAt: '2024-02-01T00:00:00Z', - }, - { - id: 'user-004', - username: 'wangkaifa', - nickname: '王开发', - email: 'wangkaifa@company.com', - phone: '13800138003', - roles: ['developer'], - status: 'active', - lastLoginAt: '2025-03-30T10:00:00Z', - createdAt: '2024-03-01T00:00:00Z', - }, - { - id: 'user-005', - username: 'zhaokaifa', - nickname: '赵开发', - email: 'zhaokaifa@company.com', - phone: '13800138004', - roles: ['developer'], - status: 'active', - lastLoginAt: '2025-03-28T16:00:00Z', - createdAt: '2024-06-01T00:00:00Z', - }, -]; - -// 角色数据 -export const roles: Role[] = [ - { - id: 'role-001', - name: '超级管理员', - code: 'admin', - description: '拥有系统所有权限', - permissions: ['*'], - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'role-002', - name: '运维工程师', - code: 'ops', - description: '负责系统运维和监控', - permissions: ['server:read', 'server:write', 'k8s:*', 'monitor:*', 'alert:*', 'ticket:*'], - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'role-003', - name: '开发工程师', - code: 'developer', - description: '负责应用开发和发布', - permissions: ['server:read', 'k8s:read', 'deploy:*', 'ticket:read', 'ticket:write'], - createdAt: '2024-01-01T00:00:00Z', - }, - { - id: 'role-004', - name: '系统工程师', - code: 'engineer', - description: '负责系统架构和优化', - permissions: ['server:*', 'k8s:*', 'monitor:read', 'ticket:*'], - createdAt: '2024-01-01T00:00:00Z', - }, -]; - -// 操作日志数据 -export const operationLogs: OperationLog[] = [ - { - id: 'log-001', - userId: 'user-001', - username: '管理员', - module: '服务器管理', - action: '创建服务器', - resource: 'srv-011', - ip: '192.168.1.100', - userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', - result: 'success', - createdAt: '2025-03-30T10:00:00Z', - }, - { - id: 'log-002', - userId: 'user-002', - username: '李运维', - module: '告警管理', - action: '修改告警规则', - resource: 'rule-001', - ip: '192.168.1.100', - userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', - result: 'success', - createdAt: '2025-03-30T09:30:00Z', - }, - { - id: 'log-003', - userId: 'user-003', - username: '张工程师', - module: 'K8s管理', - action: '删除Pod', - resource: 'pod-old-001', - ip: '192.168.1.100', - userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', - result: 'failure', - message: '权限不足', - createdAt: '2025-03-30T09:00:00Z', - }, -]; - -// 定时任务数据 -export const currentUser = { - id: 'user-001', username: 'admin', nickname: '管理员', email: 'admin@company.com', - phone: '13800138000', roles: ['admin'], avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=admin' -}; - -// 导出聚合对象供api.ts使用 -export const pendingApprovals = [ - { id: 'app-001', type: '服务器申请', title: '申请2台16核64G服务器', applicant: '王开发', createdAt: '2025-04-14 09:00:00' }, - { id: 'app-002', type: '发布审批', title: '订单服务v3.2.0发布到生产', applicant: '李运维', createdAt: '2025-04-14 10:00:00' }, - { id: 'app-003', type: '数据库变更', title: '用户表添加手机号验证字段', applicant: '张工程师', createdAt: '2025-04-14 11:00:00' } -]; - -// ============ 用户数据 ============