Environment
Ubuntu 18.04 / netdata v1.33.0-50-g49d5e73c8
Problem/Question
I created a custom python.d monitoring script to monitor the status of UFW.
-- coding: utf-8 --
Description: Check UFW Status using Pythin
from bases.FrameworkServices.ExecutableService import ExecutableService
from bases.collection import find_binarypriority = 90000
ORDER = [
‘Status’,
]CHARTS = {
‘Status’: {
‘options’: [‘UFW Status’, ‘0 disable, 1 enable’, None, None, None, ‘line’],
‘lines’: [
[‘status’]
]
}
}SUDO = ‘sudo’
UFWSTATUS = ‘ufw’class Service(ExecutableService):
def init(self, configuration=None, name=None):
ExecutableService.init(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.num_lines = 1
self.lower = 0
self.upper = 2@staticmethod def check(): return True def get_data(self): data = dict() if 'Status' not in self.charts['Status']: self.charts['Status'].add_dimension(['Status']) sudo_binary = find_binary(SUDO) ufwstatus_binary = find_binary(UFWSTATUS) command = [sudo_binary, ufwstatus_binary, 'status'] smbstatus = '{0} status'.format(ufwstatus_binary) allowed = self._get_raw_data(command=command) if allowed[0].strip() == 'Status: inactive': data['status'] = 0 else: data['status'] = 1 return data
Basically, this create a graph with two values (0 or 1) depending of the status of UFW.
I would like know to create an alarm which would raise if the status = 0, but I can’t really understand the documentation to do so.
I have been looking for some example in the existing health conf but didn’t find any.
Does anyone has an example somewhere I could referee to ?
Thanks for the help.
DeWaRs