Add /var/log/kern.log to kernel log files.
This file is present in most distros and provides most of the logs we're looking for. We support the others if this one is not available.
This commit is contained in:
parent
8197d35ea2
commit
a5d99c3aa8
@ -16,7 +16,7 @@ package oomparser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -187,17 +187,20 @@ func trySystemd() (*OomParser, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List of possible kernel log files. These are prioritized in order so that
|
||||||
|
// we will use the first one that is available.
|
||||||
|
var kernelLogFiles = []string{"/var/log/kern.log", "/var/log/messages", "/var/log/syslog"}
|
||||||
|
|
||||||
// looks for system files that contain kernel messages and if one is found, sets
|
// looks for system files that contain kernel messages and if one is found, sets
|
||||||
// the systemFile attribute of the OomParser object
|
// the systemFile attribute of the OomParser object
|
||||||
func getSystemFile() (string, error) {
|
func getSystemFile() (string, error) {
|
||||||
const varLogMessages = "/var/log/messages"
|
for _, logFile := range kernelLogFiles {
|
||||||
const varLogSyslog = "/var/log/syslog"
|
if utils.FileExists(logFile) {
|
||||||
if utils.FileExists(varLogMessages) {
|
glog.Infof("OOM parser using kernel log file: %q", logFile)
|
||||||
return varLogMessages, nil
|
return logFile, nil
|
||||||
} else if utils.FileExists(varLogSyslog) {
|
}
|
||||||
return varLogSyslog, nil
|
|
||||||
}
|
}
|
||||||
return "", errors.New("neither " + varLogSyslog + " nor " + varLogMessages + " exists from which to read kernel errors")
|
return "", fmt.Errorf("unable to find any kernel log file available from our set: %v", kernelLogFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initializes an OomParser object and calls getSystemFile to set the systemFile
|
// initializes an OomParser object and calls getSystemFile to set the systemFile
|
||||||
|
Loading…
Reference in New Issue
Block a user