Giter Club home page Giter Club logo

logstashzabbix's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

logstashzabbix's Issues

"awk" reaplacement for "head"

I met an issue then head not works with mjson.tool.
We have replaced it with following code

awk 'BEGIN { i=0 } { ++i; if (i<=30) { print $0; } }'

Where 30 is amount of string have to be selected.

In the end I've got following logstashzabbix.sh script
#!/bin/bash
case $1 in
status )
initctl status logstash | grep -q running && echo 1 || echo 0 ;;
heap_bytes )
curl -s http://localhost:9600//_node/stats/jvm | python -mjson.tool | grep "heap_used_in_bytes | awk '{ print $2 }' | sed 's/,//' ;;
heap_percent )
curl -s http://localhost:9600//_node/stats/jvm | python -mjson.tool | grep "heap_used_percent | awk '{ print $2 }' | sed 's/,//' ;;
heap_max )
curl -s http://localhost:9600//_node/stats/jvm | python -mjson.tool | grep "heap_max_in_bytes | awk '{ print $2 }' | sed 's/,//' ;;
events_in )
curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool | awk 'BEGIN { i=0 } { ++i; if (i<=10) { print $0; } }' | grep "in | awk '{ print $2 }' | sed 's/,//' ;;
events_filtered )
curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool | awk 'BEGIN { i=0 } { ++i; if (i<=10) { print $0; } }' | grep "filtered | awk '{ print $2 }' | sed 's/,//' ;;
events_out )
curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool | awk 'BEGIN { i=0 } { ++i; if (i<=11) { print $0; } }' | grep "out | awk '{ print $2 }' | sed 's/,//' ;;
failures )
curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool | grep "failures | awk '{ print $2 }' | sed 's/,//' ;;
esac

`

Logstash 6.2

I discovered that existing script do not return pipeline stats with Logstash 6.2
spoiler alert: pipeline now called pipelines

https://www.elastic.co/guide/en/logstash/current/node-stats-api.html

Manual says that we do not need python and head anymore (API can transmit stats in pretty json format by itself)

That is my version of your script

#!/bin/bash

case $1 in
status )
initctl status logstash | grep -q running && echo 1 || echo 0 ;;
heap_bytes )
curl -s 'localhost:9600/_node/stats/jvm?pretty' | grep "heap_used_in_bytes | awk '{ print $3 }' | sed 's/,//' ;;
heap_percent )
curl -s 'localhost:9600/_node/stats/jvm?pretty' | grep "heap_used_percent | awk '{ print $3 }' | sed 's/,//' ;;
heap_max )
curl -s 'localhost:9600/_node/stats/jvm?pretty' | grep "heap_max_in_bytes | awk '{ print $3 }' | sed 's/,//' ;;
events_in )
curl -s 'localhost:9600/_node/stats/events?pretty' | grep "in | awk '{ print $3 }' | sed 's/,//' ;;
events_filtered )
curl -s 'localhost:9600/_node/stats/events?pretty' | grep "filtered | awk '{ print $3 }' | sed 's/,//' ;;
events_out )
curl -s 'localhost:9600/_node/stats/events?pretty' | grep "out | awk '{ print $3 }' | sed 's/,//' ;;
failures )
curl -s 'localhost:9600/_node/stats/reloads?pretty' | grep "failures | awk '{ print $3 }' | sed 's/,//' ;;
esac

Python json.tool module errors

So I'm using centos 7 and sometimes python dumps a bunch of error output along with the value causing zabbix to turn the item unsupported due to a type mismatch.

I redirected stderr with 2>/dev/null on each line in the bash script and it started working fine for me as I was getting sporadic results in the graphs.

I'm also using Zabbix 3.0 (I know it's old, planning on upgrading) but I back ported your template to 3.0 if you want it.

#!/bin/bash

case $1 in
    status )
        initctl status logstash | grep -q running && echo 1 || echo 0 ;;
    heap_bytes )
        curl -s http://localhost:9600//_node/stats/jvm | python -mjson.tool 2>/dev/null | grep \"heap_used_in_bytes | awk '{ print $2 }' | sed 's/,//' ;;
    heap_percent )
        curl -s http://localhost:9600//_node/stats/jvm | python -mjson.tool 2>/dev/null | grep \"heap_used_percent | awk '{ print $2 }' | sed 's/,//' ;;
    heap_max )
        curl -s http://localhost:9600//_node/stats/jvm | python -mjson.tool 2>/dev/null | grep \"heap_max_in_bytes | awk '{ print $2 }' | sed 's/,//' ;;
    events_in )
        curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool 2>/dev/null | head -10 | grep \"in | awk '{ print $2 }' | sed 's/,//' ;;
    events_filtered )
        curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool 2>/dev/null | head -10 | grep \"filtered | awk '{ print $2 }' | sed 's/,//' ;;
    events_out )
        curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool 2>/dev/null | head -11 | grep \"out | awk '{ print $2 }' | sed 's/,//' ;;
    failures )
        curl -s http://localhost:9600//_node/stats/pipeline | python -mjson.tool 2>/dev/null | grep \"failures | awk '{ print $2 }' | sed 's/,//' ;;
esac

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.