Skip to content

Commit

Permalink
fix(dmesg): fallback in case "dmesg --since" flag doesn't exist in ol…
Browse files Browse the repository at this point in the history
…der versions (#45)

* fix(dmesg): fallback in case dmesg --since flag doesn't exist

Signed-off-by: Gyuho Lee <[email protected]>

* try

Signed-off-by: Gyuho Lee <[email protected]>

* Revert "try"

This reverts commit a23f9ca.

---------

Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho authored Sep 2, 2024
1 parent d0be7d6 commit 0eb10d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/dmesg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ const DefaultDmesgFile = "/var/log/dmesg"
func DefaultConfig() Config {
scanCommands := [][]string{
{"cat", DefaultDmesgFile},
{"dmesg", "--ctime", "--nopager", "--buffer-size", "163920", "--since", "'1 hour ago'"},

// some old dmesg versions don't support --since, thus fall back to the one without --since and tail the last 200 lines
// ref. https://github.com/leptonai/gpud/issues/32
{"dmesg --ctime --nopager --buffer-size 163920 --since '1 hour ago' || dmesg --ctime --nopager --buffer-size 163920 | tail -n 200"},
}
if _, err := os.Stat(DefaultDmesgFile); os.IsNotExist(err) {
scanCommands = [][]string{
{"dmesg", "--ctime", "--nopager", "--buffer-size", "163920", "--since", "'1 hour ago'"},
// some old dmesg versions don't support --since, thus fall back to the one without --since and tail the last 200 lines
// ref. https://github.com/leptonai/gpud/issues/32
{"dmesg --ctime --nopager --buffer-size 163920 --since '1 hour ago' || dmesg --ctime --nopager --buffer-size 163920 | tail -n 200"},
}
}

Expand Down

0 comments on commit 0eb10d6

Please sign in to comment.