Something I’ve been pondering for some time is how to set up some simple Linux service monitoring so that I can display an in indicator light in a web page to show whether a Linux service is running or not.
For example, in the TM351 VM, it could be handy to display some indicator lights in a Jupyter notebook status bar showing whether the database services we connect to from the notebooks are running correctly,
So here are some pieces that may contribute to that:
monit
, a Linux monitoring app that can run an arbitrary script if it detects that a service has stopped running; for example, this fragment shows how to post alerts frommonit
to Slack; thecheck process
watcher can run an arbitrary script;- a JQuery fragment to refresh an HTML image periodically:
setInterval(function(){ $("#myimg").attr("src", "/myimg.jpg?"+new Date().getTime()); },2000);
- some JS/CSS to display some LED style indicator lights;
My thinking is:
- use
monit
to monitor a process; if the process is down, write to a service status file in mywww
server directory, egservice_servicename_status.txt
. If a service is running the contents of this file are1
, otherwise0
; - use the JQuery fragment to poll the status file every few seconds;
- if the status file returns
0
, display a red indicator, otherwise green.
Here are some other monitoring / environment managing fragments I’m pondering:
- something like
ps_mem
, a Python utility *to accurately report the in core memory usage for a program*. I’m wondering if I could use that to track how much memory each Jupyter notebook python kernel is taking up (or maybemonit
can do that?) There’s an old extnesion that looks like ti shows reports:nbtop
. Or perhaps usepsutil
(via this issue, which seems to offer a solution?); - a minimal example of setting up notebook homepage tab for a hello world webpage; Writing a notebook server extension looks like it has the ingredients, and nb_conda provides a fuller working example. Actually, that extension looks useful for *Jupyter-as-a-learning-environment* because it lets you select different
conda
environments, which could be handy for running different activities.
Any other examples out there of Jupyter monitoring / environment management?