コード例 #1
0
ファイル: misc.go プロジェクト: nyanshak/distributive
func (chk Module) Status() (int, string, error) {
	// kernelModules returns a list of all Modules that are currently loaded
	// TODO just read from /proc/Modules
	kernelModules := func() (Modules []string) {
		cmd := exec.Command("/sbin/lsmod")
		return chkutil.CommandColumnNoHeader(0, cmd)
	}
	Modules := kernelModules()
	if tabular.StrIn(chk.name, Modules) {
		return errutil.Success()
	}
	return errutil.GenericError("Module is not loaded", chk.name, Modules)
}
コード例 #2
0
ファイル: misc.go プロジェクト: nyanshak/distributive
func (chk Running) Status() (int, string, error) {
	// getRunningCommands returns the entries in the "Command" column of `ps aux`
	getRunningCommands := func() (Commands []string) {
		cmd := exec.Command("ps", "aux")
		return chkutil.CommandColumnNoHeader(10, cmd)
	}
	// remove this process from consideration
	Commands := getRunningCommands()
	var filtered []string
	for _, cmd := range Commands {
		if !strings.Contains(cmd, "distributive") {
			filtered = append(filtered, cmd)
		}
	}
	if tabular.StrIn(chk.name, filtered) {
		return errutil.Success()
	}
	return errutil.GenericError("Process not Running", chk.name, filtered)
}