PI Services

Le blog des collaborateurs de PI Services

Orchestrator – Requête du dernier status de tout les runbooks

Cette requête SQL affiche le dernier status d’exécution de tout les runbooks d’une instance, triés par dernière date d’exécution.

--***REQUETES DES DERNIERS STATUS D'EXECUTION DE TOUT LES RUNBOOKS TRIES PAR DATE D'EXECUTION AVEC UN FILTRE SUR LE NOM DES RUNBOOKS ***/ --*** NB: Ajouter un critere sur RL.Name pour un job spécifique (ex: RL.Name = 'My_job') USE ORCHESTRATOR SELECT RL.Name as RunbookName, MAX(RI.CompletionTime)as dernieredate INTO TEMP_ALL_JOB_LAST_STATUS FROM [Orchestrator].[Microsoft.SystemCenter.Orchestrator.Runtime].RunbookInstances as RI INNER JOIN [Orchestrator].[Microsoft.SystemCenter.Orchestrator].Runbooks as RL ON RL.Id=RI.RunbookId WHERE ((RL.Name NOT LIKE '%OLD%') AND (RL.Name NOT LIKE '%TEST%')) GROUP BY RL.Name ORDER BY RL.Name; SELECT RunbookName, dernieredate as Derniere_date_Execution, RI.Status as Dernier_Status FROM [Orchestrator].[Microsoft.SystemCenter.Orchestrator.Runtime].RunbookInstances as RI INNER JOIN [Orchestrator].[Microsoft.SystemCenter.Orchestrator].Runbooks as RL ON RL.Id=RI.RunbookId INNER JOIN TEMP_ALL_JOB_LAST_STATUS ON TEMP_ALL_JOB_LAST_STATUS.RunbookName=RL.Name and dernieredate = RI.CompletionTime ORDER BY Derniere_date_Execution DESC GO DROP TABLE TEMP_ALL_JOB_LAST_STATUS

Orchestrator : Requête de l’état des dernières instances de job.

 

Voici une requête a exécuter sur l’instance SQL de votre serveur orchestrator pour récupérer l’état de la dernière exécution d’une liste de runbooks

Vous pouvez de-commenter (—) la clause WHERE pour exclure certain nom de runbook ou encore choisir une des clauses ORDER BY pour choisir un critère de tri.

USE ORCHESTRATOR SELECT RL.Name as RunbookName, MAX(RI.CompletionTime)as dernieredate INTO MyTableau FROM [Orchestrator].[Microsoft.SystemCenter.Orchestrator.Runtime].RunbookInstances as RI INNER JOIN [Orchestrator].[Microsoft.SystemCenter.Orchestrator].Runbooks as RL ON RL.Id=RI.RunbookId --WHERE RL.Name NOT LIKE '%TEST%' GROUP BY RL.Name ORDER BY RL.Name; --ORDER BY MAX(RI.CompletionTime) DESC, RL.Name --ORDER BY LastStatus DESC SELECT RunbookName, dernieredate as Derniere_date_Execution, RI.Status FROM [Orchestrator].[Microsoft.SystemCenter.Orchestrator.Runtime].RunbookInstances as RI INNER JOIN [Orchestrator].[Microsoft.SystemCenter.Orchestrator].Runbooks as RL ON RL.Id=RI.RunbookId INNER JOIN MyTableau ON MyTableau.RunbookName=RL.Name and dernieredate = RI.CompletionTime; GO DROP TABLE MyTableau