SSE 订阅
为 Redfish 服务创建“服务器发送事件”的订阅,以便将事件发送到客户端并保持连接打开。
请求 URL
POST https://<BMC_IPADDR>/{ServerSentEventUri}
ServerSentEventUri:在 EventService 的 ServerSentEventUri 属性中指定。
请求正文
无
响应正文
无
状态代码
无
示例
订阅 SSE 事件 - curl
curl 命令的以下示例将创建 SSE 连接并通过此连接接收事件。
$ curl "https://192.168.0.1/redfish/v1/EventService/ServerSentEvent" -X GET -k -u USERID:PASSW0RD
订阅 SSE 事件 - 浏览器
使用 Web 浏览器(例如 Chrome)访问 URI https://192.168.0.1/redfish/v1/EventService/ServerSentEvent,您将看到浏览器显示收到的事件。
事件 JSON 数据响应
返回以下示例 JSON 响应。
…
…
: stream keep-alive
id:2
data:{
data: "Events@odata.count": 1,
data: "Id": "2",
data: "Events": [
data: {
data: "MessageArgs": [
data: "USERID",
data: "the standard password",
data: "web",
data: "192.168.0.2"
data: ],
data: "Message": "Remote Login Successful. Login ID: USERID using the standard password from web at IP address 192.168.0.2.",
data: "EventGroupId": 0,
data: "Oem": {
data: "SystemSerialNumber": "DSYM09X",
data: "Lenovo": {
data: "ReportingChain": "",
data: "IsLocalEvent": true,
data: "RawDebugLogURL": "",
data: "AffectedIndicatorLEDs": [
data: ],
data: "EventFlag": 0,
data: "AuxiliaryData": "",
data: "Source": "System",
data: "FailingFRU": [
data: {
data: "FRUSerialNumber": "",
data: "FRUNumber": ""
data: }
data: ],
data: "TSLVersion": "0",
data: "RelatedEventID": "",
data: "Hidden": false,
data: "EventID": "0x4000000e00000000",
data: "EventSequenceNumber": 1616,
data: "EventType": 0,
data: "@odata.type": "#LenovoLogEntry.v1_0_0.StandardLogEntry",
data: "LenovoMessageID": "Lenovo0014",
data: "TotalSequenceNumber": 1965,
data: "CommonEventID": "FQXSPSE4001I",
data: "Serviceable": "Not Serviceable"
data: },
data: "SystemMachineTypeModel": "7X05CTO1WW",
data: "SystemUUID": "F0F63E94-8E25-11E8-9A5A-7ED30A5E2267"
data: },
data: "EventId": "16ED786F53C",
data: "MemberId": "0001",
data: "MessageId": "EventRegistry.1.0.FQXSPSE4001I",
data: "MessageSeverity": "OK",
data: "OriginOfCondition": {
data: "@odata.id": "/redfish/v1/Systems/1/LogServices/StandardLog"
data: },
data: "EventTimestamp": "2019-12-05T19:26:16+00:00"
data: }
data: ],
data: "@odata.type": "#Event.v1_4_0.Event",
data: "Name": "Redfish Event",
data: "Description": "This resource represents an event for a Redfish implementation."
data:}
: stream keep-alive
: stream keep-alive
…
…
查询 SSE 事件订阅
GET https://192.168.0.1/redfish/v1/EventService/Subscriptions,然后找到集合中的 SSE 新订阅。
在本例中,是“/redfish/v1/EventService/Subscriptions/C8ECC924”。
{
"Members": [
{
"@odata.id": "/redfish/v1/EventService/Subscriptions/C8ECC924"
}
],
"@odata.type": "#EventDestinationCollection.EventDestinationCollection",
"@odata.id": "/redfish/v1/EventService/Subscriptions",
"Members@odata.count": 1,
"@odata.etag": "\"1554741700566\"",
"Name": "Subscriptions",
"@odata.context": "/redfish/v1/$metadata#EventDestinationCollection.EventDestinationCollection"
}
GET https://192.168.0.1/redfish/v1/EventService/Subscriptions/C8ECC924,然后查找订阅属性。
{
"HttpHeaders": [],
"Id": "C8ECC924",
"SubordinateResources": null,
"Context": null,
"MessageIds": [],
"SubscriptionType": "SSE",
"ResourceTypes": [],
"OriginResources@odata.count": 0,
"Protocol": "Redfish",
"Name": "Destination",
"RegistryPrefixes": [],
"@odata.type": "#EventDestination.v1_5_0.EventDestination",
"@odata.id": "/redfish/v1/EventService/Subscriptions/C8ECC924",
"Description": "This resource represents the target of an event subscription, including the types of events subscribed and context to provide to the target in the Event payload.",
"@odata.etag": "\"1575573946737\"",
"OriginResources": [],
"EventFormatType": "Event"
}
注:“SubscriptionType”属性值为“SSE”,表示 SSE 订阅。
提供反馈