Telegraf의 Plugin을 이용하면 특정 Process를 monitoring 할 수 있습니다.
1. Telegraf의 설정파일내의 procstat을 수정합니다.
# # Monitor process cpu and memory usage [[inputs.procstat]] # ## PID file to monitor process # pid_file = "/var/run/nginx.pid" # ## executable name (ie, pgrep <exe>) # # exe = "nginx" # ## pattern as argument for pgrep (ie, pgrep -f <pattern>) pattern = "telegraf" # ## user as argument for pgrep (ie, pgrep -u <user>) # # user = "nginx" # ## Systemd unit name # # systemd_unit = "nginx.service" # ## CGroup name or path # # cgroup = "systemd/system.slice/nginx.service" # # ## Windows service name # # win_service = "" # # ## override for process_name # ## This is optional; default is sourced from /proc/<pid>/status # # process_name = "bar" # # ## Field name prefix # # prefix = "" # # ## When true add the full cmdline as a tag. # # cmdline_tag = false # # ## Add PID as a tag instead of a field; useful to differentiate between # ## processes whose tags are otherwise the same. Can create a large number # ## of series, use judiciously. # pid_tag = false # # ## Method to use when finding process IDs. Can be one of 'pgrep', or # ## 'native'. The pgrep finder calls the pgrep executable in the PATH while # ## the native finder performs the search directly in a manor dependent on the # ## platform. Default is 'pgrep' # # pid_finder = "pgrep"
1) 위 예시의 2번 줄 [[inputs.procstat]] 의 주석을 해제합니다.
2) 위 예시의 8번째 줄 pattern 의 주석을 해제하고, monitoring하려는 process 명을 입력하면 process 명칭으로 모니터링을 할 수 있습니다.
pid_file , exe, user, systemd_unit, cgroup, win_service 등으로도 특정 프로세스를 지정할 수 있습니다.
현재 ZMC 에서 사용중인 PROCESS COUNT 템플릿은 pattern에 대한 감시 템플릿이므로 pid_file,exe 등 다른 방식에 대한 감시가 필요한 경우 티켓을 통해 요청주시면 관련 템플릿 생성이 가능합니다.
3) 그 외의 설정은 특별히 변경이 필요한 부분은 없으나, 상황에 맞게 변경하여 사용할 수 있습니다.
2. 설정을 저장 후 수집기 서비스를 다시 시작해야 변경된 설정이 적용됩니다.
$ sudo service telegraf restart or PS> net stop telegraf && net start telegraf
3. 감시 등록은 다음과 같이 진행하실 수 있습니다.
ZMC 접속 방법 및 Alert Rule Set 추가방법
https://support.skdt.co.kr/ko/support/solutions/articles/42000071438 참고
1) ZMClink에 접속하여 Alert Rule Set 메뉴를 클릭합니다.
2) 신규 Alert Rule Set을 추가하거나 기존 Alert Rule Set을 선택한 후, Alert Rule목록에서 Add 버튼을 클릭합니다.
3) Alert Rule 설정 팝업에서 Alert Rule Template 항목을 PROCESS COUNT[LINUX] or PROCESS COUNT[WINDOWS] 으로 선택합니다.
4) PROCESS COUNT(target + Status Condition) configuration
1 - Metric : 알람 메시지 전송 시 org 명과 함께 표기되므로, 사용자가 구분할 수 있는 명칭을 입력합니다.
Rules (수식 입력 방식):
2 - Target(procstat_lookup.pattern): telegraf 설정 시 [[input.procstat]] 에서 설정한 pattern 값을 입력합니다. 한 번에 한 개의 pattern 만 입력할 수 있으며, 여러 개의 pattern 을 감시하고자 할 경우 Alert rule 을 별도로 추가하여야 정상적으로 동작합니다.
3 - Status Condition: 좌변은 수집 field 가 표시되고, 해당 수집값에 대한 임계치를 수식으로 입력합니다. 위의 이미지에서는 수집 field 를 pid_count 선택 하였고 비교 연산자를 >= 로 선택하였으며 우변에 1 을 입력하였으므로, 입력한 target 의 pid_count 값이 1 이상일 경우 알람이 발생하게 됩니다.
4 - Duration: Status Condition 에서 설정한 조건을 충족하였을 때 Duration 에 설정한 시간 동안 조건이 유지되어야 알람을 발생하도록 설정할 수 있습니다. 예를 들어 Duration 을 1분으로 설정했을 경우, 1분 동안 3에서 설정한 Status Condition 이 유지되어야 최종적으로 알람이 발생합니다. 만약 설정한 Duration 인 1분이 되기 전에 Status Condition 을 충족하지 못하는 상황이 되면 알람이 발생하지 않습니다.
5 - Level: 해당 Rule 의 알람을 주의로 보낼지 경고로 보낼지 선택합니다.
6 - Message: 기본 메시지에 대신 희망하는 알람 메세지로 전송을 설정할 수 있습니다. Preview 버튼에 마우스오버하면 알람이 발생했을 때 예시 메시지를 확인할 수 있습니다.
Preview 버튼을 클릭할 경우 볼 수 있는 Message Popup
7 - Monitoring List: 설정한 Alert Rule 을 적용할 대상을 추가합니다. Add 버튼을 클릭하면 추가할 대상을 선택할 수 있는 Monitoring List 팝업이 생성됩니다 (아래 이미지).
해당 목록에서 추가할 대상을 선택하고 Select 버튼을 클릭하면 Alert Rule 설정창에 선택한 대상이 추가됩니다. 단, Alert Rule 설정창의 리스트는 팝업에서 최종적으로 선택한 리스트만 표시됩니다. Alert rule 설정을 저장하고 난 뒤에는 해당 설정창에서 이미 추가된 리스트는 확인 할 수 없습니다. 이미 추가된 리스트는 Alert Rule Set 상세화면에서 Alert rule 선택 시 하위 monitoring list 에서 확인이 가능합니다.
Procstat Plugin에 대한 측정항목 등에 대한 상세 참고는 아래 링크를 통해 가능합니다.