OpManager를 Freshservice와 통합하여 경고를 Freshservice에서 집계된 기록으로 추적하고 처리하여 문제를 빠르게 이해하고 해결할 수 있습니다.
Freshservice에서의 구성:
1단계:
관리자 패널로 이동하여 IT 운영 관리로 스크롤한 후 모니터링 도구를 선택합니다.
계정에 워크스페이스가 여러 개 있는 경우, 관리자 > {워크스페이스 이름} > IT 운영 관리> 모니터링 도구로 이동합니다.
2단계:
이제 모니터링 도구 목록 페이지에 있습니다. 모니터링 도구 추가를 선택하여 새 통합을 추가합니다.
3단계
사전 구성된 통합 목록, 웹훅을 사용한 사용자 정의 통합의 게이트웨이, 경고를 위한 이메일 채널 사용 옵션을 볼 수 있습니다. OpManager를 선택합니다.
4단계
OpManager에 대한 엔드포인트 URL과 인증 키를 얻으려면 통합 설정을 따르십시오.
웹훅을 사용한 OpManager 구성:
1. OpManager에 로그인하고 설정 -> 알림 -> 알림 프로필로 이동합니다.
2. 알림 프로필 페이지에서 새 프로필을 생성하고 "웹훅 호출"을 선택합니다.
3. Hook URL 드롭다운에서 "POST"를 선택하고 드롭다운 후 텍스트 상자에 Freshservice 통합을 복사하여 붙여넣습니다.
4. 데이터 유형을 "raw"로 변경합니다.
5. 페이로드 유형을 "JSON"으로 변경합니다.
6. 본문 내용에 아래 컨텍스트를 붙여넣습니다.
{
"resource": "$displayName",
"metric_name": "$MonitorField(monitorName)",
"severity" : "$stringseverity",
"message": "$message",
"category": "$category",
"event_type": "$eventType",
"entity": "$entity",
"timestamp": "$strModTime",
"value": "$lastPolledValue",
"ip_address": "$DeviceField(ipAddress)",
"device_type": "$DeviceField(type)"
}7. 헤더 이름을 "Authorization"으로 하여 새 요청 헤더를 추가하고 Freshservice 통합에서 인증 키를 헤더 값에 복사합니다.
8. 자체 기준을 설정합니다.
9. 장치를 선택합니다.
10. 시간 창, 지연 트리거 및 반복 트리거를 구성합니다.
11. "테스트 경고"를 클릭하여 통합을 테스트합니다. 이것은 Freshservice에 테스트 경고를 보내야 합니다.
12. 위의 변경 사항을 저장하고 닫습니다.
13. OpManager는 Freshservice에 경고를 보내고 자동으로 해결할 수 있어야 합니다.
Powershell 스크립트를 사용한 OpManager 구성:
사전 요구 사항:
이 통합은 Windows 머신에서 실행 중인 OpManager에만 가능합니다.
1. Windows 버전의 경우, Powershell 스크립트가 OpManager가 설치된 서버/머신에 있어야 합니다.
2. Windows 서버에 Powershell 버전 4 이상이 있어야 합니다.
3. Powershell은 실행(RemoteSigned/Unrestricted) 권한이 있어야 합니다.
4. 아래 스크립트를 텍스트 파일에 복사하여 붙여넣고 확장자를 .ps1로 설정하여 알림을 보내기 위한 Powershell 스크립트를 생성합니다.
5. 스크립트에서 인증 토큰과 엔드포인트 URL을 Freshservice에서 복사한 값으로 대체합니다.
# This will send a REST api request to Freshservice AMS module.
# metric_name, resource and entity combination forms the business key of the alert.
# amsAuthKey has to be replaced with the value copied from Freshservice
# amsURL: has to be replaced with the endpoint URL copied from Freshservice
#input parameters from Webhook/script action
Param(
[string]$resource,
[string]$metric_name,
[string]$severity,
[string]$message,
[string]$category,
[string]$event_type,
[string]$entity,
[string]$value,
[string]$ip_address,
[string]$timestamp,
[string]$device_type,
[string]$amsURL = "https://testbyruban.alerts.freshcmdb.com/integrations/53545/alerts?auth-key=eyJhbGciOiJIUzI1NiJ9.eyJhX2lkIjo1MTMzLCJzX2lkIjoxMCwidHMiOjE2Njc4ODA2NDAuMzM2MDYzNH0.PAmVagJHLMiewkaBsjmoypKPIzVhOOGxC2J4r2kR3k0"
)
try {
Write-Host "FS:Starting..."
if ($metric_name -eq '') {
$metric_name = $entity
}
Write-Host "FS:After check..."
#RestAPI headers
$AuthHeader = @{
"Content-Type" = "application/json";
}
Write-Host "FS:After header construction..."
#payload construction
$jsondata = @{
resource = $resource;
metric_name = $metric_name;
severity = $severity;
message = $message;
category = $category;
event_type = $event_type;
entity = $entity;
value = $value;
ip_address = $ip_address;
timestamp = $timestamp;
device_type = $device_type;
description = $message;
}
Write-Host "FS:After payload construction..."
#remove empty keys
($jsondata.GetEnumerator() | ? { -not $_.Value }) | % { $jsondata.Remove($_.Name) }
Write-Host "FS:After removing empty entities..."
#convert to json object
$Body = ConvertTo-Json $jsondata
Write-Host $Body
#To Fix UnauthorizedAccess due to TLS protocol version
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
# Freshservice AMS restapi call
Invoke-RestMethod -Method Post -Uri $amsURL -Headers $AuthHeader -Body $Body;
exit 0;
}
Catch {
$ErrorMessage = $_.Exception.Message
Write-Host "Error: " $ErrorMessage
}알림 프로필 추가
OpManager 웹 UI에 로그인합니다.
설정 -> 알림 메뉴로 이동합니다. "추가" 버튼을 클릭하여 새 알림 프로필을 생성합니다.
알림 프로필 유형으로 "프로그램 실행"을 선택합니다.
명령 이름 및 프로그램 인수를 아래와 같이 추가합니다:
명령 이름:
명령 이름은 다음 형식이어야 합니다
Powershell.exe -file <알림을 위한 Powershell 스크립트 파일 경로>
예:
powershell.exe -file D:\Build\Opmanager_notification\AlertNotification.ps1
인수:
-resource "$displayName" -metric_name "$MonitorField(monitorName)" -severity "$stringseverity" -message "$message" -category "$category" -event_type "$eventType" -entity "$entity" -timestamp "$strModTime" -value "$lastPolledValue" -ip_address "$DeviceField(ipAddress)" -device_type "$DeviceField(type)"
다음을 클릭하고 알림을 실행하기 위한 적용 가능한 기준을 선택합니다.
필요한 옵션을 선택한 후 다음을 클릭합니다.
"알림 프로필 연결"에서 적용 가능한 장치 또는 URL을 선택합니다. 우리의 경우 모니터링 URL을 선택합니다.
다음을 클릭하고 "시간 창" 화면으로 이동합니다. 기본적으로 우리는 24x7 모니터링 중입니다.
다음을 클릭합니다. "프로그램 실행" 요약 페이지가 표시됩니다.
프로필 이름을 추가하고 페이지를 저장합니다.
알림 프로필을 테스트하려면 "작업 테스트" 버튼을 클릭합니다.
이제 Freshservice에서 경고를 수신할 준비가 되었습니다.
문제 해결:
경고가 생성되지 않은 경우, 명령 프롬프트에서 실행하여 PS 스크립트 파일을 테스트합니다:
아래 예제에서 powershell.exe 경로와 알림 스크립트 경로를 적절히 대체합니다.
C:\integration\opmanager_notification> powershell.exe -file C:\integration\opmanager_notification\AlertNotification.ps1 -resource "Mailserver1" -metric_name "CPUUtilization" -message "CPU greater than 80%" -category "Poll" -event_type "Threshold" -entity "MailServer1 CPU2" -timestamp "123455444" -value "80%" -ip_address "10.10.1.108" -device_type "Server" -severity "Critical"
2. Powershell 스크립트가 실행되지 않는 경우, 명령 프롬프트에서 다음을 실행해야 합니다.
PS > Set-ExecutionPolicy RemoteSigned –Force
PS > start-job { Set-ExecutionPolicy RemoteSigned -Force } -RunAs32


