Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1


Remember Me


0 votes
Last Release Date
Compatible With
  • Nagios 3.x
check_defrag.zipbin and source

Help Support Ethan Galstad's New Project:

Help Support Ethan

A Message From The Founder...

As the founder of Nagios, I'm asking for your help in a cause that's dear to my heart.

I'm launching a new project to help better the world by providing the information, ideas, and inspiration that I believe can improve the lives of people everywhere.

I know you're busy managing networks, but I would appreciate it if you would consider liking my Facebook page and showing your support for the content and messages I produce by sharing them with your friends and family.

You can learn more about my project by visiting Thank you for your time. I wish you all the best in your endeavors, whatever they may be.

- Ethan

This plug-in for Nagios allows you to check if a disk needs to be defragmented.
This plug-in helps you to monitor fragmented disks.

NB: It doesn't run a defrag, It only tells you if you have to defrag your disks.

To function properly it needs .Net Framework 2.0 or higher.


The plug-in queries windows through WMI. It returns a critical state (or an ok state) according to what windows returns.
It works on windows 2003 and windows 2008.

The plug-in also return performance data.


This plug-in runs on a windows server that is checked by nagios. I used NSClient++ but i think that you can also use check_mk.

To print the help use the following command:

check_defrag.exe /h

If you use NSClient++ you have to copy check_defrag.exe into the scripts subfolder and then add the current lines into the NSC.ini file:

[NRPE Handlers]

check_ExecCustScript= scripts\$ARG1$ $ARG2$

If the lines above do not work then you probably need to edit them according to the version of NSClient that you are using.
I suggest you to increase the command_timeout in the NSC.ini

On Nagios server you have to define a new command:

define command {
command_name check_defrag_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 3600 -c check_execcustscript -a "check_defrag.exe" "$ARG1$"

Now on Nagios server you can define a new service:

define service {
use your_service_template
host_name your_server
service_description Disk Fragmentation C: D:
check_command check_defrag_nrpe!C: D:


I defined this command on NSClient:

check_ExecCustScript= scripts$ARG1$ $ARG2$

This allows you to define several commands on Nagios without edit NSC.ini of your servers.

For example, you can put (on the NSClient++ scripts subfolder of your windows server) a.exe, b.exe, c.bat and then define the following commands on Nagios:

define command {
command_name check_a
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "a.exe" "$ARG1$"

define command {
command_name check_b
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "b.exe" "$ARG1$"

define command {
command_name check_c
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_execcustscript -a "c.bat" "$ARG1$"

For any questions or concerns please contact me:

Alan Pipitone.