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:
David G. Simmons
2017-09-29 12:57:13 -04:00
parent c3b11f9cfb
commit b2453e3ec3
7 changed files with 0 additions and 2537 deletions

View File

@@ -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)
}