Skip to content

Commit

Permalink
readme update; couple minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryran committed Jul 23, 2015
1 parent ba5ce55 commit bbc7977
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
- With no args, inspects most recent startup
- Use `--verbose` or `-v` to see the 2 relevant log entries

![a1](http://people.redhat.com/rsawhill/rebooty-v0.2.x-a1.png)
![a1](http://people.redhat.com/rsawhill/rebooty-v0.3.x-a1.png)

- Use `--all` or `-a` to inspect all events in log file (which defaults to `/var/log/messages` -- there's an option to change that as well)
- Use `--glob` or `-g` to search through older logs too (e.g., `/var/log/messages*`)

![a2](http://people.redhat.com/rsawhill/rebooty-v0.2.x-a2.png)
![a2](http://people.redhat.com/rsawhill/rebooty-v0.3.x-a2.png)

- Use `--lines` or `-n` to see arbitrary number of lines before startup event

![a3](http://people.redhat.com/rsawhill/rebooty-v0.2.x-a3.png)
![a3](http://people.redhat.com/rsawhill/rebooty-v0.3.x-a3.png)

- Use `--event` or `-e` to specify a single startup event number to inspect (defaults to showing 40 lines but obviously that can be overridden with `-n`)

![a4](http://people.redhat.com/rsawhill/rebooty-v0.3.x-a4.png)

- Pass a directory to run against sosreports
- Use `--event` or `-e` to specify a single startup event number to inspect (defaults to showing 40 lines)

![b1](http://people.redhat.com/rsawhill/rebooty-v0.2.x-b1.png)
![b1](http://people.redhat.com/rsawhill/rebooty-v0.3.x-b1.png)

### Install

Expand All @@ -26,6 +29,11 @@ yum/dnf install http://people.redhat.com/rsawhill/rpms/latest-rsawaroha-release.
yum/dnf install Rebooty-inspector
```

### Written in bash? With awk? Why not python?

- I want this to be able to run live on RHEL 5 & 6 & 7 machines, as well as on files/sosreports
- I started to play with python but v2.6 (RHEL 5 & 6) is a frigg'n mess and I couldn't handle it
- In the end, the job is perfect for `tac` + `gawk`

### Help page describes all features

Expand Down Expand Up @@ -77,6 +85,6 @@ Many things that aren't configurable with options can be tweaked with
environment variables (including log messages sent with --logit).
Reference variables names declared at the start of the script.
Version info: Rebooty-inspector v0.2.0 last mod 2015/07/21
Version info: Rebooty-inspector v0.3.0 last mod 2015/07/23
Contact rsaw@redhat.com or <github.com/ryran/Rebooty-inspector>
```
15 changes: 8 additions & 7 deletions Rebooty-inspector
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ version=$(gawk 'NR==2{print;exit}' "${0}")
: ${logTag:="$app"}
: ${logSuccess:="Most recent boot follows graceful shutdown"}
: ${logFailure:="MOST RECENT BOOT FOLLOWS UNGRACEFUL SHUTDOWN"}
: ${tag_beginFile:="Preceded by unknown: reached beginning of input -- no log entries"}
: ${tag_beginFile:="Reached beginning of input -- ran out of log entries"}
: ${tag_eventSeperator:="\n"}
: ${tag_noMatch:="Input contained 0 boot events matching regex:"}

Expand Down Expand Up @@ -130,13 +130,13 @@ autodetect_rhel5_syslog_type() {
chkconfigOutput=$(chkconfig --list syslog; chkconfig --list rsyslog)
rpmOutput=$(rpm -q rsyslog rsyslog5 2>/dev/null)
elif [[ -r ${rootDir}/chkconfig && -r ${rootDir}/installed-rpms ]]; then
chkconfigOutput=$(awk '$1 ~ /^r?syslog$/' <"${rootDir}"/chkconfig)
rpmOutput=$(awk '/^rsyslog(-3|5-)/' <"${rootDir}"/installed-rpms)
chkconfigOutput=$(gawk '$1 ~ /^r?syslog$/' <"${rootDir}"/chkconfig)
rpmOutput=$(gawk '/^rsyslog(-3|5-)/' <"${rootDir}"/installed-rpms)
else
err "${app}: unable to read chkconfig/installed-rpms to determine syslog type!"
exit 4
fi
_type=$(awk '$5 ~ /on/ {print $1}' <<<"${chkconfigOutput}")
_type=$(gawk '$5 ~ /on/ {print $1}' <<<"${chkconfigOutput}")
case ${_type} in
syslog)
printf "${D}Log format detected as sysklogd${Z}\n"
Expand Down Expand Up @@ -250,14 +250,14 @@ parse_positional_params() {
TMPDIR=$(mktemp -d -p ${parent})
gawkFile=${TMPDIR}/gawkFile
if [[ ${debug} == 1 ]]; then
err "DEBUG: awk script @ ${gawkFile}"
err "DEBUG: gawk script @ ${gawkFile}"
else
trap "rm -rf ${TMPDIR} 2>/dev/null" INT TERM EXIT
fi

cat >${gawkFile} <<\EOF
function getline_err(id) {
printf " %s❔ %s %s%s\n", YELLOW, tag_beginFile, id, zero
printf " %s? %s %s%s\n", yellow, tag_beginFile, id, zero
}
function cprint(startColor, input) {
printf "%s%s%s\n", startColor, input, zero
Expand Down Expand Up @@ -382,7 +382,7 @@ $0 ~ RE_kernelVers {
}
END {
if (eventNum == 0) {
printf "%s%s %s%s\n", YELLOW, tag_noMatch, RE_first, zero
printf "%s%s\n %s%s\n", YELLOW, tag_noMatch, RE_first, zero
exit(7)
}
}
Expand Down Expand Up @@ -436,6 +436,7 @@ get_input |
-v PURPLE="${P}" \
-v blue="${b}" \
-v BLUE="${B}" \
-v yellow="${y}" \
-v YELLOW="${Y}" \
-v zero="${Z}" \
-f "${gawkFile}"
Expand Down

0 comments on commit bbc7977

Please sign in to comment.