Ad Widget

Collapse

vfs.dir.count - time out...

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alfista
    Senior Member
    • Mar 2017
    • 136

    #1

    vfs.dir.count - time out...

    Hi,

    I use longer time the parameter vfs.dir.count to monitor the number of files in the folders, but when there is a small amount of files all is working but when the count rise to more then 2000 files then I have this error in items:

    Code:
    Timeout while waiting for data.
    I have extend the time out on the monitored PC in the ZabbixAgent config to the max 30s, but still the same error.
    Please can you help me what I can do with it? I nee dto monitor bic files count - up to 10000.

    Thanks.
  • Answer selected by Alfista at 05-09-2022, 14:25.
    Alfista
    Senior Member
    • Mar 2017
    • 136

    Hi,

    thanks vicbc, I didn't know about this funcionality.
    I'm running it on Zabbix 5.4.7 and I have found a solution.
    Even the Windows use another slash as linux, by playing with it and changing the slash type to linux all started working. So I found that in Zabbix we can use the linux slashes and it will be automaticaly translated to Windows slashes by Zabbix Agend on the Windows PC.

    So now I use this commands:

    Code:
    UserParameter=AWO2[*],dir /a:-d /s /b "$1" | find /c ":"
    and in Item I call it over this key:

    Code:
    AWO1["Z:/Avid MediaFiles/MXF/AWO1/1"]
    and it works :-)

    Thanks for all your helps.

    Comment

    • vicbc
      Member
      • Nov 2021
      • 39

      #2
      Hey there Alfista.

      Yeah that's a bummer...
      As you can see in the documentation it will fail if you want to count that much of files:

      Click image for larger version

Name:	image_2021-11-23_161119.png
Views:	2632
Size:	629.9 KB
ID:	435373

      A workaround (not a perfect one but that works), since you want to gather the amount of files inside a Directory, would be to create a new item of the type SSH Agent, and from it run the commands:

      "count=`ls -la <dest_dir> | wc -l` | expr $count - 3"

      What is going there:
      We're setting a variable called count, which will be receiving the value of the command "ls -la" of your destination directory, and them you will be counting each line of it with the command "wc -l".

      In the print below, there it is. There are 10 files inside this directory. But after I use the command "wc -l" it's returning 13. It happens because wc is also counting the lines "total 8" and for directories "." and "..".
      So, because of that I'm passing the expression $count - 3, so it will return the correct value of the amount of files inside this directory.
      Click image for larger version

Name:	image_2021-11-23_163034.png
Views:	2552
Size:	9.4 KB
ID:	435374

      As I said, it's a workaround that might work, specially if you're working with 10k+ files inside a folder.
      Try it out and let us know.

      Hope it helped.

      Cheers.

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #3
        I would offer alternative as to a command proposed to run on shell. Original key also includes subfolders content into counting, based on max_depth option available. 'ls' would not do that by default, and using -R option would create too much false matches for count(pseudo-directories . and .. for each sub-folder, 1 line for each sub-folder name, empty lines between subfolder listings). Can go for something like 'find . -type f 2>/dev/null | wc -l '

        Code:
        [username@system /]$ find . -type f 2>/dev/null | wc -l
        144277
        [username@system /]$
        My system is currently has pretty low load, so execution time is pretty low as for 144k files:

        Code:
        real 0m0.573s
        user 0m0.283s
        sys 0m0.333s
        Don't know how much it will go up for high loaded systems.

        In my tests it was also giving bunch of access permission errors(was not testing as root), hence '2>/dev/null' in command.
        Last edited by ISiroshtan; 23-11-2021, 23:01.

        Comment

        • Alfista
          Senior Member
          • Mar 2017
          • 136

          #4
          Hi,

          thanks for answers.
          I dont understand when I set TimeOUt for 25~30sec while it will not count files to 10k, while when I do the same in shell directly i have it in about 1sec.

          I do it on Windows PC and not on linux and I need to have the count only the files in the folder, I dont have there any subfoldes.

          If I understand you, I should give it as a user parammeter in the Zabbix Agent?

          Thanks.

          Comment

          • Alfista
            Senior Member
            • Mar 2017
            • 136

            #5
            Hi,

            I try this user paramer:

            Code:
            UserParameter=AWO2[*],dir /a:-d /s /b "$1" | find /c ":"
            and in Item I call it over this key:

            Code:
            AWO1["Z:\Avid MediaFiles\MXF\AWO1\1"]
            but now have this error:

            Code:
            Character "\" is not allowed
            I dont know how to send the Windows folder parh without the sign " \ "

            Thanks.

            Comment

            • ISiroshtan
              Senior Member
              • Nov 2019
              • 324

              #6
              I'm a bit blind here, as I have no Win machines with agent installed readily available for me.

              Could you specify what Zabbix server version you running and where exactly you getting error from? Is it when you create item with said key? Is it error you get when item becomes unsupported? Is it some other place?

              Comment

              • vicbc
                Member
                • Nov 2021
                • 39

                #7
                Originally posted by Alfista
                Hi,

                I try this user paramer:

                Code:
                UserParameter=AWO2[*],dir /a:-d /s /b "$1" | find /c ":"
                and in Item I call it over this key:

                Code:
                AWO1["Z:\Avid MediaFiles\MXF\AWO1\1"]
                but now have this error:

                Code:
                Character "\" is not allowed
                I dont know how to send the Windows folder parh without the sign " \ "

                Thanks.


                Hey Alfista.

                Didn't think it was an Windows Host, sorry.

                In this case, Zabbix won't accept some characters, unless you enable UnsafeParameters



                Code:
                Allow all characters to be passed in arguments to user-defined parameters.
                0 - do not allow
                1 - allow
                The following characters are not allowed:
                \ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @
                Additionally, newline characters are not allowed.
                After enabling it, it should work.

                Let us know how it goes.

                Cheers

                Comment

                • Alfista
                  Senior Member
                  • Mar 2017
                  • 136

                  #8
                  Hi,

                  thanks vicbc, I didn't know about this funcionality.
                  I'm running it on Zabbix 5.4.7 and I have found a solution.
                  Even the Windows use another slash as linux, by playing with it and changing the slash type to linux all started working. So I found that in Zabbix we can use the linux slashes and it will be automaticaly translated to Windows slashes by Zabbix Agend on the Windows PC.

                  So now I use this commands:

                  Code:
                  UserParameter=AWO2[*],dir /a:-d /s /b "$1" | find /c ":"
                  and in Item I call it over this key:

                  Code:
                  AWO1["Z:/Avid MediaFiles/MXF/AWO1/1"]
                  and it works :-)

                  Thanks for all your helps.

                  Comment

                  Working...