Exemplo n.º 1
0
func main() {
	now := uint(time.Now().Unix())
	yesterday := uint(time.Now().Add(-24 * time.Hour).Unix())
	flag.UintVar(&from, "from", yesterday, "Unix epoch time of the beginning of the requested interval. (default: 24 hours ago)")
	flag.UintVar(&until, "until", now, "Unix epoch time of the end of the requested interval. (default: now)")
	flag.Parse()

	if flag.NArg() != 1 {
		usage()
	}

	path := flag.Args()[0]
	fromTime := uint32(from)
	untilTime := uint32(until)

	w, err := whisper.Open(path)
	if err != nil {
		log.Fatal(err)
	}

	interval, points, err := w.FetchUntil(fromTime, untilTime)

	fmt.Printf("Values in interval %+v\n", interval)
	for i, p := range points {
		fmt.Printf("%d %v\n", i, p)
	}
	return
}
Exemplo n.º 2
0
func main() {
	flag.StringVar(&url, "u", "", "URL to load test (required)")
	flag.StringVar(&method, "m", "GET", "HTTP method")
	flag.UintVar(&concurrency, "c", 10, "number of concurrent requests")
	flag.UintVar(&requests, "n", 1000, "number of total requests to make")
	flag.UintVar(&timeout, "t", 15, "request timeout in seconds")
	flag.StringVar(&regions, "r", "us-east-1,eu-west-1,ap-northeast-1", "AWS regions to run in (comma separated, no spaces)")
	flag.Parse()

	if url == "" {
		flag.Usage()
		os.Exit(0)
	}

	test, testerr := goad.NewTest(&goad.TestConfig{
		URL:            url,
		Concurrency:    concurrency,
		TotalRequests:  requests,
		RequestTimeout: time.Duration(timeout) * time.Second,
		Regions:        strings.Split(regions, ","),
		Method:         method,
	})
	if testerr != nil {
		fmt.Println(testerr)
		os.Exit(1)
	}

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}
Exemplo n.º 3
0
func init() {
	flag.IntVar(&port, "port", 80, "Webserver port.")
	flag.IntVar(&port, "p", 80, "Webserver port (shorthand).")

	flag.BoolVar(&passThrough, "through", false, "Pass serial input to STDOUT.")
	flag.BoolVar(&passThrough, "t", false, "Pass serial input to STDOUT (shorthand).")

	flag.BoolVar(&logging, "log", false, "Log HTTP requests to STDOUT")
	flag.BoolVar(&logging, "l", false, "Log HTTP requests to STDOUT (shorthand).")

	flag.BoolVar(&devMode, "dev", false, "Dev mode")
	flag.BoolVar(&devMode, "d", false, "Dev mode (shorthand).")

	flag.IntVar(&maxLogSize, "num", 180, "Number of previous temperatures to keep in memory.")
	flag.IntVar(&maxLogSize, "n", 180, "Number of previous temperatures to keep in memory (shorthand).")

	flag.UintVar(&baudRate, "baud", 115200, "Serial port baud rate.")
	flag.UintVar(&baudRate, "b", 115200, "Serial port baud rate.")

	flag.StringVar(&serialPort, "serial", "/dev/ttyATH0", "Serial port device.")
	flag.StringVar(&serialPort, "s", "/dev/ttyATH0", "Serial port device.")

	// Dev starting values
	lastDevGrouphead = 100.0
	lastDevBoiler = 180.0

	// Set up hub
	h.Connections = make(map[*socket]bool)
	h.Pipe = make(chan string, 1)
}
Exemplo n.º 4
0
func init() {
	var secret string
	flag.StringVar(&secret, "secret", "", "The passphrase used to decrypt target server address")
	flag.StringVar(&cfgGatewayAddr, "addr", cfgGatewayAddr, "Network address for gateway")
	flag.StringVar(&cfgPprofAddr, "pprof", cfgPprofAddr, "Network address for net/http/pprof")
	flag.BoolVar(&cfgReusePort, "reuse", cfgReusePort, "Enable reuse port feature")
	flag.UintVar(&cfgDialRetry, "retry", cfgDialRetry, "Retry times when dial to target server timeout")
	flag.UintVar(&cfgDialTimeout, "timeout", cfgDialTimeout, "Timeout seconds when dial to targer server")
	flag.UintVar(&cfgBufferSize, "buffer", cfgBufferSize, "Buffer size for io.CopyBuffer()")
	flag.Parse()

	cfgSecret = []byte(secret)

	cfgDialTimeout = uint(time.Second) * cfgDialTimeout

	handshakeBufPool.New = func() interface{} {
		buf := make([]byte, 64)
		return &buf
	}

	copyBufPool.New = func() interface{} {
		buf := make([]byte, cfgBufferSize)
		return &buf
	}
}
Exemplo n.º 5
0
Arquivo: main.go Projeto: egelmex/hgd2
func init() {
	const (
		defaultPort = 8080
		usagePort   = "port to connect to"

		usageDIR = "dir for HDG configuration files"

		usageInit       = "First time initialisation"
		defaultPassword = ""

		defaultMaxUploadSize = 100
		usageMaxUploadSize   = "Maximum upload size in MB."
	)

	defaultDIR := xdgbase.GetConfigHome() + "/hgd"

	flag.UintVar(&settings.port, "port", defaultPort, usagePort)
	flag.UintVar(&settings.port, "p", defaultPort, usagePort+" (shorthand)")

	flag.StringVar(&settings.dir, "dir", defaultDIR, usageDIR)
	flag.StringVar(&settings.dir, "d", defaultDIR, usageDIR+" (shorthand)")

	flag.StringVar(&initPassword, "init", defaultPassword, usageInit)

	flag.UintVar(&settings.maxUploadSize, "s", defaultMaxUploadSize, usageMaxUploadSize)

	log.SetFlags(log.Lshortfile | log.Ldate | log.Ltime)
}
Exemplo n.º 6
0
func init() {
	flag.StringVar(&conf.fname, "f", conf.fname, "apache log file")
	flag.UintVar(&conf.trafficLimitLow, "tmin", conf.trafficLimitLow, "traffic min threshold ")
	flag.UintVar(&conf.trafficLimitHigh, "tmax", conf.trafficLimitHigh, "traffic max threshold ")
	flag.UintVar(&conf.statPeriodSec, "s", conf.statPeriodSec, "stat snapshot period (sec)")
	flag.UintVar(&conf.alertPeriodMin, "a", conf.alertPeriodMin, "alerts check period (min)")
}
Exemplo n.º 7
0
func main() {
	count := uint(30)
	width := uint(1920)
	height := uint(1080)
	flag.UintVar(&count, "framecnt", count, "Frames generated per simulation packet")
	flag.UintVar(&width, "width", width, "Width of output surface")
	flag.UintVar(&height, "height", height, "Height of output surface")
	flag.Parse()

	yard := ext.StdExtensions()
	shapes := animate.StdShapes
	groups := animate.StdGroupFacts

	fact := animate.RenderFactory{}
	fact.Width = width
	fact.Height = height
	fact.Yard = yard
	fact.Framecnt = count
	fact.EntShapes = shapes
	fact.EntGroups = groups
	frtun := runFrameTunnel(fact)

	for frch := range frtun {
		for fr := range frch {
			werr := animate.WriteFrame(fr, os.Stdout)
			if werr != nil {
				fmt.Fprintf(os.Stderr, "Warning: %v", werr)
			}
		}
	}
}
Exemplo n.º 8
0
func init() {
	flag.UintVar(&port, "port", DEFAULT_PORT, "the app will listen on this port")
	flag.UintVar(&port, "p", DEFAULT_PORT, "the app will listen on this port")
	flag.BoolVar(&showVersion, "version", false, "show version information")
	flag.BoolVar(&devMode, "dev", false, "start in dev mode")
	flag.Parse()
}
Exemplo n.º 9
0
func LoadConfig() (config *Config) {
	config = new(Config)

	flag.StringVar(&config.GridHost, "grid-host", "192.168.124.200", "IP of Infoblox Grid Host")
	flag.StringVar(&config.WapiVer, "wapi-version", "2.0", "Infoblox WAPI Version.")
	flag.StringVar(&config.WapiPort, "wapi-port", "443", "Infoblox WAPI Port.")
	flag.StringVar(&config.WapiUsername, "wapi-username", "", "Infoblox WAPI Username")
	flag.StringVar(&config.WapiPassword, "wapi-password", "", "Infoblox WAPI Password")
	flag.StringVar(&config.SslVerify, "ssl-verify", "false", "Specifies whether (true/false) to verify server certificate. If a file path is specified, it is assumed to be a certificate file and will be used to verify server certificate.")
	config.HttpRequestTimeout = HTTP_REQUEST_TIMEOUT
	config.HttpPoolConnections = HTTP_POOL_CONNECTIONS
	config.HttpPoolMaxSize = HTTP_POOL_MAX_SIZE

	flag.StringVar(&config.PluginDir, "plugin-dir", "/run/docker/plugins", "Docker plugin directory where driver socket is created")
	flag.StringVar(&config.DriverName, "driver-name", "mddi", "Name of Infoblox IPAM driver")
	flag.StringVar(&config.GlobalNetview, "global-view", "default", "Infoblox Network View for Global Address Space")
	flag.StringVar(&config.GlobalNetworkContainer, "global-network-container", "172.18.0.0/16", "Subnets will be allocated from this container when --subnet is not specified during network creation")
	flag.UintVar(&config.GlobalPrefixLength, "global-prefix-length", 24, "The default CIDR prefix length when allocating a global subnet.")
	flag.StringVar(&config.LocalNetview, "local-view", "default", "Infoblox Network View for Local Address Space")
	flag.StringVar(&config.LocalNetworkContainer, "local-network-container", "192.168.0.0/16", "Subnets will be allocated from this container when --subnet is not specified during network creation")
	flag.UintVar(&config.LocalPrefixLength, "local-prefix-length", 24, "The default CIDR prefix length when allocating a local subnet.")

	flag.Parse()

	return config
}
Exemplo n.º 10
0
func main() {
	flag.UintVar(&concurrency, "c", 10, "number of concurrent requests")
	flag.UintVar(&requests, "n", 1000, "number of total requests to make")
	flag.UintVar(&timeout, "t", 15, "request timeout in seconds")
	flag.StringVar(&region, "r", "us-east-1", "AWS regions to run in")
	flag.Parse()

	if len(flag.Args()) < 1 {
		fmt.Println("You must specify a URL as a last argument")
		os.Exit(1)
	}

	url = flag.Args()[0]

	test, testerr := goad.NewTest(&goad.TestConfig{
		URL:            url,
		Concurrency:    concurrency,
		TotalRequests:  requests,
		RequestTimeout: time.Duration(timeout) * time.Second,
		Region:         region,
	})
	if testerr != nil {
		fmt.Println(testerr)
		os.Exit(1)
	}

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}
Exemplo n.º 11
0
func init() {
	flag.StringVar(&opts.containerNetwork, "container-network", "10.1.0.0/16", "container network")
	flag.UintVar(&opts.containerSubnetLength, "container-subnet-length", 8, "container subnet length")
	flag.StringVar(&opts.serviceNetwork, "service-network", "172.30.0.0/16", "service network")
	flag.UintVar(&opts.mtu, "mtu", 1450, "maximum transmission unit for the overlay network")
	flag.StringVar(&opts.etcdEndpoints, "etcd-endpoints", "http://127.0.0.1:4001", "a comma-delimited list of etcd endpoints")
	flag.StringVar(&opts.etcdPath, "etcd-path", "/registry/sdn/", "etcd path")
	flag.StringVar(&opts.nodePath, "node-path", "/kubernetes.io/minions/", "etcd path that will be watched for node creation/deletion (Note: -sync flag will override this path with -etcd-path)")
	flag.StringVar(&opts.minionPath, "minion-path", "", "Deprecated, use -node-path instead")
	flag.StringVar(&opts.etcdKeyfile, "etcd-keyfile", "", "SSL key file used to secure etcd communication")
	flag.StringVar(&opts.etcdCertfile, "etcd-certfile", "", "SSL certification file used to secure etcd communication")
	flag.StringVar(&opts.etcdCAFile, "etcd-cafile", "", "SSL Certificate Authority file used to secure etcd communication")

	flag.StringVar(&opts.ip, "public-ip", "", "Publicly reachable IP address of this host (for node mode).")
	flag.StringVar(&opts.hostname, "hostname", "", "Hostname as registered with master (for node mode), will default to 'hostname -f'")

	flag.BoolVar(&opts.master, "master", true, "Run in master mode")
	flag.BoolVar(&opts.node, "node", false, "Run in node mode")
	flag.BoolVar(&opts.minion, "minion", false, "Deprecated, use -node instead")
	flag.BoolVar(&opts.skipsetup, "skip-setup", false, "Skip the setup when in node mode")
	flag.BoolVar(&opts.sync, "sync", false, "Sync the nodes directly to etcd-path (Do not wait for PaaS to do so!)")
	flag.BoolVar(&opts.kube, "kube", false, "Use kubernetes hooks for optimal integration with OVS. This option bypasses the Linux bridge. Any docker containers started manually (not through OpenShift/Kubernetes) will stay local and not connect to the SDN.")
	flag.BoolVar(&opts.multitenant, "multitenant", false, "Same as 'kube' but with multitenant capabilities. This option will only be examined if 'kube' option is 'false'.")

	flag.BoolVar(&opts.help, "help", false, "print this message")
}
Exemplo n.º 12
0
func init() {
	// Fill in default values
	CFG.Net.ListenTCP = true
	CFG.Net.MaxOutCons = 9
	CFG.Net.MaxInCons = 10
	CFG.Net.MaxBlockAtOnce = 3

	CFG.WebUI.Interface = "127.0.0.1:8833"
	CFG.WebUI.AllowedIP = "127.0.0.1"
	CFG.WebUI.ShowBlocks = 25

	CFG.TXPool.Enabled = true
	CFG.TXPool.AllowMemInputs = true
	CFG.TXPool.FeePerByte = 10
	CFG.TXPool.MaxTxSize = 10e3
	CFG.TXPool.MinVoutValue = 0
	CFG.TXPool.TxExpireMinPerKB = 100
	CFG.TXPool.TxExpireMaxHours = 12

	CFG.TXRoute.Enabled = true
	CFG.TXRoute.FeePerByte = 10
	CFG.TXRoute.MaxTxSize = 10e3
	CFG.TXRoute.MinVoutValue = 500 * CFG.TXRoute.FeePerByte // Equivalent of 500 bytes tx fee

	CFG.Memory.GCPercTrshold = 100 // 100%

	CFG.MiningStatHours = 24
	CFG.UserAgent = DefaultUserAgent
	CFG.PayCommandName = "pay_cmd.txt"

	cfgfilecontent, e := ioutil.ReadFile(ConfigFile)
	if e == nil {
		e = json.Unmarshal(cfgfilecontent, &CFG)
		if e != nil {
			println("Error in", ConfigFile, e.Error())
			os.Exit(1)
		}
	}

	flag.BoolVar(&FLAG.Rescan, "r", false, "Rebuild the unspent DB (fixes 'Unknown input TxID' errors)")
	flag.BoolVar(&CFG.Testnet, "t", CFG.Testnet, "Use Testnet3")
	flag.StringVar(&CFG.ConnectOnly, "c", CFG.ConnectOnly, "Connect only to this host and nowhere else")
	flag.BoolVar(&CFG.Net.ListenTCP, "l", CFG.Net.ListenTCP, "Listen for incomming TCP connections (on default port)")
	flag.StringVar(&CFG.Datadir, "d", CFG.Datadir, "Specify Gocoin's database root folder")
	flag.UintVar(&CFG.Net.MaxUpKBps, "ul", CFG.Net.MaxUpKBps, "Upload limit in KB/s (0 for no limit)")
	flag.UintVar(&CFG.Net.MaxDownKBps, "dl", CFG.Net.MaxDownKBps, "Download limit in KB/s (0 for no limit)")
	flag.StringVar(&CFG.WebUI.Interface, "webui", CFG.WebUI.Interface, "Serve WebUI from the given interface")
	flag.StringVar(&CFG.Beeps.MinerID, "miner", CFG.Beeps.MinerID, "Monitor new blocks with the string in their coinbase TX")
	flag.BoolVar(&CFG.TXRoute.Enabled, "txp", CFG.TXPool.Enabled, "Enable Memory Pool")
	flag.BoolVar(&CFG.TXRoute.Enabled, "txr", CFG.TXRoute.Enabled, "Enable Transaction Routing")

	if flag.Lookup("h") != nil {
		flag.PrintDefaults()
		os.Exit(0)
	}
	flag.Parse()

	Reset()
}
Exemplo n.º 13
0
func main() {
	heightInt, widthInt, _ := pty.Getsize(os.Stdout)

	var width uint
	var height uint

	// The three subtracted lines is to have room for command, file name and prompt after explosion
	flag.UintVar(&width, "w", uint(widthInt), "Maximum width of output in number of columns")
	flag.UintVar(&height, "h", uint((heightInt-3)*2), "Maximum height of output in number of half lines")
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: %s [options] [file | - ...]\n\n", os.Args[0])
		fmt.Fprintln(os.Stderr, "  Specify \"-\" or just noting to read from stdin.")
		fmt.Fprintln(os.Stderr)
		fmt.Fprintln(os.Stderr, "Options:")
		flag.PrintDefaults()
	}
	flag.Parse()

	filenames := flag.Args()
	if len(filenames) == 0 {
		fmt.Println("stdin:")
		sourceImage, _, err := image.Decode(os.Stdin)
		if err != nil {
			fmt.Fprintln(os.Stderr, "Error:", err)
		} else {
			printImage(sourceImage, width, height)
		}
	} else {
		for i, filename := range filenames {
			if i > 0 {
				fmt.Println()
			}

			var file *os.File
			var err error

			if filename == "-" {
				fmt.Println("stdin:")
				file = os.Stdin
			} else {
				fmt.Printf("%s:\n", filename)
				file, err = os.Open(filename)
				if err != nil {
					fmt.Fprintln(os.Stderr, "Error:", err)
					continue
				}
			}

			sourceImage, _, err := image.Decode(file)
			_ = file.Close()
			if err != nil {
				fmt.Fprintln(os.Stderr, "Error:", err)
				continue
			}

			printImage(sourceImage, width, height)
		}
	}
}
Exemplo n.º 14
0
Arquivo: main.go Projeto: crask/tsuite
func init() {
	flag.StringVar(&localAddr, "l", ":7777", "set local address")
	flag.StringVar(&remoteAddr, "r", "localhost:7777", "set remote address")
	flag.UintVar(&inputDelay, "id", 0, "set input delay ")
	flag.UintVar(&outputDelay, "od", 0, "set output delay ")
	flag.StringVar(&inputFile, "if", "/dev/stdout", "set input log")
	flag.StringVar(&outputFile, "of", "/dev/stdout", "set output log")
}
Exemplo n.º 15
0
func main() {
	var config Config
	config.Backend.Type = "vxlan"
	if backend := os.Getenv("BACKEND"); backend != "" {
		config.Backend.Type = backend
	}
	config.Network = os.Getenv("NETWORK")
	if config.Network == "" {
		config.Network = "100.100.0.0/16"
	}
	flag.StringVar(&config.SubnetMin, "subnet-min", "", "container network min subnet")
	flag.StringVar(&config.SubnetMax, "subnet-max", "", "container network max subnet")
	flag.UintVar(&config.SubnetLen, "subnet-len", 0, "container network subnet length")
	flag.UintVar(&config.Backend.VNI, "vni", 0, "vxlan network identifier")
	flag.UintVar(&config.Backend.Port, "port", 0, "vxlan communication port (UDP)")
	flag.Parse()

	// wait for discoverd to come up
	status, err := cluster.WaitForHostStatus(os.Getenv("EXTERNAL_IP"), func(status *host.HostStatus) bool {
		return status.Discoverd != nil && status.Discoverd.URL != ""
	})
	if err != nil {
		log.Fatal(err)
	}

	// create service and config if not present
	client := discoverd.NewClientWithURL(status.Discoverd.URL)
	if err := client.AddService(serviceName, nil); err != nil && !hh.IsObjectExistsError(err) {
		log.Fatalf("error creating discoverd service: %s", err)
	}
	data, err := json.Marshal(map[string]Config{"config": config})
	if err != nil {
		log.Fatal(err)
	}
	err = client.Service(serviceName).SetMeta(&discoverd.ServiceMeta{Data: data})
	if err != nil && !hh.IsObjectExistsError(err) {
		log.Fatalf("error creating discoverd service metadata: %s", err)
	}

	flanneld, err := exec.LookPath("flanneld")
	if err != nil {
		log.Fatal(err)
	}

	if err := syscall.Exec(
		flanneld,
		[]string{
			flanneld,
			"-discoverd-url=" + status.Discoverd.URL,
			"-iface=" + os.Getenv("EXTERNAL_IP"),
			"-http-port=" + os.Getenv("PORT"),
			fmt.Sprintf("-notify-url=http://%s:1113/host/network", os.Getenv("EXTERNAL_IP")),
		},
		os.Environ(),
	); err != nil {
		log.Fatal(err)
	}
}
Exemplo n.º 16
0
func init() {
	flag.StringVar(&conf.WsHost, "websocket-host", "", "bind websocket endpoint with given interface")
	flag.UintVar(&conf.WsPort, "websocket-port", 8080, "websocket endpoint will listen on this port")
	flag.StringVar(&conf.BackHost, "backend-host", "", "bind backend endpoint with given interface")
	flag.UintVar(&conf.BackPort, "backend-port", 8081, "backend endpoint will listen on this port")
	flag.StringVar(&conf.CertFile, "cert", "", "path to server certificate")
	flag.StringVar(&conf.KeyFile, "key", "", "private key")
	flag.Parse()
}
Exemplo n.º 17
0
func readArgs() params {
	args := params{}
	flag.UintVar(&args.jobs, "jobs", 1, "Number of concurrent render jobs")
	flag.UintVar(&args.port, "port", 9898, "Port for webservice")
	flag.StringVar(&args.bind, "bind", "127.0.0.1", "Interface to bind against")
	flag.StringVar(&args.origins, "origins", "", "Comma separated CORS client origins")
	flag.BoolVar(&args.debug, "debug", false, "Verbose logging")
	flag.Parse()
	return args
}
Exemplo n.º 18
0
Arquivo: cli.go Projeto: goadapp/goad
func main() {
	var printVersion bool

	flag.StringVar(&url, "u", "", "URL to load test (required)")
	flag.StringVar(&method, "m", "GET", "HTTP method")
	flag.StringVar(&body, "b", "", "HTTP request body")
	flag.UintVar(&concurrency, "c", 10, "number of concurrent requests")
	flag.UintVar(&requests, "n", 1000, "number of total requests to make")
	flag.UintVar(&timeout, "t", 15, "request timeout in seconds")
	flag.StringVar(&regions, "r", "us-east-1,eu-west-1,ap-northeast-1", "AWS regions to run in (comma separated, no spaces)")
	flag.StringVar(&awsProfile, "p", "", "AWS named profile to use")
	flag.StringVar(&outputFile, "o", "", "Optional path to JSON file for result storage")
	flag.Var(&headers, "H", "List of headers")
	flag.BoolVar(&printVersion, "version", false, "print the current Goad version")
	flag.Parse()

	if printVersion {
		fmt.Println(version.Version)
		os.Exit(0)
	}

	if url == "" {
		flag.Usage()
		os.Exit(0)
	}

	test, testerr := goad.NewTest(&goad.TestConfig{
		URL:            url,
		Concurrency:    concurrency,
		TotalRequests:  requests,
		RequestTimeout: time.Duration(timeout) * time.Second,
		Regions:        strings.Split(regions, ","),
		Method:         method,
		Body:           body,
		Headers:        headers,
		AwsProfile:     awsProfile,
	})
	if testerr != nil {
		fmt.Println(testerr)
		os.Exit(1)
	}

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	if outputFile != "" {
		defer saveJSONSummary(outputFile, &finalResult)
	}

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}
Exemplo n.º 19
0
func init() {
	flag.UintVar(&Num, "n", 10, "number of concurrent clients")
	flag.UintVar(&Size, "s", 1, "packet size (in bytes)")
	flag.Parse()

	Addr = flag.Arg(0)
	if Addr == "" {
		usage()
		os.Exit(1)
	}
}
Exemplo n.º 20
0
func getArgs() args {
	params := args{}
	flag.UintVar(&params.sheeplecnt, "sheeple", 0, "Number of sheeple")
	flag.UintVar(&params.tvcnt, "tv", 0, "Number of TVs")
	flag.UintVar(&params.itermax, "iterations", 100, "Number of iterations")
	flag.Float64Var(&params.width, "width", 10, "Torus width")
	flag.Float64Var(&params.height, "height", 10, "Torus height")
	flag.StringVar(&params.beliefs, "beliefs", "A,B,C", "Comma separated belief list")
	flag.Parse()
	return params
}
Exemplo n.º 21
0
Arquivo: ocp.go Projeto: nhp/ocp
func init() {
	flag.UintVar(&throttle, "c", 1, "URLs to prime at once")
	flag.UintVar(&max, "max", 0, "maximum number of uncached URLs to prime")
	flag.StringVar(&localDir, "l", "", "directory containing cached files (relative file names, i.e. /about/ -> <path>/about/index.html)")
	flag.StringVar(&localSuffix, "ls", "index.html", "suffix of locally cached files")
	flag.StringVar(&userAgent, "ua", defaultUA, "User-Agent header to send")
	flag.BoolVar(&verbose, "v", false, "show additional information about the priming process")
	flag.BoolVar(&nowarn, "no-warn", false, "do not warn about pages that were not primed successfully")
	flag.BoolVar(&printUrls, "print", false, "(exclusive) just print the sorted URLs (can be used with xargs)")
	flag.BoolVar(&primeUrls, "urls", false, "prime the URLs given as arguments rather than a sitemap")
	flag.Parse()
}
Exemplo n.º 22
0
func parseArguments(args *commandLine) {
	flag.UintVar(&args.iterateLimit, "iterateLimit", 255, "Maximum number of iterations")
	flag.Float64Var(&args.divergeLimit, "divergeLimit", 4.0, "Limit where function is said to diverge to infinity")
	flag.UintVar(&args.width, "imageWidth", 800, "Width of output PNG")
	flag.UintVar(&args.height, "imageHeight", 600, "Height of output PNG")
	flag.StringVar(&args.filename, "filename", "mandelbrot.png", "Name of output PNG")
	flag.Float64Var(&args.xOffset, "xOffset", -1.5, "Leftmost position of complex plane projected onto PNG image")
	flag.Float64Var(&args.yOffset, "yOffset", 1.0, "Topmost position of complex plane projected onto PNG image")
	flag.Float64Var(&args.zoom, "zoom", 1.0, "Look into the eyeball")
	flag.StringVar(&args.mode, "mode", "sequential", "Render mode")
	flag.Parse()
}
Exemplo n.º 23
0
func initFlags() {
	flag.UintVar(&listeningPort, "port", 8080, "Proxy listening port")
	flag.BoolVar(&dnsPrefetching, "dns", false, "Enable DNS prefetching")
	flag.BoolVar(&caching, "cache", false, "Enable object caching")
	flag.UintVar(&cacheTimeout, "timeout", 120, "Cache timeout in seconds")
	flag.UintVar(&maxCacheSize, "max_cache", MAX_CACHE_SIZE, "Maximum cache size")
	flag.UintVar(&maxObjSize, "max_obj", MAX_OBJ_SIZE, "Maximum object size")
	flag.BoolVar(&linkPrefetching, "link", false, "Enable link prefetching")
	flag.UintVar(&maxConcurrency, "max_conc", 10, "Number of threads for link prefetching")
	flag.StringVar(&outputFile, "file", "proxy.log", "Output file name")
	flag.Parse()
}
Exemplo n.º 24
0
func readflags() *string {
	sourcelist := flag.String("sourcelist", "sourcelist.txt", "list of source files with metadata")
	flag.UintVar(&bands, "bands", 10, "number of bands")
	var err os.Error
	soxpath, err = exec.LookPath("sox")
	defaults := "Default is " + soxpath
	checksoxpath := false
	if err != nil {
		checksoxpath = true
		defaults = "No sox found in path. No default"
	}

	flag.StringVar(&soxpath, "sox", soxpath, "Path to sox binary. "+defaults)
	flag.UintVar(&samplerate, "samplerate", 44100, "Sample rate in hz. Default 44100")
	flag.UintVar(&beatlength, "beatlength", 0, "Length of output beats in samples. No default")
	flag.StringVar(&tmpdir, "tmpdir", "/tmp", "Tmpdir to hold FIFOs. Must exist.")
	flag.StringVar(&outputdir, "outputdir", ".", "Dir to hold output files. Default is working directory")
	flag.StringVar(&outputext, "outputext", "remix.wav", "Output default extension. Do NOT start this with a dot. Default is remix.wav")

	flag.Parse()

	if checksoxpath && soxpath == "" {
		fmt.Fprintln(os.Stderr, "No sox found on PATH and no sox specified")
	}

	if beatlength == 0 {
		fmt.Fprintln(os.Stderr, "No beatlength specified.")
		os.Exit(1)
	}

	if samplerate == 0 && !(samplerate == 22050 || samplerate == 44100 || samplerate == 48000) {
		fmt.Fprintln(os.Stderr, "Bad samplerate specified")
		os.Exit(1)
	}

	stat, err := os.Stat(tmpdir)
	if err != nil || !stat.IsDirectory() {
		fmt.Fprintf(os.Stderr, "tmpdir %s does not exist or is not a directory: %s.\n", tmpdir, err.String())
		os.Exit(1)
	}

	stat, err = os.Stat(outputdir)
	if err != nil || !stat.IsDirectory() {
		fmt.Fprintf(os.Stderr, "outputdir %s does not exist or is not a directory: %s.\n", outputdir, err.String())
		os.Exit(1)
	}

	soxformatopts = append(soxformatopts, []string{"-b", "16", "-e", "signed-integer", "-B", "-r", strconv.Uitoa(samplerate), "-t", "raw"}...)

	buffersize = 512
	return sourcelist
}
Exemplo n.º 25
0
func readArgs() params {
	args := params{}
	flag.UintVar(&args.zt.Frames, "frames", 1, "Number of frames in zoom")
	flag.UintVar(&args.zt.Xmin, "xmin", 0, "X-Min")
	flag.UintVar(&args.zt.Xmax, "xmax", 0, "X-Max")
	flag.UintVar(&args.zt.Ymin, "ymin", 0, "Y-Min")
	flag.UintVar(&args.zt.Ymax, "ymax", 0, "Y-Max")
	flag.BoolVar(&args.zt.Reconfigure, "reconf", true, "Reconfigure magnified request")
	flag.BoolVar(&args.zt.UpPrec, "incprec", true, "Increase precision for zoom")
	flag.Parse()

	return args
}
Exemplo n.º 26
0
func init() {
	flag.Usage = func() {
		fmt.Printf("Usage: program [options]\n\n")
		flag.PrintDefaults()
	}

	flag.StringVar(&arguments.web, "web", "cmd/web-raytracer/frontend", "web frontend location")
	flag.StringVar(&arguments.tree, "tree", "tree.oct", "octree to serve clients")
	flag.BoolVar(&arguments.pprof, "pprof", false, "enables cpu profiler and pprof over http, port 6060")
	flag.UintVar(&arguments.port, "port", 8080, "server port")
	flag.UintVar(&arguments.timeout, "timeout", 3, "max session length in minutes")
	flag.Float64Var(&arguments.viewDistance, "dist", 1, "max view-distance")
}
Exemplo n.º 27
0
func init() {
	flag.StringVar(&port, "port", "8080", "Port number of the satchel service")
	flag.StringVar(&port, "p", "8080", "Port number of the satchel service (shorthand)")

	flag.UintVar(&limit, "limit", 60, "Limit of requests per hour")
	flag.UintVar(&limit, "l", 60, "Limit of requests per hour (shorthand)")

	runtime.GOMAXPROCS(runtime.NumCPU())
	flag.Usage = func() {
		fmt.Printf("Usage: satchel [options] URL\n")
		flag.PrintDefaults()
	}
}
Exemplo n.º 28
0
func init() {
	// setup the command line processing
	flag.UintVar(&flagOutOfStyleSeconds, "o", 100, "seconds it takes for mainstream data to go out of style")
	flag.UintVar(&flagMainstreamThreshold, "m", 20, "how many times data can be accessed before it is mainstream")
	flag.StringVar(&flagPort, "p", ":9999", "port number to run the DB interface on")

	flag.Usage = usage
	flag.Parse()

	// setup our datastore
	ds = &datastore.Datastore{OutOfStyleSeconds: flagOutOfStyleSeconds, MainstreamThreshold: flagMainstreamThreshold}
	datastore.ProcessOutOfStyle()
}
func initFlags() {
	flag.StringVar(&targetURL, "url", "", "Target URL")
	flag.BoolVar(&waterfall, "waterfall", false, "Generate waterfall chart")
	flag.BoolVar(&browser, "browser", false, "Simulate human browsing")
	flag.StringVar(&outputFile, "file", "log.txt", "Base name for output files")
	flag.UintVar(&numRequests, "num_req", 20, "Number of requests for linked pages")
	flag.UintVar(&initTime, "init_time", 30, "Sleep time before starting.")
	flag.UintVar(&sleepTime, "sleep_time", 5, "Sleep time between page fetches")
	flag.StringVar(&proxy, "proxy", "", "Address of the proxy server")
	flag.Parse()
	if targetURL == "" {
		log.Fatal("You must specify the target URL")
	}
}
Exemplo n.º 30
0
func main() {
	var config Config
	config.Backend.Type = "vxlan"
	flag.StringVar(&config.Network, "network", "100.100.0.0/16", "container network")
	flag.StringVar(&config.EtcdURLs, "etcd", "http://127.0.0.1:2379", "etcd URLs")
	flag.StringVar(&config.SubnetMin, "subnet-min", "", "container network min subnet")
	flag.StringVar(&config.SubnetMax, "subnet-max", "", "container network max subnet")
	flag.UintVar(&config.SubnetLen, "subnet-len", 0, "container network subnet length")
	flag.UintVar(&config.Backend.VNI, "vni", 0, "vxlan network identifier")
	flag.UintVar(&config.Backend.Port, "port", 0, "vxlan communication port (UDP)")
	etcdKey := flag.String("key", "/coreos.com/network/config", "flannel etcd configuration key")
	flag.Parse()

	bytes, err := json.Marshal(&config)
	if err != nil {
		log.Fatal(err)
	}
	data := string(bytes)

	client := etcd.NewClient(strings.Split(config.EtcdURLs, ","))
	if err := networkConfigAttempts.Run(func() error {
		_, err = client.Create(*etcdKey, data, 0)
		if e, ok := err.(*etcd.EtcdError); ok && e.ErrorCode == 105 {
			// Skip if the key exists
			err = nil
		}
		return err
	}); err != nil {
		log.Fatal(err)
	}

	flanneld, err := exec.LookPath("flanneld")
	if err != nil {
		log.Fatal(err)
	}

	if err := syscall.Exec(
		flanneld,
		[]string{
			flanneld,
			"-etcd-endpoints=" + config.EtcdURLs,
			"-iface=" + os.Getenv("EXTERNAL_IP"),
			fmt.Sprintf("-notify-url=http://%s:1113/host/network", os.Getenv("EXTERNAL_IP")),
		},
		os.Environ(),
	); err != nil {
		log.Fatal(err)
	}
}