Gibbs Kim's playground

[ElasticStack-33] Machinebeat test with opcua 본문

Tech 기록지/Elastic Stack

[ElasticStack-33] Machinebeat test with opcua

Lio Grande 2021. 6. 1. 16:13

opc-ua 서버를 테스트하던 도중 해당 데이터를 ES에 적재하여야 하는 상황을 겪었다.

이때, machinebeat라는 수집도구를 사용하여 opc-ua 서버에서 ES로 적재하는 것을 알게되었다.

 

해당 과정에 대한 수행내역을 기록해본다.

 

1) opc-ua 테스트용 서버 구축

https://mingsigi.tistory.com/entry/opc-ua-test-server-via-python

 

opc ua test server via python

from time import sleep import random from opcua import Server server = Server() server.set_endpoint("opc.tcp://127.0.0.1:12345") server.register_namespace("Room1") objects = server.get_objects_node(..

mingsigi.tistory.com

2) machinebeat 파일 다운로드

 - Github에 관련 데이터가 있다. (https://github.com/elastic/Machinebea)

 

elastic/Machinebeat

This is a beat for collecting data of machines, sensors and PLCs. At the moment this is supporting OPC UA and MQTT. More to add. - elastic/Machinebeat

github.com

 - git clone (.zip 파일 받으면 실행에 필요한 machinebeat이 없다)

 - 혹시 .zip을 받았다면 Makefile이 있는 경로에서 make를 실행하자

    - 이러면 깃에서 필요한 파일들을 추가로 다운로드 받는다

- 클론한 파일은 다음과 같은 디렉토리로 구성되어 있다.

machinebeat/
	---- machinebeat
    ---- machinebeat.yml
    ---- data/
    ---- logs/
    ---- modules.d/

 - modules.d 디렉토리 아래에 *.yml 패턴의 설정파일이 두 개 있다.

mqtt.yml.disabled
opcua.yml.disabled

 - opcua 연동을 위해서 YAML파일을 사용가능하게 바꿔보자

>> /home/user/machinebeat/modules.d/machinebeat enable opcua

 - 명령어 사용 후 *.yml이 다음과 같이 바뀐다.

mqtt.yml.disabled
opcua.yml

 - 이제 기존에 만들었던 테스트용 opcua와의 연동을 위해 opcua.yml 설정을 바꿔보자.

## vi opcua.yml
## ...
 module: opcua
 enabled: true
 period: 2s
 
 endpoint: "opc.tcp://127.0.0.1:12345"
 ## ...

 - machinebeat를 구동해보자

home/user/machinebeat/machinebeat -e -c machinebeat.yml