-
서버 핑 테스트해서 슬랙으로 메시지 보내기 with Shell Script 1부Shell Script 2023. 5. 8. 20:23
에 가서 로그인을 한다.
your app 을 클릭한다.
밑에 있는 github-log 는 무시해도 좋다. 실험삼아 만들어본거여서.. 여튼 create new app 을 누른다.
from scratch 를 누른다.
원하는 채널 이름을 적어주고 create App을 누른다.
incoming Webhooks를 누른다.
켜준다.
누른다.
slack 앱을 켜서 게시할 채널을 하나 빠르게 만들어준다. 나는 server-channel로 만들겠다.
만들어준다.
채널을 만들고, 다시 브라우저로 오면 새로고침되어있지 않으므로 일단 취소를 누르고 재진입해보자.
잘 추가가 되었고, 브라우저에는 oauth토큰과 웹훅URL이 나온다. 이를 잘 저장해두자.(oauth는 필요없을거 같은데..)
webhook url 로 슬랙에 만든 server-channel에 메시지를 어떻게 보낼까?
여기 보면 이렇게 나와있다. 이거를 copy 하고 cmd 열어서 그대로 붙여넣어보자.
cmd로 하면 에러가 난다. 그래서 git bash를 열고 붙여넣어주면 성공한다.
다음에는 ec2에서 스프링 jar를 하나 nohup 으로 실행시킨후, 쉘스크립트를 통해 30초마다 ping을 쏴서 5XX에러를 받으면 스크립트가 curl을 사용해서 슬랙에 알려주는 것을 만들겠다.
'Shell Script' 카테고리의 다른 글
서버 핑 테스트해서 슬랙으로 메시지 보내기 with Shell Script 2부 (0) 2023.05.08