Esempio n. 1
0
//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
}
Esempio n. 2
0
//Claim a service while checking
func (service *Service) Claim() {
	log.Debug("Claiming", service.Identifier)
	service.Claimed = true
}