Monitoring of node.js server

Hi all,

I am sure some of you probably have a system set up to monitor your node.js server, as many of us likely use this as a connection between devices and ST.

I wanted to see if someone could provide some assistance, via private message is fine as well, to set up a monitoring system for a node.js server I am running. All I need it to do is email me when it sees an ERROR message on the node.

From my research, I found one common utility most programmers seem to use to monitor their Java Script server - 'log4js.'
I also discovered ‘nodemailer’ is a way to integrate email messages with ‘log4js.’

If one or more could help give me guidance on this, I would really appreciate it. I’ve found some guides online, but the ones I found are somewhat generic and appear to be angled toward those with some good programming background, which I do not have.


I recommend using Pushover to send messages as somewhat easier than email, imho; you can message with a single line of curl.

A watchdog script is pretty easy to write too (which OS?), though PM2 is worth installing as it contains node watchdog and auto restarting, etc.

1 Like

Appreciate you offering some input on this. I should have mentioned that the node.js running on a Raspberry Pi and I run the ST app on iOS. I already have the system watching for a crash or reboot and it automatically re-loads, but I’m not sure how to integrate the health watch part.

Well, there’s 2 parts to the task:

  1. A log watcher (can be as simple as a shell script checking a tail -f;… Or PM2 or more complex ones).

  2. A notification method. I recommend trying Pushover. It’s a very simple curl statement. But Sendmail or curl to some mail server may also work.

Just need to learn how to implement both of those things, especially #1.

I have no programming knowledge :slight_smile:

1 Like

It does depend a lot on exactly what you want and need to monitor. With PM2 a node process is automatically restarted when failed, and that can prove to be so resilient that major failures are so extremely rare it’s actually not worth the trouble to do any complicated monitoring!

What do you mean by a “node.js” server? Is it an “express” web server, or does it provide some other service? There are free web services that can “ping” your server and send you a message if no response. That’s more reliable than running a monitor on the server itself. In fact, you could use SmartThings to “easily” execute a periodic ping! … A little Groovy programming, or maybe CoRE can do it?

Do a bunch of Googling?

Here’s a simple way to do process exit monitoring:

But, indeed, … tell me more of what exactly are you monitoring for?

Thanks…let me take a look at your links a bit :slight_smile:

sorry to break in on the topic like this, but where would I start setting up a node.js server that would communicate with Smartthings (I’m mainly looking at something to control my Yeelights and Xiaomi sensors)

Is there a way to have a SmartApp or device that connects to a server and monitors PM2 commands? What I would like to do is have SmartThings monitor my Mac Mini’s various apps running via PM2, such as homebridge and OpenHab. What I imagine is something like an on/off switch. The device on command would send something like “pm2 start homebridge”, the off command would send “pm2 stop homebridge”, and the device state could be learned by tailing the pm2 logs for homebridge.

Does anything like this exist? Would be really useful so that I could restart HomeBridge via SmartThings if I add a device to SmartThings and want to expose it to Homebridge via homebridge-smartthings. Likewise, it would make monitoring my various pm2 apps much easier while remote. might work for you @smartie?

Thanks - I was able to get some programming help on a solution.