Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pythonの勉強がてら死活監視ツールを作った話

 Pythonの勉強がてら死活監視ツールを作った話

OSCのLT新人戦用に作成したスライド
pythonを使って自社サービスの監視ツールについて話します。

6ab47a68ee78e84c34731ce12333deff?s=128

虎の穴ラボ株式会社

February 22, 2019
Tweet

More Decks by 虎の穴ラボ株式会社

Other Decks in Programming

Transcript

  1.       Python  ! 

       1 2019/02/22 OSC LT Python ! Copyright © 2019 Toranoana Inc. All Rights Reserved.
  2. . + . + . + . + . +

    . + -!, 2 Copyright © 2019 Toranoana Inc. All Rights Reserved.  5" ( %$' 521 3* ') /05JavaJS  5 # &  5    4
  3.       3 Copyright © 2019

    Toranoana Inc. All Rights Reserved. • Python? •  •  • 
  4.       Python? !  

    JavaJavaScript   ↓  "#  4 Copyright © 2019 Toranoana Inc. All Rights Reserved.
  5.       Python?   5

    Copyright © 2019 Toranoana Inc. All Rights Reserved.
  6. 2 / 2 / 2 / 2 / 2 /

    2 / ,-.3 1 6 Copyright © 2019 Toranoana Inc. All Rights Reserved. Web( AP( DB( nginx& nginxhttp https !" +)'4%6   KEEPER5 Rails& $ !$ #*0 MySQL& $ $* 0
  7.        7 Copyright ©

    2019 Toranoana Inc. All Rights Reserved. Web AP DB Web  http://toranoana-keeper.com/ HTTP   HTTP301  
  8.        8 Copyright ©

    2019 Toranoana Inc. All Rights Reserved. Web AP DB AP  https://toranoana-keeper.com/ (TOP )  HTTP200  
  9. " " " " " " #! 9 Copyright ©

    2019 Toranoana Inc. All Rights Reserved. Web AP DB DB  https://toranoana-keeper.com/search (  ) GET:'search[q]'='aaaa'  HTTP200 % $
  10.        10 Copyright ©

    2019 Toranoana Inc. All Rights Reserved. Web AP DB     slack
  11.        #pyenv  pyenv

    install 3.6.8 pyenv local 3.6.8 #HTTP  Requests pip install requests 11
  12. &$ &$ &$ &$ &$ &$ )(Web   )

    #   import requests #Web   (allow_redirects=False    ! (# ) url = "http://toranoana-keeper.com/" r = requests.get(url,allow_redirects=False) print (r.status_code, r.reason) ↓'%" 301 Moved Permanently 12
  13.       (AP) #  

     import requests #AP url = "https://toranoana-keeper.com/" r = requests.get(url) print (r.status_code, r.reason) ↓ 200 OK 13
  14.       (DB) #  

     import requests #DB url = "https://toranoana-keeper.com/search" r = requests.get(url,params={'search[q]': 'aaaa'}) print (r.status_code, r.reason) ↓ 200 OK 14
  15.       (slack) #slack import json

    def post_slack(check_name, check_result): message = "   :" + check_name + "¥n" message += "  :" + check_result + "¥n" print(message) slack_url = "https://hooks.slack.com/services/*****/*****/*****" payload_dic = { "username": "  ", "text": message } r = requests.post(slack_url, data=json.dumps(payload_dic)) n.dumps(payload_dic)) 15
  16.        16

  17. 85 85 85 85 85 85  17 )HTTP&$&'+3 

    6-*#HTTP * .0slack94  )slack 2 /71 Raspberry Pi"!&(%,  94