mirror of https://github.com/divan/expvarmon.git
Merge pull request #5 from nightlyone/support_ssl_urls
hacked up support for https URLs
This commit is contained in:
commit
730bf52a5e
3
main.go
3
main.go
|
@ -12,6 +12,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
urls = &StringArray{}
|
||||
interval = flag.Duration("i", 5*time.Second, "Polling interval")
|
||||
portsArg = flag.String("ports", "", "Ports for accessing services expvars (start-end,port2,port3)")
|
||||
varsArg = flag.String("vars", "mem:memstats.Alloc,mem:memstats.Sys,mem:memstats.HeapAlloc,mem:memstats.HeapInuse,memstats.EnableGC,memstats.NumGC,duration:memstats.PauseTotalNs", "Vars to monitor (comma-separated)")
|
||||
|
@ -20,6 +21,7 @@ var (
|
|||
)
|
||||
|
||||
func main() {
|
||||
flag.Var(urls, "url", "urls to poll for expvars")
|
||||
flag.Usage = Usage
|
||||
flag.Parse()
|
||||
|
||||
|
@ -31,6 +33,7 @@ func main() {
|
|||
ports = append(ports, port)
|
||||
}
|
||||
}
|
||||
ports = append(ports, *urls...)
|
||||
if len(ports) == 0 {
|
||||
fmt.Fprintln(os.Stderr, "no ports specified. Use -ports arg to specify ports of Go apps to monitor")
|
||||
Usage()
|
||||
|
|
|
@ -112,6 +112,9 @@ func guessValue(value *jason.Value) interface{} {
|
|||
//
|
||||
// If host is not specified, 'localhost' is used.
|
||||
func (s Service) Addr() string {
|
||||
if strings.HasPrefix(s.Port, "https://") {
|
||||
return fmt.Sprintf("%s%s", s.Port, ExpvarsURL)
|
||||
}
|
||||
// Try as port only
|
||||
_, err := strconv.Atoi(s.Port)
|
||||
if err == nil {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type StringArray []string
|
||||
|
||||
func (a *StringArray) Set(s string) error {
|
||||
s = strings.TrimSuffix(s, "/debug/vars")
|
||||
*a = append(*a, s)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *StringArray) String() string {
|
||||
return strings.Join(*a, ",")
|
||||
}
|
Loading…
Reference in New Issue