GO Script to return Site 24x7 Monitor Group Details for specific Monitor Group ID

The following will take one argument which is the Monitor Group ID returned within the JSON from the previous blog post script.  This will return the full details for that monitor group i.e. monitors, display name etc
To compile

go build -tags 'main2' -o GetMonitorGroup.exe

// +build main2

package main

import (
    "fmt"
"os"
    "net/http"
    "io/ioutil"
)

func main() {
arg := os.Args[1]
    url := "https://www.site24x7.com/api/monitor_groups/" + arg
 
    fmt.Println("URL:>", url)

    req, err := http.NewRequest("GET", url, nil)
    req.Header.Set("Authorization", "Zoho-authtoken <place your token id here>")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Println("response Status:", resp.Status)
    fmt.Println("response Headers:", resp.Header)
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println("\n\n==================\n")
    fmt.Println("response Body:", string(body))
    fmt.Println("\n==================\n")
}


Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Creating a simple Alert / Success Message with ASP.NET/VB using Bootstrap