Hi everyone! I created few scripts to backum my server’s data to my S3 storage and wanted to be notified when backup fails. Until now I used Zabbix with zabix-sender but I found maybe better server monitoring for me: Netdata. So when I dont use zabbix anymore I needed another solution and found one. You can post status code with curl to any api (or you can create easy script for example in the GO to send data to the api, this is just easier and faster solution for me now.)
How to get exit code?
#!/bin/bash
# ... your code
#read exit code and add it to variable
STATUS_CODE=$?
# and send it
curl -i --data state=${STATUS_CODE} https://your-url-to-server
That’s it, easy no? This is how you can post status/exit code to your api, you can add more data or header for authentication. You can send an email for example if status change from default or if it is changed from last one or anything you want.
I wanted to be notified over SMS message so i created Cake-Notify. It is using Twilio service to send message to provided phone number. This app is in early stage of development but it is usable. I plannig to add more services to use for sending notifications, but for now it knows only sending SMS over Twilio.
This is how you can send exit code to my api
curl -i --data state=1 -H "__token__:<change-to-your-token>" https://<change-to-server-address>/api/v1/applications/create-log/<application-id>.json
… and this is all. You are free to check it yourself, or contribute if you want, i will be glad.
Thank you for reading, Have a nice day. 👋
Reply by Email