"github.com/Sirupsen/logrus"
	"github.com/olivere/elastic"
	"github.com/spf13/cobra"
	"github.com/yieldbot/sensuplugin/sensuhandler"
	"github.com/yieldbot/sensupluginses/version"
)

// elasticsearch endpoint configuration
var esHost string
var esIndex string
var esPort string
var esType = DefaultEsType

// Bring in the environmant details
var sensuEnv = new(sensuhandler.EnvDetails)

// main entry point
var handlerElasticsearchStatusCmd = &cobra.Command{
	Use:   "handlerElasticsearchStatus --index <index> --host <host> --port <port>",
	Short: "This will input a single record for each check result given, overwriting the currect record.",
	Long: `This will take a single check result and create a key based upon the host name and
  the check name. This key will remain consistent so that only the latest status will be available in
  the index. This is designed to allow the creation of current dashboards from Kibana or Dashing.`,

	Run: func(sensupluginses *cobra.Command, args []string) {

		// read in the event data from the sensu server
		sensuEvent := new(sensuhandler.SensuEvent)
		sensuEvent = sensuEvent.AcquireSensuEvent()
Esempio n. 2
0
	"github.com/spf13/cobra"
)

// slack channel to post messages to
var channelID string

// handlerSlackCmd represents the handlerSlack command
var handlerSlackCmd = &cobra.Command{
	Use:   "handlerSlack --token <token> --channel <slack channel>",
	Short: "Post Sensu check results to a slack channel",
	Long: `Read in the Sensu check result and condense the output and post it
	 as a Slack attachment to a given channel`,
	Run: func(sensupluginsslack *cobra.Command, args []string) {

		// Bring in the environmant details
		sensuEnv := new(sensuhandler.EnvDetails)
		sensuEnv = sensuEnv.SetSensuEnv()

		if slackToken == "" {
			syslogLog.WithFields(logrus.Fields{
				"check":      "sensupluginsslack",
				"client":     host,
				"version":    version.AppVersion(),
				"slackToken": slackToken,
			}).Error(`Please enter a valid slack token`)
			sensuutil.Exit("RUNTIMEERROR")
		}
		// read in the event data from the sensu server
		sensuEvent := new(sensuhandler.SensuEvent)
		sensuEvent = sensuEvent.AcquireSensuEvent()