Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pretty sort for foreman tasks #144

Open
meteryam opened this issue Jan 26, 2024 · 0 comments
Open

pretty sort for foreman tasks #144

meteryam opened this issue Jan 26, 2024 · 0 comments

Comments

@meteryam
Copy link

meteryam commented Jan 26, 2024

When I look at the file "sos_commands/foreman/foreman_tasks_tasks", I like to sort it with this command:

# cat sosreport-*/sos_commands/foreman/foreman_tasks_tasks | tr ',' '|' | sort -t "|" -k 4 | awk -F"|" '{print $1 "|" $4 "|" $6 "|" $7 "|" $12 }' | sed 's/^[ \t]*//;s/[ \t]*$//'

However, that does only show start times, so this command might or might not occasionally be helpful instead (this shows both start and end times):

# cat sosreport-*/sos_commands/foreman/foreman_tasks_tasks | tr ',' '|' | sort -t "|" -k 4 | awk -F"|" '{print $1 "|" $4 "|" $5 "|" $6 "|" $7 "|" $12 }' | sed 's/^[ \t]*//;s/[ \t]*$//'

My fork currently has these bits of code under the ## foreman section:

			log "// Tasks TOP"
			log "from file \$base_dir/sos_commands/foreman/foreman_tasks_tasks"
			log "---"
			#log_cmd "grep Actions $base_dir/sos_commands/foreman/foreman_tasks_tasks  | cut -d, -f3 | sed 's/^[ \t]*//;s/[ \t]*$//' | sort -k 7 | tail -100 | egrep --color=always '^|paused|running|error|pending|warning|scheduled' | sed s'/  //'g"
			tasks_top=`grep Actions $base_dir/sos_commands/foreman/foreman_tasks_tasks | tr ',' '|' | sort -t "|" -k 10 | head -50 | awk -F"|" '{print $1, "|", $4, "|", $6, "|", $7, "|", $12}' | sed 's/^[ \t]*//;s/[ \t]*$//' | egrep --color=always '^|error|warning|paused'`
			log "$tasks_top"
			log "---"
			log


			log "// Failed Tasks TOP"
			log "from file \$base_dir/sos_commands/foreman/foreman_tasks_tasks"
			log "---"
#			failed_tasks_top=`grep Actions $base_dir/sos_commands/foreman/foreman_tasks_tasks | egrep -v "success|running|scheduled" | tr ',' '|' | sort -t "|" -k 10 | head -50 | awk -F"|" '{print $1, "|", $4, "|", $6, "|", $7, "|", $12}' | sed 's/^[ \t]*//;s/[ \t]*$//'`
			failed_tasks_top=`grep Actions $base_dir/sos_commands/foreman/foreman_tasks_tasks | egrep -v 'success|running|scheduled' | tr ',' '|' | sort -t "|" -k 10 | head -50 | awk -F"|" '{print $1, "|", $4, "|", $6, "|", $7, "|", $12}' | sed 's/^[ \t]*//;s/[ \t]*$//' | egrep --color=always '^|error|warning|paused|pending'`
			log "$failed_tasks_top"
			log "---"
			log

			log "// paused foreman tasks"
			log "grepping foreman_tasks_tasks for paused tasks"
			log "---"
#			log_cmd "grep -E '(^                  id|paused)' $base_dir/sos_commands/foreman/foreman_tasks_tasks | sed 's/  //g' | sed -e 's/ |/|/g' | sed -e 's/| /|/g' | sed -e 's/^ //g' | sed -e 's/|/,/g' | tr ',' '|' | sort -t '|' -k 3"
			tasks_paused=`grep Actions $base_dir/sos_commands/foreman/foreman_tasks_tasks | egrep paused | tr ',' '|' | sort -t "|" -k 10 | head -50 | awk -F"|" '{print $1, "|", $4, "|", $6, "|", $7, "|", $12}' | sed 's/^[ \t]*//;s/[ \t]*$//' | egrep --color=always '^|error|warning|paused'`
			log "$tasks_paused"
			log "---"
			log

			log "// invalid foreman tasks"
			log "grepping foreman_tasks_tasks for paused tasks"
			log "---"
#			log_cmd "grep -E '(^                  id|paused)' $base_dir/sos_commands/foreman/foreman_tasks_tasks | sed 's/  //g' | sed -e 's/ |/|/g' | sed -e 's/| /|/g' | sed -e 's/^ //g' | sed -e 's/|/,/g' | tr ',' '|' | sort -t '|' -k 3"
			tasks_invalid=`grep Actions $base_dir/sos_commands/foreman/foreman_tasks_tasks | egrep pending | tr ',' '|' | sort -t "|" -k 10 | egrep stopped | head -50 | awk -F"|" '{print $1, "|", $4, "|", $6, "|", $7, "|", $12}' | sed 's/^[ \t]*//;s/[ \t]*$//'`
			log "$tasks_invalid"
			log "---"
			log
			log "Note:  An invalid task status is the status 'pending|stopped'."
			log

It could be helpful, if you're interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant