{% extends 'status/base.html' %} {% block title %}API说明{% endblock %} {% block content %}
本系统提供以下RESTful API接口,用于服务状态的上报和查询。
目前所有API接口均无需认证,可直接访问。后续版本可能会添加认证机制。
用于客户端上报服务状态信息。如果服务不存在,系统会自动创建。
{
"service_name": "Web服务",
"host": "192.168.1.100",
"port": 80,
"check_type": "http",
"status": "UP",
"response_time": 120.5,
"message": "连接成功"
}
{
"code": 200,
"message": "服务状态已更新",
"service_id": 1
}
获取所有服务的列表及其最新状态。
[
{
"id": 1,
"name": "Web服务",
"host": "192.168.1.100",
"port": 80,
"check_type": "http",
"group": "Web服务组",
"description": "公司主网站",
"latest_status": "UP",
"latest_check_time": "2025-06-15T10:30:00Z",
"latest_response_time": 120.5
}
]
获取指定服务的历史检测记录。
{
"count": 1,
"total_pages": 1,
"current_page": 1,
"page_size": 20,
"results": [
{
"id": 1,
"service": 1,
"status": "UP",
"response_time": 120.5,
"message": "连接成功",
"check_time": "2025-06-15T10:30:00Z"
}
]
}
获取所有服务的状态摘要统计信息。
{
"total_services": 10,
"up_count": 8,
"down_count": 1,
"unknown_count": 1
}