ifedix / logstashzabbix Goto Github PK
View Code? Open in Web Editor NEWA simple logstash plugin for Zabbix
License: GNU General Public License v3.0
A simple logstash plugin for Zabbix
License: GNU General Public License v3.0
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
`
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.