Ad Widget

Collapse

Discovery rule to create item of each subfolder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ltep
    Member
    • Nov 2022
    • 42

    #1

    Discovery rule to create item of each subfolder

    Hi,
    I need some help with creating a discovery rule:

    I have 1 folder C:\temp with 100+ subfolders. For example C:\temp\folderA, C:\temp\folderB, ...
    For every subfolder in C:\temp (max depth = 1) i want to create an item which contains the folder size. For example C:\temp\folderA - 10GB, C:\temp\folderB - 20GB.

    For this i created a discovery rule with:
    Name = folder discovery
    Key = vfs.dir.get["C:\\temp",,,,,1]
    This should get the subfolders from C:\temp with a max depth of 1.

    In LLD macros i have set 1 macro:
    LLD macro = {#DIR}
    JSONPath = $.*

    As Item prototype i used:
    Name = folder size {#DIR}
    Key = vfs.dir.size[C:\\temp\{#DIR}]
    Units = B

    When i execute the discovery rule it creates items but not with the result i want.
    The results looks like it's collecting the permissions of the folders instead of the size.

    vfs.dir.size["C:\temp\[{"modify".15598434 ....



  • ltep
    Member
    • Nov 2022
    • 42

    #2
    I found a solution myself. Here it is if someone is looking for something simular:

    Item = Contents of folder C:\temp
    Key = vfs.dir.get["C:\\temp",,,dir,,0]

    Then create a dependent discovery rule for the item above:
    Name = discovery of folders in C:\temp
    Key = discovery.folders.C.temp
    Master item = Content of folder C:\temp

    LLD macros:
    {#FOLDERNAME} -> $.basename
    {#PATHNAME} -> $.pathname

    Item prototypes:
    Name = Folder {#FOLDERNAME}
    Key = vfs.dir.size[{#PATHNAME},,,,,]
    Units = B

    Comment

    Working...