impfee: init

This commit is contained in:
Astro 2021-03-24 20:55:50 +01:00
parent 77c864b4d7
commit ebf0ca2e68
1 changed files with 28 additions and 0 deletions

28
impfee/scrape.rb Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
require 'influxdb'
# https://www.countee.ch/app/de/counter/impfee/_iz_sachsen
data = JSON.parse open("https://www.startupuniverse.ch/api/1.1/de/counters/getAll/_iz_sachsen").read()
points = []
data['response']['data'].each do |id, iz|
next if iz['closed'] != 0
sum = iz['counteritems'].map { |item| item['val'] }.sum
points.push({
series: "iz",
tags: {
name: iz['name'],
slug: iz['slug'],
},
values: {
sum: sum,
},
})
end
db = InfluxDB::Client.new(url: "http://grafana.serv.zentralwerk.dn42:8086/impfee")
db.write_points points