server-status-project / server-status

Simple, modern looking server status page with administration and some nice features, that can run even on shared webhosting
https://demo.status.sajdl.com/
Apache License 2.0
394 stars 87 forks source link

integrate with Uptime Robot #171

Open solaceten opened 1 year ago

solaceten commented 1 year ago

Does this currently integrate with Uptime Robot's API ? https://uptimerobot.com/api/

If not - how could that be done ?

yigitkeremoktay commented 1 year ago

There is sadly no way to do this built-in. The API is also read-only so your only way to do this could be by having a PHP Script on Cron or NodeJS app that will check the UptimeRobot API status and create an incident in Server Status database directly, through MySQL.

If you would look into spending a bit more time and contribute, you could use the classes from the project and create a file inside the repo that could be setup to use uptimerobot if it is enabled in the config.

@Pryx would be of better help if you decide to write something yourself

Steffen-MLR commented 1 year ago

I think implementing a write-enabled API would be the best way. Maybe with a simple user/pw authentication for starters.

yigitkeremoktay commented 1 year ago

I think implementing a write-enabled API would be the best way. Maybe with a simple user/pw authentication for starters.

Most likely but it's a big amount of change that may not be that easy to do. I also don't think anyone is active enough to do such major updates.

Steffen-MLR commented 1 year ago

``I have an Idea: start with a request to login to your instance:

curl -X POST 'http://example/admin/' \
   --header 'Accept: */*' \
   --form 'email="<mail@example>"' \
   --form 'pass="<password>"' -v

Get the Line Set-Cookie: Set-Cookie: PHPSESSID=<seesionid>; path=/ and strip out PHPSESSID=<sessionid>. then create an incident by:

curl -X POST \
  'http://example/admin/?new=incident' \
  --header 'Accept: */*' \
  --header 'Cookie: PHPSESSID=<sessionid>' \
  --form 'type="1"' \
  --form 'title="title2"' \
  --form 'text="test123"' \
  --form 'services[]="1"'

further explanations: possible values for type are: 0 = "Major outage", 1 = "Minor outage", 2 = "Planned maintenance", 3 = "Operational" possible values for services[] are indexes starting with 1, for your exisiting services. If you have only one, 1 would be the correct value.

NOTE: if you want to add an incident of type=2, you need to submit additional form params time and end_time using ISO 8601 Format. e.g. 2023-03-12 12:00. Value of time need to be before end_time.

NOTE 2: Since these features were not considered when creating the functions, there is no exception handling there. Do not test it in Production.

Hope this helps. i am currently working on PHP8 support, Maybe I can look into this after that. Should not be that hard to do this with one single request instead of using two.