Ad Widget

Collapse

[v5.0] - Discovery Rule and Item Prototype to find and list folder sizes (Windows)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ZabTheo
    Member
    • Apr 2023
    • 62

    #1

    [v5.0] - Discovery Rule and Item Prototype to find and list folder sizes (Windows)

    Zabbix version 5.0

    Hello,

    I am trying to create a discovery rule to find folders and list their size.

    This is what I have setup already but it isn't working

    1. I have a powershell script to list all the folders and display it in JSON format:

    Code:
    WRITE-HOST "{"
    WRITE-HOST "`"data`":["
    $items = Get-ChildItem D:\Shares\OSTs\
    $count = 0
    ForEach ($item in $items) {
        $n = $item.FullName -replace('\\','/')
        WRITE-HOST  "`{ `"`{`#FOLDERNAME`}`":`"$n`"`}"
        $count++
        if ($count -lt $items.Count) {
            WRITE-HOST ","
        }
    }
    WRITE-HOST "]"
    WRITE-HOST "}"​
    2. I have added a UserParameter to run the powershell script
    Code:
    UserParameter=folder.discovery,powershell -File "C:\zabbix\scripts\FolderSize.ps1"
    3. I have verified the script runs using:
    Code:
    zabbix_get -s SERVERNAME -k folder.discovery
    I get the following output format:
    Code:
    {
    "data":[
    { "{#FOLDERNAME}":"D:/Shares/OSTs/USERA"}
    ,
    { "{#FOLDERNAME}":"D:/Shares/OSTs/USERB"}
    .....
    ]
    }
    ​
    4. This is what I have applied in Zabbix but I am getting no data. The server being monitored is showing no errors in the log file.

    Click image for larger version

Name:	Z1.png
Views:	892
Size:	23.1 KB
ID:	463485

    Click image for larger version

Name:	Z2.png
Views:	939
Size:	12.2 KB
ID:	463484



    Help is greatly appreciated. Thanks
    Attached Files
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    "D:/Shares/OSTs/USERB"
    Shoudln't here be \-s instead? Or has windows learned to use /-s also? :P

    if you run zabbix_get and vfs.dir.size[an of your directories] ? getting any info?

    Comment

    • ZabTheo
      Member
      • Apr 2023
      • 62

      #3
      Originally posted by cyber
      "D:/Shares/OSTs/USERB"
      Shoudln't here be \-s instead? Or has windows learned to use /-s also? :P

      if you run zabbix_get and vfs.dir.size[an of your directories] ? getting any info?
      Thanks so much for your reply, it makes complete sense, however it started working after I posted this thread. No idea why.. I just need to be more patient!

      Comment

      Working...