예제 #1
0
// GetResource return mikrotik resource
// free-hdd-space:8380416 architecture-name:smips cpu:MIPS 24Kc V7.4 cpu-frequency:650 total-memory:33554432 bad-blocks:0 version:6.33 (stable) free-memory:7995392 cpu-load:0 total-hdd-space:16777216 platform:MikroTik build-time:Nov/06/2015 12:49:27 cpu-count:1 write-sect-total:10339 board-name:hAP lite uptime:11h45m40s write-sect-since-reboot:865
func GetResource(c *api.Client) (r Resource, err error) {
	res, err := c.Call("/system/resource/getall", nil)
	if err != nil {
		return r, err
	}
	r.Uptime = res.SubPairs[0]["uptime"]
	r.Version = res.SubPairs[0]["version"]
	r.CpuLoad = res.SubPairs[0]["cpu-load"]
	// r. = res.SubPairs[0][""]
	// r. = res.SubPairs[0][""]
	// r. = res.SubPairs[0][""]
	return r, nil
}
예제 #2
0
func GetEthernet(e string, c *api.Client) (eth Ethernet, err error) {
	getEtherAddrs := api.NewPair("interface", e)
	getEtherAddrs.Op = "="
	var q api.Query
	q.Pairs = append(q.Pairs, *getEtherAddrs)
	q.Proplist = []string{"address"}

	res, err := c.Query("/ip/address/print", q)
	if err != nil {
		return eth, err
	}

	for _, v := range res.SubPairs {
		for _, sv := range v {
			fmt.Printf("address: %v\n", sv)
		}
	}
	return eth, nil
}