Page 1 of 2

Custom Alarm Function

Posted: Tue 14 Sep 2021 6:46 pm
by stefanbagnato
Is there any possibility to create a custom alarm function? For example, if the Data Stopped alarm triggers, (for me) the issue is due to a blocked COM port (more about that in another post) and the fix is to bounce the CMX service. I have a script to bounce the service, but I am trying to figure out a trigger. Instead of having a constantly-running script reading the mxdiags looking for a COM error, a trigger via the existing alarm setting would be awesome.

Re: Custom Alarm Function

Posted: Wed 15 Sep 2021 1:06 pm
by mcrossley
A good idea, now on the todo list.

Re: Custom Alarm Function

Posted: Wed 15 Sep 2021 10:07 pm
by Phil23
I constantly revisit a similar concept regarding overall failures.

The two basic concepts in mind were a bit like this.

1. A heartbeat file is periodically uploaded to somewhere on hosiene.co.uk & a script running on the server decides if it need to notify the user that the stations off-line.
That idea would be immediately flawed in the case of a host failure etc; Ftp could be failing to the host but fine to hosiene.

2. A script on hosiene grabs a users realtime.txt periodically, say 15 or 30 minute intervals, or definable with an appropriate lower limit minimum.
If the request fails or doesn't compare appropriately a notification is sent.

Both ideas would obviously need to be server based & keep within bandwidth limitations.

Cheers

Phil.

Edit:- Light bulb moment as usual on hitting submit....

Alternate location for the server side scripts to be hosted & run from could be beteljuice.co.uk :idea:

Re: Custom Alarm Function

Posted: Thu 16 Sep 2021 7:41 am
by freddie
Phil23 wrote: Wed 15 Sep 2021 10:07 pm I constantly revisit a similar concept regarding overall failures.

The two basic concepts in mind were a bit like this.

1. A heartbeat file is periodically uploaded to somewhere on hosiene.co.uk & a script running on the server decides if it need to notify the user that the stations off-line.
That idea would be immediately flawed in the case of a host failure etc; Ftp could be failing to the host but fine to hosiene.

2. A script on hosiene grabs a users realtime.txt periodically, say 15 or 30 minute intervals, or definable with an appropriate lower limit minimum.
If the request fails or doesn't compare appropriately a notification is sent.

Both ideas would obviously need to be server based & keep within bandwidth limitations.

Cheers

Phil.

Edit:- Light bulb moment as usual on hitting submit....

Alternate location for the server side scripts to be hosted & run from could be beteljuice.co.uk :idea:
A good idea - the external monitoring bit - but as you point out it is prone to host/internet connection failures, so I think a centralised monitor is unworkable.

What I do is periodically check access to the port that the MX interface is running on, which I have found to be extremely reliable. It's not a complex script - just a simple one-liner. I put it directly in my crontab and set it to run every 5 minutes and it will drop you an email if the connection is unavailable.

Code: Select all

nc -zw 2 IP.ADDR.OF.MX 8998 && { echo "CumulusMX up" ; } || { `mail -r xxxx@hosiene.co.uk -s "[LAN monitor]: CumulusMX check" yyyy@hosiene.co.uk <<< 'CumulusMX is down'` ; }
'nc' is netcat. If you don't have it installed, use the following:

Code: Select all

sudo apt install netcat
Other package managers use different commands to install.

Re: Custom Alarm Function

Posted: Thu 16 Sep 2021 12:43 pm
by stefanbagnato
Yeah I do like the idea. However, for some folks (myself included) it wouldn't be that useful. Everything is local; physical server, CMX db, web server, etc.

My idea (hope?) was just the support for a custom function. Like the ability to call a batch file or ps script. Then I can make it do whatever magic I'd like ;)

Re: Custom Alarm Function

Posted: Thu 16 Sep 2021 2:32 pm
by freddie
The drawback of a custom function is that it won't tell you if MX stops running - as it will be MX triggering your magic.

This idea (using nc or some other external utility) is purely for alerting you when MX stops running.

Re: Custom Alarm Function

Posted: Thu 16 Sep 2021 8:37 pm
by Phil23
stefanbagnato wrote: Thu 16 Sep 2021 12:43 pm Yeah I do like the idea. However, for some folks (myself included) it wouldn't be that useful. Everything is local; physical server, CMX db, web server, etc.
If you are locally hosting a publicly visible website, then wouldn't something like the 2nd idea would make sense.

The initial idea is not so much a CMX not working watchdog, more a case of simply my Website is not updating.

That could be for a variety of reasons in the chain.

Re: Custom Alarm Function

Posted: Thu 16 Sep 2021 10:03 pm
by Phil23
So if a service running on another Webhost somewhere was to grab my realtime.txt file every hour or two,
That would serve as a time stamp & could be compared with now and then in need be trigger an email etc.

Does that create difficulties from the point of view of cross site scripting?

Developing something like this is way out of my skill sets & have no idea what can and cannot be done from a hosts side.

Phil.

Re: Custom Alarm Function

Posted: Fri 17 Sep 2021 8:23 am
by freddie
It's a simple enough proposal. It won't be affected by XSS if you code it appropriately. I would implement it internally to your LAN if it was just a lack of updates that you wished to notice. The only reason I would do it from another web host out in the wild was if you wanted to notice lack of access to your whole website - but there are providers out there who already offer this service.

Re: Custom Alarm Function

Posted: Fri 17 Sep 2021 1:17 pm
by stefanbagnato
Phil23 wrote: Thu 16 Sep 2021 8:37 pm If you are locally hosting a publicly visible website, then wouldn't something like the 2nd idea would make sense.

The initial idea is not so much a CMX not working watchdog, more a case of simply my Website is not updating.

That could be for a variety of reasons in the chain.
Yes, this is true. IMO I think this has morphed into multiple ideas, which is awesome. My initial premise was simply related to when there is an issue with data making it to CMX, and the subsequent actions taken. However, the CMX -> Website link is equally important as well, as you stated.

Re: Custom Alarm Function

Posted: Fri 17 Sep 2021 9:46 pm
by Phil23
Ok,

Interesting real life example came up yesterday while attending one of my client's sites.

The Spare Parts Guy hits me with "When are you going to Fix your Weather Pages?".

I told him it was fine, he argued it was stuck on the 15th @ 18°C.
Opened the Gauges page in his browser & showed him it was fine.
He added that yes, the gauges worked OK & all the others were broken.
Tried hard refreshes & confirmed he was right.

Checked the same on my phone & again he's right.
Back home I find a 2nd instance has loaded due to a script timing issue (maybe).
Restarted & all was back to being fine.

So the state it was in had Realtime FTP still running fine, but the 10 minute interval process & upload was what had broken.

So in effect that creates a fault in my suggestion above that just the Realtime.txt could be used as the basis of a watchdog.

Although I check my station repeatedly each day, my link button point to the gauges page & I mostly simply take a glance then get back to what I'm doing.

Re: Custom Alarm Function

Posted: Tue 04 Oct 2022 9:16 pm
by dazza1223
freddie wrote: Thu 16 Sep 2021 7:41 am
Phil23 wrote: Wed 15 Sep 2021 10:07 pm I constantly revisit a similar concept regarding overall failures.

The two basic concepts in mind were a bit like this.

1. A heartbeat file is periodically uploaded to somewhere on hosiene.co.uk & a script running on the server decides if it need to notify the user that the stations off-line.
That idea would be immediately flawed in the case of a host failure etc; Ftp could be failing to the host but fine to hosiene.

2. A script on hosiene grabs a users realtime.txt periodically, say 15 or 30 minute intervals, or definable with an appropriate lower limit minimum.
If the request fails or doesn't compare appropriately a notification is sent.

Both ideas would obviously need to be server based & keep within bandwidth limitations.

Cheers

Phil.

Edit:- Light bulb moment as usual on hitting submit....

Alternate location for the server side scripts to be hosted & run from could be beteljuice.co.uk :idea:
A good idea - the external monitoring bit - but as you point out it is prone to host/internet connection failures, so I think a centralised monitor is unworkable.

What I do is periodically check access to the port that the MX interface is running on, which I have found to be extremely reliable. It's not a complex script - just a simple one-liner. I put it directly in my crontab and set it to run every 5 minutes and it will drop you an email if the connection is unavailable.

Code: Select all

nc -zw 2 IP.ADDR.OF.MX 8998 && { echo "CumulusMX up" ; } || { `mail -r xxxx@hosiene.co.uk -s "[LAN monitor]: CumulusMX check" yyyy@hosiene.co.uk <<< 'CumulusMX is down'` ; }
'nc' is netcat. If you don't have it installed, use the following:

Code: Select all

sudo apt install netcat
Other package managers use different commands to install.
i came across this and i think i will use it but i put all my email in and the ip off cmx but im not getting the email when i stop cmx

Re: Custom Alarm Function

Posted: Tue 04 Oct 2022 9:52 pm
by freddie
Do you have the "mail" program installed?

Re: Custom Alarm Function

Posted: Wed 05 Oct 2022 7:05 am
by dazza1223
Yes I installed this

sudo apt install netcat

Re: Custom Alarm Function

Posted: Wed 05 Oct 2022 7:47 am
by freddie
That installs netcat (nc). I mean the mail program.

What does mail -V return?