Giter Site home page Giter Site logo

yanghongkjxy / snap-plugin-publisher-file Goto Github PK

View Code? Open in Web Editor NEW

This project forked from intelsdi-x/snap-plugin-publisher-file

0.0 2.0 0.0 80 KB

Publishes snap metrics to a file

Home Page: http://snap-telemetry.io/

License: Apache License 2.0

Makefile 3.22% Go 31.02% Shell 38.93% Ruby 26.82%

snap-plugin-publisher-file's Introduction

Build Status

Snap publisher plugin - File

This plugin supports pushing metrics into a local file

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

Installation

Download File 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-file

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

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

Build the plugin by running make within the cloned repo:

$ make

This builds the plugin in ./build

Configuration and Usage

Documentation

To use this plugin you have to specify a config with the location of the file you want to write to.

# JSON
"config": {
    "file": "/tmp/snap_published_file.json"
}

# YAML
config: 
    file: "/tmp/snap_published_file.json"

The plugin will write out all metrics serialized as JSON to the specified file. An example of this output is below:

[
  {
    "timestamp": "2016-07-25T11:27:59.795513984+02:00",
    "namespace": "/intel/mock/host0/baz",
    "data": 86,
    "unit": "",
    "tags": {
      "plugin_running_on": "my-machine"
    },
    "version": 0,
    "last_advertised_time": "0001-01-01T00:00:00Z"
  },
  {
    "timestamp": "2016-07-25T11:27:59.795514856+02:00",
    "namespace": "/intel/mock/host1/baz",
    "data": 70,
    "unit": "",
    "tags": {
      "plugin_running_on": "my-machine"
    },
    "version": 0,
    "last_advertised_time": "0001-01-01T00:00:00Z"
  },
  {
    "timestamp": "2016-07-25T11:27:59.795548989+02:00",
    "namespace": "/intel/mock/bar",
    "data": 82,
    "unit": "",
    "tags": {
      "plugin_running_on": "my-machine"
    },
    "version": 0,
    "last_advertised_time": "2016-07-25T11:27:21.852064032+02:00"
  },
  {
    "timestamp": "2016-07-25T11:27:59.795549268+02:00",
    "namespace": "/intel/mock/foo",
    "data": 72,
    "unit": "",
    "tags": {
      "plugin_running_on": "my-machine"
    },
    "version": 0,
    "last_advertised_time": "2016-07-25T11:27:21.852063228+02:00"
  }
]

Examples

Example of running psutil collector plugin, movingaverage processor plugin, and writing data as a JSON to file:

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:

$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-publisher-file/latest/linux/x86_64/snap-plugin-publisher-file
$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-processor-movingaverage/latest/linux/x86_64/snap-plugin-processor-movingaverage
$ 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-file
$ snaptel plugin load snap-plugin-processor-movingaverage
$ snaptel plugin load snap-plugin-collector-psutil

Create a task manifest (see exemplary tasks), for example psutil-movingaverage-file.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": [
        {
          "plugin_name": "movingaverage",
          "config": {
            "MovingAvgBufLength": 5
          }
        }
      ],
      "publish": [
        {
          "plugin_name": "file",
          "config": {
            "file": "/tmp/snap-psutil-movingaverage-file.log"
          }
        }
      ]
    }
  }
}

Create a task:

$ snaptel task create -t psutil-movingaverage-file.json

See JSON file containing the published data:

$ tailf /tmp/snap-psutil-movingaverage-file.json

To stop previously created task:

$ snaptel task stop <task_id>

Roadmap

There isn't a current roadmap for this plugin. However, if additional output types are wanted, please open an issue or submit a pull request as mentioned below.

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

Original code from the Snap repo.

Additional code written by:

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

snap-plugin-publisher-file's People

Contributors

nanliu avatar kindermoumoute avatar katarzyna-z avatar thomastaylor312 avatar izabellaraulin avatar rashmigottipati avatar bodepd avatar nguyenddn avatar kjlyon avatar mbbroberg avatar daria-lewandowska avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.