Ad Widget

Collapse

Monitor folder size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jordibrand
    Junior Member
    • Jan 2015
    • 16

    #1

    Monitor folder size

    I want to monitor size of specific folders on a windows host, and get the output in different items.

    e.g.:
    E:\TEST1
    E:\TEST2
    E:\TEST3

    Can anyone put me in the right direction? I know how it works with the whole partition, but not for each specific folder on that partition.
  • coreychristian
    Senior Member
    Zabbix Certified Specialist
    • Jun 2012
    • 159

    #2
    I don't believe Zabbix naively supports monitoring windows folder sizes.

    You could setup a UserParameter that could execute a command which would give you the folder size. If you have powershell on the hosts, below is an example UserParameter.

    UserParameter=folder.size[*],powershell -noprofile -command "ls -r "$1"|measure -s Length| select sum| ft -hide"

    I haven't tested it, but something like the above should work and add the folder.size item to that host which you can setup.

    Comment

    • jordibrand
      Junior Member
      • Jan 2015
      • 16

      #3
      Thanks, I think it's kind of works. In zabbix I get the following error: Received value [ 339088873] is not suitable for value type

      Item settings are:
      Type: Zabbix agent (active)
      Type of information: Numeric (unsigned)
      Data type: Decimal

      So zabbix knows the value of the folder, but maybe there's something wrong in the item?

      Comment

      • morrolan
        Junior Member
        • Aug 2013
        • 15

        #4
        What happens if you change the type of information to a Numeric (Float)? I'm afraid I can't test this at the moment but it looks as if it will work.

        One a side note, what happens when you run the powershell on it's own? Remember Zabbix only reads the first returned line when using User Parameters.

        Comment

        • jordibrand
          Junior Member
          • Jan 2015
          • 16

          #5
          I've changed it to type Numeric (Float), but the error is the same.
          If I run it from the command line or powershell, the only output is 339088873, so it's the same.

          Comment

          • morrolan
            Junior Member
            • Aug 2013
            • 15

            #6
            More specifically, does the number returned contain a space in front of it (it appears to contain one in your initial response to the powershell script)? I'm wondering if that is throwing it off?

            Comment

            • jordibrand
              Junior Member
              • Jan 2015
              • 16

              #7
              This is the output, a lot of spaces in front of it.
              Attached Files

              Comment

              • aib
                Senior Member
                • Jan 2014
                • 1615

                #8
                I did some research and there is small correction for PowerShell script:
                Code:
                C:\>powershell -noprofile -command "[B]([/B]ls -r c:\test|measure -s Length|select Sum|ft -hide[B]|Out-string).trim()[/B]"
                8013400
                As you can see, I added front round bracket and applied .trim() function for result string.

                Please, check the new Userparameter= line and let me know if it works.
                Code:
                UserParameter=folder.size[*],powershell -noprofile -command "(ls -r "$1"|measure -s Length| select sum| ft -hide|Out-string).trim()"
                Sincerely yours,
                Aleksey

                Comment

                • jordibrand
                  Junior Member
                  • Jan 2015
                  • 16

                  #9
                  Thanks, it works! Just one problem, it works for folders under 1GB, folder above 1GB aren't working: ZBX_NOTSUPPORTED

                  Comment

                  • jordibrand
                    Junior Member
                    • Jan 2015
                    • 16

                    #10
                    De powershell script is working, but it's only not working in zabbix with folders larger then 1GB. I tried different item settings but nothing worked.
                    Anyone an idea?

                    Comment

                    • morrolan
                      Junior Member
                      • Aug 2013
                      • 15

                      #11
                      I am testing it myself now so I will get back to you after I've finished

                      Comment

                      • aib
                        Senior Member
                        • Jan 2014
                        • 1615

                        #12
                        Originally posted by jordibrand
                        Thanks, it works! Just one problem, it works for folders under 1GB, folder above 1GB aren't working: ZBX_NOTSUPPORTED
                        Did you try Numeric (unsigned) type of data?
                        Also try to play around Use custom multiplier to multiply the input to 0.001.
                        Last edited by aib; 23-02-2015, 16:28.
                        Sincerely yours,
                        Aleksey

                        Comment

                        • jordibrand
                          Junior Member
                          • Jan 2015
                          • 16

                          #13
                          Yes, my settings are:

                          Type of information: Numeric (unsigned)
                          Data type: Decimal
                          Units: B

                          I will try your suggestion (use custom multiplier), I will let you know!

                          @morrolan, thanks!

                          Comment

                          • jordibrand
                            Junior Member
                            • Jan 2015
                            • 16

                            #14
                            Originally posted by aib
                            Did you try Numeric (unsigned) type of data?
                            Also try to play around Use custom multiplier to multiply the input to 0.001.
                            It's not working, I tried 0.1, 0.01, 0.001, 0.0001 and 0.00001.

                            Comment

                            • aib
                              Senior Member
                              • Jan 2014
                              • 1615

                              #15
                              Two more checks:
                              A) Do you mind to run powershell command on that client manually?
                              Start Powershell.
                              Copy-paste command with replaced Folder Name
                              Code:
                              powershell -noprofile -command "(ls -r "c:\Folder Name"|measure -s Length| select sum| ft -hide|Out-string).trim()"
                              Show us the result of command.

                              B) And then test how it works locally on client's side?
                              Code:
                              zabbix_agentd.exe -t folder.size[c:\Folder Name]
                              Show us the result of command also.
                              Sincerely yours,
                              Aleksey

                              Comment

                              Working...