# Need help on creating basic custom alarm.

**URL:** <https://community.netdata.cloud/t/need-help-on-creating-basic-custom-alarm/2555>\
**Category:** Help\
**Tags:** agent, alerts\
**Created:** [February 14, 2022, 10:20am UTC](https://community.netdata.cloud/t/need-help-on-creating-basic-custom-alarm/2555 "2022-02-14T10:20:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeWaRs1206](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/dewars1206/32/697_2.png) [@DeWaRs1206](https://community.netdata.cloud/u/DeWaRs1206)\
**Post date:** [February 14, 2022, 10:20am UTC](https://community.netdata.cloud/t/need-help-on-creating-basic-custom-alarm/2555/1 "2022-02-14T10:20:53Z")

</div>

## 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\_binary
> 
> priority = 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

---

<div class="post-metadata">

**Author:** ![ilyam8](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/ilyam8/32/134_2.png) [@ilyam8](https://community.netdata.cloud/u/ilyam8)\
**Post date:** [February 15, 2022, 8:52am UTC](https://community.netdata.cloud/t/need-help-on-creating-basic-custom-alarm/2555/2 "2022-02-15T08:52:03Z")

</div>

Hi, @DeWaRs1206.

> [@DeWaRs1206](#):
>
> but I can’t really understand the documentation to do so

What documentation you are referring to? Did you check [Health Configuration Reference](https://learn.netdata.cloud/docs/agent/health/reference)? See [Example 2 - disk space](https://learn.netdata.cloud/docs/agent/health/reference#example-2---disk-space), it is close to what you need.

If you still have problems and the alarm doesn’t work - share the alarm you created and we will help you to spot the problem.

---

<div class="post-metadata">

**Author:** ![DeWaRs1206](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/dewars1206/32/697_2.png) [@DeWaRs1206](https://community.netdata.cloud/u/DeWaRs1206)\
**Post date:** [February 15, 2022, 9:54am UTC](https://community.netdata.cloud/t/need-help-on-creating-basic-custom-alarm/2555/3 "2022-02-15T09:54:37Z")

</div>

@ilyam8 thanks a lot for the answer. I was indeed checking the wrong documentation: [Configure alerts | Learn Netdata](https://learn.netdata.cloud/docs/monitor/configure-alarms)

This seems to work as expected.

> 

alarm: ufw\_status  
on: ufw.UFW\_Status  
calc: $status  
every: 1m  
warn: $this = 0  
crit: $this = 0  
repeat: warning 120s critical 10s

I will read a bit more to see what could be improve.

Thanks again for your help.

---

<div class="post-metadata">

**Author:** ![DeWaRs1206](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/dewars1206/32/697_2.png) [@DeWaRs1206](https://community.netdata.cloud/u/DeWaRs1206)\
**Post date:** [February 15, 2022, 11:23am UTC](https://community.netdata.cloud/t/need-help-on-creating-basic-custom-alarm/2555/4 "2022-02-15T11:23:53Z")

</div>

@ilyam8 I have some weird behaviour with my alarm. My alarm is the following:

> alarm: ufw\_status  
> on: ufw.UFW\_Status  
> calc: $status  
> every: 1m  
> warn: $this = 0  
> crit: $this = 0  
> repeat: critical 120s

My status is 0 in my chart:

 ![Screenshot 2022-02-15 at 12.21.21](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/2X/1/1ca0c44358409ab15cc205d364f5be2f183513b9.png)

I receive an initial alarm as expected, but one minute later, I have another alarm saying everything is fixed, which is wrong:

 ![Screenshot 2022-02-15 at 12.21.52](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/2X/c/c0846e2a3231431d7a7b2328f765b653a0d1aa98.png)

My alarm is the following from Netdata dashboard:

 ![Screenshot 2022-02-15 at 12.23.01](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/2X/9/90434f803896658edf04c49d834f7563f792a8b3.png)

Any idea what I’m missing ?

Thanks again for your help.

EDIT:

I think my misunderstanding is about the “every” option. From the documentation I see “Sets the update frequency of this alarm.” but I’m not sure what this means. While my ufw status is still inactive, at the next occurence of the frequency, the alarm is “cleared”, which seems weird to me…
