GET | /healthcheck | The request for getting health check information. | Depending on the execution mode, you can determine different states of the server. |
---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ServerState:
server_name: Optional[str] = None
total_ram_in_mb: Optional[Decimal] = None
available_ram_in_mb: Optional[Decimal] = None
used_cpu_percent: Optional[Decimal] = None
class MonitoringStatus(IntEnum):
SUCCESS = 1
FAILURE = 2
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MonitoringResult:
monitoring_name: Optional[str] = None
status: Optional[MonitoringStatus] = None
status_message: Optional[str] = None
error_messages: Optional[List[str]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MonitorSummary:
monitor_name: Optional[str] = None
status: Optional[MonitoringStatus] = None
results: Optional[List[MonitoringResult]] = None
error_messages: Optional[List[str]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MonitorExecutionMetrics:
start_date_time: datetime.datetime = datetime.datetime(1, 1, 1)
end_date_time: datetime.datetime = datetime.datetime(1, 1, 1)
duration: datetime.timedelta = datetime.timedelta()
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class HealthCheckResponse:
server_state: Optional[ServerState] = None
status: Optional[MonitoringStatus] = None
status_message: Optional[str] = None
correlation_id: Optional[str] = None
failed_monitor_count: int = 0
monitor_summaries: Optional[List[MonitorSummary]] = None
execution_metrics: Optional[MonitorExecutionMetrics] = None
class ExecutionMode(IntEnum):
BASIC = 1
STANDARD = 2
ADVANCED = 3
class ServerType(IntEnum):
APP = 1
SQL = 2
FTP_API = 3
FTP = 4
BATCH = 5
IDENTITY = 6
QC = 7
XCODE_V = 8
XCODE_C = 9
MSG_VAST = 10
ASG_VAST = 11
MONGO = 12
AGENTS = 13
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class HealthCheckRequest:
# @ApiMember(DataType="ExecutionMode", Description="The mode used to determine what level of health check to perform.", IsRequired=true, ParameterType="query")
execution_mode: Optional[ExecutionMode] = None
"""
The mode used to determine what level of health check to perform.
"""
# @ApiMember(DataType="ServerType", Description="The type of server that will be used to determine which monitors will be run.", IsRequired=true, ParameterType="query")
server_type: Optional[ServerType] = None
"""
The type of server that will be used to determine which monitors will be run.
"""
# @ApiMember(DataType="boolean", Description="Indicates whether or not to include server state information in the response.", ParameterType="query")
include_server_state_information: bool = False
"""
Indicates whether or not to include server state information in the response.
"""
# @ApiMember(DataType="boolean", Description="Indicates whether or not to suppress returning error codes. This will always return a 200 code to the caller, which is required for PRTG to process the JSON response properly.", ParameterType="query")
suppress_error_codes: bool = False
"""
Indicates whether or not to suppress returning error codes. This will always return a 200 code to the caller, which is required for PRTG to process the JSON response properly.
"""
# @ApiMember(DataType="boolean", Description="Indicates whether or not to suppress deployment-related errors.", ParameterType="query")
suppress_deployment_errors: bool = False
"""
Indicates whether or not to suppress deployment-related errors.
"""
Python HealthCheckRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /healthcheck HTTP/1.1 Host: 54.235.149.200 Accept: text/csv
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"ServerState":{"ServerName":"String","TotalRamInMb":0,"AvailableRamInMb":0,"UsedCpuPercent":0},"Status":"Success","StatusMessage":"String","CorrelationId":"String","FailedMonitorCount":0,"MonitorSummaries":[{"MonitorName":"String","Status":"Success","Results":[{"MonitoringName":"String","Status":"Success","StatusMessage":"String","ErrorMessages":["String"]}],"ErrorMessages":["String"]}],"ExecutionMetrics":{"StartDateTime":"\/Date(-62135596800000-0000)\/","EndDateTime":"\/Date(-62135596800000-0000)\/","Duration":"PT0S"}}