-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolardd.rb
More file actions
31 lines (23 loc) · 751 Bytes
/
solardd.rb
File metadata and controls
31 lines (23 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'net/http'
require 'uri'
api_key = "API_KEY"
application_key = "APP_KEY"
def open(url)
Net::HTTP.get(URI.parse(url))
end
time = Time.new
today = time.strftime("%d-%m-%Y")
currenttime=time.to_i
puts currenttime
page_content = open('http://192.168.1.101/production')
production = page_content.split("Today</td> <td> ")[1].split(" kWh")[0]
puts "Todays production #{production}"
datadogoutput = `curl -sS -X POST -H "Content-type: application/json" -d \
'{"series":\
[{"metric":"test.metric",
"points":[[#{currenttime}, #{production}]],
"host":"test.example.com",
"tags":["environment:test"]}
]
}' \
https://app.datadoghq.com/api/v1/series?api_key=b628c6c3f64c0495c61704af77d065f6`