File check_puppet_agent-use_sudo_for_awk.patch of Package monitoring-plugins-puppet_agent

--- check_puppet_agent.orig	2014-04-13 14:46:40.365651118 +0200
+++ check_puppet_agent	2014-04-13 14:49:41.581447089 +0200
@@ -142,7 +142,7 @@
 fi
 
 # check when last run happened
-last_run=$(awk '/last_run:/ {print $2}' ${lastrunfile})
+last_run=$(sudo awk '/last_run:/ {print $2}' ${lastrunfile})
 last_run_human=$(date -d @${last_run} +%c)
 now=$(date +%s)
 time_since_last=$((now-last_run))
@@ -152,7 +152,7 @@
 # check last_run_report.yaml for errors
 lastrunreport=$(sudo /usr/bin/puppet config print lastrunreport)
 if [ -f ${lastrunreport} ]; then
-	last_run_log=$(awk '
+	last_run_log=$(sudo awk '
 /^  [^ ]/ { inside = 0 }
 /^  logs:/ { inside = 1 }
 inside == 1 {
@@ -164,11 +164,11 @@
 fi
 
 # get some more info from the yaml file
-config=$(awk '/config:/ {print $2}' ${lastrunfile})
-version=$(awk '/puppet:/ {print $2}' ${lastrunfile})
-failed=$(awk '/failed:/ {print $2}' ${lastrunfile})
-failure=$(awk '/failure:/ {print $2}' ${lastrunfile})
-failed_to_restart=$(awk '/failed_to_restart:/ {print $2}' ${lastrunfile})
+config=$(sudo awk '/config:/ {print $2}' ${lastrunfile})
+version=$(sudo awk '/puppet:/ {print $2}' ${lastrunfile})
+failed=$(sudo awk '/failed:/ {print $2}' ${lastrunfile})
+failure=$(sudo awk '/failure:/ {print $2}' ${lastrunfile})
+failed_to_restart=$(sudo awk '/failed_to_restart:/ {print $2}' ${lastrunfile})
 
 # if any of the values above doesn't return raise an error
 [ -z "${last_run}" -o -z "${config}" -o -z "${version}" -o -z "${failed}" -o -z "${failure}" -o -z "${failed_to_restart}" ] && result 1
openSUSE Build Service is sponsored by