Exemple #1
0
func main() {
	hsperfdata_path, err := hsperfdata.GetHSPerfDataPath(os.Args[1])
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("perfdata path: %s\n", hsperfdata_path)

	f, err := os.Open(hsperfdata_path)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	prologue, err := hsperfdata.ReadPrologue(f)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Magic: 0x%x\n", prologue.Magic)
	fmt.Printf("ByteOrder: %d\n", prologue.ByteOrder)
	fmt.Printf("MajorVersion: %d\n", prologue.MajorVersion)
	fmt.Printf("MinorVersion: %d\n", prologue.MinorVersion)
	fmt.Printf("Accessible: %d\n", prologue.Accessible)
	fmt.Printf("Used: %d\n", prologue.Used)
	fmt.Printf("Overflow: %d\n", prologue.Overflow)
	fmt.Printf("ModTimeStamp: %d\n", prologue.ModTimeStamp)
	fmt.Printf("EntryOffset: %d\n", prologue.EntryOffset)
	fmt.Printf("NumEntries: %d\n", prologue.NumEntries)

	f.Seek(int64(prologue.EntryOffset), os.SEEK_SET)

	entries, err := hsperfdata.ReadPerfEntry(f, prologue)
	if err != nil {
		log.Fatal(err)
	}

	var i int32
	for i = 0; i < prologue.NumEntries; i++ {
		fmt.Printf("[%d]: %c %s\n", i, entries[i].DataType, entries[i].EntryName)

		if entries[i].DataType == 'B' {
			fmt.Printf("  -> \"%s\"\n", entries[i].StringValue)
		} else {
			fmt.Printf("  -> %d\n", entries[i].LongValue)
		}

	}

}
Exemple #2
0
func (this *HSBeat) Setup(b *beat.Beat) error {
	var err error

	this.HSPerfDataPath, err = hsperfdata.GetHSPerfDataPath(this.Pid)
	return err
}