@@ -77,7 +77,7 @@ type Metadata struct {
7777
7878// LoadMetadata - populates and returns a Metadata structure containing state of the
7979// system.
80- func LoadMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , perfPath string , localTempDir string ) (Metadata , error ) {
80+ func LoadMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , localTempDir string ) (Metadata , error ) {
8181 uarch , err := myTarget .GetArchitecture ()
8282 if err != nil {
8383 return Metadata {}, fmt .Errorf ("failed to get target architecture: %v" , err )
@@ -86,11 +86,11 @@ func LoadMetadata(myTarget target.Target, noRoot bool, noSystemSummary bool, per
8686 if err != nil {
8787 return Metadata {}, fmt .Errorf ("failed to create metadata collector: %v" , err )
8888 }
89- return collector .CollectMetadata (myTarget , noRoot , noSystemSummary , perfPath , localTempDir )
89+ return collector .CollectMetadata (myTarget , noRoot , noSystemSummary , localTempDir )
9090}
9191
9292type MetadataCollector interface {
93- CollectMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , perfPath string , localTempDir string ) (Metadata , error )
93+ CollectMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , localTempDir string ) (Metadata , error )
9494}
9595
9696func NewMetadataCollector (architecture string ) (MetadataCollector , error ) {
@@ -112,7 +112,7 @@ type X86MetadataCollector struct {
112112type ARMMetadataCollector struct {
113113}
114114
115- func (c * X86MetadataCollector ) CollectMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , perfPath string , localTempDir string ) (Metadata , error ) {
115+ func (c * X86MetadataCollector ) CollectMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , localTempDir string ) (Metadata , error ) {
116116 var metadata Metadata
117117 var err error
118118 // Hostname
@@ -158,7 +158,7 @@ func (c *X86MetadataCollector) CollectMetadata(myTarget target.Target, noRoot bo
158158 return Metadata {}, fmt .Errorf ("failed to get number of general purpose counters: %v" , err )
159159 }
160160 // the rest of the metadata is retrieved by running scripts in parallel
161- metadataScripts , err := getMetadataScripts (noRoot , perfPath , noSystemSummary , metadata .NumGeneralPurposeCounters )
161+ metadataScripts , err := getMetadataScripts (noRoot , noSystemSummary , metadata .NumGeneralPurposeCounters )
162162 if err != nil {
163163 return Metadata {}, fmt .Errorf ("failed to get metadata scripts: %v" , err )
164164 }
@@ -282,7 +282,7 @@ func (c *X86MetadataCollector) CollectMetadata(myTarget target.Target, noRoot bo
282282 }
283283 return metadata , nil
284284}
285- func (c * ARMMetadataCollector ) CollectMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , perfPath string , localTempDir string ) (Metadata , error ) {
285+ func (c * ARMMetadataCollector ) CollectMetadata (myTarget target.Target , noRoot bool , noSystemSummary bool , localTempDir string ) (Metadata , error ) {
286286 var metadata Metadata
287287 // Hostname
288288 metadata .Hostname = myTarget .GetName ()
@@ -342,7 +342,7 @@ func (c *ARMMetadataCollector) CollectMetadata(myTarget target.Target, noRoot bo
342342 return Metadata {}, fmt .Errorf ("failed to get number of general purpose counters: %v" , err )
343343 }
344344 // the rest of the metadata is retrieved by running scripts in parallel and then parsing the output
345- metadataScripts , err := getMetadataScripts (noRoot , perfPath , noSystemSummary , metadata .NumGeneralPurposeCounters )
345+ metadataScripts , err := getMetadataScripts (noRoot , noSystemSummary , metadata .NumGeneralPurposeCounters )
346346 if err != nil {
347347 return Metadata {}, fmt .Errorf ("failed to get metadata scripts: %v" , err )
348348 }
@@ -397,7 +397,7 @@ func (c *ARMMetadataCollector) CollectMetadata(myTarget target.Target, noRoot bo
397397 return metadata , nil
398398}
399399
400- func getMetadataScripts (noRoot bool , perfPath string , noSystemSummary bool , numGPCounters int ) (metadataScripts []script.ScriptDefinition , err error ) {
400+ func getMetadataScripts (noRoot bool , noSystemSummary bool , numGPCounters int ) (metadataScripts []script.ScriptDefinition , err error ) {
401401 // reduce startup time by running the metadata scripts in parallel
402402 metadataScriptDefs := []script.ScriptDefinition {
403403 {
@@ -407,8 +407,9 @@ func getMetadataScripts(noRoot bool, perfPath string, noSystemSummary bool, numG
407407 },
408408 {
409409 Name : "perf supported events" ,
410- ScriptTemplate : perfPath + " list" ,
410+ ScriptTemplate : "perf list" ,
411411 Superuser : ! noRoot ,
412+ Depends : []string {"perf" },
412413 },
413414 {
414415 Name : "list uncore devices" ,
@@ -418,46 +419,54 @@ func getMetadataScripts(noRoot bool, perfPath string, noSystemSummary bool, numG
418419 },
419420 {
420421 Name : "perf stat instructions" ,
421- ScriptTemplate : perfPath + " stat -a -e instructions sleep 1" ,
422+ ScriptTemplate : "perf stat -a -e instructions sleep 1" ,
422423 Superuser : ! noRoot ,
424+ Depends : []string {"perf" },
423425 },
424426 {
425427 Name : "perf stat ref-cycles" ,
426- ScriptTemplate : perfPath + " stat -a -e ref-cycles sleep 1" ,
428+ ScriptTemplate : "perf stat -a -e ref-cycles sleep 1" ,
427429 Superuser : ! noRoot ,
430+ Depends : []string {"perf" },
428431 },
429432 {
430433 Name : "perf stat pebs" ,
431- ScriptTemplate : perfPath + " stat -a -e INT_MISC.UNKNOWN_BRANCH_CYCLES sleep 1" ,
434+ ScriptTemplate : "perf stat -a -e INT_MISC.UNKNOWN_BRANCH_CYCLES sleep 1" ,
432435 Superuser : ! noRoot ,
433436 Architectures : []string {cpus .X86Architecture },
437+ Depends : []string {"perf" },
434438 },
435439 {
436440 Name : "perf stat ocr" ,
437- ScriptTemplate : perfPath + " stat -a -e OCR.READS_TO_CORE.LOCAL_DRAM sleep 1" ,
441+ ScriptTemplate : "perf stat -a -e OCR.READS_TO_CORE.LOCAL_DRAM sleep 1" ,
438442 Superuser : ! noRoot ,
439443 Architectures : []string {cpus .X86Architecture },
444+ Depends : []string {"perf" },
440445 },
441446 {
442447 Name : "perf stat tma" ,
443- ScriptTemplate : perfPath + " stat -a -e '{topdown.slots, topdown-bad-spec}' sleep 1" ,
448+ ScriptTemplate : "perf stat -a -e '{topdown.slots, topdown-bad-spec}' sleep 1" ,
444449 Superuser : ! noRoot ,
445450 Architectures : []string {cpus .X86Architecture },
451+ Depends : []string {"perf" },
446452 },
447453 {
448454 Name : "perf stat fixed instructions" ,
449- ScriptTemplate : perfPath + " stat -a -e '{{{.InstructionsList}}}' sleep 1" ,
455+ ScriptTemplate : "perf stat -a -e '{{{.InstructionsList}}}' sleep 1" ,
450456 Superuser : ! noRoot ,
457+ Depends : []string {"perf" },
451458 },
452459 {
453460 Name : "perf stat fixed cpu-cycles" ,
454- ScriptTemplate : perfPath + " stat -a -e '{{{.CpuCyclesList}}}' sleep 1" ,
461+ ScriptTemplate : "perf stat -a -e '{{{.CpuCyclesList}}}' sleep 1" ,
455462 Superuser : ! noRoot ,
463+ Depends : []string {"perf" },
456464 },
457465 {
458466 Name : "perf stat fixed ref-cycles" ,
459- ScriptTemplate : perfPath + " stat -a -e '{{{.RefCyclesList}}}' sleep 1" ,
467+ ScriptTemplate : "perf stat -a -e '{{{.RefCyclesList}}}' sleep 1" ,
460468 Superuser : ! noRoot ,
469+ Depends : []string {"perf" },
461470 },
462471 {
463472 Name : "pmu driver version" ,
0 commit comments