[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 5 commits: djm: initial support for documenting web UI actions
Holger Levsen (@holger)
gitlab at salsa.debian.org
Sun Apr 9 15:28:00 BST 2023
Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net
Commits:
0ed53617 by Holger Levsen at 2023-04-09T15:20:57+02:00
djm: initial support for documenting web UI actions
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
253e7541 by Holger Levsen at 2023-04-09T15:23:54+02:00
djm: add helpful error message when trying to powercycle ionos nodes without the required environment variables
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
af2d863a by Holger Levsen at 2023-04-09T16:03:59+02:00
djm-logparser: sort actions and reasons by prevalence
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
71c6fa5b by Holger Levsen at 2023-04-09T16:25:52+02:00
djm-logparser: stop using bc
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
cab79e65 by Holger Levsen at 2023-04-09T16:27:48+02:00
djm-logparser: slight output improvements
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
2 changed files:
- bin/djm
- bin/djm-logparser
Changes:
=====================================
bin/djm
=====================================
@@ -26,6 +26,8 @@ CONFIRM=false
if [ -z "$TARGET" ] ; then
FAIL_REASON="${FAIL_REASON}Undefined target.\n"
else case $TARGET in
+ .) TARGET="."
+ ;;
all) TARGET="$(./nodes/list_nodes )"
;;
*) TARGET="$(./nodes/list_nodes | egrep $TARGET || true)"
@@ -42,6 +44,7 @@ case $ACTION in
p|powercycle) ACTION=powercycle ; CONFIRM=true ;;
a|autoremove) ACTION=autoremove ;;
s|shell) ACTION=shell ;;
+ j|jenkins-ui) ACTION=jenkins-ui ;;
*) FAIL_REASON="${FAIL_REASON}Undefined action.\n"
;;
esac
@@ -52,6 +55,8 @@ case $REASON in
dj) REASON="debug job problems" ;;
rm) REASON="regular maintenance" ;;
cs) REASON="clock skew" ;;
+ hb) REASON="host is back" ;;
+ ho) REASON="host is overloaded" ;;
*) FAIL_REASON="${FAIL_REASON}Undefined reason.\n"
;;
esac
@@ -62,6 +67,16 @@ else
DRY_MODE=true
fi
+#
+# some targets only allow specific actions
+#
+
+if [ "$TARGET" = "." ] && [ "$ACTION" != "jenkins-ui" ] ; then
+ FAIL_REASON="${FAIL_REASON}Target '.' can only be used with action 'jenkins-ui'.\n"
+elif [ "$TARGET" != "." ] && [ "$ACTION" = "jenkins-ui" ] ; then
+ FAIL_REASON="${FAIL_REASON}Action 'jenkins-ui' can only be used with target '.'.\n"
+fi
+
#
# display help text in case of problems (or no params given)
#
@@ -72,9 +87,11 @@ if [ -n "$FAIL_REASON" ] ; then
echo
echo "TARGET=\$1 'all' or grepable (jenkins, amd64, ionos, osuosl3) from ./nodes/list_nodes"
echo "ACTION=\$2 r_eboot, _p_owercycle, _a_utoremove, _s_shell (for manual maintenance)"
- echo "REASON=\$3 ku=kernel update, np=no pings, dj=debug job problems, rm=regular maintenance, cs=clock skew"
+ echo "REASON=\$3 ku=kernel update, np=no pings, dj=debug job problems, rm=regular maintenance, cs=clock skew, hb=host back, ho=host overloaded"
# TODO
# create osuosl tickets
+ # document jenkins plugin updates
+ # document other jenkins ui actions
echo "DRY_RUN=\$4 optional to force dry-run mode"
echo
echo params given:
@@ -109,7 +126,11 @@ fi
if $DRY_MODE || $CONFIRM ; then
for NODE in $TARGET ; do
- SHORTNODE=$(echo $NODE | cut -d '.' -f1)
+ if [ "$NODE" != "." ] ; then
+ SHORTNODE=$(echo $NODE | cut -d '.' -f1)
+ else
+ SHORTNODE="jenkins web UI"
+ fi
echo "$(date -u '+%Y-%m-%d %H:%M UTC'), $SHORTNODE, $ACTION, $REASON"
done
fi
@@ -143,7 +164,11 @@ get_arch_color() {
LOGDATE="$(date -u '+%Y-%m-%d %H:%M UTC')"
for NODE in $TARGET ; do
- SHORTNODE=$(echo $NODE | cut -d '.' -f1)
+ if [ "$NODE" != "." ] ; then
+ SHORTNODE=$(echo $NODE | cut -d '.' -f1)
+ else
+ SHORTNODE="jenkins web UI"
+ fi
echo "$(date -u '+%Y-%m-%d %H:%M UTC'), $SHORTNODE, $ACTION, $REASON"
get_arch_color $NODE
#
@@ -174,6 +199,10 @@ EOF
jenkins) ./bin/powercycle_x86_nodes.py jenkins
;;
ionos*) node=$(echo $NODE | cut -b 6- | cut -d '-' -f1)
+ if [ -z "$IONOS_USERNAME" ] || [ -z "$IONOS_PASSWORD" ] ; then
+ echo "Environment variables IONOS_USERNAME and IONOS_PASSWORD must be set. Exiting."
+ exit 1
+ fi
./bin/powercycle_x86_nodes.py $node
;;
*) echo FIXME, not yet implemented.
@@ -185,6 +214,8 @@ EOF
;;
shell) xterm -T "$SHORTNODE / shell" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh $NODE" &
;;
+ jenkins-ui) echo "Documenting one manual action in the jenkins-ui."
+ ;;
*) echo unsupported action, sorry, please improve.
exit 1
;;
=====================================
bin/djm-logparser
=====================================
@@ -28,13 +28,16 @@ seperator() {
#
TOTAL=$(grep -c $LOGMONTH $LOGFILE)
+HOSTS=$(cut -d ',' -f2 $LOGFILE | sort -u | grep -v "web UI"| wc -l)
HOURS=$(cut -b 1-13 $LOGFILE | sort -u | wc -l)
TEN_MIN_SLICES=$(cut -b 1-15 $LOGFILE | sort -u | wc -l)
TWENTY_MIN_SLICES=$(( TEN_MIN_SLICES + TEN_MIN_SLICES ))
-SLICES_AS_HOURS=$(echo "scale=2 ; $TWENTY_MIN_SLICES/3"|bc||echo 0)
-HOSTS=$(cut -d ',' -f2 $LOGFILE | sort -u | wc -l)
-ACTIONS=$(cut -d ',' -f3 $LOGFILE |sort -u|sed -s "s# #_#g")
-REASONS=$(cut -d ',' -f4 $LOGFILE |sort -u|sed -s "s# #_#g")
+SLICES_AS_HOURS=$(($TWENTY_MIN_SLICES/3))
+# create sorted list of actions/reasons (sorted by amount of occurances)
+# the character '%" is solely used as a delimeter for cut later
+# the character '_' is added so later we can use a for-loop without dealing with $IFS
+ACTIONS=$(cut -d ',' -f3 $LOGFILE | sort | sed 's#^#%#g'| uniq -c | sort -nr | cut -d '%' -f2| sed -s "s# #_#g")
+REASONS=$(cut -d ',' -f4 $LOGFILE | sort | sed 's#^#%#g'| uniq -c | sort -nr | cut -d '%' -f2| sed -s "s# #_#g")
echo "Still very simple statistics for djm logs at $LOGFILE in $LOGMONTH"
echo
@@ -44,17 +47,18 @@ echo " so expect changes for some time."
echo
echo
printf "$TWO_C" "djm actions:" "$TOTAL"
-printf "$TWO_C" "hours with djm usage:" "$HOURS"
+printf "$TWO_C" "hosts maintained:" "$HOSTS"
+seperator
+printf "$TWO_C" "hours with djm usage:" "${HOURS}h"
printf "$TWO_C" " ten minute slices with djm usage:" "$TEN_MIN_SLICES"
printf "$TWO_C" " twenty minute slices (because focus):" "$TWENTY_MIN_SLICES"
-printf "$TWO_C" " thoses slices as hours:" "$SLICES_AS_HOURS"
-printf "$TWO_C" "hosts maintained:" "$HOSTS"
+printf "$TWO_C" " thoses slices as hours:" "${SLICES_AS_HOURS}h"
seperator
for action in $ACTIONS ; do
grep_action="$(echo $action | sed -s 's#_# #g' | xargs echo)"
AMOUNT=$(cut -d ',' -f3 $LOGFILE |grep "$grep_action"|wc -l)
- PERCENT=$(echo "scale=2 ; $AMOUNT/$TOTAL*100"|bc||echo 0)
+ PERCENT=$((200*$AMOUNT/$TOTAL % 2 + 100*$AMOUNT/$TOTAL))
printf "$THREE_C" "$grep_action actions:" "$PERCENT%" "($AMOUNT / $TOTAL)"
done
seperator
@@ -62,7 +66,7 @@ seperator
for reason in $REASONS ; do
grep_reason="$(echo $reason | sed -s 's#_# #g' | xargs echo)"
AMOUNT=$(cut -d ',' -f4 $LOGFILE |grep "$grep_reason"|wc -l)
- PERCENT=$(echo "scale=2 ; $AMOUNT/$TOTAL*100"|bc||echo 0)
+ PERCENT=$((200*$AMOUNT/$TOTAL % 2 + 100*$AMOUNT/$TOTAL))
printf "$THREE_C" "$grep_reason reasons:" "$PERCENT%" "($AMOUNT / $TOTAL)"
done
seperator
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/01e8279cb59c20373f46544ff2d64c192bfdd776...cab79e658d7163ca180989086fb0adcca76cb3ab
--
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/01e8279cb59c20373f46544ff2d64c192bfdd776...cab79e658d7163ca180989086fb0adcca76cb3ab
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20230409/753cae50/attachment-0001.htm>
More information about the Qa-jenkins-scm
mailing list