Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"awk" reaplacement for "head" #1

Open
lzadjsf opened this issue Jan 12, 2018 · 0 comments
Open

"awk" reaplacement for "head" #1

lzadjsf opened this issue Jan 12, 2018 · 0 comments

Comments

@lzadjsf
Copy link

lzadjsf commented Jan 12, 2018

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

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant