func main()

in tools/health-monitor/main.go [74:144]


func main() {
	flag.Parse()

	if hmcommon.CheckVersion {
		fmt.Printf("health-monitor version %s\n", hmcommon.BfuseMonitorVersion)
		return
	}

	err := log.SetDefaultLogger("syslog", common.LogConfig{
		Level:       common.ELogLevel.LOG_DEBUG(),
		FilePath:    common.ExpandPath(hmcommon.DefaultLogFile),
		MaxFileSize: common.DefaultMaxLogFileSize,
		FileCount:   common.DefaultLogFileCount,
		TimeTracker: false,
		Tag:         hmcommon.BfuseMon,
	})

	if err != nil {
		fmt.Printf("Health Monitor: error initializing logger [%v]", err)
		os.Exit(1)
	}

	if len(strings.TrimSpace(hmcommon.Pid)) == 0 {
		fmt.Printf("pid of blobfuse2 process not provided\n")
		log.Err("main::main : pid of blobfuse2 process not provided")
		time.Sleep(1 * time.Second) // adding 1 second wait for adding to log(base type) before exiting
		os.Exit(1)
	}

	if hmcommon.OutputPath == "" {
		currDir, err := os.Getwd()
		if err != nil {
			fmt.Printf("health-monitor : failed to get current directory [%s]\n", err.Error())
			log.Err("main::main : failed to get current directory [%s]\n", err.Error())
			return
		}
		hmcommon.OutputPath = currDir
	}

	common.TransferPipe += "_" + hmcommon.Pid
	common.PollingPipe += "_" + hmcommon.Pid

	log.Debug("Blobfuse2 Pid: %v \n"+
		"Transfer Pipe: %v \n"+
		"Polling Pipe: %v \n"+
		"Blobfuse2 Stats poll interval: %v \n"+
		"Health Stats poll interval: %v \n"+
		"Cache Path: %v \n"+
		"Max cache size in MB: %v \n",
		"Output path: %v",
		hmcommon.Pid, common.TransferPipe, common.PollingPipe, hmcommon.BfsPollInterval,
		hmcommon.ProcMonInterval, hmcommon.TempCachePath, hmcommon.MaxCacheSize, hmcommon.OutputPath)

	comps := getMonitors()

	for _, obj := range comps {
		go obj.Monitor() // nolint
	}

	// check if the pid of blobfuse2 is active
	if len(comps) > 0 {
		hmcommon.MonitorPid()
	}

	err = hminternal.CloseExporter()
	if err != nil {
		log.Err("main::main : Unable to close exporter [%v]", err)
	}

	log.Debug("Monitoring ended")
}