
It will turn the Success variable to True and no alert will be sent to email. If the connection is successful, it will generate a success message, e.g., msg. It will create a connection with the provided name and any port number you provided. In this try statement, we have if statement having a connection of plain type. Now write the below code in the same file, and using the try statement, we are checking the connection for different servers connection types, e.g. Now: will get the current date and time while checking the connection.Success: used to tell if the connection is successful or not.Msg: used to display a message if connection established or failed which is initially empty.In this method, we have to define three variables as: So to test the server connection, we have created another method in Server() class named check_connection(). Alert: If you want to send alerts to your email.Priority: tell us the server priority, e.g., you can set alerts if you set priority.Connection: tells the connection type, e.g., SSL or ping.Port: the port number to which we want to connect.We have added some attributes for the server, e.g., any UNIX or regular computer. Let’s create a class named Server() and built a first method, which is a constructor method. We are using the platform and subprocess packages, that will tell us which operating system we are running, e.g., UNIX or Windows. Pickle: Used for saving the history of the computer’s down and uptime, as well as propagate the data from run to run with this program.DateTime: Used to check what time the server was down or active.SSL: Required for the wrapping of the socket connection.



We will be using server sockets to check if the specific port on a server is open or not, the Ping command to monitor a simple regular computer and the SSL to check if the particular server requires an SSL connection or not. It can show you how much downtime your computer or server had. Python Server Monitoring Script enables you to monitor if your server or computer is active and running.
