Ad Widget

Collapse

File count directory Windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raphael.lage
    Junior Member
    • Jul 2019
    • 9

    #1

    File count directory Windows


    Good Morning. I found some topics talking about it, but even following correctly did not work for me. I have a server and inside it G: \ foldername. In this folder I need to count the amount of files inside, how could I do that? Zabbix Version: 3.4.9
  • raphael.lage
    Junior Member
    • Jul 2019
    • 9

    #2

    Thank you for your help. In my version of zabbix, I was able to create a power shell script and collect the amount of files in a folder.

    Comment

    • baggord
      Junior Member
      • Apr 2019
      • 15

      #3
      splitek hey,

      Is it possible to define the script and user parameter from frontend or do I have to make changes directly on the host somehow?

      Comment

      • raphael.lage
        Junior Member
        • Jul 2019
        • 9

        #4
        baggord

        If you use zabbix before version 4.0, just create a power shell scritp, add UserParameter in .conf and create an item in zabbix. I did it that way and it's working perfectly. If you want to do it this way, I can pass you the script parameters.

        Comment

        • baggord
          Junior Member
          • Apr 2019
          • 15

          #5
          raphael.lage Thanks, I'm on 4.2. Actually, I'm not interested in vfs.dir.count but about custom scripting in zabbix. That's another topic, anyway, let me explain.

          I want to create custom items from windows performance monitors (perf_counter["counterid"]). (Link attached.) To do that I need to discover physical disks in a host and I have like 350+ hosts from different domains.

          Do I have to place the script in those hosts and edit the agent.conf file on hosts or is there a better way?
          ​​
          Also, I would really like see your script and item configuration just to learn more about this stuff.

          Comment

          • raphael.lage
            Junior Member
            • Jul 2019
            • 9

            #6
            baggord


            In my environment, to monitor avg disk read / write I use a template called Template OS File Server Windows and the key perf_counter [\ 234 (_Total) \ 1404].

            I saw that in your topic someone mentioned this key and you said that was not what you wanted, could give more details of what your need?

            The powershell script: Get-ChildItem c: \ yourfolder | Measure-Object | % {$ _. Count} switch ($ ITEM) { "FileCountResult" { $ count = Get-ChildItem c: \ your folder | Measure-Object | % {$ _. Count} Write-Output ($ count.FileCountResult) }}

            Note: If you want to count sub directories, add the parameter -Recurse

            Note2: If you want to filter a certain file type, add the parameter -Include * .exe

            Parameter added within .conf: UserParameter = FilesCount[*], powershell -NoProfile -ExecutionPolicy Bypass -File "script path" "$ 1"

            Comment

            • baggord
              Junior Member
              • Apr 2019
              • 15

              #7
              raphael.lage

              Thanks for the tips,

              _Total doesn't return values for all existing disks. It probably returns sum of them. I want to collect data for all separate disks. Avg Sec/Write and Avg/Sec Read for all disks and some servers has only C while many has C and D, some has E F G. So, it should be done in a flexible, dynamic way.

              Comment

              • burnsy29
                Junior Member
                • Oct 2020
                • 7

                #8
                I am using zabbix agent 3.2.4 and need to create a power shell script, add UserParameter in .conf and create an item in zabbix. If anyone can provide the code/example. I need to do a file count on the following Windows folders and trigger if count is more than 50:
                C:\inetpub\mailroot\Badmail
                C:\inetpub\mailroot\Drop
                C:\inetpub\mailroot\Pickup
                C:\inetpub\mailroot\Queue

                Many thnaks

                Comment

                Working...