예: 파일 업로드를 위한 이벤트 정책 구성
이 예에서는 분석을 위해 지정된 위치에 관련 파일을 업로드하는 이벤트 정책 작업을 구성합니다.
요구 사항
시작하기 전에:
이벤트 정책에서 참조할 대상을 구성합니다. 예: 이벤트 정책별 파일 아카이빙 대상 정의를 참조하십시오.
일반 이벤트 정책 및 트리거 이벤트를 구성합니다.
개요
이벤트 정책 작업에서 출력 파일을 생성하면 나중에 분석할 수 있도록 파일을 보관할 수 있습니다. 마찬가지로 이벤트 발생 시점부터 시스템 로그 파일, 코어 파일 및 구성 파일을 포함한 시스템 파일을 보관할 수 있습니다. 기존 시스템 파일을 업로드하거나 이벤트 발생 시 호출된 이벤트 스크립트 또는 명령에서 생성된 출력 파일을 업로드하도록 이벤트 정책을 구성할 수 있습니다. 이 섹션에서는 이벤트 정책을 사용하여 이러한 각 출력 파일을 업로드하는 데 필요한 구성을 간략하게 설명합니다.
파일을 업로드하도록 이벤트 정책을 구성하면 디바이스는 해당 이벤트 정책 작업에 대해 구성된 문에서 참조되는 destination
위치에 관련 파일을 업로드합니다. 계층 수준에서 구성된 [edit event-options destinations]
대상 이름을 지정해야 합니다.
이 예제에서 은(는) policy1
다음 문으로 구성되며, 여기서 e1 는 트리거 이벤트입니다. 그런 다음 로그 파일 및 커밋된 구성 파일뿐만 아니라 및 event-script
작업에서 생성된 execute-commands
출력 파일을 업로드하도록 이벤트 정책을 구성합니다.
[edit event-options policy policy1] events e1; then { execute-commands { commands { "show interfaces brief ge-*"; } } event-script event-script1; }
구성
CLI 빠른 구성
이 예를 빠르게 구성하려면, 아래 명령을 복사하여 텍스트 파일로 붙여 넣은 다음 모든 라인브레이크를 제거하고, 네트워크 구성을 일치하는 데 필요한 세부 사항을 변경한 다음, 계층 수준에서 명령을 CLI [edit]
에 복사하여 붙여 넣습니다.
set event-options policy policy1 then upload filename /var/log/messages destination mgmt-archives transfer-delay 4 set event-options policy policy1 then upload filename /var/log/messages destination mgmt-archives retry-count 5 retry-interval 4 set event-options policy policy1 then upload filename /var/log/messages destination mgmt-archives user-name admin set event-options policy policy1 then upload filename /var/log/messages destination mgmt-server set event-options policy policy1 then upload filename committed destination mgmt-archives set event-options policy policy1 then execute-commands output-filename ge-interfaces set event-options policy policy1 then execute-commands destination mgmt-archives transfer-delay 5 set event-options policy policy1 then execute-commands destination mgmt-archives retry-count 5 retry-interval 4 set event-options policy policy1 then event-script event-script1 output-filename policy1-script-output set event-options policy policy1 then event-script event-script1 destination mgmt-archives transfer-delay 5 set event-options policy policy1 then event-script event-script1 destination mgmt-archives retry-count 5 retry-interval 4
시스템 파일 업로드
단계별 절차
시스템 파일 /var/log/messages를 아카이브 사이트 mgmt-archives 및 mgmt-server에 업로드하도록 이벤트 정책을 policy1
구성합니다. 또한 커밋된 구성을 아카이브 사이트 mgmt-archives에 업로드합니다. 대상 보관 사이트는 계층 수준에서 이미 구성되어 [edit event-options destinations]
있어야 합니다
명령문을
upload
구성하고 아카이브할 파일과 대상 아카이브 사이트를 포함합니다.[edit event-options policy policy1 then] bsmith@R1# set upload filename /var/log/messages destination mgmt-archives bsmith@R1# set upload filename /var/log/messages destination mgmt-server
커밋된 구성 파일을 업로드하려면 파일 이름 값을 커밋됨으로 지정합니다.
[edit event-options policy policy1 then] bsmith@R1# set upload filename committed destination mgmt-archives
-
(선택 사항) 각 파일 및 대상과 관련된 전송 지연을 구성합니다.
다음 명령은 /var/log/messages 파일이 mgmt-archives 대상에 업로드될 때 4초의 전송 지연을 구성합니다. 대상에 대한 전송 지연도 구성하는 경우, 총 지연은 두 지연의 합계입니다.
[edit event-options policy policy1 then] bsmith@R1# set upload filename /var/log/messages destination mgmt-archives transfer-delay 4
-
(선택 사항) 각 파일 및 대상과 관련된 재시도 횟수 및 재시도 간격을 구성합니다.
이 예에서 /var/log/messages 파일이 mgmt-archives 사이트에 업로드되지 않으면 시스템은 업로드를 최대 5회 더 시도하고 각 시도 사이에 4초 동안 대기합니다.
[edit event-options policy policy1 then] bsmith@R1# set upload filename /var/log/messages destination mgmt-archives retry-count 5 retry-interval 4
-
(선택 사항) 파일의 업로드 작업을 위한 사용자 이름을 구성합니다. 시스템은 지정된 사용자의 권한을 사용하여 파일을 업로드합니다.
[edit event-options policy policy1 then] bsmith@R1# set upload filename /var/log/messages destination mgmt-archives user-name admin
구성을 커밋합니다.
[edit event-options policy policy1 then] bsmith@R1# commit
명령 출력 파일 업로드
단계별 절차
이벤트 정책이 작업을 호출 execute-commands
하면 명령 출력을 파일에 쓸 수 있습니다. 명령 출력을 파일에 기록하고 생성된 파일을 계층 수준에서 이미 구성되어 있는 대상 mgmt-archives에 업로드하도록 [edit event-options destinations]
이벤트 정책을 policy1
구성합니다.
-
출력 파일의 파일 이름에 포함될 설명 문자열을 정의합니다.
[edit event-options policy policy1 then] bsmith@R1# set execute-commands output-filename ge-interfaces
-
destination
생성된 파일을 지정된 아카이브 사이트에 업로드하도록 명령문을 구성합니다.[edit event-options policy policy1 then] bsmith@R1# set execute-commands destination mgmt-archives
-
(선택 사항) 업로드 작업에 대한 전송 지연을 구성합니다(이 예에서는 5초).
[edit event-options policy policy1 then] bsmith@R1# set execute-commands destination mgmt-archives transfer-delay 5
-
(선택 사항) 업로드 작업에 대한 재시도 횟수 및 재시도 간격을 구성합니다.
이 예제에서 업로드 작업이 실패하면 시스템은 업로드를 최대 5회 더 시도하고 각 시도 사이에 4초 동안 대기합니다.
[edit event-options policy policy1 then] bsmith@R1# set execute-commands destination mgmt-archives retry-count 5 retry-interval 4
구성을 커밋합니다.
[edit event-options policy policy1 then] bsmith@R1# commit
이벤트 스크립트 출력 파일 업로드
단계별 절차
이벤트 정책이 이벤트 스크립트를 호출하면 스크립트 출력을 파일에 쓸 수 있습니다. 이벤트 정책을 policy1
구성하여 이벤트 스크립트 출력을 파일에 기록하고 생성된 파일을 계층 수준에서 이미 구성되어 있는 대상 mgmt-archives에 업로드합니다 [edit event-options destinations]
. 이 예제에서 이벤트 정책은 event-script1이라는 이벤트 스크립트를 호출합니다.
-
출력 파일의 파일 이름에 포함될 설명 문자열을 정의합니다.
[edit event-options policy policy1 then] bsmith@R1# set event-script event-script1 output-filename policy1-script-output
destination
생성된 파일을 원하는 아카이브 사이트에 업로드하도록 명령문을 구성합니다.[edit event-options policy policy1 then] bsmith@R1# set event-script event-script1 destination mgmt-archives
-
(선택 사항) 업로드 작업에 대한 전송 지연을 구성합니다(이 예에서는 5초).
[edit event-options policy policy1 then] bsmith@R1# set event-script event-script1 destination mgmt-archives transfer-delay 5
-
(선택 사항) 업로드 작업에 대한 재시도 횟수 및 재시도 간격을 구성합니다.
이 예에서 업로드가 실패하면 시스템은 업로드를 최대 5회 더 시도하고 각 시도 사이에 4초 동안 대기합니다.
[edit event-options policy policy1 then] bsmith@R1# set event-script event-script1 destination mgmt-archives retry-count 5 retry-interval 4
구성을 커밋합니다.
[edit event-options policy policy1 then] bsmith@R1# commit
결과
[edit event-options policy policy1 then] upload filename /var/log/messages destination mgmt-archives { user-name admin; transfer-delay 4; retry-count 5 retry-interval 4; } upload filename /var/log/messages destination mgmt-server upload filename committed destination mgmt-archives; execute-commands { commands { "show interfaces brief ge-*"; } output-filename ge-interfaces; destination mgmt-archives { transfer-delay 5; retry-count 5 retry-interval 4; } } event-script event-script1 { output-filename policy1-script-output; destination mgmt-archives { transfer-delay 5; retry-count 5 retry-interval 4; } }
확인
업로드 확인
목적
구성된 이벤트가 이벤트 정책을 트리거하면 시스템은 생성된 출력 파일과 지정된 시스템 파일을 mgmt-archives 대상에 정의된 URL에 업로드합니다. 대상 서버에서 모든 파일이 업로드되었는지 확인합니다.
작업
대상 서버에서 업로드된 모든 파일이 있는지 확인합니다.
% ls R1_20111209_213452_ge-interfaces R1_20111209_213409_juniper.conf.gz R1_20111209_212941_messages R1_20111209_212619_policy1-script-output
의미
각 파일의 파일 이름 형식에는 장치 이름, 파일 이름, 날짜 및 시간 스탬프가 포함됩니다.
업로드된 파일이 모두 있는 경우 이벤트 정책 및 업로드 작업이 올바르게 작동하는 것입니다. 업로드된 파일이 없는 경우 대상이 구성되어 있고 보관 사이트 URL 및 필요한 암호가 올바르게 입력되었는지 확인합니다. 대상 구성에 대한 자세한 내용은 예: 이벤트 정책에 의한 파일 아카이빙의 대상 정의를 참조하십시오. 파일의 일부가 누락된 경우 더 긴 전송 지연을 구성하고 해당 파일의 재시도 횟수 및 재시도 간격을 늘립니다.