@@ -21,6 +21,7 @@ type ScriptDefinition struct {
2121 Depends []string // binary dependencies that must be available for the script to run
2222 Superuser bool // requires sudo or root
2323 Sequential bool // run script sequentially (not at the same time as others)
24+ NeedsKill bool // process/script needs to be killed after run without a duration specified, i.e., it doesn't stop through SIGINT
2425}
2526
2627const (
@@ -902,11 +903,17 @@ rm -rf $test_dir`, params.StorageDir)
902903 countInt := params .Duration / params .Interval
903904 count = strconv .Itoa (countInt )
904905 }
905- return fmt .Sprintf (`mpstat -u -T -I SCPU -P ALL %d %s` , params .Interval , count )
906+ script := fmt .Sprintf (`mpstat -u -T -I SCPU -P ALL %d %s` , params .Interval , count )
907+ script += " &" // run it in the background
908+ script += "\n echo $! > {cmd_pid}\n " // this is used to kill the command
909+ script += "wait\n " // wait for the command to finish
910+ return script
911+
906912 }(),
907913 Superuser : true ,
908914 Lkms : []string {},
909915 Depends : []string {"mpstat" },
916+ NeedsKill : true ,
910917 },
911918 {
912919 Name : IostatScriptName ,
@@ -916,11 +923,16 @@ rm -rf $test_dir`, params.StorageDir)
916923 countInt := params .Duration / params .Interval
917924 count = strconv .Itoa (countInt )
918925 }
919- return fmt .Sprintf (`S_TIME_FORMAT=ISO iostat -d -t %d %s | sed '/^loop/d'` , params .Interval , count )
926+ script := fmt .Sprintf (`S_TIME_FORMAT=ISO iostat -d -t %d %s | sed '/^loop/d'` , params .Interval , count )
927+ script += " &" // run it in the background
928+ script += "\n echo $! > {cmd_pid}\n " // this is used to kill the command
929+ script += "wait\n " // wait for the command to finish
930+ return script
920931 }(),
921932 Superuser : true ,
922933 Lkms : []string {},
923934 Depends : []string {"iostat" },
935+ NeedsKill : true ,
924936 },
925937 {
926938 Name : SarMemoryScriptName ,
@@ -930,11 +942,16 @@ rm -rf $test_dir`, params.StorageDir)
930942 countInt := params .Duration / params .Interval
931943 count = strconv .Itoa (countInt )
932944 }
933- return fmt .Sprintf (`sar -r %d %s` , params .Interval , count )
945+ script := fmt .Sprintf (`sar -r %d %s` , params .Interval , count )
946+ script += " &" // run it in the background
947+ script += "\n echo $! > {cmd_pid}\n " // this is used to kill the command
948+ script += "wait\n " // wait for the command to finish
949+ return script
934950 }(),
935951 Superuser : true ,
936952 Lkms : []string {},
937953 Depends : []string {"sar" , "sadc" },
954+ NeedsKill : true ,
938955 },
939956 {
940957 Name : SarNetworkScriptName ,
@@ -944,11 +961,16 @@ rm -rf $test_dir`, params.StorageDir)
944961 countInt := params .Duration / params .Interval
945962 count = strconv .Itoa (countInt )
946963 }
947- return fmt .Sprintf (`sar -n DEV %d %s` , params .Interval , count )
964+ script := fmt .Sprintf (`sar -n DEV %d %s` , params .Interval , count )
965+ script += " &" // run it in the background
966+ script += "\n echo $! > {cmd_pid}\n " // this is used to kill the command
967+ script += "wait\n " // wait for the command to finish
968+ return script
948969 }(),
949970 Superuser : true ,
950971 Lkms : []string {},
951972 Depends : []string {"sar" , "sadc" },
973+ NeedsKill : true ,
952974 },
953975 {
954976 Name : TurbostatScriptName ,
@@ -958,11 +980,50 @@ rm -rf $test_dir`, params.StorageDir)
958980 countInt := params .Duration / params .Interval
959981 count = "-n " + strconv .Itoa (countInt )
960982 }
961- return fmt .Sprintf (`turbostat -S -s PkgWatt,RAMWatt -q -i %d %s` , params .Interval , count ) + ` | awk '{ print strftime("%H:%M:%S"), $0 }'`
983+ script := fmt .Sprintf (`turbostat -S -s PkgWatt,RAMWatt -q -i %d %s` , params .Interval , count ) + ` | awk '{ print strftime("%H:%M:%S"), $0 }'`
984+ script += " &" // run it in the background
985+ script += "\n echo $! > {cmd_pid}\n " // this is used to kill the command
986+ script += "wait\n " // wait for the command to finish
987+ return script
962988 }(),
963989 Superuser : true ,
964990 Lkms : []string {"msr" },
965991 Depends : []string {"turbostat" },
992+ NeedsKill : true ,
993+ },
994+ {
995+ Name : InstructionMixScriptName ,
996+ Script : func () string {
997+ script := fmt .Sprintf ("echo TIME: $(date +\" %%H:%%M:%%S\" )\n echo INTERVAL: %d\n " , params .Interval )
998+ commandParts := []string {
999+ "processwatch -c" ,
1000+ }
1001+ // if no PID specified, increase the sampling interval (defaults to 100,000) to reduce overhead
1002+ if params .PID == 0 {
1003+ commandParts = append (commandParts , fmt .Sprintf ("-s %d" , 1000000 ))
1004+ } else {
1005+ commandParts = append (commandParts , fmt .Sprintf ("-p %d" , params .PID ))
1006+ }
1007+ for _ , cat := range params .Filter {
1008+ commandParts = append (commandParts , fmt .Sprintf ("-f %s" , cat ))
1009+ }
1010+ if params .Duration != 0 && params .Interval != 0 {
1011+ count := params .Duration / params .Interval
1012+ commandParts = append (commandParts , fmt .Sprintf ("-n %d" , count ))
1013+ }
1014+ if params .Interval != 0 {
1015+ commandParts = append (commandParts , fmt .Sprintf ("-i %d" , params .Interval ))
1016+ }
1017+ script += strings .Join (commandParts , " " )
1018+ script += " &" // run it in the background
1019+ script += "\n echo $! > {cmd_pid}\n " // this is used to kill the command
1020+ script += "wait\n " // wait for the command to finish
1021+ return script
1022+ }(),
1023+ Superuser : true ,
1024+ Lkms : []string {"msr" },
1025+ Depends : []string {"processwatch" },
1026+ NeedsKill : true ,
9661027 },
9671028
9681029 // flamegraph scripts
@@ -1098,35 +1159,6 @@ fi
10981159 Superuser : true ,
10991160 Depends : []string {"perf" },
11001161 },
1101- {
1102- Name : InstructionMixScriptName ,
1103- Script : func () string {
1104- script := fmt .Sprintf ("echo TIME: $(date +\" %%H:%%M:%%S\" )\n echo INTERVAL: %d\n " , params .Interval )
1105- scriptParts := []string {
1106- "processwatch -c" ,
1107- }
1108- // if no PID specified, increase the sampling interval (defaults to 100,000) to reduce overhead
1109- if params .PID == 0 {
1110- scriptParts = append (scriptParts , fmt .Sprintf ("-s %d" , 1000000 ))
1111- } else {
1112- scriptParts = append (scriptParts , fmt .Sprintf ("-p %d" , params .PID ))
1113- }
1114- for _ , cat := range params .Filter {
1115- scriptParts = append (scriptParts , fmt .Sprintf ("-f %s" , cat ))
1116- }
1117- if params .Duration != 0 && params .Interval != 0 {
1118- count := params .Duration / params .Interval
1119- scriptParts = append (scriptParts , fmt .Sprintf ("-n %d" , count ))
1120- }
1121- if params .Interval != 0 {
1122- scriptParts = append (scriptParts , fmt .Sprintf ("-i %d" , params .Interval ))
1123- }
1124- return script + strings .Join (scriptParts , " " )
1125- }(),
1126- Superuser : true ,
1127- Lkms : []string {"msr" },
1128- Depends : []string {"processwatch" },
1129- },
11301162 }
11311163
11321164 // validate script definitions
0 commit comments