This code allows us to communicate to a WS as a client, get it's state, either UP or DOWN. Outputs it's status when it changes to the console and notifies us on telegram.
Feel free to edit the code's necessary params to your needs
Clone the repository
Compile the files either using the makefile file(lol)
or
gcc Availability_Eval.c -o Availability_Eval
gcc WS_Client.c -o WS_Client
Change the line 24 on the 'Availability_Eval.c' file to meet your telegram bot's and profile ChatID params
// Send a notif to a telegram bot. Change this URL to your use case. Change the chat ID to your own personnal chatID
system("curl -s -X POST https://api.telegram.org/bot123456789101112123/sendMessage -d chat_id=12345678 -d text=\"Server is Down!\"");
You should also change the server's IP on the file WS_Client.c to meet your needs
serverAddress.sin_port = htons(80); // Define the port
serverAddress.sin_addr.s_addr = inet_addr("127.0.0.1"); //This is the server's IP address
On the Linux terminal
./WS_Client | ./Availability_Eval