|
@@ -9,10 +9,9 @@ groups[group2]="Alice Bob Dave"
|
|
|
|
|
|
ret=0
|
|
|
|
|
|
-check_instances() {
|
|
|
+check_one_log() {
|
|
|
counts="$(grep -Ec "$1" shadow.data/hosts/*/*.stdout | cut -d: -f2 | sort -n)"
|
|
|
- top=$(echo "$counts" | tail -1)
|
|
|
- if [[ $top -lt $2 ]] ; then
|
|
|
+ if [[ $(echo "$counts" | tail -1) -lt $2 ]] ; then
|
|
|
echo "Not enough matches of pattern: $1"
|
|
|
ret=1
|
|
|
fi
|
|
@@ -22,15 +21,27 @@ check_instances() {
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
+check_all_logs() {
|
|
|
+ counts="$(grep -Ec "$1" shadow.data/hosts/*/*.stdout | cut -d: -f2 | sort -n)"
|
|
|
+ if [[ $(echo "$counts" | tail -1) -lt $2 ]] ; then
|
|
|
+ echo "Not enough matches of pattern: $1"
|
|
|
+ ret=1
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
for group in ${!groups[@]} ; do
|
|
|
for name in ${groups[$group]} ; do
|
|
|
echo "$group,$name"
|
|
|
# user sent at least 10 messages to the group
|
|
|
- check_instances "$name,$group,send," 10
|
|
|
+ check_one_log "$name,$group,send," 10
|
|
|
# user got at least 10 receipts from the group
|
|
|
- check_instances "$name,$group,receive,.*,receipt" 10
|
|
|
+ check_one_log "$name,$group,receive,.*,receipt" 10
|
|
|
+ # users got at least 10 receipts from this user in this group
|
|
|
+ check_all_logs "$group,receive,.*,$name,receipt" 10
|
|
|
# user got at least 10 normal messages from the group
|
|
|
- check_instances "$name,$group,receive,.*,[0-9]+" 10
|
|
|
+ check_one_log "$name,$group,receive,.*,[0-9]+" 10
|
|
|
+ # users got at least 10 normal messages from this user in this group
|
|
|
+ check_all_logs "$group,receive,.*,$name,[0-9]+" 10
|
|
|
done
|
|
|
done
|
|
|
|