Tutorial: Visualizza le informazioni sulle finestre di manutenzione utilizzando il AWS CLI - AWS Systems Manager

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Tutorial: Visualizza le informazioni sulle finestre di manutenzione utilizzando il AWS CLI

Questo tutorial include comandi che consentono di aggiornare o ottenere informazioni su finestre di manutenzione, task, esecuzioni e invocazioni. Gli esempi sono organizzati per comando, per dimostrare come utilizzare le opzioni dei comandi per filtrare il tipo di dettaglio che si desidera visualizzare.

Mentre segui i passaggi di questo tutorial, sostituisci i valori in corsivo red testo con le tue opzioni e. IDs Ad esempio, sostituisci l'ID della finestra di manutenzione mw-0c50858d01EXAMPLE e l'ID dell'istanza i-02573cafcfEXAMPLE insieme IDs di risorse che crei.

Per informazioni sull'impostazione e la configurazione di AWS Command Line Interface (AWS CLI), vedere Installazione, aggiornamento e disinstallazione di AWS CLI e Configurazione di. AWS CLI

Esempi di '' describe-maintenance-windows

Elenca tutte le finestre di manutenzione del tuo Account AWS

Esegui il comando seguente.

aws ssm describe-maintenance-windows

Questo sistema restituisce informazioni simili alle seguenti.

{
   "WindowIdentities":[
      {
         "WindowId":"mw-0c50858d01EXAMPLE",
         "Name":"My-First-Maintenance-Window",
         "Enabled":true,
         "Duration":2,
         "Cutoff":0,
         "NextExecutionTime": "2019-05-18T17:01:01.137Z"        
      },
      {
         "WindowId":"mw-9a8b7c6d5eEXAMPLE",
         "Name":"My-Second-Maintenance-Window",
         "Enabled":true,
         "Duration":4,
         "Cutoff":1,
         "NextExecutionTime": "2019-05-30T03:30:00.137Z"        
      },
   ]
}
Elenca tutte le finestre di manutenzione abilitate

Esegui il comando seguente.

aws ssm describe-maintenance-windows --filters "Key=Enabled,Values=true"

Questo sistema restituisce informazioni simili alle seguenti.

{
   "WindowIdentities":[
      {
         "WindowId":"mw-0c50858d01EXAMPLE",
         "Name":"My-First-Maintenance-Window",
         "Enabled":true,
         "Duration":2,
         "Cutoff":0,
         "NextExecutionTime": "2019-05-18T17:01:01.137Z"        
      },
      {
         "WindowId":"mw-9a8b7c6d5eEXAMPLE",
         "Name":"My-Second-Maintenance-Window",
         "Enabled":true,
         "Duration":4,
         "Cutoff":1,
         "NextExecutionTime": "2019-05-30T03:30:00.137Z"        
      },
   ]
}
Elenca tutte le finestre di manutenzione disabilitate

Esegui il comando seguente.

aws ssm describe-maintenance-windows --filters "Key=Enabled,Values=false"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "WindowIdentities": [
        {
            "WindowId": "mw-6e5c9d4b7cEXAMPLE",
            "Name": "My-Disabled-Maintenance-Window",
            "Enabled": false,
            "Duration": 2,
            "Cutoff": 1
        }
    ]
}
Elenca tutte le finestre di manutenzione con nomi che iniziano con un determinato prefisso

Esegui il comando seguente.

aws ssm describe-maintenance-windows --filters "Key=Name,Values=My"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "WindowIdentities": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "Enabled": true,
            "Duration": 2,
            "Cutoff": 0,
            "NextExecutionTime": "2019-05-18T17:01:01.137Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "Enabled": true,
            "Duration": 4,
            "Cutoff": 1,
            "NextExecutionTime": "2019-05-30T03:30:00.137Z"
        },
        {
            "WindowId": "mw-6e5c9d4b7cEXAMPLE",
            "Name": "My-Disabled-Maintenance-Window",
            "Enabled": false,
            "Duration": 2,
            "Cutoff": 1
        }
    ]
}

Esempi di 'describe-maintenance-window-targets'

Visualizza le destinazioni di una finestra di manutenzione che corrispondono a un determinato valore delle informazioni dello specifico proprietario

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-targets \ --window-id "mw-6e5c9d4b7cEXAMPLE" \ --filters "Key=OwnerInformation,Values=CostCenter1"
Windows
aws ssm describe-maintenance-window-targets ^ --window-id "mw-6e5c9d4b7cEXAMPLE" ^ --filters "Key=OwnerInformation,Values=CostCenter1"
Nota

Le chiavi di filtro supportate sono Type, WindowTargetId e OwnerInformation.

Questo sistema restituisce informazioni simili alle seguenti.

{
    "Targets": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowTargetId": "e32eecb2-646c-4f4b-8ed1-205fbEXAMPLE",
            "ResourceType": "INSTANCE",
            "Targets": [
                {
                    "Key": "tag:Name",
                    "Values": [
                        "Production"
                    ]
                }
            ],
            "OwnerInformation": "CostCenter1",
            "Name": "Target1"
        }
    ]
}

Esempi per 'describe-maintenance-window-tasks'

Mostra tutte le attività registrate che richiamano il documento di SSM comando AWS-RunPowerShellScript

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-tasks \ --window-id "mw-0c50858d01EXAMPLE" \ --filters "Key=TaskArn,Values=AWS-RunPowerShellScript"
Windows
aws ssm describe-maintenance-window-tasks ^ --window-id "mw-0c50858d01EXAMPLE" ^ --filters "Key=TaskArn,Values=AWS-RunPowerShellScript"

Questo sistema restituisce informazioni simili alle seguenti.

{
   "Tasks":[
      {
         "ServiceRoleArn": "arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
         "MaxErrors":"1",
         "TaskArn":"AWS-RunPowerShellScript",
         "MaxConcurrency":"1",
         "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
         "TaskParameters":{
            "commands":{
               "Values":[
                  "driverquery.exe"
               ]
            }
         },
         "Priority":3,
         "Type":"RUN_COMMAND",
         "Targets":[
            {
               "TaskTargetId":"i-02573cafcfEXAMPLE",
               "TaskTargetType":"INSTANCE"
            }
         ]
      },
      {
         "ServiceRoleArn":"arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
         "MaxErrors":"1",
         "TaskArn":"AWS-RunPowerShellScript",
         "MaxConcurrency":"1",
         "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
         "TaskParameters":{
            "commands":{
               "Values":[
                  "ipconfig"
               ]
            }
         },
         "Priority":1,
         "Type":"RUN_COMMAND",
         "Targets":[
            {
               "TaskTargetId":"i-02573cafcfEXAMPLE",
               "TaskTargetType":"WINDOW_TARGET"
            }
         ]
      }
   ]
}
Mostra tutte le attività registrate che hanno una priorità di "3"

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-tasks \ --window-id "mw-9a8b7c6d5eEXAMPLE" \ --filters "Key=Priority,Values=3"
Windows
aws ssm describe-maintenance-window-tasks ^ --window-id "mw-9a8b7c6d5eEXAMPLE" ^ --filters "Key=Priority,Values=3"

Questo sistema restituisce informazioni simili alle seguenti.

{
   "Tasks":[
      {
         "ServiceRoleArn":"arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
         "MaxErrors":"1",
         "TaskArn":"AWS-RunPowerShellScript",
         "MaxConcurrency":"1",
         "WindowTaskId":"4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
         "TaskParameters":{
            "commands":{
               "Values":[
                  "driverquery.exe"
               ]
            }
         },
         "Priority":3,
         "Type":"RUN_COMMAND",
         "Targets":[
            {
               "TaskTargetId":"i-02573cafcfEXAMPLE",
               "TaskTargetType":"INSTANCE"
            }
         ]
      }
   ]
}
Mostra tutte le attività registrate che hanno una priorità di "1" e utilizzano Run Command

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-tasks \ --window-id "mw-0c50858d01EXAMPLE" \ --filters "Key=Priority,Values=1" "Key=TaskType,Values=RUN_COMMAND"
Windows
aws ssm describe-maintenance-window-tasks ^ --window-id "mw-0c50858d01EXAMPLE" ^ --filters "Key=Priority,Values=1" "Key=TaskType,Values=RUN_COMMAND"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "Tasks": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowTaskId": "4f7ca192-7e9a-40fe-9192-5cb15EXAMPLE",
            "TaskArn": "AWS-RunShellScript",
            "Type": "RUN_COMMAND",
            "Targets": [
                {
                    "Key": "InstanceIds",
                    "Values": [
                        "i-02573cafcfEXAMPLE"
                    ]
                }
            ],
            "TaskParameters": {},
            "Priority": 1,
            "ServiceRoleArn": "arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
            "MaxConcurrency": "1",
            "MaxErrors": "1"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowTaskId": "8a5c4629-31b0-4edd-8aea-33698EXAMPLE",
            "TaskArn": "AWS-UpdateSSMAgent",
            "Type": "RUN_COMMAND",
            "Targets": [
                {
                    "Key": "InstanceIds",
                    "Values": [
                        "i-0471e04240EXAMPLE"
                    ]
                }
            ],
            "TaskParameters": {},
            "Priority": 1,
            "ServiceRoleArn": "arn:aws:iam::111122223333:role/MyMaintenanceWindowServiceRole",
            "MaxConcurrency": "1",
            "MaxErrors": "1",
            "Name": "My-Run-Command-Task",
            "Description": "My Run Command task to update SSM Agent on an instance"
        }
    ]
}

Esempi di '-target' describe-maintenance-windows-for

Elenca le informazioni sulle destinazioni della finestra di manutenzione o sui task associati a un nodo specifico.

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-windows-for-target \ --resource-type INSTANCE \ --targets "Key=InstanceIds,Values=i-02573cafcfEXAMPLE" \ --max-results 10
Windows
aws ssm describe-maintenance-windows-for-target ^ --resource-type INSTANCE ^ --targets "Key=InstanceIds,Values=i-02573cafcfEXAMPLE" ^ --max-results 10

Questo sistema restituisce informazioni simili alle seguenti.

{
    "WindowIdentities": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window"
        }
    ]
}

Esempi per '' describe-maintenance-window-executions

Visualizza tutte le attività eseguite prima di una determinata data

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-executions \ --window-id "mw-9a8b7c6d5eEXAMPLE" \ --filters "Key=ExecutedBefore,Values=2019-05-12T05:00:00Z"
Windows
aws ssm describe-maintenance-window-executions ^ --window-id "mw-9a8b7c6d5eEXAMPLE" ^ --filters "Key=ExecutedBefore,Values=2019-05-12T05:00:00Z"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "WindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "14bea65d-5ccc-462d-a2f3-e99c8EXAMPLE",
            "Status": "FAILED",
            "StatusDetails": "The following SSM parameters are invalid: LevelUp",
            "StartTime": 1557617747.993,
            "EndTime": 1557617748.101
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "WindowExecutionId": "791b72e0-f0da-4021-8b35-f95dfEXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557594085.428,
            "EndTime": 1557594090.978
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "ecec60fa-6bb0-4d26-98c7-140308EXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557593793.483,
            "EndTime": 1557593798.978
        }
    ]
}
Elenca tutte le attività eseguite dopo una determinata data

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-executions \ --window-id "mw-9a8b7c6d5eEXAMPLE" \ --filters "Key=ExecutedAfter,Values=2018-12-31T17:00:00Z"
Windows
aws ssm describe-maintenance-window-executions ^ --window-id "mw-9a8b7c6d5eEXAMPLE" ^ --filters "Key=ExecutedAfter,Values=2018-12-31T17:00:00Z"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "WindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "14bea65d-5ccc-462d-a2f3-e99c8EXAMPLE",
            "Status": "FAILED",
            "StatusDetails": "The following SSM parameters are invalid: LevelUp",
            "StartTime": 1557617747.993,
            "EndTime": 1557617748.101
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "WindowExecutionId": "791b72e0-f0da-4021-8b35-f95dfEXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557594085.428,
            "EndTime": 1557594090.978
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "WindowExecutionId": "ecec60fa-6bb0-4d26-98c7-140308EXAMPLE",
            "Status": "SUCCESS",
            "StartTime": 1557593793.483,
            "EndTime": 1557593798.978
        }
    ]
}

Esempi per 'describe-maintenance-window-schedule'

Visualizza le prossime dieci esecuzioni programmate della finestra di manutenzione per un determinato nodo.

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-schedule \ --resource-type INSTANCE \ --targets "Key=InstanceIds,Values=i-07782c72faEXAMPLE" \ --max-results 10
Windows
aws ssm describe-maintenance-window-schedule ^ --resource-type INSTANCE ^ --targets "Key=InstanceIds,Values=i-07782c72faEXAMPLE" ^ --max-results 10

Questo sistema restituisce informazioni simili alle seguenti.

{
    "ScheduledWindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-05-18T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-05-25T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-06-01T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-06-08T23:35:24.902Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "ExecutionTime": "2019-06-15T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-06-22T23:35:24.902Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "ExecutionTime": "2019-06-29T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-07-06T23:35:24.902Z"
        },
        {
            "WindowId": "mw-9a8b7c6d5eEXAMPLE",
            "Name": "My-Second-Maintenance-Window",
            "ExecutionTime": "2019-07-13T23:35:24.902Z"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "My-First-Maintenance-Window",
            "ExecutionTime": "2019-07-20T23:35:24.902Z"
        }
    ],
    "NextToken": "AAEABUXdceT92FvtKld/dGHELj5Mi+GKW/EXAMPLE"
}
Visualizza la pianificazione della finestra di manutenzione per le nodi taggati con una determinata coppia chiave-valore

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-schedule \ --resource-type INSTANCE \ --targets "Key=tag:prod,Values=rhel7"
Windows
aws ssm describe-maintenance-window-schedule ^ --resource-type INSTANCE ^ --targets "Key=tag:prod,Values=rhel7"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "ScheduledWindowExecutions": [
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-20T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-21T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-22T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-23T05:34:56-07:00"
        },
        {
            "WindowId": "mw-0c50858d01EXAMPLE",
            "Name": "DemoRateStartDate",
            "ExecutionTime": "2019-10-24T05:34:56-07:00"
        }
    ],
    "NextToken": "AAEABccwSXqQRGKiTZ1yzGELR6cxW4W/EXAMPLE"
}
Visualizza gli orari di inizio delle prossime quattro esecuzioni di una finestra di manutenzione

Esegui il comando seguente.

Linux & macOS
aws ssm describe-maintenance-window-schedule \ --window-id "mw-0c50858d01EXAMPLE" \ --max-results "4"
Windows
aws ssm describe-maintenance-window-schedule ^ --window-id "mw-0c50858d01EXAMPLE" ^ --max-results "4"

Questo sistema restituisce informazioni simili alle seguenti.

{
    "WindowSchedule": [
        {
            "ScheduledWindowExecutions": [
                {
                    "ExecutionTime": "2019-10-04T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                },
                {
                    "ExecutionTime": "2019-10-11T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                },
                {
                    "ExecutionTime": "2019-10-18T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                },
                {
                    "ExecutionTime": "2019-10-25T10:10:10Z",
                    "Name": "My-First-Maintenance-Window",
                    "WindowId": "mw-0c50858d01EXAMPLE"
                }
            ]
        }
    ]
}