示例#1
0
func DiscoverEndpoint(cmd *m.EndpointDiscoveryCommand) error {
	monitors := make([]*m.SuggestedMonitor, 0)

	endpoint, err := NewEndpoint(cmd.Name)
	if err != nil {
		return err
	}

	pingMonitor, err := DiscoverPing(endpoint)
	if err == nil {
		monitors = append(monitors, pingMonitor)
	}

	httpMonitor, err := DiscoverHttp(endpoint)
	if err == nil {
		monitors = append(monitors, httpMonitor)
	}

	httpsMonitor, err := DiscoverHttps(endpoint)
	if err == nil {
		monitors = append(monitors, httpsMonitor)
	}

	if !endpoint.IsIP {
		dnsMonitor, err := DiscoverDNS(endpoint)
		if err == nil {
			monitors = append(monitors, dnsMonitor)
		}
	}

	cmd.Result = monitors
	return nil

}
示例#2
0
func DiscoverEndpoint(cmd *m.EndpointDiscoveryCommand) error {
	monitors := make([]*m.SuggestedMonitor, 0)

	domain, err := getHostName(cmd.Name)
	if err != nil {
		return err
	}

	pingMonitor, err := DiscoverPing(domain)
	if err != nil {
		fmt.Println("failed to discover Ping", err)
	} else {
		monitors = append(monitors, pingMonitor)
	}

	httpMonitor, err := DiscoverHttp(domain)
	if err != nil {
		fmt.Println("failed to discover HTTP", err)
	} else {
		monitors = append(monitors, httpMonitor)
	}

	httpsMonitor, err := DiscoverHttps(domain)
	if err != nil {
		fmt.Println("failed to discover HTTPS", err)
	} else {
		monitors = append(monitors, httpsMonitor)
	}

	dnsMonitor, err := DiscoverDNS(domain)
	if err != nil {
		fmt.Println("failed to discover DNS", err)
	} else {
		monitors = append(monitors, dnsMonitor)
	}
	cmd.Result = monitors
	return nil

}