Skip to content

jszzang/snap-plugin-publisher-mysql

 
 

Repository files navigation

Snap publisher plugin - MySQL

This plugin publishes data to MySQL database.

It's used in the Snap framework.

  1. Getting Started
  1. Documentation
  1. Community Support
  2. Contributing
  3. License
  4. Acknowledgements

Getting Started

System Requirements

Operating systems

All OSs currently supported by Snap:

  • Linux/amd64
  • Darwin/amd64

Installation

Download mysql plugin binary:

You can get the pre-built binaries for your OS and architecture at plugin's GitHub Releases page.

To build the plugin binary:

Fork https://github.com/intelsdi-x/snap-plugin-publisher-mysql

Clone repo into $GOPATH/src/github.com/intelsdi-x/:

$ git clone https://github.com/<yourGithubID>/snap-plugin-publisher-mysql.git

Build the plugin by running make within the cloned repo:

$ make

This builds the plugin in ./build

Configuration and Usage

Documentation

There are a number of other resources you can review to learn to use this plugin:

Task Manifest Config

In task manifest, the config section of mysql publisher describes how to establish a connection to the MySQL server.

Name Data Type Default Description
hostname string localhost the host of MySQL service
port string 3306 the port number of MySQL service
username string root the name of user
password string root the password of user
database string SNAP_TEST the name of database (use existed or create a new)
tablename string info the name of table (use existed or create a new)

Each connection parameter has a default value, but it can be override by set a value in task manifest (see exemplary task manifest)

Database schema

Metrics are saved in table with following schema:

+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| timestamp     | varchar(200) | YES  |     | NULL    |       |
| source_column | varchar(200) | YES  |     | NULL    |       |
| key_column    | varchar(200) | YES  |     | NULL    |       |
| value_column  | varchar(200) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+

Examples

Example of running psutil collector plugin and publishing data to MySQL database.

Set up the Snap framework

Ensure Snap daemon is running:

  • initd: service snap-telemetry start
  • systemd: systemctl start snap-telemetry
  • command line: sudo snapteld -l 1 -t 0 &

Download and load Snap plugins (paths to binary files for Linux/amd64):

$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-publisher-mysql/latest/linux/x86_64/snap-plugin-publisher-mysql
$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-collector-psutil/latest/linux/x86_64/snap-plugin-collector-psutil
$ snaptel plugin load snap-plugin-publisher-mysql
$ snaptel plugin load snap-plugin-collector-psutil

Create a task manifest (see exemplary tasks), for example psutil-mysql.json with following content:

{
  "version": 1,
  "schedule": {
    "type": "simple",
    "interval": "1s"
  },
  "max-failures": 10,
  "workflow": {
    "collect": {
      "metrics": {
        "/intel/psutil/load/load1": {},
        "/intel/psutil/load/load15": {},
        "/intel/psutil/load/load5": {},
        "/intel/psutil/vm/available": {},
        "/intel/psutil/vm/free": {},
        "/intel/psutil/vm/used": {}
      },
      "process": null,
      "publish": [
        {
          "plugin_name": "mysql",
          "config": {
            "username": "root",
            "password": "root",
            "hostname": "localhost",
            "port": "3306",
            "database": "mydb",
            "tablename": "snap_metrics"
          }
        }
      ]
    }
  }
}

Create a task:

$ snaptel task create -t psutil-mysql.json

Watch created task:

$ snaptel task watch <task_id>

To stop previously created task:

$ snaptel task stop <task_id>

The running task is collecting data and publishing them into MySQL database. The config section of publisher defining a database connection. If such database does not exist, a new one will be created (if a given user has privileges to create a db).

Roadmap

There isn't a current roadmap for this plugin, but it is in active development. As we launch this plugin, we do not have any outstanding requirements for the next release. If you have a feature request, please add it as an issue and/or submit a pull request.

Community Support

This repository is one of many plugins in Snap, a powerful telemetry framework. See the full project at http://github.com/intelsdi-x/snap To reach out to other users, head to the main framework

Contributing

We love contributions!

There's more than one way to give back, from examples to blogs to code updates. See our recommended process in CONTRIBUTING.md.

License

Snap, along with this plugin, is an Open Source software released under the Apache 2.0 License.

Acknowledgements

And thank you! Your contribution, through code and participation, is incredibly important to us.

About

Publishes snap metrics to MySQL

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 47.3%
  • Shell 29.9%
  • Ruby 20.4%
  • Makefile 2.4%