1
0

Updated main.go.

This commit is contained in:
Alexander Andreev 2024-07-07 17:23:29 +04:00
parent ef99d71a1a
commit 68e968d712
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34

12
main.go
View File

@ -23,19 +23,19 @@ var version string
// A process is effectively a substring that is being looked in a cmdline file // A process is effectively a substring that is being looked in a cmdline file
// in /proc/ dir on unix-like systems. // in /proc/ dir on unix-like systems.
type Process struct { type Process struct {
Alias string `json:"alias"`
Process string `json:"process"` Process string `json:"process"`
Alias string `json:"alias"`
} }
// ProcessesState is a map of processes' aliases and its statuses. // ProcessesState is a map of processes' aliases and its statuses.
type ProcessesState map[string]bool type ProcessesState map[string]bool
func GetProcessesState(procs *[]Process) (ps ProcessesState) { func GetProcessesState(procs *[]Process) (ps ProcessesState) {
ps = make(ProcessesState) ps = make(ProcessesState, len(*procs))
for _, proc := range *procs { for _, proc := range *procs {
pids, err := GetProcessPIDs(proc.Process) run, _ := IsProcessRuns(proc.Process)
ps[proc.Alias] = err == nil && len(pids) > 0 ps[proc.Alias] = run
} }
return return
@ -73,12 +73,12 @@ func LoadConfiguration(path string) (conf *Configuration, err error) {
} }
func main() { func main() {
log.SetFlags(0) log.SetFlags(log.Llongfile)
flag.Parse() flag.Parse()
if *showVersion { if *showVersion {
fmt.Fprintln(os.Stderr, "httpprocprobed ver.", version, "\nCopyright (c) 2021-2024 Alexander \"Arav\" Andreev <me@arav.su>") fmt.Fprintln(os.Stderr, "httpprocprobed ver.", version, "\nCopyright (c) 2021-2024 Alexander \"Arav\" Andreev <me@arav.su>")
os.Exit(0) return
} }
conf, err := LoadConfiguration(*configPath) conf, err := LoadConfiguration(*configPath)