This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
strutture:lnf:dr:calcolo:sistemi:check_mk_custom_check_script [2018/02/01 17:55] tota@infn.it |
strutture:lnf:dr:calcolo:sistemi:check_mk_custom_check_script [2018/02/01 18:09] (current) tota@infn.it |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== check_mk custom agent check ===== | ||
+ | |||
+ | ==== script sul nodo da monitorare ==== | ||
+ | |||
+ | Sul nodo da monitorare, dopo aver installato e configurato check_mk_agent, | ||
+ | |||
+ | Es. script che restituisce in output informazioni sullo stato del cluster percona. | ||
+ | |||
+ | < | ||
+ | vi / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | # Check percona cluster status | ||
+ | |||
+ | if which mysqladmin >/ | ||
+ | then | ||
+ | |||
+ | mysql --defaults-extra-file=$MK_CONFDIR/ | ||
+ | -e " | ||
+ | show global status like ' | ||
+ | |||
+ | fi | ||
+ | </ | ||
+ | |||
+ | Diamo i permessi di esecuzione al file | ||
+ | |||
+ | < | ||
+ | # chmod +x / | ||
+ | </ | ||
+ | |||
+ | ==== script sul nodo check_mk server ==== | ||
+ | |||
+ | Sul nodo check_mk server verifichiamo che l' | ||
+ | |||
+ | < | ||
+ | |||
+ | # su - lnf | ||
+ | |||
+ | # check_mk -d [PERCONA_HOST] | fgrep -A 5 percona_status | ||
+ | |||
+ | </ | ||
+ | |||
+ | Se l' | ||
+ | |||
+ | < | ||
+ | <<< | ||
+ | wsrep_local_state_uuid de5a461b-7059-11e7-9135-b6f59edaa63d | ||
+ | wsrep_protocol_version 7 | ||
+ | wsrep_last_committed 28327916 | ||
+ | wsrep_replicated 4751904 | ||
+ | wsrep_replicated_bytes 19439632755 | ||
+ | </ | ||
+ | |||
+ | Creiamo adesso uno script Python per analizzare l' | ||
+ | |||
+ | Il file DEVE avere lo stesso nome definito nello script sull' | ||
+ | |||
+ | < | ||
+ | # vi / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | # | ||
+ | |||
+ | def parse_mysql(info): | ||
+ | values = {} | ||
+ | for line in info: | ||
+ | if len(line) == 2: | ||
+ | varname, value = line | ||
+ | try: | ||
+ | value = int(value) | ||
+ | except: | ||
+ | pass | ||
+ | else: | ||
+ | varname = line[0] | ||
+ | value = None | ||
+ | |||
+ | values[varname] = value | ||
+ | return values | ||
+ | |||
+ | |||
+ | def inventory_percona_status(info): | ||
+ | values = parse_mysql(info) | ||
+ | if ' | ||
+ | return [(None, {})] | ||
+ | |||
+ | def check_percona_status(item, | ||
+ | values = parse_mysql(info) | ||
+ | if ' | ||
+ | return (3, ' | ||
+ | |||
+ | if ' | ||
+ | return (3, ' | ||
+ | |||
+ | # Clustr sync status | ||
+ | cluster_sync_status = values[' | ||
+ | |||
+ | if cluster_sync_status == " | ||
+ | syncStatus = 0 | ||
+ | syncStatus_txt = " | ||
+ | else: | ||
+ | syncStatus = 2 | ||
+ | syncStatus_txt = " | ||
+ | |||
+ | # Clustr size | ||
+ | cluster_size = float(values[' | ||
+ | |||
+ | if cluster_size > 1: | ||
+ | sizeStatus = 0 | ||
+ | elif cluster_size == 1: | ||
+ | sizeStatus = 2 | ||
+ | |||
+ | sizeStatus_txt = " | ||
+ | |||
+ | if syncStatus == 0 and sizeStatus == 0: | ||
+ | status = 0 | ||
+ | else: | ||
+ | status = 2 | ||
+ | |||
+ | status_txt = syncStatus_txt + sizeStatus_txt | ||
+ | |||
+ | return (status, status_txt + ': %d' % (cluster_size)) | ||
+ | |||
+ | |||
+ | check_info[' | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||