Skip to content

proxmox_provisioned ignores node parameter and so recognizes cluster storage which is not mapped to host #251

@fuf42

Description

@fuf42

proxmox_provisioned ignores node parameter and so recognizes cluster storage which is not mapped to host. Like this the check tries to return information for non existing storage which will lead to a crash of the check on the server side
(e.g. in my case zfs pool on pve-01, pve-02, but not on pve-03)

This could fix it (for the 2.2 version, but I think the agent plugin did not change a lot)

pve-03:/usr/lib/check_mk_agent/plugins/300 # diff proxmox_provisioned ../../proxmox_provisioned.orig
19,21d18
< # Get the short hostname of the current node
< current_node="$(hostname -s)"
<
25a23
>
83,99d80
< # Check if current node is in a comma-separated nodes list.
< # Returns 0 (true) if node is in list or list is empty (storage is shared to all).
< nodeIsAllowed() {
<   local nodes_value="$1"
<   # No nodes restriction → storage available on all nodes
<   if [ -z "$nodes_value" ]; then
<     return 0
<   fi
<   local IFS=','
<   for n in $nodes_value; do
<     if [ "$n" = "$current_node" ]; then
<       return 0
<     fi
<   done
<   return 1
< }
<
102,122d82
<   # Track per-storage-block state
<   dstype=""
<   dsname=""
<   ds_path=""
<   ds_pool=""
<   ds_nodes=""
<
<   flushStorage() {
<     # Called when a new storage block starts or at EOF — process the previous block
<     if [ -z "$dstype" ]; then
<       return
<     fi
<     if nodeIsAllowed "$ds_nodes"; then
<       if [[ "$dstype" = "dir" || "$dstype" = "nfs" ]] && [ -n "$ds_path" ]; then
<         handleDirStorage "$ds_path"
<       elif [ "$dstype" = "zfspool" ] && [ -n "$ds_pool" ]; then
<         handleZfsStorage "$ds_pool"
<       fi
<     fi
<   }
<
125,126d84
<       # New storage block starts — flush the previous one first
<       flushStorage
129,137c87,90
<       ds_path=""
<       ds_pool=""
<       ds_nodes=""
<     elif [ "$key" = "path" ]; then
<       ds_path="$value"
<     elif [ "$key" = "pool" ]; then
<       ds_pool="$value"
<     elif [ "$key" = "nodes" ]; then
<       ds_nodes="$value"
---
>     elif [[ "$key" = "path" && ( "$dstype" = "dir" || "$dstype" = "nfs" ) ]]; then
>       handleDirStorage "$value"
>     elif [ "$key" = "pool" ] && [ "$dstype" = "zfspool" ]; then
>       handleZfsStorage "$value"
140,142d92
<
<   # Flush the last storage block after EOF
<   flushStorage
pve-03:/usr/lib/check_mk_agent/plugins/300 # cat /etc/pve/storage.cfg
dir: local
        path /var/lib/vz
        content images,import,iso,vztmpl
        shared 0
....
zfspool: zfspool-no-snapshots
        pool tank/zfspool-no-snapshots
        content images,rootdir
        mountpoint /tank/zfspool-no-snapshots
        nodes pve-01,pve-02
        sparse 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions