func readKprobeProfile(path string) (map[string]KprobeStats, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, errors.Wrapf(err, "error opening kprobe profile file at: %s", path)
	}
	defer f.Close()

	scanner := bufio.NewScanner(f)
	scanner.Split(bufio.ScanLines)

	stats := map[string]KprobeStats{}
	for scanner.Scan() {
		fields := strings.Fields(scanner.Text())
		if len(fields) != 3 {
			continue
		}

		hits, err := strconv.ParseInt(fields[1], 10, 64)
		if err != nil {
			log.Debugf("error parsing kprobe_profile output for hits (%s): %s", fields[1], err)
			continue
		}

		misses, err := strconv.ParseInt(fields[2], 10, 64)
		if err != nil {
			log.Debugf("error parsing kprobe_profile output for miss (%s): %s", fields[2], err)
			continue
		}

		stats[fields[0]] = KprobeStats{
			Hits:   hits,
			Misses: misses,
		}
	}

	return stats, nil
}
// readKprobeProfile reads a /sys/kernel/debug/tracing/kprobe_profile file and returns a map of probe -> stats
readKprobeProfile reads a /sys/kernel/debug/tracing/kprobe_profile file and returns a map of probe -> stats
// readKprobeProfile reads a / sys / kernel / debug / tracing / kprobe_profile file and returns a map of probe - > stats
func readKprobeProfile(path string) (map[string]KprobeStats, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, errors.Wrapf(err, "error opening kprobe profile file at: %s", path)
	}
	defer f.Close()
	scanner := bufio.NewScanner(f)
	scanner.Split(bufio.ScanLines)
	stats := map[string]KprobeStats{}
	for scanner.Scan() {
		fields := strings.Fields(scanner.Text())
		if len(fields) != 3 {
			continue
		}
		hits, err := strconv.ParseInt(fields[1], 10, 64)
		if err != nil {
			log.Debugf("error parsing kprobe_profile output for hits (%s): %s", fields[1], err)
			continue
		}
		misses, err := strconv.ParseInt(fields[2], 10, 64)
		if err != nil {
			log.Debugf("error parsing kprobe_profile output for miss (%s): %s", fields[2], err)
			continue
		}
		stats[fields[0]] = KprobeStats{
			Hits:   hits,
			Misses: misses,
		}
	}
	return stats, nil
}
func readKprobeProfile ( path string ) ( map [ string ] KprobeStats , error ) { f , err := os . Open ( path ) if err != nil { return nil , errors . Wrapf ( err , " " , path ) } defer f . Close ( ) scanner := bufio . NewScanner ( f ) scanner . Split ( bufio . ScanLines ) stats := map [ string ] KprobeStats { } for scanner . Scan ( ) { fields := strings . Fields ( scanner . Text ( ) ) if len ( fields ) != 3 { continue } hits , err := strconv . ParseInt ( fields [ 1 ] , 10 , 64 ) if err != nil { log . Debugf ( " " , fields [ 1 ] , err ) continue } misses , err := strconv . ParseInt ( fields [ 2 ] , 10 , 64 ) if err != nil { log . Debugf ( " " , fields [ 2 ] , err ) continue } stats [ fields [ 0 ] ] = KprobeStats { Hits : hits , Misses : misses , } } return stats , nil }
readKprobeProfile reads a /sys/kernel/debug/tracing/kprobe_profile file and returns a map of probe -> stats
readKprobeProfile reads a / sys / kernel / debug / tracing / kprobe_profile file and returns a map of probe - > stats