battery-historian: Index | Files

package kernel

import ""

Package kernel parses Kernel wakesource files, and outputs CSV entries for integration with Historian v2.


Package Files



const (
    // TimeLayout is the layout passed to time.Parse.
    TimeLayout = "2006-01-02 15:04:05"

    // PositiveTransition is the string for positive transitions in the Kernel wakesource file.
    PositiveTransition = "wakeup_source_activate"

    // NegativeTransition is the string for negative transitions in the Kernel wakesource file.
    NegativeTransition = "wakeup_source_deactivate"

    // KernelWakeSource is the csv description for the Kernel wakesource metric.
    KernelWakeSource = "Kernel Wakesource"


var (

    // TraceFileRE is a regular expression to match the top line in a kernel trace file.
    TraceFileRE = regexp.MustCompile(`^# tracer: nop\n`)

    // WakeSourceRE is a regular expression to match a line in the Kernel wakesource file.
    //   e.g. healthd-188 [001] d..2 "2015-05-28 19:50:27.636636" wakeup_source_activate: eventpoll state=0x176d0004
    WakeSourceRE = regexp.MustCompile(`^` + `[^"]+` + `\s+` + `["]` + `(?P<timeStamp>[^.]+)` + `[.]` + `(?P<remainder>\d+)` + `["]` + `\s+` + `(?P<transitionType>\S+):` + `\s+` + `(?P<value>\S+)`)

func IsSupportedDevice Uses

func IsSupportedDevice(device string) bool

IsSupportedDevice returns true if the kernel trace file is currently parseable for that device. 'device' should be device name (eg. hammerhead) and not model name (eg. Nexus 5).

func IsTrace Uses

func IsTrace(f []byte) bool

IsTrace returns true if the given contents match a kernel trace file.

func Parse Uses

func Parse(f string) (bool, string, []error)

Parse writes a csv entry for each line in the kernel log file, and returns whether the format was valid.

Package kernel imports 8 packages (graph) and is imported by 2 packages. Updated 2016-11-07. Refresh now. Tools for package owners.