View Full Version : Monitoring a folder size
isaaczabbix
12-07-2007, 11:30
I need monitor a folder size. I know that is perfect posible using scripts in the agent machine but i would like to know if zabbix has a function predefined.
Currently agent does not natively support monitoring of folder size.
you can add userParameter in you /etc/zabbix/agentd.conf
here's how you do it:
1: Open your /etc/zabbix/agentd.conf with your favourite text editor
(exp. nano /etc/zabbix/agentd.conf ) but don't forget the user rights:)
than check this in your terminal:
du /your/path/to/folder/ -cb
and see what it outputs.
ex.:
.
.
.
124502 /home/zabbix/zabbix-1.4.1/upgrades
19071805 /home/zabbix/zabbix-1.4.1
22328245 /home/zabbix/
22328245 total
and check if you have written total or some other (if you have translated linux)
and then you add this line at the bottom of the file:
UserParameter=folder_size1,du /your/path/to/folder/ -cb | grep total | cut -f1
(and replace the total with other word in case of translation)
2: go to terminal and check if it works
zabbix_agentd -p
you should get your filesize written like this:
folder_size1 [t|583417//your filesize]
3:
if it does then you can go to your zabbix web interface and go to:
Configuration => Items, select your host and click create item..
give it a name and in the key field write this:
folder_size1
select type number(float) and write in the unit field "B" as byts.
at application field select filesystem. Set it as active and that's it.
you should now see it at monitoring..
Volia you get your monitoring of an folder!!
just2blue4u
02-08-2007, 09:40
Just as a small hint:
If that doesn't help, you might have less user rights.
Check if Zabbix user has at least read access to that directory and its content.
(i had that Problems some time ago...)
blue_moon
22-01-2009, 15:13
This is ok, unless you want to check the sizes of 40 folders on a 500 GB disk. I suppose the agent will start all 40 "du" at the same time. Is there a way to do this sequentially?
I made a HowTo for Monitoring a FolderSize on a Windows Host.
You have to write an bat File that gives as result the size of a given folder.
This file has to be placed in an directory on the host that is in the path variable of the system (like c:\windows)
Example GetFolderSize.bat
@echo off
@rem -- Batchfile to get the size of an folder
setLocal EnableDelayedExpansion
set /a value=0
FOR /R %1 %%I IN (*) DO set /a value=!value!+%%~zI
@echo !value!
After that you have to edit the zabbix_agentd.conf an add an userparameter that uses the created bat file.
Example zabbix_agentd.conf:
### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
UserParameter=folder_size1,GetFolderSize.bat C:\temp
Now you can add an Item to Zabbix. As Key you have to enter the <folder_size1> from the example.
I hope this helps someone a little bit.
loalvares
27-07-2011, 15:00
I made a HowTo for Monitoring a FolderSize on a Windows Host.
You have to write an bat File that gives as result the size of a given folder.
This file has to be placed in an directory on the host that is in the path variable of the system (like c:\windows)
Example GetFolderSize.bat
@echo off
@rem -- Batchfile to get the size of an folder
setLocal EnableDelayedExpansion
set /a value=0
FOR /R %1 %%I IN (*) DO set /a value=!value!+%%~zI
@echo !value!
After that you have to edit the zabbix_agentd.conf an add an userparameter that uses the created bat file.
Example zabbix_agentd.conf:
### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
UserParameter=folder_size1,GetFolderSize.bat C:\temp
Now you can add an Item to Zabbix. As Key you have to enter the <folder_size1> from the example.
I hope this helps someone a little bit.
I was looking for this solutions. I will test your script today.
Thanks.
I was looking for this solutions. I will test your script today.
Thanks.
Remember, this script is a little slow.
So if you want to check very large folders it could take some time.
If you want to check you could replace the script by an executable that does the same.
Just Google foldersize. There are some programs availible.
I used this script because my folders are not larger than 100MB an i dont want to place binarys on our servers.
loalvares
04-08-2011, 21:04
Hi guys,
I did some modifications on how to monitor windows files (with large foldes, like 20GB)
I've followed this steps:
1 - Configue zabbix agent to be actives
2 - At zabbix_agentd.conf, create your own scritp:
UserParameter=rede.size2 ,cscript //nologo <path_to_script> "$1"
3 - Use this script to return foldes size (this is a .vbs script):
Dim objFSO , objFolder, sLoc
Set objFSO = CreateObject("Scripting.FileSystemObject")
sLoc = WScript.Arguments(0)
If objFSO.FolderExists(sLoc) Then
Set objFolder = objFSO.GetFolder(sLoc)
wscript.echo objFolder.Size
Else
wscript.Echo "Fodler does not exist."
End If
Set objFolder = Nothing
Set objFSO = Nothing
4 - configure your Zabbix frontend to call your own script. You should do this usind the key value like:
rede.size2[<path_to_folder_monitored>]
5 - Create an item to each monitored folder you wants.
Best regards,
Leandro Alvares
Zickowskj
31-08-2011, 16:12
Hi guys,
I did some modifications on how to monitor windows files (with large foldes, like 20GB)
I've followed this steps:
1 - Configue zabbix agent to be actives
2 - At zabbix_agentd.conf, create your own scritp:
UserParameter=rede.size2 ,cscript //nologo <path_to_script> "$1"
3 - Use this script to return foldes size (this is a .vbs script):
4 - configure your Zabbix frontend to call your own script. You should do this usind the key value like:
rede.size2[<path_to_folder_monitored>]
5 - Create an item to each monitored folder you wants.
Best regards,
Leandro Alvares
this script is good only for monitoring large file or folder too??
loalvares
01-09-2011, 02:12
You can monitor all folder sizes.
I have created this script because it is faster than
UserParameter=folder_size1,du /your/path/to/folder/ -cb | grep total | cut -f1
I'm monitoring folder like 40 GB and it runs in 3 seg. To not decrease my zabbix server performance, I've set the agents like active.
regards,
Leandro Alvares
I have created this script because it is faster
I wonder if there can be something really faster than a du to check directory sizes. The major part of the work is reading file sizes from the disk. And this has to be done no matter which method you use.
Be aware that it can be hard to compare speed of different implementations. The problem is that the necessary info is cached by the kernel (in Linux for sure, can't say about other OSs) so the first try you make will be slow because it actually read the info from the disk. Any further try will be orders of magnitude faster as the info will be cached.
Having said all that here is a slight modification of the first suggestion with a little (cosmetic?) improvement:
du /your/path/to/folder/ -cbxs | grep total | cut -f1
It just reduces the amount of info outputed by du. I don't expect it to be faster than the previous option. It also reads info about one single filesystem: (the -x flag).