Code Monkey home page Code Monkey logo

sflow's Introduction

Sflow

Tiny sflow collector and parser script based on eventmachine. It listens for sflow v5 samples, parses them and sends it to logstash.

Installation

Clone this repository

$ git clone http://github.com/netways/sflow

Change directory

$ cd sflow

Install dependencies using bundler

$ bundle install

Configure your logstash endpoint

$ vi ./etc/config.yaml

And then execute:

$ bundle exec ./bin/sflow.rb

Logstash Configuration

A complete logstash installation is a prerequisite.

For getting the parsed sflow-packets as JSON via UDP into logstash you have to configure a input, filter and a output accordingly:

input {
 udp {
  port => 6543
  type => "sflow"
  codec => 'json'
 }
}

filter {
 json {
  source => "message"
  type => "json"
 }
}

output {
 elasticsearch_http {
  workers => 8
  host => "elasticsearch.host"
 }
}

Kibana

You can create your very own kibana dashboard for viewing the information and graphs you are interested in. For a quick start you'll find a dashboard in the misc folder, which can be imported via the kibana webinterface.

Alt text

Contributing

  1. Fork it ( http://github.com/netways/sflow/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

sflow's People

Contributors

blook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sflow's Issues

Does not install on ubuntu 14.04

Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 1.5) ruby

Current Bundler version:
bundler (1.3.5)

This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running gem install bundler?

Upgrading bundler prepends the new version in the bundler list but it still tries to run 1.3.5.

undefined method `[]' for nil:NilClass

I'm having some issues getting the collector to run successfully. It looks like the code is being executed successfully because I can see that it establishes the logstash connection and opens the listening port via netstat. When running tcpdump on the second terminal I can also see that no packets are being sent from the sflow listener to logstash. The error below repeats indefinitely and the speed seems to be related to the expected flows, leading me to believe it is successfully receiving the packets, but just unable to process them successfully. I've gone back and ensured that eventmachine, yaml, and bindata are installed. Any other thoughts on what the issue may be? Thanks!

OS: CentOS 6.5
Ruby: ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]
Logstash: logstash-1.4.2

TERMINAL 1
[root@HOST sflow]# bundle exec ./bin/sflow.rb
Connecting to Logstash: localhost:6543
Server listening.
2014-11-07 09:50:23 -0500
nil
undefined method []' for nil:NilClass /DIR/logstash-1.4.2/sflow/lib/sflow/parsers/parsers.rb:7:inparse_packet'
/DIR/logstash-1.4.2/sflow/lib/sflow/collector.rb:13:in block in receive_data' /usr/local/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
2014-11-07 09:50:23 -0500

TERMINAL 2
[root@HOST sflow]# netstat -anup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:6543 0.0.0.0:* 32242/java
udp 0 0 127.0.0.1:57626 127.0.0.1:6543 ESTABLISHED 493/ruby
udp 0 0 0.0.0.0:6343 0.0.0.0:* 493/ruby

Any particular charset I need to use for this?

I’ve getting the below warn logs:

{:timestamp=>"2015-10-22T16:32:13.196000+0100", :message=>"Received an event that has a different character encoding than you configured.", :text=>"\\u0000\\u0000\\u0000\\u0005\\u0000\\u0000\\u0000\\u0001\\xC0\\xA8\\u0001\\xEE\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0003\\u0000\\u0000\\xA7\\xF8\\u0000\\u0000\\u0000\\u0001\\u0000\\u0000\\u0000\\u0002\\u0000\\u0000\\u0002\\x90\\u0000\\u0000\\u0000\\u0003\\u0002\\u0000\\u0000\\u0001\\u0000\\u0000\\u0000\\a\\u0000\\u0000\\b4\\u0000\\u0000\\u0000\\u001C\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\a\\xD1\\u0000\\u0000\\u0001\\u0004\\u0000\\u0000\\u0000\\u0010\\u0000\\u0000\\u0000R\\u0000\\u0000\\u0000\\u0001\\u0000\\u0015]\\u0001\\x82\\x8F\\u0000\\u0000\\u0000\\u0000\\u0000M\\u0000\\u0000\\u0000\\u0001\\u001C>\\x84\\u0010o\\xD1\\u0000\\u0000\\u0000\\u0000\\u0000A\\u0000\\u0000\\u0000\\u0001\\u0000\\u0015]\\u0001\\x82r\\u0000\\u0000\\u0000\\u0000\\u0000=\\u0000\\u0000\\u0000\\u0001\\u0002\\u0000LOOP\\u0000\\u0000\\u0000\\u0000\\u00000\\u0000\\u0000\\u0000\\u0001\\u0002\\u0000LOOP\\u0000\\u0000\\u0000\\u0000\\u0000\\r\\u0000\\u0000\\u0000\\u0001 \\x89\\x84j\\xF8\\u000F\\u0000\\u0000\\u0000\\u0000\\u0000\\v\\u0000\\u0000\\u0000\\u0001\\u0000\\u0015]\\u0001\\x82\\b\\u0000\\u0000\\u0000\\u0000\\u0000L\\u0000\\u0000\\u0000\\u0001\\u001C>\\x84\\u0010o\\xD1\\u0000\\u0000\\u0000\\u0000\\u0000\\b\\u0000\\u0000\\u0000\\u0001 \\x89\\x84j\\xF8\\u000F\\u0000\\u0000\\u0000\\u0000\\u0000-\\u0000\\u0000\\u0000\\u0001\\u0000\\u0005\\x9A<x\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0017\\u0000\\u0000\\u0000\\u0001\\u0000\\xFF*\\xFC\\x91\\xCE\\u0000\\u0000\\u0000\\u0000\\u0000;\\u0000\\u0000\\u0000\\u0001\\u0002\\u0000LOOP\\u0000\\u0000\\u0000\\u0000\\u0000\\u000F\\u0000\\u0000\\u0000\\u0001\\u0000\\xFF\\xAEbq\\x98\\u0000\\u0000\\u0000\\u0000\\u0000\\u0010\\u0000\\u0000\\u0000\\u0001\\b\\u0000'\\u0000 \\x83\\u0000\\u0000\\u0000\\u0000\\u0000\\t\\u0000\\u0000\\u0000\\u0001\\u0002\\u0000LOOP\\u0000\\u0000\\u0000\\u0000\\u0000D\\u0000\\u0000\\u0000\\u0001\\u001C>\\x84\\u0010o\\xD1\\u0000\\u0000\\u0000\\u0000\\a\\xD5\\u0000\\u0000\\u00004\\u0000\\u0000\\u0000\\xAE\\x92\\xAF\\xE0\\u0000\\u0000\\u0000\\u0000G\\xE8\\u001D\\xE0\\u0000\\u0000\\u0000$\\xF9\\u0000\\t\\x97\\xDA\\u0000\\u0000\\u0000\\u0005\\f\\xB2:\\u0000\\u0004\\xA3B~\\u0000\\n#\\xFF\\u0000\\u0000\\u0000\\u0000\\u0000\\n#\\xFF\\a\\vE\\xA4\\u0000\\u0000\\a\\xD4\\u0000\\u0000\\u0000H\\u0000\\u0000\\u0000\\u0001\\xF4\\xA5\u0000\u0000\u0000\u0000\u0000\u000Fn\xE0\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x98r\x90\u0000\u0000\u0000\u0000\u0002D\xA5\\u0000\\u0000\\u0000\\u0000\\u0000\\xB9S\\xE0\\u0000\\u0000=\\xA6\\xFC\\u0000\\u0010K\\x9C\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\u0000\\u0000\\a\\xD3\\u0000\\u0000\\u0000P?r0\\xEA>|&\\\\=\\xAF\\u0014U\\u0000\\u0000\\u0000\\u0002\\u0000\\u0000\\u0000s\\u0000\\u0000\\u0000\\u0004\\u0000\\u0000\\n\\\"\\u0000\\u0001\\xB0h\\u0000\\x89X\\xF3\\xFF\\xFF\\xFF\\xFF\\u0000M\\u0012\\xE1\\u0002Q~\\u0016\\xFF\\xFF\\xFF\\xFF\\u0000\\u0002\\x94\\x89\\xFF\\xFF\\xFF\\xFFs\\x82N\\xE4\\xDC\\xCF/\\x9C\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\a\\xD6\\u0000\\u0000\\u0000(\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000O\\xE4\\u0000\\u0000\\u0000\\xB4\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0012\\xC8\\u0000\\u0000\\u0000$\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000\\a\\xD0\\u0000\\u0000\\u00008\\u0000\\u0000\\u0000\\tBVDCS-LAP\\u0000\\u0000\\u0000[\\xAE.\\xEA\\x95\\f\\u0011⸱ \\x89\\x84j\\xF8\\u000F\\u0000\\u0000\\u0000\\u0003\\u0000\\u0000\\u0000\\u0003\\u0000\\u0000\\u0000\\t6.2.9200 \\u0000\\u0000\\u0000", :expected_charset=>"UTF-8", :level=>:warn}
Thanks

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.