Created
          March 11, 2020 03:22 
        
      - 
      
- 
        Save quangthe/52a4c1bf3e946fa5e595c99210c5ba72 to your computer and use it in GitHub Desktop. 
    Simple monitoring for app tienluong
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #! /usr/bin/python | |
| import datetime | |
| import time | |
| import urllib2 | |
| from contextlib import closing | |
| from urllib import urlencode | |
| def http_get(url): | |
| req = urllib2.Request(url) | |
| response = urllib2.urlopen(req) | |
| return response.read() | |
| def check_url(url): | |
| try: | |
| with closing(urllib2.urlopen(url, timeout=10)) as response: | |
| if response.getcode() == 200: | |
| print "{}: PASSED".format(datetime.datetime.now()) | |
| else: | |
| print "{}: FAILED! Code = {}".format(datetime.datetime.now(), response.code) | |
| http_get( | |
| 'https://api.telegram.org/bot1004943065:AAGs7DFeNO9bAE-ZMjraUh5jp2Y3nWZdtWc/sendMessage?chat_id=@viditechbot&text=App Tien Luong - Down') | |
| except Exception as e: | |
| print "{}: ERROR: {}".format(datetime.datetime.now(), e) | |
| if __name__ == '__main__': | |
| host = 'http://app.ductuong.vn' | |
| print "Check url {}".format(host) | |
| check_url(host) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment