Ad Widget

Collapse

zabbix 5.0 cluster shared volume monitoring for windows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lavish
    Junior Member
    • Apr 2024
    • 6

    #1

    zabbix 5.0 cluster shared volume monitoring for windows

    Hello everyone,

    Encountering a problem while applying a custom discovery rule via a Zabbix template on a Windows Server to identify the cluster shared volume. My Zabbix server is running version 5.0.15, as is my agent. Although we're able to fetch the JSON output during discovery, when fetching the item value discovery, the values aren't coming through, and the error displayed is "Unsupported item Key".

    Here are the detailed steps:
    1. Developed a PowerShell script to retrieve CSV details (script path: C:\Program Files\Zabbix Agent\csv_latest.ps1). The script snippet is as follows:
    Import-Module FailoverClusters
    $objs = @()
    $csvs = Get-ClusterSharedVolume
    foreach ($csv in $csvs)
    {
    $csvinfos = $csv | Select-Object -Property Name -ExpandProperty SharedVolumeInfo
    foreach ($csvinfo in $csvinfos)
    {
    $obj = [PSCustomObject]@{
    Name = $csv.Name
    CSVPATH = $csvinfo.FriendlyVolumeName
    Size = $csvinfo.Partition.Size
    FreeSpace = $csvinfo.Partition.FreeSpace
    UsedSpace = $csvinfo.Partition.UsedSpace
    PercentFree = $csvinfo.Partition.PercentFree
    }
    $objs += $obj
    }
    }
    $objs | ConvertTo-Json
    1. Output of the PowerShell script in JSON format after execution:
    [
    {
    "Name": "Cluster Disk 1",
    "CSVPATH": "C:\\ClusterStorage\\Volume1",
    "Size": 2894926442496,
    "FreeSpace": 279024824320,
    "UsedSpace": 2615901618176,
    "PercentFree": 9.638409
    },
    {
    "Name": "Cluster Disk 2",
    "CSVPATH": "C:\\ClusterStorage\\Volume2",
    "Size": 699863658496,
    "FreeSpace": 679058444288,
    "UsedSpace": 20805214208,
    "PercentFree": 97.02725
    }
    ]
    1. Integrated the script into UserParameters in zabbix_agentd.conf on the Windows client host:

    UserParameter=csv.discovery,powershell.exe -ExecutionPolicy Bypass -file "C:\Program Files\Zabbix Agent\csv_latest.ps1"
    Configuration on Zabbix Server GUI
    1. Template creation
    Click image for larger version

Name:	dataurl124873.png
Views:	1139
Size:	31.9 KB
ID:	482656
    1. Discovery rule Creation

    Click image for larger version

Name:	dataurl124877.png
Views:	803
Size:	50.2 KB
ID:	482660
    1. LLD macros creation in discovery rule
    Inside discovery rule, lld macros were created with jsonpath node values
    1. Discovery rule Tested and is giving proper json format response as per below screen
    Click image for larger version

Name:	dataurl124880.png
Views:	801
Size:	97.0 KB
ID:	482658
    1. Item Prototype Creation within the discovery rule – “cluster discovery”

    Click image for larger version

Name:	dataurl124878.png
Views:	802
Size:	64.9 KB
ID:	482657
    1. Item Prototype Testing is giving error as “Unsupported item key”

    Any assistance in identifying the issue or providing a fix would be greatly appreciated.
    Click image for larger version

Name:	dataurl124879.png
Views:	805
Size:	61.3 KB
ID:	482659


    Any help in identifying the issue or any fix.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    But you do not have item or UserParameter named csv.size, how can you expect it to work.. Your discovery script already returns all the values, you should change item type to depending item, add some preprocessing to extract that value from master data (jsonpath).

    Comment

    • TheMiloNet
      Junior Member
      • Sep 2024
      • 1

      #3
      Hi all, have you an update for this script?
      Is there a solution to discover and monitor csv space that works? I can't find anything. It seems impossible to me!

      Comment

      • Xenixx
        Junior Member
        • Dec 2024
        • 2

        #4
        Hey everyone, I am fairly new to Zabbix, but for anyone interested I managed to solve the issue of discovering the CSV (I am using Zabbix version 7.0 though, so I am not sure if this will work with previous versions).
        First I created an item with the key defined in UserParameter in Zabbix agent config. Then created discovery rule of dependent item type (depending on the original item). In the discovery rule I needed to do the preprocessing of json values, as well as create two LLD macros for the future item prototypes. Here is the preprocessing (I used JavaScript to do it):

        Code:
        var clusters = JSON.parse(value);
        result = clusters.map(function (clusters) {
        return {
        'name': clusters.Name,
        'csvpath': clusters.CSVPATH
        };
        });
        
        return JSON.stringify(result);
        and then created following macros (using JSONPath:
        {#CSVNAME} $.name
        {#CSVPATH} $.csvpath

        I then created one item prototype dependent on the original item (called 'data' and added another preprocessing - this time JSONPath with the following: $.[?(@.Name=='{#CSVNAME}')].first().
        With this I could create item prototypes (this time they are dependent on the 'data' item prototype) for all the data returned by script and named them using LLD macros. In each created prototype I needed to add JSONPath preprocessing with the value i wanted to get for each prototype: $.PercentFree, $.FreeSpace etc. Be aware that in the key field you need use one of the LLD macros (I used the {#CSVPATH}).
        I am not sure if this is the best solution, but I recreated it based on some out of the box template discovery and it works for me. The only issue I have sometimes is getting timeouts when executing script despite increasing the timeout period in Zabbix agent config file causing items to become unsupported. I am not sure what to do with this problem, but doesn't seem that big of an issue since the next time the script executes correctly everything goes back to normal.

        Comment

        Working...