Add collector for /proc/stat, enabled by default.

This gives cpu stats, boot time, context switches, forks.
Done.


On 6 June 2014 10:18, juliusv <notifications@github.com> wrote:

> In collector/stat.go:
>
> > +	for scanner.Scan() {
> > +		parts := strings.Fields(scanner.Text())
> > +		switch {
> > +		case strings.HasPrefix(parts[0], "cpu"):
> > +			// Export only per-cpu stats, it can be aggregted up in prometheus.
> > +			if parts[0] == "cpu" {
> > +				break
> > +			}
> > +			// Only some of these may be present, depending on kernel version.
> > +			cpuFields := []string{"user", "nice", "system", "idle", "iowait", "irq", "softirq", "steal", "guest"}
> > +			for i, v := range parts[1 : len(cpuFields)+1] {
> > +				value, err := strconv.ParseFloat(v, 64)
> > +				if err != nil {
> > +					return updates, err
> > +				}
> > +				value /= 100 // Convert from ticks to seconds
>
> Aren't "ticks" equivalent to the kernel's timer interrupt frequency and
> thus configurable?
>
> http://linux.die.net/man/2/times says, "The number of clock ticks per
> second can be obtained using: sysconf(_SC_CLK_TCK);"
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/prometheus/node_exporter/pull/14/files#r13481959>.
>