本文整理汇总了Golang中flag.DurationVar函数的典型用法代码示例。如果您正苦于以下问题:Golang DurationVar函数的具体用法?Golang DurationVar怎么用?Golang DurationVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DurationVar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
flag.BoolVar(&versionFlag, "version", false, "Print the version number and exit.")
flag.BoolVar(&versionFlag, "V", false, "Print the version number and exit (shorthand).")
flag.StringVar(&verboseFlag, "verbose", "", "Display debug information: choose between text or JSON.")
flag.StringVar(&verboseFlag, "v", "", "Display debug information: choose between text or JSON (shorthand).")
hostname, _ := os.Hostname()
flag.StringVar(&prefixFlag, "prefix", hostname, "Change series name prefix.")
flag.StringVar(&prefixFlag, "P", hostname, "Change series name prefix (shorthand).")
flag.StringVar(&hostFlag, "host", "localhost:8086", "Connect to host.")
flag.StringVar(&hostFlag, "h", "localhost:8086", "Connect to host (shorthand).")
flag.StringVar(&usernameFlag, "username", "root", "User for login.")
flag.StringVar(&usernameFlag, "u", "root", "User for login (shorthand).")
flag.StringVar(&passwordFlag, "password", "root", "Password to use when connecting to server.")
flag.StringVar(&passwordFlag, "p", "root", "Password to use when connecting to server (shorthand).")
flag.StringVar(&databaseFlag, "database", "", "Name of the database to use.")
flag.StringVar(&databaseFlag, "d", "", "Name of the database to use (shorthand).")
flag.StringVar(&collectFlag, "collect", "cpus,mem,swap,uptime,load,network,disks", "Chose which data to collect.")
flag.StringVar(&collectFlag, "c", "cpus,mem,swap,uptime,load,network,disks", "Chose which data to collect (shorthand).")
flag.BoolVar(&daemonFlag, "daemon", false, "Run in daemon mode.")
flag.BoolVar(&daemonFlag, "D", false, "Run in daemon mode (shorthand).")
flag.DurationVar(&daemonIntervalFlag, "interval", time.Second, "With daemon mode, change time between checks.")
flag.DurationVar(&daemonIntervalFlag, "i", time.Second, "With daemon mode, change time between checks (shorthand).")
}
开发者ID:joukou-forks,项目名称:sysinfo_influxdb,代码行数:28,代码来源:main.go
示例2: parseArgs
func parseArgs() {
// set options
flag.DurationVar(&option.interval, "interval",
time.Second, "Measurement interval")
flag.BoolVar(&option.no_interval_backoff, "no-interval-backoff",
false, "Disable interval backoff")
flag.DurationVar(&option.timeout, "timeout",
time.Second*0, "Measurement timeout")
flag.DurationVar(&option.start_delay, "start-delay",
time.Second*0, "Wait time before measurement")
flag.StringVar(&option.output, "output",
"-", "Output file name")
flag.BoolVar(&option.no_cpu, "no-cpu",
false, "Do not record CPU usage")
flag.BoolVar(&option.no_disk, "no-disk",
false, "Do not record disk usage")
flag.BoolVar(&option.no_net, "no-net",
false, "Do not record net usage")
flag.BoolVar(&option.debug, "debug",
false, "Enable debug mode")
flag.BoolVar(&option.listDevices, "list-devices",
false, "List devices and exits")
flag.StringVar(&option.disks, "disks",
"", "Disk devices to be monitored")
flag.StringVar(&option.player_bin, "player-bin",
"", "Run perfmonger-player to show JSON output")
flag.Parse()
if option.player_bin == "" && terminal.IsTerminal(int(os.Stdout.Fd())) &&
option.output == "-" {
fmt.Fprintf(os.Stderr, "[recording to data.pgr]\n")
option.output = "data.pgr"
}
if option.disks == "" {
option.targetDisks = nil
} else {
option.targetDisks = new(map[string]bool)
*option.targetDisks = make(map[string]bool)
for _, dev := range strings.Split(option.disks, ",") {
(*option.targetDisks)[dev] = true
}
}
if option.debug {
os.Stderr.WriteString(
fmt.Sprintf(
`== option
- output : %s
- interval : %s
- debug : %t
- remainings: %s
`,
option.output,
option.interval.String(),
option.debug,
fmt.Sprint(flag.Args())))
}
}
开发者ID:pazjacket,项目名称:hayamiz-_-perfmonger,代码行数:60,代码来源:perfmonger-recorder.go
示例3: init
func init() {
flag.BoolVar(&versionFlag, "version", false, "Print the version number and exit.")
flag.BoolVar(&versionFlag, "V", false, "Print the version number and exit (shorthand).")
flag.BoolVar(&verboseFlag, "verbose", false, "Display debug information: choose between text or JSON.")
flag.BoolVar(&verboseFlag, "v", false, "Display debug information: choose between text or JSON (shorthand).")
flag.BoolVar(&sslFlag, "ssl", false, "Enable SSL/TLS encryption.")
flag.BoolVar(&sslFlag, "S", false, "Enable SSL/TLS encryption (shorthand).")
flag.StringVar(&hostFlag, "host", "localhost:8086", "Connect to host.")
flag.StringVar(&hostFlag, "h", "localhost:8086", "Connect to host (shorthand).")
flag.StringVar(&usernameFlag, "username", "root", "User for login.")
flag.StringVar(&usernameFlag, "u", "root", "User for login (shorthand).")
flag.StringVar(&passwordFlag, "password", "root", "Password to use when connecting to server.")
flag.StringVar(&passwordFlag, "p", "root", "Password to use when connecting to server (shorthand).")
flag.StringVar(&secretFlag, "secret", "", "Absolute path to password file (shorthand). '-p' is ignored if specifed.")
flag.StringVar(&secretFlag, "s", "", "Absolute path to password file. '-p' is ignored if specifed.")
flag.StringVar(&databaseFlag, "database", "", "Name of the database to use.")
flag.StringVar(&databaseFlag, "d", "", "Name of the database to use (shorthand).")
flag.StringVar(&retentionPolicyFlag, "retentionpolicy", "", "Name of the retention policy to use.")
flag.StringVar(&retentionPolicyFlag, "rp", "", "Name of the retention policy to use (shorthand).")
flag.StringVar(&collectFlag, "collect", "cpu,cpus,mem,swap,uptime,load,network,disks,mounts", "Chose which data to collect.")
flag.StringVar(&collectFlag, "c", "cpu,cpus,mem,swap,uptime,load,network,disks,mounts", "Chose which data to collect (shorthand).")
flag.BoolVar(&daemonFlag, "daemon", false, "Run in daemon mode.")
flag.BoolVar(&daemonFlag, "D", false, "Run in daemon mode (shorthand).")
flag.DurationVar(&daemonIntervalFlag, "interval", time.Second, "With daemon mode, change time between checks.")
flag.DurationVar(&daemonIntervalFlag, "i", time.Second, "With daemon mode, change time between checks (shorthand).")
flag.DurationVar(&daemonConsistencyFlag, "consistency", time.Second, "With custom interval, duration to bring back collected values for data consistency (0s to disable).")
flag.DurationVar(&daemonConsistencyFlag, "C", time.Second, "With daemon mode, duration to bring back collected values for data consistency (shorthand).")
flag.StringVar(&pidFile, "pidfile", "", "the pid file")
}
开发者ID:jmptrader,项目名称:sysinfo_influxdb,代码行数:34,代码来源:main.go
示例4: init
func init() {
defaultDelay := time.Duration(1500 * time.Millisecond)
flag.DurationVar(&delayFlag, "d", defaultDelay, "")
flag.DurationVar(&delayFlag, "delay", defaultDelay, "")
flag.BoolVar(&kernelFlag, "k", false, "")
flag.BoolVar(&kernelFlag, "kernel", false, "")
flag.StringVar(&pidsFlag, "p", "", "")
flag.StringVar(&pidsFlag, "pids", "", "")
defaultSort := CPUPercentColumn.Title
flag.StringVar(&sortFlag, "s", defaultSort, "")
flag.StringVar(&sortFlag, "sort", defaultSort, "")
flag.BoolVar(&treeFlag, "t", false, "")
flag.BoolVar(&treeFlag, "tree", false, "")
flag.StringVar(&usersFlag, "u", "", "")
flag.StringVar(&usersFlag, "users", "", "")
flag.BoolVar(&verboseFlag, "verbose", false, "")
flag.Usage = func() {
fmt.Fprint(os.Stdout, usage)
}
}
开发者ID:mayhewj,项目名称:jtop,代码行数:27,代码来源:jtop.go
示例5: main
func main() {
flag.StringVar(&emailAddr, "email", "[email protected]", "email recipient for notificiations")
flag.StringVar(&listenAddr, "listen", ":7700", "webserver listen address")
flag.IntVar(&failLimit, "failLimit", 4, "number failed ping attempts in a row to consider host down")
flag.DurationVar(&interval, "interval", 5*time.Second, "seconds between each ping")
flag.DurationVar(&ping.TimeOut, "timeOut", 5*time.Second, "seconds for single ping timeout")
flag.Parse()
// read non flag arguments as hosts to start monitoring
hosts := flag.Args()
var pool = &pingd.Pool{
Interval: interval,
FailLimit: failLimit,
Receive: http.NewReceiverFunc(listenAddr), // start/stop commands via HTTP
Notify: mail.NewNotifierFunc(emailAddr, sendMail), // notify up/down via email
Load: std.NewLoaderFunc(hosts), // load initial hosts from command line
}
pool.Start()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
<-c // Exit on interrupt
}
开发者ID:agilemobiledev,项目名称:pingd,代码行数:26,代码来源:cmd.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng