eth-netstats - 이더리움 네트워크 상태 모니터링 툴 설치하기
eth-netstats는 github에서도 밝혔듯이 이더리움 네트워크를 모니터링하는 아래와 같은 비쥬얼 인터페이스이다.
인터페이스는 웹으로 실행되며, 이더리움 노드와 통신하기 위하여 웹소켓을 사용한다.따라서 노드에서 eth-netstats에 등록하기 위하여 서로 약속된 WS_SECRET 라는 환경변수를 사용한다.
eth-netstats를 설치해보기 위해서는 제일 먼저 이더리움 네트워크가 있어야 하고, 둘째로 eth-netstats가 필요하다.
이더리움 네트워크
이더리움 네트워크는 앞 [연재] POA 합의 알고리즘으로 구현하는 Private Network 에서 구축한 네트워크를 그대로 사용하겠다. 실재 추가되는 부분은 아래 옵션 하나이기 때문에 그대로 사용해도 문제가 없다.
--ethstats node1:Hello@localhost:3000
--ethstats 옵션은 다음의 형식으로 구성된다.
노드명:WS_SECRET:eth-netstat url
노드1
앞 연재에서 사용했던 node1 번 실행 스크립트를 다음과 같이 바꾼다.
geth --datadir node1 \
--ethstats node1:Hello@localhost:3000 \
--syncmode 'full' --port 30302 \
--bootnodes 'enode://a1de3ef130544423e8d1c3951a9502659238baa5149428b5cf3bd78f1525a9567bd4e4c25cc30ca2dc18a947bf4c47f7678f88a1f47bc84fd18015b27910c156@127.0.0.1:30301' \
--networkid 12345 --gasprice '1' \
--unlock '0x0a57f15f4e3c22c4d79c52307ef5fce8aff69e4c' --password ./password.txt --mine console
노드2
geth --datadir node2 \
--ethstats node2:Hello@localhost:3000 \
--syncmode 'full' --port 30303 \
--bootnodes 'enode://a1de3ef130544423e8d1c3951a9502659238baa5149428b5cf3bd78f1525a9567bd4e4c25cc30ca2dc18a947bf4c47f7678f88a1f47bc84fd18015b27910c156@127.0.0.1:30301' \
--networkid 12345 --gasprice '1' \
--unlock '0x2fd8cd8b880727c11ad7c65dc83255b46be0f9cd' --password ./password.txt --mine console
노드3
geth --datadir node3 \
--ethstats node3:Hello@localhost:3000 \
--syncmode 'full' --port 30304 \
--bootnodes 'enode://a1de3ef130544423e8d1c3951a9502659238baa5149428b5cf3bd78f1525a9567bd4e4c25cc30ca2dc18a947bf4c47f7678f88a1f47bc84fd18015b27910c156@127.0.0.1:30301' \
--networkid 12345 --gasprice '1' \
--unlock '0x8fb13b3c7e3868df8de563bf7e133a0cec5b1ec9' --password ./password.txt --mine console
eth-netstats 설치
eth-netstats 는 아래와 같이 git으로 설치한다. 이 내용은 eth-netstats github 사이트에도 나와 있으므로 참조하기 바란다.
git clone https://github.com/cubedro/eth-netstats cd eth-netstats npm install
eth-netstats가 설치되었으며 github 사이트에 나와 있는 대로 grunt를 실행한다. grunt가 없으면 grunt를 설치하기 바란다(sudo npm install -g grunt-cli).
grunt
grunt 까지 실행 완료하였으면 이제 eth-netstats를 실행해보자. 여기서 주의할 점은 WS_SECRET 환경 변수를 설정해줘야 한다는 것이다.
WS_SECRET값은 앞 노드들을 실행할 때 줬던 Hello(이건 정하기 나름이다)를 주면 된다.
WS_SECRET=Hello npm start
이 명령을 실행하면 다음과 같이 노드들을 연결하는 내용이 콘솔에 나올 것이다.
eth-netstats 실행
자 이제 연결된 것을 확인했으면 브라우저에서 이를 확인해보자.
등록된 노드들이 모두 목록에 나오는지, 현재 블럭 번호가 일치하는지, 그리고 PoA 망이므로 매 5초마다 블럭이 생성되는지 확인하기 바란다.
덧붙여
우상단에 보이는 지도에는 노드가 Public IP를 사용하면 geoip-lite 패키지를 사용하여 위치 정보를 세계지도 위에 표시한다.