mirror of
https://github.com/iv-org/instances-api.git
synced 2025-05-11 11:05:07 -04:00
add support for updown.io
This commit is contained in:
parent
a4c097175f
commit
177c403a89
2 changed files with 14 additions and 20 deletions
|
@ -31,25 +31,19 @@ INSTANCES = {} of String => Instance
|
||||||
spawn do
|
spawn do
|
||||||
loop do
|
loop do
|
||||||
monitors = [] of JSON::Any
|
monitors = [] of JSON::Any
|
||||||
#page = 1
|
begin
|
||||||
loop do
|
client = HTTP::Client.new(URI.parse("https://updown.io/p/wqufo"))
|
||||||
begin
|
client.connect_timeout = 10.seconds
|
||||||
client = HTTP::Client.new(URI.parse("https://updown.io/p/wqufo"))
|
client.read_timeout = 10.seconds
|
||||||
client.connect_timeout = 10.seconds
|
response = JSON.parse(client.get("/api/checks?api-key=ro-52iHyp6LBqQq7rGp4N7p").body)
|
||||||
client.read_timeout = 10.seconds
|
monitors += response.as_a
|
||||||
response = JSON.parse(client.get("/api/checks?api-key=ro-52iHyp6LBqQq7rGp4N7p").body)
|
rescue ex
|
||||||
|
error_message = response.try &.as?(String).try &.["errorStats"]?
|
||||||
# monitors += response["psp"]["monitors"].as_a
|
error_message ||= ex.message
|
||||||
# page += 1
|
puts "Error pulling monitors: #{error_message}"
|
||||||
|
break
|
||||||
# break if response["psp"]["perPage"].as_i * (page - 1) + 1 > response["psp"]["totalMonitors"].as_i
|
|
||||||
rescue ex
|
|
||||||
error_message = response.try &.as?(String).try &.["errorStats"]?
|
|
||||||
error_message ||= ex.message
|
|
||||||
puts "Error pulling monitors: #{error_message}"
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
body = HTTP::Client.get(URI.parse("https://raw.githubusercontent.com/iv-org/documentation/master/docs/instances.md")).body
|
body = HTTP::Client.get(URI.parse("https://raw.githubusercontent.com/iv-org/documentation/master/docs/instances.md")).body
|
||||||
rescue ex
|
rescue ex
|
||||||
|
@ -151,7 +145,7 @@ static_headers do |response, filepath, filestat|
|
||||||
end
|
end
|
||||||
|
|
||||||
SORT_PROCS = {
|
SORT_PROCS = {
|
||||||
"health" => ->(alias : String, instance : Instance) { -(instance[:monitor]?.try &.["30dRatio"]["ratio"].as_s.to_f || 0.0) },
|
"health" => ->(alias : String, instance : Instance) { -(instance[:monitor]?.try &.["uptime"].as_s.to_f || 0.0) },
|
||||||
"location" => ->(alias : String, instance : Instance) { instance[:region]? || "ZZ" },
|
"location" => ->(alias : String, instance : Instance) { instance[:region]? || "ZZ" },
|
||||||
"name" => ->(name : String, instance : Instance) { name },
|
"name" => ->(name : String, instance : Instance) { name },
|
||||||
"signup" => ->(alias : String, instance : Instance) { instance[:stats]?.try &.["openRegistrations"]?.try { |bool| bool.as_bool ? 0 : 1 } || 2 },
|
"signup" => ->(alias : String, instance : Instance) { instance[:stats]?.try &.["openRegistrations"]?.try { |bool| bool.as_bool ? 0 : 1 } || 2 },
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
<td><%= instance[:stats]?.try &.["usage"]?.try &.["users"]["total"] || "-" %></td>
|
<td><%= instance[:stats]?.try &.["usage"]?.try &.["users"]["total"] || "-" %></td>
|
||||||
<td><%= instance[:stats]?.try &.["openRegistrations"]?.try { |bool| bool.as_bool ? "✔" : "❌" } || "-" %></td>
|
<td><%= instance[:stats]?.try &.["openRegistrations"]?.try { |bool| bool.as_bool ? "✔" : "❌" } || "-" %></td>
|
||||||
<td><%= instance[:flag]? ? "#{instance[:flag]} #{instance[:region]}" : "-" %></td>
|
<td><%= instance[:flag]? ? "#{instance[:flag]} #{instance[:region]}" : "-" %></td>
|
||||||
<td><%= instance[:monitor]?.try &.["30dRatio"]["ratio"] || "-" %></td>
|
<td><a href='https://updown.io/<%= instance[:monitor]?.try &.["token"] || "p/resvf" %>'><%= instance[:monitor]?.try &.["uptime"] || "-" %></a></td>
|
||||||
<td><%= instance[:cors] == nil ? "-" : instance[:cors] ? "✔" : "❌" %></td>
|
<td><%= instance[:cors] == nil ? "-" : instance[:cors] ? "✔" : "❌" %></td>
|
||||||
<td><%= instance[:api] == nil ? "-" : instance[:api] ? "✔" : "❌" %></td>
|
<td><%= instance[:api] == nil ? "-" : instance[:api] ? "✔" : "❌" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue