Prince Pereira | c1c21d6 | 2021-04-22 08:38:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // Package msgbus holds messagebus related util functions |
| 18 | package msgbus |
| 19 | |
| 20 | import ( |
| 21 | "context" |
| 22 | |
| 23 | "github.com/opencord/device-management-interface/go/dmi" |
| 24 | ) |
| 25 | |
| 26 | // SendSampleMetric sends a sample metric |
| 27 | func SendSampleMetric(ctx context.Context) { |
| 28 | m := new(dmi.Metric) |
| 29 | m.MetricId = dmi.MetricNames_METRIC_CPU_TEMP |
| 30 | m.MetricMetadata = new(dmi.MetricMetaData) |
| 31 | m.MetricMetadata.ComponentName = "CPU-COMPONENT" |
| 32 | m.MetricMetadata.ComponentUuid = new(dmi.Uuid) |
| 33 | m.MetricMetadata.ComponentUuid.Uuid = "uuid-123" |
| 34 | m.MetricMetadata.DeviceUuid = new(dmi.Uuid) |
| 35 | m.MetricMetadata.DeviceUuid.Uuid = "dev-uuid-123" |
| 36 | go SendMetric(ctx, m) |
| 37 | } |
| 38 | |
| 39 | // SendSampleEvent sends a sample event |
| 40 | func SendSampleEvent(ctx context.Context) { |
| 41 | e := new(dmi.Event) |
| 42 | e.EventId = dmi.EventIds_EVENT_FAN_FAILURE |
| 43 | e.EventMetadata = new(dmi.EventMetaData) |
| 44 | e.EventMetadata.ComponentName = "CPU-COMPONENT" |
| 45 | e.EventMetadata.ComponentUuid = new(dmi.Uuid) |
| 46 | e.EventMetadata.ComponentUuid.Uuid = "uuid-123" |
| 47 | go SendEvent(ctx, e) |
| 48 | } |