GoSolar is a SolarWinds client library written in Go. It allows you to submit queries to the SolarWinds Information Service (SWIS) and do various other things.
mrxinu/gosolar is a wrapper around REST calls to the SWIS and makes working with a SolarWinds install a little easier.
GoSolar has the following generic methods:
GoSolar has the following query wrappers for ease of use:
interface{}
from the query.[]byte
representing the single row.[]interface{}
from the query.GoSolar has the following convenience methods:
Install via go get:
go get -u github.com/mrxinu/gosolar
See http://godoc.org/github.com/mrxinu/gosolar or your local go doc server for full documentation, as well as the examples.
cd $GOPATH
godoc -http=:6060 &
$preferred_browser http://localhost:6060/pkg &
Basic usage can be found below but more specific examples are in the examples folder:
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/mrxinu/gosolar"
)
func main() {
hostname := "localhost"
username := "admin"
password := ""
// NewClient creates a client that will handle the connection to SolarWinds
// along with the timeout and HTTP conversation.
client := gosolar.NewClient(hostname, username, password, true)
// run the query without any parameters by passing nil as the 2nd parameter
res, err := client.Query("SELECT Caption, IPAddress FROM Orion.Nodes", nil)
if err != nil {
log.Fatal(err)
}
// build a structure to unmarshal the results into
var nodes []struct {
Caption string `json:"caption"`
IPAddress string `json:"ipaddress"`
}
// let unmarshal do the work of unpacking the JSON
if err := json.Unmarshal(res, &nodes); err != nil {
log.Fatal(err)
}
// iterate over the resulting slice of node structures
for _, n := range nodes {
fmt.Printf("Working with node [%s] on IP address [%s]...\n", n.Caption, n.IPAddress)
}
}
Please create an issue on GitHub with details about the bug and steps to reproduce it.