[uyuni-users] Query all System History Event information
Hi all We have State Channels and run them once a day to ensure everything is set up to our guidelines. If one of those events fails or even if it is successful but changes had to be made, I want to know. I can get failed actions using spacecmd schedule_listfailed and more details with schedule_getoutput. However, I haven't been able to identify events that were successful, but had to do changes on the system. The needed information is available in the WebUI in the System History Event (Systems > SystemXY > Events > History > EventXY). First there are the details of the event:
This action will be executed after 5/7/20 10:16:43 AM CEST This action's status is: Completed. The client completed this action on 5/7/20 10:16:48 AM CEST Client execution returned
Then there is a box which says:
Successfully applied state(s): [custom]
Then comes a second box which contains the information I need. It looks something like this: Results: ---------- ID: /etc/environment_TERM Function: file.blockreplace Name: /etc/environment Result: true Comment: Changes were made Started: 10:16:48.450723 Duration: 4.14 SLS: manager_org_2.base_environment Changed: diff: "--- +++ @@ -4,4 +4,5 @@ # Syntax: simple \"KEY=VAL\" pairs on seperate lines # # BLOCK TOP : salt managed zone. Do not edit!! +TERM=xterm \ \ # BLOCK BOTTOM : end of salt managed zone " I also tried to get this information by using the API (system.listSystemEvents() and schedule.listFailedSystems()) but I can't get more than the details about the action and the message from the first box. Any suggestions how I could get to this information by CLI or the API? I tried with Uyuni 4.0.2 and SUSE Manager 4.0.4. Regards, Javier
Hi Javier, Unfortunately, it's not possible currently which means there is no API end point to help you. What I can tell you is that states results are saved in /rhnActionApplyStatesResult/ table. PRs are always welcome though in case you decide to add such API endpoint :-) Best regards, Abid On 5/8/20 11:17 AM, Javier.Flores@gmz.migros.ch wrote:
Hi all
We have State Channels and run them once a day to ensure everything is set up to our guidelines. If one of those events fails or even if it is successful but changes had to be made, I want to know.
I can get failed actions using spacecmd schedule_listfailed and more details with schedule_getoutput. However, I haven’t been able to identify events that were successful, but had to do changes on the system.
The needed information is available in the WebUI in the System History Event (Systems > SystemXY > Events > History > EventXY).
First there are the details of the event:
This action will be executed after 5/7/20 10:16:43 AM CEST This action's status is: Completed. The client completed this action on 5/7/20 10:16:48 AM CEST Client execution returned
Then there is a box which says:
Successfully applied state(s): [custom]
Then comes a second box which contains the information I need. It looks something like this:
Results:
----------
ID: /etc/environment_TERM
Function: file.blockreplace
Name: /etc/environment
Result: true
Comment: Changes were made
Started: 10:16:48.450723
Duration: 4.14
SLS: manager_org_2.base_environment
Changed: diff: "---
+++
@@ -4,4 +4,5 @@
# Syntax: simple \"KEY=VAL\" pairs on seperate lines
#
# BLOCK TOP : salt managed zone. Do not edit!!
+TERM=xterm
\
\ # BLOCK BOTTOM : end of salt managed zone
"
I also tried to get this information by using the API (system.listSystemEvents() and schedule.listFailedSystems()) but I can’t get more than the details about the action and the message from the first box.
Any suggestions how I could get to this information by CLI or the API?
I tried with Uyuni 4.0.2 and SUSE Manager 4.0.4.
Regards,
Javier
-- Abid Mehmood SUSE Linux GmbH Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)
Hi Abid
Thank you for your reply. Unfortunately at this point I don't have the skills to write such an API endpoint.
I wrote a small Python script to get the information from the database. Maybe someone else finds it useful.
https://github.com/seriola/uyuni_scripts/blob/master/check_state_result/chec...
It needs one argument: action_id
There is an optional verbose flag.
With this I can get the results of all "Apply State" Events of the past 24 hours:
for i in $(spacecmd -qy "schedule_list -24h" | grep "Apply states" | sed -e s/\ .*//g); do /path/to/check_state_result.py -id $i; done
Then I can check the output for the string "comment: Changes were made"
Regards,
Javier
Von: Abid Mehmood
This action will be executed after 5/7/20 10:16:43 AM CEST This action's status is: Completed. The client completed this action on 5/7/20 10:16:48 AM CEST Client execution returned
Then there is a box which says:
Successfully applied state(s): [custom]
Then comes a second box which contains the information I need. It looks something like this: Results: ---------- ID: /etc/environment_TERM Function: file.blockreplace Name: /etc/environment Result: true Comment: Changes were made Started: 10:16:48.450723 Duration: 4.14 SLS: manager_org_2.base_environment Changed: diff: "--- +++ @@ -4,4 +4,5 @@ # Syntax: simple \"KEY=VAL\" pairs on seperate lines # # BLOCK TOP : salt managed zone. Do not edit!! +TERM=xterm \ \ # BLOCK BOTTOM : end of salt managed zone " I also tried to get this information by using the API (system.listSystemEvents() and schedule.listFailedSystems()) but I can't get more than the details about the action and the message from the first box. Any suggestions how I could get to this information by CLI or the API? I tried with Uyuni 4.0.2 and SUSE Manager 4.0.4. Regards, Javier -- Abid Mehmood SUSE Linux GmbH Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)
Hello
I have also made a note to implement this after Summer.
Thank you
Pau Garcia Quiles
SUSE Manager Product Owner & Technical Project Manager
SUSE Software Solutions Spain
________________________________
De: Javier.Flores@gmz.migros.ch
This action will be executed after 5/7/20 10:16:43 AM CEST This action's status is: Completed. The client completed this action on 5/7/20 10:16:48 AM CEST Client execution returned
Then there is a box which says:
Successfully applied state(s): [custom]
Then comes a second box which contains the information I need. It looks something like this: Results: ---------- ID: /etc/environment_TERM Function: file.blockreplace Name: /etc/environment Result: true Comment: Changes were made Started: 10:16:48.450723 Duration: 4.14 SLS: manager_org_2.base_environment Changed: diff: "--- +++ @@ -4,4 +4,5 @@ # Syntax: simple \"KEY=VAL\" pairs on seperate lines # # BLOCK TOP : salt managed zone. Do not edit!! +TERM=xterm \ \ # BLOCK BOTTOM : end of salt managed zone " I also tried to get this information by using the API (system.listSystemEvents() and schedule.listFailedSystems()) but I can’t get more than the details about the action and the message from the first box. Any suggestions how I could get to this information by CLI or the API? I tried with Uyuni 4.0.2 and SUSE Manager 4.0.4. Regards, Javier -- Abid Mehmood SUSE Linux GmbH Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 21284 (AG Nürnberg)
participants (3)
-
Abid Mehmood
-
Javier.Flores@gmz.migros.ch
-
Pau Garcia Quiles