Zabbix API - Create Maintenance Window
Aus Wiki-WebPerfect
Version vom 16. Mai 2017, 13:59 Uhr von Admin (Diskussion | Beiträge)
if(!$credential){ $credential = Get-Credential } $baseurl = '<Zabbix-Server-URL>' $params = @{ body = @{ "jsonrpc"= "2.0" "method"= "user.login" "params"= @{ "user"= $credential.UserName "password"= $credential.GetNetworkCredential().Password } "id"= 1 "auth"= $null } | ConvertTo-Json uri = "$baseurl/api_jsonrpc.php" headers = @{"Content-Type" = "application/json"} method = "Post" } $result = Invoke-WebRequest @params $params.body = @{ "jsonrpc" = "2.0" "method" = "maintenance.create" "params" = @{ "name" = "Test-RHE" "description" = "Test-RHE-Beschreibung" "active_since" = 1494921600 "active_till" = 1514826000 "hostids" = @('10347') "groupids" = @() "maintenance_type" = 0 "timeperiods" = @( @{ "timeperiod_type" = 0 "start_date" = 1494932400 "period" = 3600 }) } auth = ($result.Content | ConvertFrom-Json).result id = 13 } | ConvertTo-Json -Depth 100 $result = Invoke-WebRequest @params $result = $result.Content | ConvertFrom-Json