File: salinfo_shell

package info (click to toggle)
salinfo 0.7-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 196 kB
  • ctags: 596
  • sloc: ansic: 2,256; sh: 126; makefile: 62
file content (37 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

# Usage: salinfo_shell /proc/sal <type> <log_dir>
#
# This script waits for SAL events (mca, init, cmc, or cpe),
# saves the error records in log files, and decodes them.
#
# Example only for testing via shell commands, use salinfo_decode for
# production work.

SALDIR=$1
TYPE=$2
LOGDIR=$3

EVENT=$SALDIR/$TYPE/event
DATA=$SALDIR/$TYPE/data

mkdir -p $LOGDIR

while read ACTION CPU < $EVENT; do
    DATE=`date +%F_%T`
    LOGBASE=$LOGDIR/${DATE}_cpu${CPU}_${TYPE}
    LOGSUFFIX=0
    while([ -e $LOGBASE.$LOGSUFFIX ])
    do
        LOGSUFFIX=`expr $LOGSUFFIX + 1`
    done
    LOG=$LOGBASE.$LOGSUFFIX
    echo $ACTION $CPU > $DATA
    cat $DATA > $LOG
    echo clear $CPU > $DATA
    if [ -s $LOG ]; then
	./decode $LOG
    else
    	rm -f $LOG
    fi
done