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.

    Strange issue

    Scheduled Pinned Locked Moved Troubleshooting
    24 Posts 6 Posters 9.0k Views 6 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.
    • evroomE Offline
      evroom
      last edited by yawns

      Hi,

      Investigating crashes and freezes, etc, can be very difficult.
      When everything is running fine and you collect data, you will see that everything is more or less okay.
      When it crashed or is frozen, you are too late.

      Since a few weeks I had the problem that my MM was frozen and I could not enter any commands or a command took painstakingly long to return output.
      A command like top was out of the question for example.
      Using a script running as a cron job, I was able to identify a memory issue with electron.js.
      I then decide to use a usb stick on which I created a swap device.
      Since then my MM is not freezing anymore.
      And I am able to see electron.js using up my memory and sometimes I see spikes in CPU usage.

      Mind you, that crashing is something different then freezing, but the tools to use are more or less the same, provided the MM application or a MM module is not the culprit.

      My script to check memory usage, very basic and simple:

      pi@MagicPi:~ $ cat top.sh
      #!/bin/sh
      
      date >> /home/pi/top.txt
      top -b -o +%MEM | head -n 22 >> /home/pi/top.txt
      echo "=============================================" >> /home/pi/top.txt
      

      The cron job:

      00,05,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/top.sh >/dev/null 2>&1
      

      %CPU will sort on CPU usage.

      Concerning swap space, top will show the usage, but this gives a quick view:

      $ free -h
      

      Swap details via:

      $ swapon -s
      

      There are many more commands and settings to look at, but one has to start somewhere :-)

      Good luck.

      MagicMirror version: 2.30.0
      Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
      Raspbian GNU/Linux 12 (bookworm)

      Test environment:
      MagicMirror version: v2.30.0
      Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
      Raspbian GNU/Linux 12 (bookworm)

      1 Reply Last reply Reply Quote 1
      • richland007R Offline
        richland007
        last edited by

        @evroom Thank you for your reply and i want to try all that you have written as i really feel it may help my case … but i am having a hard time decoding your steps.

        Please walk me through it, on a step by step all the way to the end on how to even increase the swap file, and what to put on my scrip and make it executable and what is a cron job?? that will be my first one actually :)

        Denis

        1 Reply Last reply Reply Quote 0
        • evroomE Offline
          evroom
          last edited by

          @richland007
          Since you managed to setup MM to the point that it is running, but crashing, I take it you know a little bit of Linux.
          Otherwise it will be more like a Linux workshop.

          Do you know how to use nano and/or vi to edit files?
          Know what for example cat, tail and head does?
          Just some Linux basics.

          I do not want to sound like a smartarse and knowitall, am a hobbyist just like you.
          Just to know the level of describing that is needed.

          MagicMirror version: 2.30.0
          Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
          Raspbian GNU/Linux 12 (bookworm)

          Test environment:
          MagicMirror version: v2.30.0
          Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
          Raspbian GNU/Linux 12 (bookworm)

          1 Reply Last reply Reply Quote 0
          • richland007R Offline
            richland007
            last edited by

            @evroom Hahah dont’ worry about coming out the wrong way … i know a little bit and i do know what nano and vi does …i use nano.
            I am not familiar with cats and tails etc but i am a fast learner and i have set up quite a bit of MM modules some stubborn ones as well but i am no expert by all means.

            I couldn’t read your first response at the beginning for some reason it wasn’t structured properly or my browser wasn’t reading it right now its a bit better but i still need some guidance

            So i need to set up a script called “top” and make it executable right??
            Than i have no idea what to do with cron :) !!!

            Lets start somewhere :)

            Denis

            1 Reply Last reply Reply Quote 0
            • evroomE Offline
              evroom
              last edited by

              @richland007

              Then let’s give it a try :slightly_smiling_face:

              First create the script:

              pi@MagicPi:~ $ cd
              pi@MagicPi:~ $ nano top.sh
              

              Copy-paste this:

              !/bin/sh
              
              date >> /home/pi/top.txt
              top -b -o +%MEM | head -n 22 >> /home/pi/top.txt
              top -b -o +%MEM | head -n 22 >> /home/pi/top.txt
              echo "=============================================" >> /home/pi/top.txt
              

              Make it executable:

              pi@MagicPi:~ $ chmod 755 top.sh
              

              Perhaps a good idea to prepare the output file in order to be sure the cron user can write in it:

              pi@MagicPi:~ $ touch /home/pi/top.txt
              pi@MagicPi:~ $ chmod 666 /home/pi/top.txt
              

              Now we add a cronjob:

              pi@MagicPi:~ $ crontab -e
              

              Add this line at the end:

              00,05,10,15,20,25,30,35,40,45,50,55 * * * * /home/pi/top.sh >/dev/null 2>&1
              

              To verify:

              pi@MagicPi:~ $ crontab -l
              

              To verify if the cronjob is actually running:

              pi@MagicPi:~ $ tail -F /var/log/syslog
              

              To check if something comes in your output file:

              pi@MagicPi:~ $ tail -F top.txt
              

              The script will run every 5 minutes, every hour, every day.
              It will output the top 15 MEMory usage and the top 15 CPU usage.

              In your case, it will be interesting to look at the last entries before the crash.
              Need to identify first if it is an CPU or MEM issue, or both.
              Then we can modify the script.

              Please do not post lengthy output.
              Better we minimise the output by grepping and sorting, etc.

              Success!

              MagicMirror version: 2.30.0
              Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
              Raspbian GNU/Linux 12 (bookworm)

              Test environment:
              MagicMirror version: v2.30.0
              Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
              Raspbian GNU/Linux 12 (bookworm)

              1 Reply Last reply Reply Quote 0
              • richland007R Offline
                richland007
                last edited by

                @evroom Ahhh you are a great man
                I will set it up as soon as i get home
                thanks in advance
                Denis

                1 Reply Last reply Reply Quote 0
                • evroomE Offline
                  evroom
                  last edited by

                  Ha ha, not that great, my MM is as slow as a turtle again.
                  The used swap on my USB stick in the meanwhile is 1GB.
                  Cannot use any commands to investigate further.
                  Not very satisfactory. :frowning_face:

                  MagicMirror version: 2.30.0
                  Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
                  Raspbian GNU/Linux 12 (bookworm)

                  Test environment:
                  MagicMirror version: v2.30.0
                  Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
                  Raspbian GNU/Linux 12 (bookworm)

                  richland007R 1 Reply Last reply Reply Quote 0
                  • richland007R Offline
                    richland007 @evroom
                    last edited by

                    @evroom Mine is not slow it works “fine” it just keeps restarting
                    I am really curious to see the output of that file and see whats causing this behavior
                    D

                    1 Reply Last reply Reply Quote 0
                    • V Offline
                      vinp Module Developer
                      last edited by

                      If previous suggestions dont help, try removing the MMM-WatchDog module and see if it crashes anymore.

                      1 Reply Last reply Reply Quote 1
                      • evroomE Offline
                        evroom
                        last edited by evroom

                        @richland007
                        I re-read your first post and your problem is more restarting then actual crashing.
                        Of course a restart can be caused by a crash …
                        MMM-WatchDog tends to restart MM, so I too would suggest to remove this module.
                        In principle all it does is sending a ping and restarting MM using pm2 when a timeout occurs.
                        I also would expect to see some lines in the pm2 logs on WatchDog.
                        Can you do ?:

                        pi@MagicPi:~ $ grep -i watchdog /home/pi/.pm2/logs/mm-out.log
                        pi@MagicPi:~ $ grep -i watchdog /home/pi/.pm2/logs/mm-error.log
                        

                        What is alo a good package to install is sysstat:

                        pi@MagicPi:~ $ sudo apt-get install sysstat
                        

                        This allows for commands like iostat and sar.

                        vmstat 10 10
                        iostat 10 10
                        sar 10 10
                        

                        MagicMirror version: 2.30.0
                        Raspberry Pi 4 Model B Rev 1.5 (8 GB RAM)
                        Raspbian GNU/Linux 12 (bookworm)

                        Test environment:
                        MagicMirror version: v2.30.0
                        Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
                        Raspbian GNU/Linux 12 (bookworm)

                        richland007R 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 2 / 3
                        • First post
                          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