summaryrefslogtreecommitdiffstats
path: root/abs/core/xymon/hobbit_notify.sh
blob: 39e4d4345b31ffb5ba371e146ff89ec262a41ba4 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
. /etc/systemconfig
#
#    BBCOLORLEVEL  - The color of the alert: "red", "yellow" or "purple"
#    BBALPHAMSG    - The full text of the status log triggering the alert
#    ACKCODE       - The "cookie" that can be used to acknowledge the alert
#    RCPT          - The recipient, from the SCRIPT entry
#    BBHOSTNAME    - The name of the host that the alert is about
#    MACHIP        - The IP-address of the host that has a problem
#    BBSVCNAME     - The name of the service that the alert is about
#    BBSVCNUM      - The numeric code for the service. From SVCCODES definition.
#    BBHOSTSVC     - HOSTNAME.SERVICE that the alert is about.
#    BBHOSTSVCCOMMAS - As BBHOSTSVC, but dots in the hostname replaced with commas
#    BBNUMERIC     - A 22-digit number made by BBSVCNUM, MACHIP and ACKCODE.
#    RECOVERED     - Is "1" if the service has recovered.
#    DOWNSECS      - Number of seconds the service has been down.
#    DOWNSECSMSG   - When recovered, holds the text "Event duration : N" where


# echo $BBCOLORLEVEL  > /tmp/hobbitout
# echo $BBALPHAMSG >>/tmp/hobbitout
# echo $RCPT >>/tmp/hobbitout
# echo $BBHOSTNAME >>/tmp/hobbitout
# echo $BBSVCNAME >>/tmp/hobbitout
# echo $BBHOSTSVC >>/tmp/hobbitout

#BBCOLORLEVEL=red
#BBCOLORLEVEL=yellow
#BBALPHAMSG="vmtest:disk red [751147]"
#BBHOSTNAME="testcraa"
#BBSVCNAME="disk"
#BBSVCNAME="func"
#BBHOSTSVC="vmtest.disk"

#/usr/LH/bin/msg_client.py --msg "$BBCOLORLEVEL\n$BBHOSTSVC"
#/usr/bin/func "*" call msg display

function msg_func_out() {
    /usr/bin/func "*" call msg display "${1}"
}

function msg_local_out() {
    /usr/LH/bin/msg_client.py --msg "${1}"
}



case x$BBSVCNAME in

  xdisk)
    case $BBCOLORLEVEL in
        red )
            if [[ $BBALPHAMSG == *"&red / ("* ]]
            then
                msg_func_out "The OS (/) partition on $BBHOSTNAME is over 99% full|alert"
            fi
            if [[ $BBALPHAMSG == *"&red /home ("* ]]
            then
                msg_func_out "The home (/home) partition on $BBHOSTNAME is over 99% full|alert"
            fi
            if [[ $BBALPHAMSG == *"&red /data/srv/mysql ("* ]]
            then
                msg_func_out "The mysql (/data/srv/mysql) partition on $BBHOSTNAME is over 99% full|alert"
            fi
            ;;
        yellow )
            msg_func_out "A disk on $BBHOSTNAME is almost full"
            ;;
  esac
  ;;

  xmemory)
    #do nothing for memory
  ;;

  xfunc)
        if [ "x$hostname" = "x$BBHOSTNAME" ]
        then
            msg_local_out "System can not communicate with itself (func)|alert"
        else
            msg_func_out "$hostname can not communicate with $BBHOSTNAME (func)|alert"
        fi
    ;;

  *)
    #catch all for everything else
    msg_func_out "Condition $BBCOLORLEVEL $BBSVCNAME on $BBHOSTNAME\nSee the system health webpage.|alert"
    ;;
esac