Zabbix monitors elk es (online) and zabbixelk
# Elk elasticsearch (online)
### 1. elasticsearch server, 192. 168. **. ** server (agent)
1.> first, use curl-s-XGET http: // localhost: 9200/_ cat/indices? Bytes = G to get data
1.> install zabbix-agent
1.> use shell scripts to output value names in json format
Vim elk. discovery. sh
''' Script path:/opt/sbin
#! /Bin/bash
Indexarray = ('curl-s-XGET-k-u manager: eMBPVpeumhdiewgz https: // localhost: 9200/_ cat/indices \? Bytes \ = G | sort-rnk8 | awk '{print $3}' | egrep "^ [^ B] | boxfish. * $ (date + % Y. % m. % d) "| sed's/$ (date + % Y % m % d) '// G ')
Length =$ {# indexarray [@]}
Printf "{\ n"
Printf' \ t' "\" data \":["
For (I = 0; I <$ length; I ++ ))
Do
Printf' \ n \ t {'
Printf "\" {# ELKINDEX} \ ": \" $ {indexarray [$ I]} \ "}"
If [$ I-lt $ [$ length-1]; then
Printf ','
Fi
Done
Printf "\ n \ t] \ n"
Printf "} \ n"
'''
Script authorization:
'''
Chmod + x elk. discovery. sh
'''
4.> vim/etc/zabbix/elk. index. sh # script 192. 168. **. ** server (agent)
'''
#! /Bin/bash
If [$ {}== boxfish]; then
A = 'curl-s-XGET-k-u manager: eMBPVpeumhdiewgz https: // localhost: 9200/_ cat/indices \? Bytes \ = G | sort-rnk8 | egrep "$1-$ (date + % Y. % m. % d )"'
Else
A = 'curl-s-XGET-k-u manager: eMBPVpeumhdiewgz https: // localhost: 9200/_ cat/indices \? Bytes \ = G | sort-rnk8 | egrep "$1 "'
Fi
B = 'echo $ a | awk' {print $9 }''
C = 'echo $ B | egrep-o "... $ "'
Size = 'echo $ B | sed-rn's # (. *)... \ $ # \ 1 # gp''
Case $ c in
Gb)
S = 'echo | awk "{print $ size * 1024 }"'
;;
Kb)
# S = 'scale = 3 echo "$ size/1024" | bc'
S = 'echo "$ size" | awk '{printf ("%. 3f \ n", $1/1024 )}''
# S = 'echo | awk "{print $ size/1024 }"'
;;
*)
S = $ size
Esac
Echo $ s
'''
Script authorization:
'''
Chmod + x elk. discovery. sh
'''
5.> zabbix_agent settings
'''
Mkdir-p/etc/zabbix/zabbix_agentd.d/userparameter_elk.conf
'''
/Etc/zabbix/zabbix_agentd.d # cat userparameter_elk.conf
'''
UserParameter = elk. discovery,/etc/zabbix/elk. discovery. sh
UserParameter = elk. index [*],/bin/bash/etc/zabbix/elk. index. sh $1
'''
6.> zabbix-server test
Run the name test on the zabbix_server Server:
'''
Zabbix_get-s 192. 168. **. **-k elk. discovery # script trial
{
"Data ":[
{"{# ELKINDEX}": "logstash-nginx-access "},
{"{# ELKINDEX}": ". kibana "}
]
}
'''
Value test: zabbix_get-s 192. 168. **. **-k elk. index [. kibana]
'''
25.1
'''
### 2. Configure the zabbix-server web Interface
1.> Configuration Template
! [Es1] (http://on7oqnlte.bkt.clouddn.com/es1.png)
---
! [Es2] (http://on7oqnlte.bkt.clouddn.com/es2.png)
> Click Save.
! [Es3] (http://on7oqnlte.bkt.clouddn.com/es3.png)
2.> create discovery rule
! [Es4] (http://on7oqnlte.bkt.clouddn.com/es4.png)
---
! [Es5] (http://on7oqnlte.bkt.clouddn.com/es5.png)
3.> click item prototypes.
! [Es6] (http://on7oqnlte.bkt.clouddn.com/es6.png)
---
! [Es7] (http://on7oqnlte.bkt.clouddn.com/es7.png)
4.> click Trigger prototypes.
! [Es8] (http://on7oqnlte.bkt.clouddn.com/es8.png)
---
! [Es9] (http://on7oqnlte.bkt.clouddn.com/es9.png)
---
! [Es10] (http://on7oqnlte.bkt.clouddn.com/es10.png)
5.> Add a template to the host
! [Es11] (http://on7oqnlte.bkt.clouddn.com/es11.png)
---
! [Es12] (http://on7oqnlte.bkt.clouddn.com/es12.png)
6.> Add Images
! [Es13] (http://on7oqnlte.bkt.clouddn.com/es13.png)
---
! [Es14] (http://on7oqnlte.bkt.clouddn.com/es14.png)
> Integrate all images into one graph
! [Es15] (http://on7oqnlte.bkt.clouddn.com/es14)
### 3. view the image
! [Es16] (http://on7oqnlte.bkt.clouddn.com/es15)
! [] ()
! [] ()