From ef4598ae11e98eaa8524e4b32573133b848951f7 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Mon, 12 Nov 2012 18:35:56 +0100 Subject: improve performance --- etc/munin/plugins/jenkins_builds_results | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'etc/munin/plugins/jenkins_builds_results') diff --git a/etc/munin/plugins/jenkins_builds_results b/etc/munin/plugins/jenkins_builds_results index 82b8ff73..ab36f1b2 100755 --- a/etc/munin/plugins/jenkins_builds_results +++ b/etc/munin/plugins/jenkins_builds_results @@ -40,7 +40,7 @@ if [ "$1" = "config" ]; then echo 'graph_category jenkins' draw=AREA for PREFIX in $JOB_PREFIXES ; do - for STATE in success unstable failed ; do + for STATE in success unstable failure ; do echo "jenkins_builds_results_${PREFIX}_${STATE}.label ${PREFIX} ${STATE}" echo "jenkins_builds_results_${PREFIX}_${STATE}.draw $draw" if [ "$draw" = "AREA" ] ; then draw=STACK ; fi @@ -50,9 +50,15 @@ if [ "$1" = "config" ]; then fi for PREFIX in $JOB_PREFIXES ; do - for STATE in success unstable failed ; do + PREFIX_RESULTS=$(for i in /var/lib/jenkins/jobs/${PREFIX}*/builds/*_*/log ; do tail -1 $i 2>/dev/null; echo " \n"; done ) + for STATE in success unstable failure ; do NR=0 - NR=$( (for i in /var/lib/jenkins/jobs/${PREFIX}*/builds/*_*/log ; do tail -1 $i 2>/dev/null; done ) | grep -i -c $STATE) - echo "jenkins_builds_results_${PREFIX}_${STATE}.value $NR" + if [ "$STATE" = "failure" ] ; then + # count aborted as failed + NR=$(echo -e "$PREFIX_RESULTS" | egrep -i -c "($STATE|aborted)") + else + NR=$(echo -e "$PREFIX_RESULTS" | grep -i -c $STATE) + fi + echo "jenkins_builds_results_${PREFIX}_${STATE}.value $NR" done done -- cgit v1.2.3-70-g09d2