summaryrefslogtreecommitdiff
path: root/sysutils/ipmitool/files/status-ipmi.sh.in
blob: 51fd00d0cd4d623f36b5567dc1b954b9c0230747 (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#
# Check status of IPMI sensors and System Event Log
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

sdr_list_args=${daily_status_ipmi_sdr_list_args:-}
sel_list_args=${daily_status_ipmi_sel_list_args:-}
sel_cap_warn_pct=${daily_status_ipmi_sel_cap_warn_pct:-80}

ipmitool=%%PREFIX%%/bin/ipmitool

rc=0

case "${daily_status_ipmi_enable}" in
    [Yy][Ee][Ss])
        if [ ! -x $ipmitool ]; then
          echo "\$daily_status_ipmi_enable is set but ${ipmitool}" \
               "isn't executable"
          exit 2
        fi

        echo ""
        echo "Checking IPMI sensors:"

        $ipmitool sdr list $sdr_list_args && rc=1 || rc=3

        echo ""
        echo "Checking IPMI System Event Log:"

        info=`$ipmitool sel info` || exit 3
        used=$(echo "${info}" | awk '/Percent Used/{print 0 + $4}')
        entries=$(echo "${info}" | awk '/Entries/{print 0 + $3}')

        if [ $used -gt $sel_cap_warn_pct ]; then
           echo "  SEL is at ${used}% capacity"
           rc=3
        fi

        last=`cat /var/db/ipmi-sel-count 2>/dev/null || echo 0`

        if [ $entries -gt $last ]; then
          echo $entries > /var/db/ipmi-sel-count
          echo ""
          if [ "$sel_list_args" ]; then
            $ipmitool sel list $sel_list_args
          else
            count=$(($entries-$last))
            $ipmitool sel list last $count
          fi
          rc=3
        fi
        ;;
    *)
        rc=0
        ;;
esac

exit $rc