Example #1
0
func main() {
	flag.Parse()
	// connect with the logging server
	if logger != "" && (amroot || debug) {
		// blocks until we can connect to the logger
		lh, err := logutils.NewLoggerHook(logger, hostname, app)
		if err != nil {
			log.WithFields(log.Fields{
				"file": logutils.File(),
			}).Fatalln("ERROR SETTING UP LOGGING SERVER:", err)
		}
		log.AddHook(lh)
	}
	//log.Println("IN FORKEXEC")
	////log.SetOutput(ioutil.Discard)
	////log.Println("Log Test")
	////fmt.Println("exiting logger block")
	//}
	// log.Println("IN FORK EXEC")
	// recombine the flags for exec to use
	args := []string{
		"-failures=" + strconv.Itoa(failures),
		"-rfail=" + strconv.Itoa(rFail),
		"-ffail=" + strconv.Itoa(fFail),
		"-hostname=" + hostname,
		"-config=" + configFile,
		"-logger=" + logger,
		"-app=" + app,
		"-pprof=" + pprofaddr,
		"-physaddr=" + physaddr,
		"-rootwait=" + strconv.Itoa(rootwait),
		"-debug=" + strconv.FormatBool(debug),
		"-rounds=" + strconv.Itoa(rounds),
		"-amroot=" + strconv.FormatBool(amroot),
		"-test_connect=" + strconv.FormatBool(testConnect),
		"-suite=" + suite,
	}
	cmd := exec.Command("./exec", args...)
	cmd.Stdout = log.StandardLogger().Writer()
	cmd.Stderr = log.StandardLogger().Writer()
	// log.Println("running command:", cmd)
	err := cmd.Run()
	if err != nil {
		log.Errorln("cmd run:", err)
	}

	// get CPU usage stats
	st := cmd.ProcessState.SystemTime()
	ut := cmd.ProcessState.UserTime()
	log.WithFields(log.Fields{
		"file":     logutils.File(),
		"type":     "forkexec",
		"systime":  st,
		"usertime": ut,
	}).Info("")

}
Example #2
0
func (s *Server) ConnectToLogger() {
	return
	if s.Logger == "" || s.Hostname == "" || s.App == "" {
		log.Println("skipping connect to logger")
		return
	}
	log.Println("Connecting to Logger")
	lh, _ := logutils.NewLoggerHook(s.Logger, s.Hostname, s.App)
	log.Println("Connected to Logger")
	log.AddHook(lh)
}
Example #3
0
func main() {
	flag.Parse()
	if logger != "" {
		// blocks until we can connect to the logger
		lh, err := logutils.NewLoggerHook(logger, name, "timeclient")
		if err != nil {
			log.Fatal(err)
		}
		log.AddHook(lh)
	}
	stampclient.Run(server, nmsgs, name, rate, debug)
}
Example #4
0
File: exec.go Project: ineiti/prifi
func main() {
	flag.Parse()
	log.Println("Running Timestamper:", logger)
	defer func() {
		log.Errorln("TERMINATING HOST")
	}()

	// connect with the logging server
	if logger != "" && (amroot || debug) {
		// blocks until we can connect to the logger
		log.Println("Connecting to Logger")
		lh, err := logutils.NewLoggerHook(logger, hostname, app)
		log.Println("Connected to Logger")
		if err != nil {
			log.WithFields(log.Fields{
				"file": logutils.File(),
			}).Fatalln("ERROR SETTING UP LOGGING SERVER:", err)
		}
		log.AddHook(lh)
		//log.SetOutput(ioutil.Discard)
		//fmt.Println("exiting logger block")
	}
	if physaddr == "" {
		h, _, err := net.SplitHostPort(hostname)
		if err != nil {
			log.Fatal("improperly formatted hostname")
		}
		physaddr = h
	}

	// run an http server to serve the cpu and memory profiles
	go func() {
		_, port, err := net.SplitHostPort(hostname)
		if err != nil {
			log.Fatal("improperly formatted hostname: should be host:port")
		}
		p, _ := strconv.Atoi(port)
		// uncomment if more fine grained memory debuggin is needed
		//runtime.MemProfileRate = 1
		log.Println(http.ListenAndServe(net.JoinHostPort(physaddr, strconv.Itoa(p+2)), nil))
	}()

	// log.Println("!!!!!!!!!!!!!!!Running timestamp with rFail and fFail: ", rFail, fFail)
	timestamper.Run(hostname, cfg, app, rounds, rootwait, debug, testConnect, failures, rFail, fFail, logger, suite)
}