How to automatically notify by phone when the python system is down

background

The server is operating as a personal PJ. I want to recover immediately when a fatal error occurs. Notification method What should I do

Common solutions

Django has Error Email Notification.

Problems with common solutions

If it is gmail, it will be treated as SPAM and will be thrown into junk mail. Same with carrier email. Treated as SPAM. It is very troublesome to set the mail of the server so that it will not be treated as SPAM.

I tried using Twilio

An American company with KDDI as an agent in Japan A service for making phone calls via API. Japan Official Page Twilio

Will phone bankruptcy or bill shock die?

The rate plan focuses on sending SMS, receiving calls, and making calls. It is designed not to assume the form of calling and leaving an incoming call. It can be used for free to some extent. If you just make a call and leave the incoming call history, it seems that you can operate it for free.

It seems that it will be 189 yen a month when charging. high. Stable to use only for free. スクリーンショット 2015-03-30 23.00.43.png

account registration

Account registration and issue the following 3-piece set ・ Calling phone number ・ ACCOUNT_SID ・ AUTH_TOKEN

Installation

shell


pip install twilio

Make a phone call

from twilio.rest import TwilioRestClient
ACCOUNT_SID = "ABCDEFG"
AUTH_TOKEN = "0x0x0x0x0x0x"
FROM_CALL_NUMBER = "8109012345678"
TO_CALL_NUMBER = "8109011223344"

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
call = client.calls.create(to=TO_CALL_NUMBER, from_=FROM_CALL_NUMBER,
                           url="http://foo.com/call.xml")
print call.length
print call.sid

I got a call

Incoming call in about 15 seconds after hitting the API スクリーンショット 2015-03-30 23.17.23.png

Recommended Posts

How to automatically notify by phone when the python system is down
How to erase the characters output by Python
What happens to the access log when the website is automatically accessed by selenium-webdriver
How to switch the configuration file to be read by Python
How to get the Python version
[Python] How to import the library
Let's use AWS Lambda to create a mechanism to notify slack when the value monitored by CloudWatch is exceeded on Python
How to judge that the cross key is input in Python3
How to use the asterisk (*) in Python. Maybe this is all? ..
What to do when the value type is ambiguous in Python?
Write a script in Shell and Python to notify you in Slack when the process is finished
How to deal with the problem that the current directory moves when Python is executed from Atom
How to use is and == in Python
[Python Kivy] How to get the file path by dragging and dropping
[PostgreSQL] How to grant superuser authority when the user (role) with superuser authority is 0
[Python] What is a formal argument? How to set the initial value
How to hide the command prompt when running python in visual studio 2015
Notify using Notification Center when the execution environment is macOS in Python
How to sort by specifying a column in the Python Numpy array.
How to start Python (Flask) when EC2 starts
[python] How to display list elements side by side
How to use the C library in Python
[Python] How to change the date format (display format)
How to read all the classes contained in * .py in the directory specified by Python
[python] How to sort by the Nth Mth element of a multidimensional array
[Algorithm x Python] How to use the list
How to get the files in the [Python] folder
Notify slack when the switch sales page is updated ~ slack bot development with python ③ ~
[Python] How to sort instances by instance variables
"Cython" tutorial to make Python explosive: Handling when a function on the C ++ side is passed by reference.
[Introduction to Python] What is the recommended way to install pip, a package management system?
How to check in Python if one of the elements of a list is in another list
[Introduction to Python] What is the important "if __name__ =='__main__':" when dealing with modules?
[Python] How to remove duplicate values from the list
How to retrieve the nth largest value in Python
How to get the variable name itself in python
Think about how to program Python on the iPad
How to get the number of digits in Python
[Introduction to Python] How to iterate with the range function?
How to know the current directory in Python in Blender
[Reintroduction to python] How to import via the parent directory
How to disable the reference feature when outputting PyYaml
How to use the Raspberry Pi relay module Python
Python3 datetime is faster just by specifying the timezone
[Python] How to specify the download location with youtube-dl
Read the xml file by referring to the Python tutorial
[Python] How to use the graph creation library Altair
How to check the Java version used by Maven
Specifies the function to execute when the python program ends
[Introduction to Udemy Python3 + Application] 27. How to use the dictionary
How to save a table scraped by python to csv
[Introduction to Udemy Python3 + Application] 30. How to use the set
[Python] Summary of how to specify the color of the figure
How to use the model learned in Lobe in Python
[Introduction to Python] How to stop the loop using break?
[Python] How to rewrite the table style with python-pptx [python-pptx]
How to enjoy Python on Android !! Programming on the go !!
[Python] How to output the list values in order
How to unprefix the DB name used by pytest-django
How to install Python
How to install python