Revert "New Particle.io Plugin for Telegraf"
This reverts commit c3b11f9cfb.
Accidentally pushed to master, instead of my fork. Backing it out.
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
package particle
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/influxdata/telegraf"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ParticleWebhook struct {
|
||||
Path string
|
||||
acc telegraf.Accumulator
|
||||
}
|
||||
|
||||
func (rb *ParticleWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
|
||||
router.HandleFunc(rb.Path, rb.eventHandler).Methods("POST")
|
||||
log.Printf("I! Started the webhooks_particle on %s\n", rb.Path)
|
||||
rb.acc = acc
|
||||
}
|
||||
|
||||
func (rb *ParticleWebhook) eventHandler(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
data, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
dummy := &DummyData{}
|
||||
if err := json.Unmarshal(data, dummy); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
pd := &ParticleData{}
|
||||
if err := json.Unmarshal([]byte(dummy.Data), pd); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
pTime, err := dummy.Time()
|
||||
if err != nil {
|
||||
log.Printf("Time Conversion Error")
|
||||
}
|
||||
rb.acc.AddFields("particle_webhooks", pd.Fields, pd.Tags, pTime)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
Reference in New Issue
Block a user