How do I check file count inside a directory with Monit?How to monitor passenger with monitWith Monit, how do I restart a process when a directory timestamp check fails?monit: check process without pidfilemonitoring nfs with monitPID file for C program for monitmonit “check program” with email?Monitor # of established sockets with Monit?How can i send daily alerts for linux server monitoring using Monit tool(free edition)?How to make Monit “check process” conditional inside docker based on docker run args?monit check http response header

Applying Graph Theory to Linear Algebra (not the other way around)

Proof that 1-P(B|C)=P(~B|C). Is everything correct?

How to hide an urban landmark?

Do simulator games use a realistic trajectory to get into orbit?

How is water heavier than petrol, even though its molecular weight is less than petrol?

How to handle self harm scars on the arm in work environment?

Pre-1972 sci-fi short story or novel: alien(?) tunnel where people try new moves and get destroyed if they're not the correct ones

How to trick the reader into thinking they're following a redshirt instead of the protagonist?

Zeros of the Hadamard product of holomorphic functions

How can this tool find out registered domains from an IP?

How to communicate to my GM that not being allowed to use stealth isn't fun for me?

Second (easy access) account in case my bank screws up

How to tell your grandparent to not come to fetch you with their car?

Can U.S. Tax Forms Be Legally HTMLified?

Can Rydberg constant be in joules?

Why doesn't Adrian Toomes give up Spider-Man's identity?

Commas in clist_map_inline:nn split values in undesired places

How to create a pyramidal panel for a door?

Should I avoid hard-packed crusher dust trails with my hybrid?

Winning Strategy for the Magician and his Apprentice

Archi vs trop vs hyper

Playing a Character as Unobtrusive and Subservient, Yet Not Passive

How do governments keep track of their issued currency?

f-type expansion



How do I check file count inside a directory with Monit?


How to monitor passenger with monitWith Monit, how do I restart a process when a directory timestamp check fails?monit: check process without pidfilemonitoring nfs with monitPID file for C program for monitmonit “check program” with email?Monitor # of established sockets with Monit?How can i send daily alerts for linux server monitoring using Monit tool(free edition)?How to make Monit “check process” conditional inside docker based on docker run args?monit check http response header






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I have a directory on my server and I want to monitor the number of files inside this directory with Monit... How can this be done?










share|improve this question






























    2















    I have a directory on my server and I want to monitor the number of files inside this directory with Monit... How can this be done?










    share|improve this question


























      2












      2








      2








      I have a directory on my server and I want to monitor the number of files inside this directory with Monit... How can this be done?










      share|improve this question
















      I have a directory on my server and I want to monitor the number of files inside this directory with Monit... How can this be done?







      linux monit






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 22 at 16:54









      JakeGould

      3,2491836




      3,2491836










      asked Oct 8 '14 at 16:54









      Matthew LevisMatthew Levis

      132




      132




















          1 Answer
          1






          active

          oldest

          votes


















          2














          There should be some better way to do that, but this works:




          • Create your monitoring program like this, for example in /tmp/monit-num-files.sh:



            #!/bin/bash

            maxfiles=80
            dir="/tmp"

            if [ $(ls $dir|wc -l) -ge $maxfiles ]; then
            exit 1
            else
            exit 0
            fi



          • Then add this to your Monit configuration.



            check program number-of-files with path "/tmp/monit-num-files.sh"
            if status != 0 then alert


          This alerts if the number of files in /tmp is more or equal 80. Directories are counted as files (but this can be changed easily).



          If you want to change the file limit or the directory simply change the variables "maxfiles" and "dir" in the monitoring program.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "2"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f634487%2fhow-do-i-check-file-count-inside-a-directory-with-monit%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            There should be some better way to do that, but this works:




            • Create your monitoring program like this, for example in /tmp/monit-num-files.sh:



              #!/bin/bash

              maxfiles=80
              dir="/tmp"

              if [ $(ls $dir|wc -l) -ge $maxfiles ]; then
              exit 1
              else
              exit 0
              fi



            • Then add this to your Monit configuration.



              check program number-of-files with path "/tmp/monit-num-files.sh"
              if status != 0 then alert


            This alerts if the number of files in /tmp is more or equal 80. Directories are counted as files (but this can be changed easily).



            If you want to change the file limit or the directory simply change the variables "maxfiles" and "dir" in the monitoring program.






            share|improve this answer





























              2














              There should be some better way to do that, but this works:




              • Create your monitoring program like this, for example in /tmp/monit-num-files.sh:



                #!/bin/bash

                maxfiles=80
                dir="/tmp"

                if [ $(ls $dir|wc -l) -ge $maxfiles ]; then
                exit 1
                else
                exit 0
                fi



              • Then add this to your Monit configuration.



                check program number-of-files with path "/tmp/monit-num-files.sh"
                if status != 0 then alert


              This alerts if the number of files in /tmp is more or equal 80. Directories are counted as files (but this can be changed easily).



              If you want to change the file limit or the directory simply change the variables "maxfiles" and "dir" in the monitoring program.






              share|improve this answer



























                2












                2








                2







                There should be some better way to do that, but this works:




                • Create your monitoring program like this, for example in /tmp/monit-num-files.sh:



                  #!/bin/bash

                  maxfiles=80
                  dir="/tmp"

                  if [ $(ls $dir|wc -l) -ge $maxfiles ]; then
                  exit 1
                  else
                  exit 0
                  fi



                • Then add this to your Monit configuration.



                  check program number-of-files with path "/tmp/monit-num-files.sh"
                  if status != 0 then alert


                This alerts if the number of files in /tmp is more or equal 80. Directories are counted as files (but this can be changed easily).



                If you want to change the file limit or the directory simply change the variables "maxfiles" and "dir" in the monitoring program.






                share|improve this answer















                There should be some better way to do that, but this works:




                • Create your monitoring program like this, for example in /tmp/monit-num-files.sh:



                  #!/bin/bash

                  maxfiles=80
                  dir="/tmp"

                  if [ $(ls $dir|wc -l) -ge $maxfiles ]; then
                  exit 1
                  else
                  exit 0
                  fi



                • Then add this to your Monit configuration.



                  check program number-of-files with path "/tmp/monit-num-files.sh"
                  if status != 0 then alert


                This alerts if the number of files in /tmp is more or equal 80. Directories are counted as files (but this can be changed easily).



                If you want to change the file limit or the directory simply change the variables "maxfiles" and "dir" in the monitoring program.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 22 at 16:56









                JakeGould

                3,2491836




                3,2491836










                answered Oct 8 '14 at 18:26









                unlinkunlink

                560510




                560510



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Server Fault!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f634487%2fhow-do-i-check-file-count-inside-a-directory-with-monit%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

                    What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

                    Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos