• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

ChatGpt developed Module MMM-Dockerstat

Scheduled Pinned Locked Moved Development
27 Posts 4 Posters 5.7k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    Rags @mumblebaj
    last edited by Apr 2, 2023, 3:18 PM

    @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.

    6ddea81e-8969-4d68-b3c3-62dfb470ab10-image.png

    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.

    S M 2 Replies Last reply Apr 2, 2023, 3:26 PM Reply Quote 0
    • S Away
      sdetweil @Rags
      last edited by sdetweil Apr 2, 2023, 3:52 PM Apr 2, 2023, 3:26 PM

      @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…

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      R 1 Reply Last reply Apr 2, 2023, 4:26 PM Reply Quote 0
      • M Online
        mumblebaj Module Developer @Rags
        last edited by Apr 2, 2023, 3:50 PM

        @Rags you can drop the -f name portion which will then list all containers running. Maybe change the query to something like the following which should give you some JSON type object which you can then work with.

        docker ps --format '{"ID":"{{ .ID }}", "Image": "{{ .Image }}", "Names":"{{ .Names }}, "Status": {{.Status}}"}'
        

        This will return something like the below:

        {"ID":"4c57d2ba3fd8", "Image": "getting-started", "Names":"silly_hodgkin, "Status": Up 44 minutes"}
        

        From this you can then extract the container you want and check the status. What I have seen the query only returns all running containers

        Check out my modules at: https://github.com/mumblebaj?tab=repositories

        S 1 Reply Last reply Apr 2, 2023, 3:56 PM Reply Quote 0
        • S Away
          sdetweil @mumblebaj
          last edited by Apr 2, 2023, 3:56 PM

          @mumblebaj but you don’t need to do all that fancy formatting if you are going to extract the info

          awk can do that

          11e836525b8d   jshridha/blueiris   "/usr/bin/supervisord"   2 years ago   Up 8 months   0.0.0.0:82->81/tcp, :::82->81/tcp, 0.0.0.0:5901->5900/tcp, :::5901->5900/tcp, 0.0.0.0:8280->8080/tcp, :::8280->8080/tcp   blueiris
          (base) sam@sams:~/MagicMirror/config$ 
          

          docker ps | awk ‘{print $1}’

          awk can split a string into parts (using some separator char (-F parm, space is default) and then u can print out just the parm u want

          also docker ps -q
          only displays the container ids.

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          M 1 Reply Last reply Apr 2, 2023, 4:07 PM Reply Quote 0
          • M Online
            mumblebaj Module Developer @sdetweil
            last edited by Apr 2, 2023, 4:07 PM

            @sdetweil Thanks Sam. I just installed Docker for the first time earlier and also learning. :-) Looks fun though. I was looking jq but can’t get that to work, How do i install jq on Docker? Or get it to work off the command line?

            Check out my modules at: https://github.com/mumblebaj?tab=repositories

            S 1 Reply Last reply Apr 2, 2023, 4:16 PM Reply Quote 0
            • S Away
              sdetweil @mumblebaj
              last edited by Apr 2, 2023, 4:16 PM

              @mumblebaj sorry, no idea on jq

              i use terminal commands all the time… jq only in nodejs

              when I have a terminal command i need output of, I use terminal command tools.

              the thing about docker is you can make an image of a ‘thing’ you want to run, and run it everywhere that supports that processor type. independent of OS and you can run multiple instance at the same time (scale up server?) without changing anything inside the image

              start up a web server with this content (mapped source folder)
              or that content , or both poof a docker command and up you go.

              getting the folders mapped to the right place for the ‘thing’ in the container takes a little (tiny amount) work

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • R Offline
                Rags @sdetweil
                last edited by Apr 2, 2023, 4:26 PM

                @sdetweil said in ChatGpt developed Module MMM-Dockerstat:

                @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…

                Sorry if i have not been clear. My MagicMirror is in the living room. The MM is running on the first pi( standalone ) not in any container. The second pi in my network is tucked away in my study. This machine is installed with Docker containing multiple containers, which include pihole, wireguard, nginx, apache etc. Occasionally, one or two containers would quit running and I would realise quite late that a particular service is down. That’s why i was trying to build this module so that the status of all containers are known in a jiffy on the MM display.
                So when the MM docker module probes the second pi it should just ssh into it and retrieve the docker status easily, format the info in an array and display it. Simple (apparently ).

                S K 2 Replies Last reply Apr 2, 2023, 4:30 PM Reply Quote 0
                • S Away
                  sdetweil @Rags
                  last edited by Apr 2, 2023, 4:30 PM

                  @Rags got it…

                  ssh will be the fun part (I think!)

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    karsten13 @Rags
                    last edited by Apr 2, 2023, 5:04 PM

                    @Rags said in ChatGpt developed Module MMM-Dockerstat:

                    and I would realise quite late that a particular service is down

                    then docker ps --format "{{.Names}} {{.State}}" maybe is the better choice, State can be one of the following: (created|restarting|running|removing|paused|exited|dead)

                    R 1 Reply Last reply Apr 3, 2023, 2:40 AM Reply Quote 0
                    • R Offline
                      Rags @karsten13
                      last edited by Rags Apr 3, 2023, 2:44 AM Apr 3, 2023, 2:40 AM

                      @karsten13 said in ChatGpt developed Module MMM-Dockerstat:

                      docker ps --format "{{.Names}} {{.State}}

                      should this command produce an output when run directly on the docker machine? I am not getting any output.!
                      2023-04-03_07-55-53.png

                      Docker ps -a gives this output listing all containers whether up or exited. I need to just pickup name and status
                      2023-04-03_08-12-19.png
                      Now just need to workout (as Sam says ‘the fun part’) ssh into second pi retrieve the docker ps -a and display.

                      K 1 Reply Last reply Apr 3, 2023, 7:46 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 2 / 3
                      2 / 3
                      • First post
                        20/27
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy