コード例 #1
0
ファイル: child.go プロジェクト: mdeheij/monitoring
//CheckService accepts a command and returns a status code, output (stdout) and the reaction time
func CheckService(timeout int, command string) (status int, output string, rtime int64) {
	// Initialization.
	now := time.Now()

	//Convert executable to Go's os/exec.Command
	commandSlice := str.ToArgv(configuration.C.Paths.Checks + "/" + command)
	status, output = Execute(timeout, commandSlice[0], commandSlice[1:len(commandSlice)]...)

	//TODO: implement error logging
	elapsedTime := time.Since(now)
	elapsedTimeHuman := elapsedTime.Nanoseconds() / 1000000

	symbol := message.StatusColor("●", status)
	log.Debug(symbol + " (" + strconv.Itoa(status) + ") - " + command + " - " + output)

	return status, output, elapsedTimeHuman
}
コード例 #2
0
ファイル: service.go プロジェクト: mdeheij/monitoring
//Claim a service while checking
func (service *Service) Claim() {
	log.Debug("Claiming", service.Identifier)
	service.Claimed = true
}