本文整理汇总了Golang中github.com/mackerelio/go-mackerel-plugin.NewMackerelPlugin函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMackerelPlugin函数的具体用法?Golang NewMackerelPlugin怎么用?Golang NewMackerelPlugin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMackerelPlugin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Do
// Do the plugin
func Do() {
optAccessKeyID := flag.String("access-key-id", "", "AWS Access Key ID")
optSecretAccessKey := flag.String("secret-access-key", "", "AWS Secret Access Key")
optIdentifier := flag.String("identifier", "", "Distribution ID")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var plugin CloudFrontPlugin
plugin.AccessKeyID = *optAccessKeyID
plugin.SecretAccessKey = *optSecretAccessKey
plugin.Name = *optIdentifier
err := plugin.prepare()
if err != nil {
log.Fatalln(err)
}
helper := mp.NewMackerelPlugin(plugin)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-cloudfront"
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例2: main
func main() {
flag.StringVar(&Options.Host, "host", "localhost", "fluentd monitor_agent host")
flag.IntVar(&Options.Port, "port", 24220, "fluentd monitor_agent port")
flag.StringVar(&Options.Tempfile, "tempfile", "", "Temp file name")
flag.Parse()
plugin := Plugin{
Target: fmt.Sprintf("http://%s:%d/api/plugins.json", Options.Host, Options.Port),
}
plugin.Prepare()
helper := mp.NewMackerelPlugin(plugin)
if Options.Tempfile != "" {
helper.Tempfile = Options.Tempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-fluentd-%s-%d", Options.Host, Options.Port)
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例3: main
func main() {
optUri := flag.String("uri", "", "URI")
optScheme := flag.String("scheme", "http", "Scheme")
optHost := flag.String("host", "localhost", "Hostname")
optPort := flag.String("port", "8080", "Port")
optPath := flag.String("path", "/nginx_status", "Path")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var nginx NginxPlugin
if *optUri != "" {
nginx.Uri = *optUri
} else {
nginx.Uri = fmt.Sprintf("%s://%s:%s%s", *optScheme, *optHost, *optPort, *optPath)
}
helper := mp.NewMackerelPlugin(nginx)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-nginx")
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例4: main
func main() {
optAPIKey := flag.String("api-key", "", "API Key")
optDatabase := flag.String("database", "", "Database name")
optIgnoreTableNames := flag.String("ignore-table", "", "Ignore Table name (Can be Comma-Separated)")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var plugin TDTablePlugin
plugin.APIKey = *optAPIKey
plugin.Database = *optDatabase
ignoreTableNames := []string{}
if *optIgnoreTableNames != "" {
ignoreTableNames = strings.Split(*optIgnoreTableNames, ",")
}
plugin.IgnoreTableNames = ignoreTableNames
helper := mp.NewMackerelPlugin(plugin)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-td-table"
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例5: main
func main() {
optHost := flag.String("host", "localhost", "Hostname")
optPort := flag.String("port", "3306", "Port")
optUser := flag.String("username", "root", "Username")
optPass := flag.String("password", "", "Password")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var mysql MySQLPlugin
mysql.Target = fmt.Sprintf("%s:%s", *optHost, *optPort)
mysql.Username = *optUser
mysql.Password = *optPass
helper := mp.NewMackerelPlugin(mysql)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-mysql-%s-%s", *optHost, *optPort)
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例6: main
func main() {
optRegion := flag.String("region", "", "AWS Region")
optInstanceID := flag.String("instance-id", "", "Instance ID")
optAccessKeyID := flag.String("access-key-id", "", "AWS Access Key ID")
optSecretAccessKey := flag.String("secret-access-key", "", "AWS Secret Access Key")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var cpucredit CPUCreditPlugin
if *optRegion == "" || *optInstanceID == "" {
cpucredit.Region = aws.InstanceRegion()
cpucredit.InstanceID = aws.InstanceId()
} else {
cpucredit.Region = *optRegion
cpucredit.InstanceID = *optInstanceID
}
cpucredit.AccessKeyID = *optAccessKeyID
cpucredit.SecretAccessKey = *optSecretAccessKey
helper := mp.NewMackerelPlugin(cpucredit)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-cpucredit"
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例7: Do
// Do the plugin
func Do() {
optScheme := flag.String("scheme", "http", "Scheme")
optHost := flag.String("host", "localhost", "Host")
optPort := flag.String("port", "9200", "Port")
optPrefix := flag.String("metric-key-prefix", "elasticsearch", "Metric key prefix")
optLabelPrefix := flag.String("metric-label-prefix", "", "Metric Label prefix")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var elasticsearch ElasticsearchPlugin
elasticsearch.URI = fmt.Sprintf("%s://%s:%s", *optScheme, *optHost, *optPort)
elasticsearch.Prefix = *optPrefix
if *optLabelPrefix == "" {
elasticsearch.LabelPrefix = strings.Title(*optPrefix)
} else {
elasticsearch.LabelPrefix = *optLabelPrefix
}
helper := mp.NewMackerelPlugin(elasticsearch)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-elasticsearch-%s-%s", *optHost, *optPort)
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例8: main
func main() {
optEndpoint := flag.String("endpoint", "", "AWS Endpoint")
optAccessKeyID := flag.String("access-key-id", "", "AWS Access Key ID")
optSecretAccessKey := flag.String("secret-access-key", "", "AWS Secret Access Key")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var ses SESPlugin
ses.Endpoint = *optEndpoint
ses.AccessKeyID = *optAccessKeyID
ses.SecretAccessKey = *optSecretAccessKey
helper := mp.NewMackerelPlugin(ses)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-ses"
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例9: main
func main() {
optHost := flag.String("host", "localhost", "Hostname")
optPort := flag.String("port", "8983", "Port")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
solr := SolrPlugin{
Protocol: "http",
Host: *optHost,
Port: *optPort,
Prefix: "solr",
}
solr.BaseURL = fmt.Sprintf("%s://%s:%s/solr", solr.Protocol, solr.Host, solr.Port)
solr.loadStats()
helper := mp.NewMackerelPlugin(solr)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-%s-%s-%s", solr.Prefix, *optHost, *optPort)
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例10: main
func main() {
optRegion := flag.String("region", "", "AWS Region")
optAccessKeyId := flag.String("access-key-id", "", "AWS Access Key ID")
optSecretAccessKey := flag.String("secret-access-key", "", "AWS Secret Access Key")
optIdentifier := flag.String("identifier", "", "DB Instance Identifier")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var rds RDSPlugin
if *optRegion == "" {
rds.Region = aws.InstanceRegion()
} else {
rds.Region = *optRegion
}
rds.Identifier = *optIdentifier
rds.AccessKeyId = *optAccessKeyId
rds.SecretAccessKey = *optSecretAccessKey
helper := mp.NewMackerelPlugin(rds)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-rds"
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例11: main
func main() {
optHost := flag.String("host", "127.0.0.1", "Hostname")
optPort := flag.String("port", "6379", "port")
optTempfile := flag.String("tempfile", "", "Temp file name")
optDB := flag.String("db", "0", "Database")
optNamespace := flag.String("namespace", "", "Namespace")
flag.Parse()
var sidekiq SidekiqPlugin
sidekiq.Target = *optHost + ":" + *optPort
sidekiq.Database = *optDB
sidekiq.Namespace = *optNamespace
helper := mp.NewMackerelPlugin(sidekiq)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-sidekiq-" + *optHost + "-" + *optPort
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例12: doMain
// main function
func doMain(c *cli.Context) {
var linux LinuxPlugin
linux.Type = c.String("type")
helper := mp.NewMackerelPlugin(linux)
helper.Tempfile = c.String("tempfile")
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例13: main
func main() {
optHost := flag.String("hostname", "localhost", "Hostname to login to")
optPort := flag.String("port", "5432", "Database port")
optUser := flag.String("user", "", "Postgres User")
optDatabase := flag.String("database", "", "Database name")
optPass := flag.String("password", "", "Postgres Password")
optSSLmode := flag.String("sslmode", "disable", "Whether or not to use SSL")
optConnectTimeout := flag.Int("connect_timeout", 5, "Maximum wait for connection, in seconds.")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
if *optUser == "" {
logger.Warningf("user is required")
flag.PrintDefaults()
os.Exit(1)
}
if *optPass == "" {
logger.Warningf("password is required")
flag.PrintDefaults()
os.Exit(1)
}
option := ""
if *optDatabase != "" {
option = fmt.Sprintf("dbname=%s", *optDatabase)
}
var postgres PostgresPlugin
postgres.Host = *optHost
postgres.Port = *optPort
postgres.Username = *optUser
postgres.Password = *optPass
postgres.SSLmode = *optSSLmode
postgres.Timeout = *optConnectTimeout
postgres.Option = option
helper := mp.NewMackerelPlugin(postgres)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-postgres-%s-%s", *optHost, *optPort)
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例14: main
func main() {
optGraphName := flag.String("name", "snmp", "Graph name")
optGraphUnit := flag.String("unit", "float", "Graph unit")
optHost := flag.String("host", "localhost", "Hostname")
optCommunity := flag.String("community", "public", "SNMP V2c Community")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
var snmp SNMPPlugin
snmp.Host = *optHost
snmp.Community = *optCommunity
snmp.GraphName = *optGraphName
snmp.GraphUnit = *optGraphUnit
sms := []SNMPMetrics{}
for _, arg := range flag.Args() {
vals := strings.Split(arg, ":")
if len(vals) < 2 {
continue
}
mpm := mp.Metrics{Name: vals[1], Label: vals[1]}
if len(vals) >= 3 {
mpm.Diff, _ = strconv.ParseBool(vals[2])
}
if len(vals) >= 4 {
mpm.Stacked, _ = strconv.ParseBool(vals[3])
}
sms = append(sms, SNMPMetrics{OID: vals[0], Metrics: mpm})
}
snmp.SNMPMetricsSlice = sms
helper := mp.NewMackerelPlugin(snmp)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-snmp-%s-%s", *optHost, *optGraphName)
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}
示例15: Do
// Do the plugin
func Do() {
optRegion := flag.String("region", "", "AWS Region")
optAccessKeyID := flag.String("access-key-id", "", "AWS Access Key ID")
optSecretAccessKey := flag.String("secret-access-key", "", "AWS Secret Access Key")
optIdentifier := flag.String("identifier", "", "DB Instance Identifier")
optEngine := flag.String("engine", "", "RDS Engine")
optPrefix := flag.String("metric-key-prefix", "rds", "Metric key prefix")
optLabelPrefix := flag.String("metric-label-prefix", "", "Metric Label prefix")
optTempfile := flag.String("tempfile", "", "Temp file name")
flag.Parse()
rds := RDSPlugin{
Prefix: *optPrefix,
}
if *optLabelPrefix == "" {
if *optPrefix == "rds" {
rds.LabelPrefix = "RDS"
} else {
rds.LabelPrefix = strings.Title(*optPrefix)
}
} else {
rds.LabelPrefix = *optLabelPrefix
}
if *optRegion == "" {
rds.Region = aws.InstanceRegion()
} else {
rds.Region = *optRegion
}
rds.Identifier = *optIdentifier
rds.AccessKeyID = *optAccessKeyID
rds.SecretAccessKey = *optSecretAccessKey
rds.Engine = *optEngine
helper := mp.NewMackerelPlugin(rds)
if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = "/tmp/mackerel-plugin-rds"
}
if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
} else {
helper.OutputValues()
}
}