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;
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
add a comment |
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
add a comment |
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
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
linux monit
edited May 22 at 16:54
JakeGould
3,2491836
3,2491836
asked Oct 8 '14 at 16:54
Matthew LevisMatthew Levis
132
132
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
fiThen 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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
fiThen 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.
add a comment |
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
fiThen 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.
add a comment |
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
fiThen 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.
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
fiThen 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.
edited May 22 at 16:56
JakeGould
3,2491836
3,2491836
answered Oct 8 '14 at 18:26
unlinkunlink
560510
560510
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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