Skip to content

Commit

Permalink
Merge pull request google#664 from vmarmol/ooms
Browse files Browse the repository at this point in the history
Add /var/log/kern.log to kernel log files.
  • Loading branch information
rjnagal committed Apr 24, 2015
2 parents 8197d35 + a5d99c3 commit 3166552
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions utils/oomparser/oomparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package oomparser

import (
"bufio"
"errors"
"fmt"
"io"
"os"
"os/exec"
Expand Down Expand Up @@ -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
// the systemFile attribute of the OomParser object
func getSystemFile() (string, error) {
const varLogMessages = "/var/log/messages"
const varLogSyslog = "/var/log/syslog"
if utils.FileExists(varLogMessages) {
return varLogMessages, nil
} else if utils.FileExists(varLogSyslog) {
return varLogSyslog, nil
for _, logFile := range kernelLogFiles {
if utils.FileExists(logFile) {
glog.Infof("OOM parser using kernel log file: %q", logFile)
return logFile, 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
Expand Down

0 comments on commit 3166552

Please sign in to comment.