Esempio n. 1
0
File: logs.go Progetto: vmware/vic
func configureReaders() map[string]entryReader {
	defer trace.End(trace.Begin(""))

	pprofPaths := map[string]string{
		// verbose
		"verbose": "/debug/pprof/goroutine?debug=2",
		// concise
		"concise": "/debug/pprof/goroutine?debug=1",
		"block":   "/debug/pprof/block?debug=1",
		"heap":    "/debug/pprof/heap?debug=1",
		"profile": "/debug/pprof/profile",
	}

	pprofSources := map[string]string{
		"docker":    pprof.GetPprofEndpoint(pprof.DockerPort).String(),
		"portlayer": pprof.GetPprofEndpoint(pprof.PortlayerPort).String(),
		"vicadm":    pprof.GetPprofEndpoint(pprof.VicadminPort).String(),
		"vic-init":  pprof.GetPprofEndpoint(pprof.VCHInitPort).String(),
	}

	readers := map[string]entryReader{
		"proc-mounts": fileReader("/proc/mounts"),
		"uptime":      commandReader("uptime"),
		"df":          commandReader("df"),
		"free":        commandReader("free"),
		"netstat":     commandReader("netstat -ant"),
		"iptables":    commandReader("sudo iptables --list"),
		"ip-link":     commandReader("ip link"),
		"ip-addr":     commandReader("ip addr"),
		"ip-route":    commandReader("ip route"),
		"lsmod":       commandReader("lsmod"),
		// TODO: ls without shelling out
		"disk-by-path":  commandReader("ls -l /dev/disk/by-path"),
		"disk-by-label": commandReader("ls -l /dev/disk/by-label"),
		"disk-by-uuid":  commandReader("ls -l /dev/disk/by-uuid"),
		// To check we are not leaking any fds
		"proc-self-fd": commandReader("ls -l /proc/self/fd"),
		"ps":           commandReader("ps -ef"),
		"meminfo":      fileReader("/proc/meminfo"),
		"journalctl":   commandReader("/bin/journalctl --no-pager"),
		"dmesg":        commandReader("/bin/journalctl --dmesg --no-pager"),
		"sys-block":    commandReader("ls -l /sys/block/"),
	}

	// add the pprof collection
	for sname, source := range pprofSources {
		for pname, paths := range pprofPaths {
			rname := fmt.Sprintf("%s/%s", sname, pname)
			readers[rname] = urlReader(source + paths)
		}
	}

	for _, path := range logFiles() {
		// Strip off leading '/'
		readers[path[1:]] = fileReader(path)
	}

	return readers
}
Esempio n. 2
0
File: logs.go Progetto: kjplatz/vic
func configureReaders() map[string]entryReader {
	defer trace.End(trace.Begin(""))

	pprofPaths := map[string]string{
		// verbose
		"verbose": "/debug/pprof/goroutine?debug=2",
		// concise
		"concise": "/debug/pprof/goroutine?debug=1",
		"block":   "/debug/pprof/block?debug=1",
		"heap":    "/debug/pprof/heap?debug=1",
		"profile": "/debug/pprof/profile",
	}

	pprofSources := map[string]string{
		"docker":    pprof.GetPprofEndpoint(pprof.DockerPort).String(),
		"portlayer": pprof.GetPprofEndpoint(pprof.PortlayerPort).String(),
		"vicadm":    pprof.GetPprofEndpoint(pprof.VicadminPort).String(),
		"vic-init":  pprof.GetPprofEndpoint(pprof.VCHInitPort).String(),
	}

	readers := map[string]entryReader{
		"proc-mounts": fileReader("/proc/mounts"),
		"uptime":      commandReader("uptime"),
		"df":          commandReader("df"),
		"free":        commandReader("free"),
		"netstat":     commandReader("netstat -ant"),
		"iptables":    commandReader("sudo iptables --list"),
		"ip-link":     commandReader("ip link"),
		"ip-addr":     commandReader("ip addr"),
		"ip-route":    commandReader("ip route"),
		"lsmod":       commandReader("lsmod"),
		// TODO: ls without shelling out
		"disk-by-path":  commandReader("ls -l /dev/disk/by-path"),
		"disk-by-label": commandReader("ls -l /dev/disk/by-label"),
		// To check we are not leaking any fds
		"proc-self-fd": commandReader("ls -l /proc/self/fd"),
	}

	// add the pprof collection
	for sname, source := range pprofSources {
		for pname, paths := range pprofPaths {
			rname := fmt.Sprintf("%s/%s", sname, pname)
			readers[rname] = urlReader(source + paths)
		}
	}

	for _, path := range logFiles() {
		// Strip off leading '/'
		readers[path[1:]] = fileReader(path)
	}

	if config.vmPath == "" {
		log.Info("vm-path not set, skipping datastore log collection")
	} else {
		err := findDatastore()

		if err != nil {
			log.Warning(err)
		}
	}

	return readers
}