Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions internal/script/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ import (
//go:embed resources
var Resources embed.FS

type ScriptDefinition struct {
Name string // just a name
Script string // the bash script that will be run
Architectures []string // architectures, i.e., x86_64, arm64. If empty, it will run on all architectures.
Families []string // families, e.g., 6, 7. If empty, it will run on all families.
Models []string // models, e.g., 62, 63. If empty, it will run on all models.
Lkms []string // loadable kernel modules
Depends []string // binary dependencies that must be available for the script to run
Superuser bool // requires sudo or root
Sequential bool // run script sequentially (not at the same time as others)
Timeout int // seconds
}

type ScriptOutput struct {
ScriptDefinition
Stdout string
Expand Down Expand Up @@ -254,7 +241,7 @@ func RunScriptAsync(myTarget target.Target, script ScriptDefinition, localTempDi
}()
}
cmd := prepareCommand(script, myTarget.GetTempDirectory())
err = myTarget.RunCommandAsync(cmd, stdoutChannel, stderrChannel, exitcodeChannel, script.Timeout, cmdChannel)
err = myTarget.RunCommandAsync(cmd, stdoutChannel, stderrChannel, exitcodeChannel, 0, cmdChannel)
errorChannel <- err
}

Expand Down
24 changes: 18 additions & 6 deletions internal/script/script_defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ import (
"strings"
)

type ScriptDefinition struct {
Name string // just a name
Script string // the bash script that will be run
Architectures []string // architectures, i.e., x86_64, arm64. If empty, it will run on all architectures.
Families []string // families, e.g., 6, 7. If empty, it will run on all families.
Models []string // models, e.g., 62, 63. If empty, it will run on all models.
Lkms []string // loadable kernel modules
Depends []string // binary dependencies that must be available for the script to run
Superuser bool // requires sudo or root
Sequential bool // run script sequentially (not at the same time as others)
}

const (
HostnameScriptName = "hostname"
DateScriptName = "date"
Expand Down Expand Up @@ -471,7 +483,7 @@ rdmsr 0x2FFE`, // uncore client cha count, uncore cha count, uncore cha count sp
},
{
Name: LshwScriptName,
Script: "lshw -businfo -numeric",
Script: "timeout 30 lshw -businfo -numeric",
Depends: []string{"lshw"},
Superuser: true,
},
Expand All @@ -489,7 +501,7 @@ rdmsr 0x2FFE`, // uncore client cha count, uncore cha count, uncore cha count sp
},
{
Name: NicInfoScriptName,
Script: `lshw -businfo -numeric | grep -E "^(pci|usb).*? \S+\s+network\s+\S.*?" \
Script: `timeout 30 lshw -businfo -numeric | grep -E "^(pci|usb).*? \S+\s+network\s+\S.*?" \
| while read -r a ifc c ; do
ethtool "$ifc"
ethtool -i "$ifc"
Expand Down Expand Up @@ -588,26 +600,26 @@ done`,
},
{
Name: IpmitoolSensorsScriptName,
Script: "LC_ALL=C ipmitool sdr list full",
Script: "LC_ALL=C timeout 30 ipmitool sdr list full",
Superuser: true,
Depends: []string{"ipmitool"},
},
{
Name: IpmitoolChassisScriptName,
Script: "LC_ALL=C ipmitool chassis status",
Script: "LC_ALL=C timeout 30 ipmitool chassis status",
Superuser: true,
Depends: []string{"ipmitool"},
},
{
Name: IpmitoolEventsScriptName,
Script: `LC_ALL=C ipmitool sel elist | tail -n20 | cut -d'|' -f2-`,
Script: `LC_ALL=C timeout 30 ipmitool sel elist | tail -n20 | cut -d'|' -f2-`,
Superuser: true,
Lkms: []string{"ipmi_devintf", "ipmi_si"},
Depends: []string{"ipmitool"},
},
{
Name: IpmitoolEventTimeScriptName,
Script: "LC_ALL=C ipmitool sel time get",
Script: "LC_ALL=C timeout 30 ipmitool sel time get",
Superuser: true,
Depends: []string{"ipmitool"},
},
Expand Down
3 changes: 0 additions & 3 deletions internal/script/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestRunScript(t *testing.T) {
Superuser: superuser,
Lkms: []string{},
Depends: []string{},
Timeout: 0,
}
tempDir, err := os.MkdirTemp(os.TempDir(), "test")
if err != nil {
Expand Down Expand Up @@ -73,7 +72,6 @@ echo "Core Count: $num_cores_per_socket"`,
Superuser: superuser,
Lkms: []string{},
Depends: []string{},
Timeout: 0,
}
tempDir, err = os.MkdirTemp(os.TempDir(), "test")
if err != nil {
Expand Down Expand Up @@ -109,7 +107,6 @@ mpstat -u -T -I SCPU -P ALL 1 $count`,
Superuser: superuser,
Lkms: []string{},
Depends: []string{"mpstat"},
Timeout: 0,
}
tempDir, err := os.MkdirTemp(os.TempDir(), "test")
if err != nil {
Expand Down
Loading