Skip to content

pretty sort for foreman tasks #144

Description

@meteryam

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions