Esempio n. 1
0
func main() {
	_, err := flags.Parse(&opts)

	if err != nil {
		// --help is not an error
		if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {
			return
		} else {
			nagios.Exit(nagios.UNKNOWN, err.Error())
		}
	}

	state, err := ProcessLog()
	if err == nil {
		nagios.Exit(state, "")
	}
	nagios.Exit(state, err.Error())
}
Esempio n. 2
0
func main() {
	// disable date/time prefixes. Use logger, if you need timestamps
	log.SetFlags(0)

	flag.StringVar(&Account.Email, "email", "", "email address")
	flag.StringVar(&Account.Password, "password", "", "password")
	flag.StringVar(&Account.Host, "host", "localhost", "POP3 host")
	flag.StringVar(&Account.Port, "port", "pop3s", "POP3 via SSL port")
	flag.StringVar(&Configfile, "config", "", "ini style config for account info in section [ums]")
	flag.BoolVar(&verbose, "verbose", false, "verbose logging on stderr")
	flag.BoolVar(&delete_after, "delete_after", false, "delete email after processing it")
	flag.Parse()

	if !CheckArguments() {
		state, message := nagios.UNKNOWN, "invalid or missing comandline parameters. Use -h for help"
		nagios.Exit(state, message)
	}

	// The real plugin
	state, message := ProcessMails()
	nagios.Exit(state, message)
}