Ad Widget

Collapse

Monitoring a folder size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isaaczabbix
    Junior Member
    • Jun 2007
    • 17

    #1

    Monitoring a folder size

    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.
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Currently agent does not natively support monitoring of folder size.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • bss
      Junior Member
      • Aug 2007
      • 3

      #3
      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:
      Code:
      du /your/path/to/folder/ -cb
      and see what it outputs.
      ex.:
      Code:
      .
      .
      .
      124502  /home/zabbix/zabbix-1.4.1/upgrades
      19071805        /home/zabbix/zabbix-1.4.1
      22328245        /home/zabbix/
      22328245        [B]total[/B]
      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:
      Code:
      UserParameter=folder_size1,du /your/path/to/folder/ -cb | grep [B]total[/B] | cut -f1
      (and replace the total with other word in case of translation)

      2: go to terminal and check if it works
      Code:
      zabbix_agentd -p
      you should get your filesize written like this:
      Code:
      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:
      Code:
      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!!

      Comment

      • just2blue4u
        Senior Member
        • Apr 2006
        • 347

        #4
        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...)
        Big ZABBIX is watching you!
        (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

        Comment

        • blue_moon
          Junior Member
          • Oct 2008
          • 1

          #5
          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?

          Comment

          • Ulewu
            Junior Member
            • Feb 2011
            • 5

            #6
            HowTo Windows FolderSize

            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
            Code:
            @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:
            Code:
            ### 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.

            Comment


            • Thomas90
              Thomas90 commented
              Editing a comment
              Hi, how can i add the item to Zabbix? I've tried from triggers, but i cant find it..
          • loalvares
            Member
            • Jun 2011
            • 35

            #7
            Great

            Originally posted by Ulewu
            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
            Code:
            @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:
            Code:
            ### 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.

            Comment

            • Ulewu
              Junior Member
              • Feb 2011
              • 5

              #8
              Originally posted by loalvares
              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.

              Comment

              • loalvares
                Member
                • Jun 2011
                • 35

                #9
                A new solution to monitor Windows Folder Sizes

                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

                Comment

                • Zickowskj
                  Member
                  Zabbix Certified Specialist
                  • Apr 2011
                  • 32

                  #10
                  Originally posted by loalvares
                  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??

                  Comment

                  • loalvares
                    Member
                    • Jun 2011
                    • 35

                    #11
                    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

                    Comment

                    • rsevero
                      Junior Member
                      • Sep 2011
                      • 1

                      #12
                      It it really?

                      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:
                      Code:
                      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).
                      Last edited by rsevero; 12-09-2011, 17:21. Reason: Text clarification

                      Comment

                      • Tec_Technician
                        Member
                        • Dec 2015
                        • 39

                        #13
                        Reviving Thread

                        Hi Zabbix Masters!!

                        I was looking for the best way to monitor a folder with Zabbix and i found this thread, it's a little old one and i want to know....

                        Today is this still the best way to monitor folder size??
                        (i dont want to install external programs or addons to zabbix).

                        I have Zabbix 3.0 in server and clients.
                        With Ubuntu 14.0.4. both of them.

                        Thanks for your time.

                        Best regards.
                        Last edited by Tec_Technician; 14-07-2016, 14:45. Reason: Forgot to add important information about the SO.

                        Comment

                        • system.schraube
                          Junior Member
                          • Aug 2016
                          • 24

                          #14
                          I have the same question.

                          I installed Zabbix 3 on Debian and would like check the size of some folders in a windows server.

                          Is this possible now?

                          Comment

                          Working...