Read the statement by Michael Teeuw here.
ChatGpt developed Module MMM-Dockerstat
-
@Rags Lots of issues in the code you had. I created a PR. Check it out.
-
@mumblebaj
Yes Sir. I noticed the changes committed by you and I immediately approved the merge commit. Please understand this is my first attempt and I had ChatGPT to help me. I guess we both are still learning. Well, I cloned the fresh updated repository and installed it. Now when i run it the constantly rotating arrow is not displayed anymore, but even the status of the containers are not being displayed. The npm start logs do not have any error messages. The dev console is also not indicating any issue. So probably some more debug is required. Sincere request to keep assisting till it is resolved.
Thanks -
@Rags Unfortunately I don’t have a docker running here so cannot test that portion of your code. You need to supply the docker name as an input parameter to feed into
.exec(`sudo docker ps -f name=${payload.container} --format "{{.Names}} {{.Status}}"`)
Have you added this into the config.js?
-
@mumblebaj can u see the container names from inside a container?
-
@sdetweil No idea. Never worked with containers before. (Shocking I know :astonished_face: ) Just gave him a bit of code to get the module running correct up until the point he has to check the status of the container code.
-
@mumblebaj {
module: ‘MMM-Dockerstat’,
header: ‘Docker Status’,
position: ‘top_right’,
config: {
host: ‘192.168.1.200’, // IP address of the second Pi running Docker
interval: 600000, //60 seconds
user:‘pi’,
password:‘mypass’,
container: ‘wireguard’, // just added to check
offlineIcon: ‘fa-times-circle’, // Font Awesome icon for offline status
onlineIcon: ‘fa-check-circle’ // Font Awesome icon for online status
}
},
Yes i added the name of the container. It is still not displaying the status. Anyways the idea was for the module to probe and display the status of all containers running in docker. -
@sdetweil said in ChatGpt developed Module MMM-Dockerstat:
@mumblebaj can u see the container names from inside a container?
‘Docker ps’ command list all the containers that are currently running. So i guess the command will execute and should be able to confirm the status with the command
" ‘.exec(sudo docker ps -f name=${payload.container} --format "{{.Names}} {{.Status}}"
)’"This command uses the Docker CLI (Command Line Interface) to list the running Docker containers on a host, filtering the results by the name of the container specified in payload.container. The --format option specifies how to format the output of the docker ps command. In this case, {{.Names}} {{.Status}} is used to output only the names and statuses of the containers that match the specified filter. The output is then captured and processed by the SSH library used in the code.
anyways " work in progress ".
-
@Rags The output from the query does not return a Status of “Online”
See below what it returns.
-
@mumblebaj said in ChatGpt developed Module MMM-Dockerstat:
@Rags The output from the query does not return a Status of “Online”
See below what it returns.
Yes you are right even i got a similar output when the command was run on the second pi directly. So at least we are getting somewhere. Good news.
sudo docker ps -f name=wireguard --format “{{.Names}} {{.Status}}”
wireguard Up 36 hours.
so now i have to figure out a command line to get status of all containers in a table form with name of container and the uptime. -
@Rags but are you running this on the docker host? outside any container?
if u run this from INSIDE the container (where MM is running) , does it work?
as I recall, it does not.
I think the command (on the host) is
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
docker exec container_id “docker -ps … rest of parms”
but you will have to use docker command to get the container_id from the name to use in the exec
long time ago, 9 years now, I wrote a whole bunch of scripts to support using docker to deploy and manage a software api testing service…