Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have many server running on live. Each server has many application. Each application has directory like /etc/somedir1, /etc/somedir2 where in each of that directory has many .html files. The application live level is showed as how many .html files available. The more the better. The .html files will be deleted from time to time. 144 or less .html files considered as critical, and I will manually add more .html files.

The server number is growing, it will be difficult in the future.

I want all that servers monitored by one server (like M/Monit), based on how many .html files left in the specific directories.

M/Monit looks great but AFAIK, it only monitor server live and its related services.

One thing that I can think is ls | wc -l and then scp to the monitor server. But I dont know how to make it displayed in the monitor server just like in other server monitoring tools.

Any ideas are welcome

share|improve this question

5 Answers 5

up vote 2 down vote accepted

Some options for you:

  • Nagios + nrpe

Write a simple script to count the number of *.html files in the specified directory:

COUNT=`ls "$1"/*.html | wc -l`
if [ $COUNT -lt $3 ]; then
    echo "OK - The number of html files in $1 is $COUNT"
    exit 0
elif [ $COUNT -ge $3 -a $COUNT -lt $5 ]; then
    echo "Warning - The number of html files in $1 is $COUNT""
    exit 1
else
    echo "Critical - The number of html files in $1 is $COUNT""
    exit 2
fi

and call it in nrpe.conf with:

command[number_of_html_files]=/path/to/html_count.sh /etc/somedir1 -w 121 -c 141
  • Ganglia + Gmetric:

Create a html_count_gmetric.sh file as belows:

/usr/bin/gmetric --name html_count --value `ls "$1"/*.html | wc -l` --type uint32 --unit files

and put it into a cron job:

* * * * * /path/to/html_count_gmetric.sh /etc/somedir1

it will create a graph for you.

share|improve this answer

We considered using monit, but wound up with the more capable-but-harder-to-configure Nagios. Nagios can certainly do what you want, albeit probably with writing a shell script that emits the right type of exit codes.

share|improve this answer
    
Basically, what Quanta has in his answer. For the monit vs. nagios question, monit is easier to set up off the bat, but much harder to get it to do anything "custom" (there are ways to do stupid tricks, like, have a cron write out a file if everything is OK, and have monit look for that; but all these tricks are horrible hacks). Nagios is harder to set up initially, but, once you get the hang of writing check scripts, is very, very powerful. Note that we still use monit in some cases, since monit is better able to restart processes that fall over, although with Upstart, there's less need. –  cjc Aug 18 '11 at 17:56

Without knowing what you're monitoring with, it's hard to say.

What you could do is use snmpd to monitor it. You can tell it to call a script and return the result as a snmp value. Using that method would probably be the easiest, especially if you already have snmpd set up on it.

share|improve this answer

as others have mentioned, writing a nagios plugin for this would be trivial. alternatively, if you don't want to spin up a nagios instance, write a little perl/python script to watch the directories with inotify, keeping track of file counts and emitting appropriate signals (flare guns, etc) as necessary.

share|improve this answer

how if scp to all servers and then store the wc results into files/database/rrd/etc. running cronjob every x minutes. and on monitoring side you just showing the results from the files/database/rrd

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.