summaryrefslogtreecommitdiff
path: root/bytemark/bin/custodian-enqueue-parse-test
blob: 9f072e6b90b9687714df111d6398c8131215b87a (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
#!/bin/sh
#
# Parse the configuration files we use, and alert if there is a failure.
#
# Steve
# --



#
#  Find the hostname of the mauve-server to alert against
#
if [ -e /etc/custodian/custodian.cfg ] ; then
    alert=$(grep ^mauve_target /etc/custodian/custodian.cfg 2>/dev/null | awk -F= '{print $2}' )
fi


#
#  If we didn't find one then we'll use the default.
#
if [ -z "$alert" ]; then
    alert=alert.bytemark.co.uk
fi


#
#  For each file.
#
for file in bytemark.cfg managed-clients.cfg ; do

    #
    #  If we cannot parse ..
    #
    if ( ! custodian-enqueue --test --file /etc/custodian/$file >/dev/null 2>/dev/null );  then

        #
        #  Raise an alert.
        #
        mauvesend $alert -i custodian-enqueue-$file -r now -s "Parse failure from custodian-enqueue against $file." --detail="<p>The file was not added to the queue successfully due to syntax error.  Please fix.</p>"
    else

        #
        #  Otherwise clear any prior alert.
        #
        mauvesend $alert -i custodian-enqueue-$file -c now -s "Parse failure from custodian-enqueue against $file." --detail="<p>The file was not added to the queue successfully due to syntax error.  Please fix.</p>"
    fi

done