File: 789

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (221 lines) | stat: -rwxr-xr-x 5,820 bytes parent folder | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/sh
# PCP QA Test No. 789
# Basic zimbra PMDA checkout
#
# Copyright (c) 2019 Ken McDonell.  All Rights Reserved.
#
# Note: this test stops working every 5 years when the self-signed
# certificates that Zimbra uses expire.
#
# To fix this and renew Zimbra self-signed certs for 5 years
# modified from ..
# https://forums.zimbra.org/viewtopic.php?t=70594
#
# sudo -u zimbra /opt/zimbra/bin/zmcertmgr createca -new
# sudo -u zimbra /opt/zimbra/bin/zmcertmgr deployca
# sudo -u zimbra /opt/zimbra/bin/zmcertmgr createcrt -new -days 1825
# sudo -u zimbra /opt/zimbra/bin/zmcertmgr deploycrt self
# sudo -u zimbra /opt/zimbra/bin/zmcertmgr viewdeployedcrt
# sudo -u zimbra /opt/zimbra/bin/zmcontrol restart
# sudo systemctl restart zimbra
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

zimbra_home=/opt/zimbra
shutdown=false

[ -d $zimbra_home ] || _notrun "Zimbra not installed"

_cleanup()
{
    cd $here
    if $install_on_cleanup
    then
	( cd $PCP_PMDAS_DIR/zimbra; $sudo ./Install </dev/null >/dev/null 2>&1 )
    else
	( cd $PCP_PMDAS_DIR/zimbra; $sudo ./Remove </dev/null >/dev/null 2>&1 )
    fi

    if $shutdown
    then
	echo "Stopping Zimbra: `date`" >>$seq_full
	$sudo systemctl stop zimbra.service
    fi

    $sudo rm -rf $tmp $tmp.*
}

# to find these puppies, for example the mailboxd metrics,
#	sudo head -1 /opt/zimbra/zmstat/mailboxd.csv
# this gives the column names, e.g.
#	timestamp,lmtp_rcvd_msgs,lmtp_rcvd_bytes, .... heap_used,heap_free
#	sudo tail -1 /opt/zimbra/zmstat/mailboxd.csv
# this gives the last values, e.g.
# 	10/08/2020 17:15:37,0,0, ... 98768824,162981960
# So below, zimbra.mailboxd.lmtp.rcvd_msgs is the first metric from a
# row and zimbra.mailboxd.heap.free is last metric from a row.
#	
_check_values()
{
    cat <<End-of-File | while read metric table regex
zimbra.fd_count			fd.csv		fd_count
zimbra.mailboxd_fd_count	fd.csv		mailboxd_fd_count
zimbra.mailboxd.lmtp.rcvd_msgs	mailboxd.csv	lmtp_rcvd_msgs
zimbra.mailboxd.heap.free	mailboxd.csv	heap_free
End-of-File
    do
	echo "--- $metric ---" >>$seq_full
	$sudo head -1 $zimbra_home/zmstat/$table >$tmp.head
	$sudo tail -1 $zimbra_home/zmstat/$table >$tmp.tail
	eval `pmprobe -v $metric \
	      | tee -a $seq_full \
	      | $PCP_AWK_PROG '{ print "numval=" $2
	      			 print "pcp_value=" $3
			       }'
	      `
	cat $tmp.head >>$seq_full
	cat $tmp.tail >>$seq_full
	if [ "$numval" -lt 1 ]
	then
	    echo "Warning: $metric: numval=$numval"
	else
	    column=''
	    eval `$PCP_AWK_PROG -F, <$tmp.head '
    { for (i = 1; i <= NF; i++) {
          if ($i ~ /^ *'$regex'$/) { print "column=" i; exit }
      }
    }' \
		  | sed -e 's/=  */=/'`
	    if [ -z "$column" ]
	    then
		echo "Error: $metric: failed to match column /^ *$regex\$/ from ..."
		cat $tmp.head
	    else
		eval `$PCP_AWK_PROG -F, <$tmp.tail '{ print "csv_value=" $'$column' }' \
		      | sed -e 's/=  */=/'`
		echo "pcp_value=\"$pcp_value\" column=$column csv_value=\"$csv_value\"" >>$seq_full
		if [ "$pcp_value" = "$csv_value" ]
		then
		    echo "$metric: OK"
		else
		    echo "Error: $metric: PCP value: \"$pcp_value\" CSV value: \"csv_value\" field $column from ..."
		    cat $tmp.tail
		fi
	    fi
	fi
    done
}

# the PMDA supports some columns that may not be present, either because
# of a different zimbra version or optional modules ... filter out the
# mismatch warnings
#
_filter()
{
    sed \
	-e '/missing from CSV$/d' \
    # end
}

status=1	# failure is the default!

install_on_cleanup=false
pminfo zimbra >/dev/null 2>&1 && install_on_cleanup=true

trap "_cleanup; exit \$status" 0 1 2 3 15

# Zimbra is such a CPU-hog, that we really would prefer to NOT have
# it running for a PCP build and QA run ... so start it here if needs
# be, but remember state so we can put it back
#
if [ "$PCPQA_SYSTEMD" = yes ]
then
    eval `systemctl show --property=ActiveState zimbra.service 2>/dev/null`
    echo "Initial ActiveState=$ActiveState" >>$seq_full
    if [ "$ActiveState" = active ]
    then
	shutdown=false
    else
	shutdown=true
	echo "Starting Zimbra: `date`" >>$seq_full
	$sudo systemctl start zimbra.service
	sleep 30
    fi 
fi

# real QA test starts here
home=$PCP_PMDAS_DIR
iam=zimbra
if [ ! -d $home/$iam ]
then
    echo "Where is $home/$iam?"
    exit
fi
cd $home/$iam

# start from a known starting point
$sudo ./Remove >/dev/null 2>&1

echo
echo "=== default $iam agent installation ==="
$sudo ./Remove >$tmp.out 2>&1
$sudo ./Install </dev/null >>$tmp.out 2>&1
_filter_pmda_install <$tmp.out \
| _filter \
| $PCP_AWK_PROG '
/Check zimbra metrics have appeared/ { if ($7 >= 0 && $7 <= 200) $7 = "N"
                                         if ($10 >= 10 && $10 <= 200) $10 = "X"
                                       }
                                       { print }'

# CSV files only updated every 30 seconds, so need to wait a while to
# reduce chances of seeing "No values available", and the zimbra java
# apps on vm29 use >80% of the CPU when zimbra is idle (!), so 30 seconds
# ain't long enough
#
max_wait=100
wait=0
while [ $wait -le $max_wait ]
do
    ok=true
    for metric in zimbra.fd_count zimbra.mailboxd_fd_count \
		zimbra.mailboxd.lmtp.rcvd_msgs zimbra.mailboxd.heap.free
    do
	nval=`pmprobe $metric | $PCP_AWK_PROG '{print $2}'`
	echo "wait=$wait metric=$metric nval=$nval" >>$seq_full
	if [ -z "$nval" ]
	then
	    ok=false
	    break
	fi
	if [ $nval -eq 0 ]
	then
	    ok=false
	    break
	fi
    done
    [ $ok = true ] && break
    sleep 10
    wait=`expr $wait + 10`
done

echo
echo "=== validate values ==="
_check_values

echo
echo "=== remove $iam agent ==="
$sudo ./Remove >$tmp.out 2>&1
_filter_pmda_install <$tmp.out \
| _filter

# success, all done
status=0
exit