diff options
author | Pablo Fernández Rodríguez <pafernan@redhat.com> | 2024-03-05 09:52:13 +0100 |
---|---|---|
committer | Jake Hunsaker <jacob.r.hunsaker@gmail.com> | 2024-03-05 21:37:06 -0500 |
commit | 7d4a0b67f5b2a4c2c64ea518cc361ef13b8e1cd0 (patch) | |
tree | de91ebb3f7a6802f80964830ad0a8c60d13d4be5 | |
parent | 8cec60768490d00ba9d06a15d4588258c7aec269 (diff) | |
download | sos-7d4a0b67f5b2a4c2c64ea518cc361ef13b8e1cd0.tar.gz |
foreman plugin: Sort by started_at foreman_tasks_tasks table
Closes: #3552
Signed-off-by: Pablo Fernández Rodríguez <pafernan@redhat.com>
use f-strings
Signed-off-by: Pablo Fernández Rodríguez <pafernan@redhat.com>
-rw-r--r-- | sos/report/plugins/foreman.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sos/report/plugins/foreman.py b/sos/report/plugins/foreman.py index 3b13fe65..c0394f58 100644 --- a/sos/report/plugins/foreman.py +++ b/sos/report/plugins/foreman.py @@ -185,6 +185,7 @@ class Foreman(Plugin): def collect_foreman_db(self): """ Collect foreman db and dynflow data """ days = '%s days' % self.get_option('days') + interval = quote(days) # Construct the DB queries, using the days option to limit the range # of entries returned @@ -194,28 +195,29 @@ class Foreman(Plugin): "'%(pass|key|secret)%'" ) + dtaskcmd = ('select * from foreman_tasks_tasks where started_at > ' + f'NOW() - interval {interval} order by started_at asc') + dyncmd = ( 'select dynflow_execution_plans.* from foreman_tasks_tasks join ' 'dynflow_execution_plans on (foreman_tasks_tasks.external_id = ' 'dynflow_execution_plans.uuid::varchar) where foreman_tasks_tasks.' - 'started_at > NOW() - interval %s' % quote(days) - ) + f'started_at > NOW() - interval {interval} order by ' + 'foreman_tasks_tasks.started_at asc') dactioncmd = ( 'select dynflow_actions.* from foreman_tasks_tasks join ' 'dynflow_actions on (foreman_tasks_tasks.external_id = ' 'dynflow_actions.execution_plan_uuid::varchar) where ' - 'foreman_tasks_tasks.started_at > NOW() - interval %s' - % quote(days) - ) + f'foreman_tasks_tasks.started_at > NOW() - interval {interval} ' + 'order by foreman_tasks_tasks.started_at asc') dstepscmd = ( 'select dynflow_steps.* from foreman_tasks_tasks join ' 'dynflow_steps on (foreman_tasks_tasks.external_id = ' 'dynflow_steps.execution_plan_uuid::varchar) where ' - 'foreman_tasks_tasks.started_at > NOW() - interval %s' - % quote(days) - ) + f'foreman_tasks_tasks.started_at > NOW() - interval {interval} ' + 'order by foreman_tasks_tasks.started_at asc') # counts of fact_names prefixes/types: much of one type suggests # performance issues @@ -247,7 +249,7 @@ class Foreman(Plugin): # Same as above, but tasks should be in CSV output foremancsv = { - 'foreman_tasks_tasks': 'select * from foreman_tasks_tasks', + 'foreman_tasks_tasks': dtaskcmd, 'dynflow_execution_plans': dyncmd, 'dynflow_actions': dactioncmd, 'dynflow_steps': dstepscmd, |