+# calcPriority <outfile> <failures>
+# returns an Opsgenie priority string
+# If all devies fail return P1, otherwise stick with P3.
+calcPriority() {
+ local outfile="${1}"
+ local failures="${2}"
+ local priority="P3"
+ local numWR="$(grep -c cLink ${outfile})"
+ # to be able to count with grep, we've to have our pattern ones per line
+ local numFailed=$(echo "${failures}"| tr ' ' '\n' | grep -c 'WR')
+
+ if [ "${numWR}" -eq "${numFailed}" ]; then
+ priority="P1"
+ fi
+
+ echo "${priority}"
+}
+