Icinga / icingaweb2-module-vspheredb

The easiest way to monitor a VMware vSphere environment.
https://icinga.com/docs/vsphere/latest
GNU General Public License v2.0
100 stars 34 forks source link

"warning is not a valid state name " on vcenter connection tests #297

Closed Mikesch-mp closed 2 years ago

Mikesch-mp commented 2 years ago

Expected Behavior

No matter if the state is in lowercase or uppercase reported by vcenters it should work.

Current Behavior

if vCener send state in lowercase (dont ask me why) the check fails with unkown state

icingaweb2:~ $ '/usr/bin/icingacli' 'vspheredb' 'check' 'vcenterconnection' '--name' 'myvecnter.fqdn' '--vCenter' '666'
[UNKNOWN] warning is not a valid state name

Possible Solution

add $state = strtoupper($state); to the function wantNumericState

    protected function wantNumericState($state)
    {
        $state = strtoupper($state);
        if (is_int($state) || ctype_digit($state)) {
            if (array_key_exists($state, $this->stateNameMap)) {
                return (int) $state;
            } else {
                throw new InvalidArgumentException(sprintf('%d is not a valid numeric state', $state));
            }
        } else {
            if (array_key_exists($state, $this->nameStateMap)) {
                return $this->nameStateMap[$state];
            } else {
                throw new InvalidArgumentException(sprintf('%s is not a valid state name', $state));
            }
        }
    }

Steps to Reproduce (for bugs)

Happens on some vecenter connection tests.

Your Environment

Thomas-Gelf commented 2 years ago

This should have been fixed