zenoss.event() 函数
zenoss.event()
是用户贡献的函数,由包作者维护。
zenoss.event()
向 Zenoss 发送事件。
函数类型签名
(
severity: A,
url: string,
?action: B,
?apiKey: C,
?collector: D,
?component: E,
?device: F,
?eventClass: G,
?eventClassKey: H,
?message: I,
?method: J,
?password: string,
?summary: K,
?tid: L,
?type: M,
?username: string,
) => int where C: Equatable
有关更多信息,请参阅函数类型签名。
参数
url
(必需)Zenoss 路由器端点 URL。
username
用于 HTTP BASIC 身份验证的 Zenoss 用户名。默认为 ""
(无身份验证)。
password
用于 HTTP BASIC 身份验证的 Zenoss 密码。默认为 ""
(无身份验证)。
apiKey
Zenoss 云 API 密钥。默认为 ""
(无 API 密钥)。
action
Zenoss 路由器名称。默认为 “EventsRouter”。
method
EventsRouter 方法。默认为 “add_event”。
type
事件类型。默认为 “rpc”。
tid
临时请求事务 ID。默认为 1
。
summary
事件摘要。默认为 ""
。
device
相关设备。默认为 ""
。
component
相关组件。默认为 ""
。
severity
(必需)事件严重级别。
支持的值:
- 严重
- 警告
- 信息
- 清除
eventClass
事件类。默认为 ""
。
eventClassKey
事件类键。默认为 ""
。
collector
Zenoss 收集器。默认为 ""
。
message
相关消息。默认为 ""
。
示例
发送最后报告的值和严重性到 Zenoss
import "contrib/bonitoo-io/zenoss"
import "influxdata/influxdb/secrets"
username = secrets.get(key: "ZENOSS_USERNAME")
password = secrets.get(key: "ZENOSS_PASSWORD")
lastReported =
from(bucket: "example-bucket")
|> range(start: -1m)
|> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_idle")
|> last()
|> findRecord(fn: (key) => true, idx: 0)
zenoss.event(
url: "https://tenant.zenoss.io:8080/zport/dmd/evconsole_router",
username: username,
username: password,
device: lastReported.host,
component: "CPU",
eventClass: "/App",
severity:
if lastReported._value < 1.0 then
"Critical"
else if lastReported._value < 5.0 then
"Warning"
else if lastReported._value < 20.0 then
"Info"
else
"Clear",
)
此页是否对您有帮助?
感谢您的反馈!