Add users filtering

This commit is contained in:
Julien Riou 2018-06-30 10:44:58 +02:00
parent a8fdfb61c0
commit ef67682463
No known key found for this signature in database
GPG key ID: BA3E15176E45E85D
6 changed files with 150 additions and 19 deletions

View file

@ -43,6 +43,10 @@ func main() {
flag.StringVar(&config.PidFile, "pid-file", "", "Write process id into a file")
flag.StringVar(&config.SyslogIdent, "syslog-ident", "pgterminate", "Define syslog tag")
flag.StringVar(&config.SyslogFacility, "syslog-facility", "", "Define syslog facility from LOCAL0 to LOCAL7")
flag.Var(&config.IncludeUsers, "include-user", "Terminate only this user (can be called multiple times)")
flag.StringVar(&config.IncludeUsersRegex, "include-users-regex", "", "Terminate users matching this regexp")
flag.Var(&config.ExcludeUsers, "exclude-user", "Ignore this user (can be called multiple times)")
flag.StringVar(&config.ExcludeUsersRegex, "exclude-users-regex", "", "Ignore users matching this regexp")
flag.Parse()
log.SetLevel(log.WarnLevel)
@ -93,6 +97,9 @@ func main() {
}
}
err = config.CompileRegexes()
base.Panic(err)
if config.PidFile != "" {
writePid(config.PidFile)
defer removePid(config.PidFile)