add monitoring for freifunk nodes
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
19dd29e847
commit
8e54d6eb23
6 changed files with 163 additions and 0 deletions
78
bundles/icinga2/files/check_freifunk_node
Normal file
78
bundles/icinga2/files/check_freifunk_node
Normal file
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from requests import get
|
||||
from sys import argv, exit
|
||||
|
||||
meshviewer_url = argv[1]
|
||||
node_id = argv[2]
|
||||
node = None
|
||||
|
||||
try:
|
||||
for n in get(meshviewer_url).json()['nodes']:
|
||||
if node_id == n['node_id']:
|
||||
node = n
|
||||
break
|
||||
|
||||
if not node:
|
||||
print('CRITICAL: Node {} not found in {}'.format(
|
||||
node_id,
|
||||
meshviewer_url,
|
||||
))
|
||||
exit(2)
|
||||
|
||||
if not node['is_online']:
|
||||
print('CRITICAL: Node "{}" is offline!'.format(
|
||||
node['hostname'],
|
||||
))
|
||||
exit(2)
|
||||
|
||||
crit = set()
|
||||
warn = set()
|
||||
if node['loadavg'] > 1:
|
||||
warn.add('has high load: {}'.format(
|
||||
node['loadavg'],
|
||||
))
|
||||
|
||||
if node['rootfs_usage'] > 0.9:
|
||||
crit.add('rootfs usage is {}%'.format(
|
||||
int(node['rootfs_usage']*100)
|
||||
))
|
||||
elif node['rootfs_usage'] > 0.8:
|
||||
warn.add('rootfs usage is {}%'.format(
|
||||
int(node['rootfs_usage']*100)
|
||||
))
|
||||
|
||||
if node['memory_usage'] > 0.9:
|
||||
crit.add('ram usage is {}%'.format(
|
||||
int(node['memory_usage']*100)
|
||||
))
|
||||
elif node['memory_usage'] > 0.8:
|
||||
warn.add('ram usage is {}%'.format(
|
||||
int(node['memory_usage']*100)
|
||||
))
|
||||
|
||||
|
||||
for line in sorted(crit):
|
||||
print('CRITICAL: Node "{}" {}'.format(
|
||||
node['hostname'],
|
||||
line,
|
||||
))
|
||||
|
||||
for line in sorted(warn):
|
||||
print('WARNING: Node "{}" {}'.format(
|
||||
node['hostname'],
|
||||
line,
|
||||
))
|
||||
|
||||
if crit:
|
||||
exit(2)
|
||||
elif warn:
|
||||
exit(1)
|
||||
else:
|
||||
print('Node "{}" reports no errors'.format(
|
||||
node['hostname'],
|
||||
))
|
||||
exit(0)
|
||||
except Exception as e:
|
||||
print(repr(e))
|
||||
exit(3)
|
|
@ -25,6 +25,13 @@ object CheckCommand "dummy_hostalive" {
|
|||
command = [ "true" ]
|
||||
}
|
||||
|
||||
object CheckCommand "check_freifunk_node" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ "/usr/local/share/icinga/plugins/check_freifunk_node", "$url$", "$id$" ]
|
||||
}
|
||||
|
||||
object CheckCommand "check_http_wget" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
|
|
@ -86,6 +86,9 @@ files = {
|
|||
'mode': '0755',
|
||||
'content_type': 'mako',
|
||||
},
|
||||
'/usr/local/share/icinga/plugins/check_freifunk_node': {
|
||||
'mode': '0755',
|
||||
},
|
||||
'/etc/sshmon.priv': {
|
||||
'content': repo.vault.decrypt_file(join('sshmon', 'sshmon.key.vault')),
|
||||
'owner': 'nagios',
|
||||
|
|
25
nodes/home/winkeeinhorn-1.py
Normal file
25
nodes/home/winkeeinhorn-1.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
nodes['home.winkeeinhorn-1'] = {
|
||||
'dummy': True,
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'default': {
|
||||
'ips': {
|
||||
'172.19.138.11',
|
||||
},
|
||||
'dhcp': True,
|
||||
'mac': 'f4:06:8d:df:05:60',
|
||||
},
|
||||
},
|
||||
'icinga2_api': {
|
||||
'freifunk': {
|
||||
'services': {
|
||||
'NODE HEALTH': {
|
||||
'check_command': 'check_freifunk_node',
|
||||
'vars.url': 'https://map.freifunk-mwu.de/data/meshviewer.json',
|
||||
'vars.id': 'f4068ddf055f',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
25
nodes/home/winkeeinhorn-2.py
Normal file
25
nodes/home/winkeeinhorn-2.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
nodes['home.winkeeinhorn-2'] = {
|
||||
'dummy': True,
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'default': {
|
||||
'ips': {
|
||||
'172.19.138.12',
|
||||
},
|
||||
'dhcp': True,
|
||||
'mac': 'f4:06:8d:df:03:38',
|
||||
},
|
||||
},
|
||||
'icinga2_api': {
|
||||
'freifunk': {
|
||||
'services': {
|
||||
'NODE HEALTH': {
|
||||
'check_command': 'check_freifunk_node',
|
||||
'vars.url': 'https://map.freifunk-mwu.de/data/meshviewer.json',
|
||||
'vars.id': 'f4068ddf0337',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
25
nodes/home/winkeeinhorn-vm.py
Normal file
25
nodes/home/winkeeinhorn-vm.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
nodes['home.winkeeinhorn-vm'] = {
|
||||
'dummy': True,
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'default': {
|
||||
'ips': {
|
||||
'172.19.138.10',
|
||||
},
|
||||
'dhcp': True,
|
||||
'mac': '42:86:56:de:00:90',
|
||||
},
|
||||
},
|
||||
'icinga2_api': {
|
||||
'freifunk': {
|
||||
'services': {
|
||||
'NODE HEALTH': {
|
||||
'check_command': 'check_freifunk_node',
|
||||
'vars.url': 'https://map.freifunk-mwu.de/data/meshviewer.json',
|
||||
'vars.id': '525400b04e4d',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue