Compare commits
	
		
			1 commit
		
	
	
		
			master
			...
			38-check_s
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9a29245cbf | 
					 643 changed files with 5728 additions and 20588 deletions
				
			
		
							
								
								
									
										7
									
								
								.github/workflows/packaging_test.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/workflows/packaging_test.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -17,20 +17,19 @@ jobs:
 | 
			
		|||
  test:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v4
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
      env:
 | 
			
		||||
        DEBIAN_FRONTEND: "noninteractive"
 | 
			
		||||
    - name: Remove github artefacts
 | 
			
		||||
      run: |
 | 
			
		||||
        rm -rf .github*
 | 
			
		||||
        rm -rf .git*
 | 
			
		||||
    - name: Adjust distibution in changelog file
 | 
			
		||||
      run: |
 | 
			
		||||
        sed -i '0,/restricted/s//stable/' debian/changelog
 | 
			
		||||
    - name: Build Debian package
 | 
			
		||||
      uses: dawidd6/action-debian-package@v1.6.0
 | 
			
		||||
      uses: dawidd6/action-debian-package@v1.4.0
 | 
			
		||||
      with:
 | 
			
		||||
        artifacts_directory: debian/build/release/
 | 
			
		||||
        os_distribution: testing
 | 
			
		||||
    - name: Debug
 | 
			
		||||
      run: |
 | 
			
		||||
        ls -la
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										9
									
								
								.github/workflows/release.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.github/workflows/release.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -18,7 +18,7 @@ jobs:
 | 
			
		|||
      release-id: ${{ steps.create_release.outputs.id }}
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout code
 | 
			
		||||
        uses: actions/checkout@v4
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
      - name: Install needed packages
 | 
			
		||||
        run: |
 | 
			
		||||
          if [ $(dpkg -l | grep -c dpkg-dev) -ne 1 ]; then sudo apt-get update && sudo apt-get install -y dpkg-dev; fi
 | 
			
		||||
| 
						 | 
				
			
			@ -43,20 +43,19 @@ jobs:
 | 
			
		|||
    needs: create-release
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v4
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
      env:
 | 
			
		||||
        DEBIAN_FRONTEND: "noninteractive"
 | 
			
		||||
    - name: Remove github artefacts
 | 
			
		||||
      run: |
 | 
			
		||||
        rm -rf .github*
 | 
			
		||||
        rm -rf .git*
 | 
			
		||||
    - name: Adjust distibution in changelog file
 | 
			
		||||
      run: |
 | 
			
		||||
        sed -i '0,/restricted/s//stable/' debian/changelog
 | 
			
		||||
    - name: Build Debian package
 | 
			
		||||
      uses: dawidd6/action-debian-package@v1.6.0
 | 
			
		||||
      uses: dawidd6/action-debian-package@v1.4.0
 | 
			
		||||
      with:
 | 
			
		||||
        artifacts_directory: debian/build/release/
 | 
			
		||||
        os_distribution: testing
 | 
			
		||||
#    - name: Build Debian package
 | 
			
		||||
#      uses: pi-top/action-debian-package@v0.2.0
 | 
			
		||||
#      with:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
#/usr/bin/make -f
 | 
			
		||||
 | 
			
		||||
include ../common.mk
 | 
			
		||||
| 
						 | 
				
			
			@ -1,149 +0,0 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
# Nagios plugin to monitor Nic Bonding state
 | 
			
		||||
#
 | 
			
		||||
# Based on check_bond.sh written by L.Gill 10/08/06 - V.1.0 as found on
 | 
			
		||||
# http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check-network-bonding/details
 | 
			
		||||
 | 
			
		||||
# currently I maintain my own version at https://github.com/aswen/nagios-plugins/blob/master/check_bond
 | 
			
		||||
# Copyright (c) 2010 L.Gill
 | 
			
		||||
# Copyright (c) 2011 Alexander Swen <a@swen.nu>
 | 
			
		||||
#
 | 
			
		||||
# Permission to use, copy, modify, and distribute this software for any
 | 
			
		||||
# purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
# copyright notice and this permission notice appear in all copies.
 | 
			
		||||
#
 | 
			
		||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 | 
			
		||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 | 
			
		||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 | 
			
		||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 | 
			
		||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 | 
			
		||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 | 
			
		||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# Example configuration
 | 
			
		||||
#
 | 
			
		||||
# Typical this check is placed on a client and runs via nrpe
 | 
			
		||||
# So add this to nrpe.cfg:
 | 
			
		||||
#  command[check_bond]=/usr/lib/nagios/plugins/check_bond
 | 
			
		||||
# This should warn when one of the slaves is down and go critical when the whole bond is not available.
 | 
			
		||||
# This plugin defaults to bond0. If you have multiple bonds you can tell the script so by adding -i <if>.
 | 
			
		||||
# It will also warn if the Currently Active Slave is not the expected primary interface,
 | 
			
		||||
# the default primary interface is eth0, You can override this with -p <if>
 | 
			
		||||
# -p can be a comma separated list like "-p eno49,eno50"
 | 
			
		||||
 | 
			
		||||
#  if you have dont_blame_nrpe=1 set you can choose to
 | 
			
		||||
#  command[check_bond]=/usr/lib/nagios/plugins/check_bond -i $ARG1$ -p $ARG2$
 | 
			
		||||
#
 | 
			
		||||
# define service {
 | 
			
		||||
#  use generic-service
 | 
			
		||||
#  service_description Bond state
 | 
			
		||||
#  check_command check_nrpe!check_bond
 | 
			
		||||
# or
 | 
			
		||||
#  check_command check_nrpe!check_bond!bond1
 | 
			
		||||
# or
 | 
			
		||||
#  check_command check_nrpe!check_bond!bond1!eth1
 | 
			
		||||
#}
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
# ------------------------------------------
 | 
			
		||||
# ########  Script Modifications  ##########
 | 
			
		||||
# ------------------------------------------
 | 
			
		||||
# Who    When      What
 | 
			
		||||
# ---    ----      ----
 | 
			
		||||
# A.Swen  2011-09-07 Add support for other bond module than bond0 (defaults to bond0 however)
 | 
			
		||||
# A.Swen  2013-10-11 Remove some obsolete stuff and make the script shorter
 | 
			
		||||
# B.Potts 2017-01-16 Check and display expected primary interface on bond
 | 
			
		||||
# J.Guldmyr 2018-09-25 Check for a list of primary interfaces instead of a single one
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# SETTINGS
 | 
			
		||||
# Default if is bond0
 | 
			
		||||
if=bond0
 | 
			
		||||
# Default pri is eth0
 | 
			
		||||
pri=eth0
 | 
			
		||||
 | 
			
		||||
# commands
 | 
			
		||||
GREP=/bin/grep
 | 
			
		||||
AWK=/usr/bin/gawk
 | 
			
		||||
LSMOD=/sbin/lsmod
 | 
			
		||||
 | 
			
		||||
# FUNCTIONS
 | 
			
		||||
get_options () {
 | 
			
		||||
  [ $# -gt 0 ]||result 5
 | 
			
		||||
  while getopts "i:p:" opt;do
 | 
			
		||||
    case ${opt} in
 | 
			
		||||
      i) export if=`echo ${OPTARG}` ;;
 | 
			
		||||
      p) export pri=`echo ${OPTARG}` ;;
 | 
			
		||||
      *) result 5;;
 | 
			
		||||
    esac
 | 
			
		||||
done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
result () {
 | 
			
		||||
  case $1 in
 | 
			
		||||
    0) echo "OK: - Bondingmode: $(grep "Bonding Mode:" /proc/net/bonding/${if}), active link: $2";;
 | 
			
		||||
    1) echo "UNKNOWN: plugin error";rc=3;;
 | 
			
		||||
    2) echo "CRITICAL: bonding module not loaded";rc=2;;
 | 
			
		||||
    3) echo "WARNING: state of ${if} device $2 is $3";rc=1;;
 | 
			
		||||
    4) echo "UNKNOWN: no bondinterface with name ${if} found";rc=3;;
 | 
			
		||||
    5) echo "UNKNOWN: Usage: ${me} [-i <bond interface name>] [-p <expected primary interface name>]";rc=3;;
 | 
			
		||||
    6) echo "CRITICAL: bondinterface ${if} has no active slaves";rc=2;;
 | 
			
		||||
    7) echo "WARNING: Bondingmode: $(grep "Bonding Mode:" /proc/net/bonding/${if}), (unexpected) active link: $2";rc=1;;
 | 
			
		||||
    8) echo "WARNING: bondinterface with name ${if} has less than 2 interfaces - so zero redundancy";rc=1;;
 | 
			
		||||
  esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# SCRIPT
 | 
			
		||||
# 1st set default return code:
 | 
			
		||||
rc=0
 | 
			
		||||
 | 
			
		||||
# test if this script was called correctly
 | 
			
		||||
[ $# -eq 1 -o $# -eq 3 -o $# -gt 4 ] && result 5
 | 
			
		||||
[ $rc -gt 0 ] && exit $rc
 | 
			
		||||
 | 
			
		||||
[ $# -eq 2 -o $# -eq 4 ] && get_options $@
 | 
			
		||||
[ $rc -gt 0 ] && exit $rc
 | 
			
		||||
 | 
			
		||||
# 1st we check if bonding module is loaded
 | 
			
		||||
[ "$(${LSMOD}|grep bonding)" = "" ] && result 2
 | 
			
		||||
[ $rc -gt 0 ] && exit $rc
 | 
			
		||||
 | 
			
		||||
# test if there is any bond interface with this name
 | 
			
		||||
[ -f "/proc/net/bonding/${if}" ] || result 4
 | 
			
		||||
[ $rc -gt 0 ] && exit $rc
 | 
			
		||||
 | 
			
		||||
case $(grep "Bonding Mode:" /proc/net/bonding/${if}) in
 | 
			
		||||
  *"IEEE 802.3ad Dynamic link aggregation"*) bondingmode=lacp;;
 | 
			
		||||
  *) bondingmode=masterslave;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# Inspect the state of the entire bond interface
 | 
			
		||||
if [ "$bondingmode" == "lacp" ]
 | 
			
		||||
then
 | 
			
		||||
  ifstate=$(${AWK} '/MII Status:/ {print $3}' /proc/net/bonding/bond0 | head -n 1)
 | 
			
		||||
  ifslavecount=$(${AWK} '/Slave Interface:/ {print $3}' /proc/net/bonding/bond0 | wc -l)
 | 
			
		||||
  [ "${ifstate}" != "up" ]&& result 6
 | 
			
		||||
  [[ "${pri}" =~ "${ifstate}" ]] || result 7 "${ifstate}"
 | 
			
		||||
  [ ${ifslavecount} -lt 2 ]&& result 8
 | 
			
		||||
else
 | 
			
		||||
  ifstate=$(${AWK} '/Currently Active Slave/ {print $4}' /proc/net/bonding/${if})
 | 
			
		||||
  [ "${ifstate}" = "None" ]&& result 6
 | 
			
		||||
  [[ "${pri}" =~ "${ifstate}" ]] || result 7 "${ifstate}"
 | 
			
		||||
  [ $rc -gt 0 ] && exit $rc
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# test state of each if in bond
 | 
			
		||||
ethdevs=$(${AWK} '/Slave Interface/ {print $3}' /proc/net/bonding/${if})
 | 
			
		||||
for ethdev in ${ethdevs};do
 | 
			
		||||
  state=$(${GREP} -A1 "Slave Interface: ${ethdev}" /proc/net/bonding/${if}|${AWK} '/MII Status:/ {print $3}')
 | 
			
		||||
  if [ "${state}" != "up" ];then
 | 
			
		||||
    result 3 ${ethdev} ${state}
 | 
			
		||||
  fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
[ $rc -eq 0 ] && result 0 "${ifstate}"
 | 
			
		||||
exit $rc
 | 
			
		||||
 | 
			
		||||
#END
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
Homepage: https://raw.githubusercontent.com/aswen/nagios-plugins/master/check_bond
 | 
			
		||||
Uploaders: Jan Wagner <waja@cyconet.org>
 | 
			
		||||
Description: plugin that checks for the status of bonding interfaces.
 | 
			
		||||
Recommends: gawk
 | 
			
		||||
| 
						 | 
				
			
			@ -1,17 +0,0 @@
 | 
			
		|||
Copyright (c) 2010 L.Gill
 | 
			
		||||
Copyright (c) 2011 Alexander Swen <a@swen.nu>
 | 
			
		||||
 | 
			
		||||
License: ISC license
 | 
			
		||||
 | 
			
		||||
  Permission to use, copy, modify, and/or distribute this software for any
 | 
			
		||||
  purpose with or without fee is hereby granted, provided that the above
 | 
			
		||||
  copyright notice and this permission notice appear in all copies.
 | 
			
		||||
 | 
			
		||||
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 | 
			
		||||
  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 | 
			
		||||
  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 | 
			
		||||
  SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 | 
			
		||||
  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 | 
			
		||||
  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 | 
			
		||||
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,8 +15,8 @@ before_script:
 | 
			
		|||
 | 
			
		||||
script: 
 | 
			
		||||
        - ./check_es_system.sh --help || true
 | 
			
		||||
        - test/test_status.sh
 | 
			
		||||
        - test/test_readonly.sh
 | 
			
		||||
        - test/test_disk.sh
 | 
			
		||||
        - |
 | 
			
		||||
          test/test_status.sh
 | 
			
		||||
          test/test_readonly.sh
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
# Script:       check_es_system.sh                                             #
 | 
			
		||||
# Author:       Claudio Kuenzler www.claudiokuenzler.com                       #
 | 
			
		||||
# Purpose:      Monitor ElasticSearch Store (Disk) Usage                       #
 | 
			
		||||
# Docs:         www.claudiokuenzler.com/monitoring-plugins/check_es_system.php #
 | 
			
		||||
# Official doc: www.claudiokuenzler.com/monitoring-plugins/check_es_system.php #
 | 
			
		||||
# License:      GPLv2                                                          #
 | 
			
		||||
# GNU General Public Licence (GPL) http://www.gnu.org/                         #
 | 
			
		||||
# This program is free software; you can redistribute it and/or                #
 | 
			
		||||
| 
						 | 
				
			
			@ -19,14 +19,14 @@
 | 
			
		|||
# You should have received a copy of the GNU General Public License            #
 | 
			
		||||
# along with this program; if not, see <https://www.gnu.org/licenses/>.        #
 | 
			
		||||
#                                                                              #
 | 
			
		||||
# Copyright 2016,2018-2021,2023 Claudio Kuenzler                               #
 | 
			
		||||
# Copyright 2016,2018-2021 Claudio Kuenzler                                    #
 | 
			
		||||
# Copyright 2018 Tomas Barton                                                  #
 | 
			
		||||
# Copyright 2020 NotAProfessionalDeveloper                                     #
 | 
			
		||||
# Copyright 2020 tatref                                                        #
 | 
			
		||||
# Copyright 2020 fbomj                                                         #
 | 
			
		||||
# Copyright 2021 chicco27                                                      #
 | 
			
		||||
#                                                                              #
 | 
			
		||||
# History/Changelog:                                                           #
 | 
			
		||||
# History:                                                                     #
 | 
			
		||||
# 20160429: Started programming plugin                                         #
 | 
			
		||||
# 20160601: Continued programming. Working now as it should =)                 #
 | 
			
		||||
# 20160906: Added memory usage check, check types option (-t)                  #
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,6 @@
 | 
			
		|||
# 20201125: Show names of read_only indexes with jq, set jq as default parser  #
 | 
			
		||||
# 20210616: Fix authentication bug (#38) and non ES URL responding (#39)       #
 | 
			
		||||
# 20211202: Added local node (-L), SSL settings (-K, -E), cpu check            #
 | 
			
		||||
# 20230929: Bugfix in readonly check type for missing privileges               #
 | 
			
		||||
################################################################################
 | 
			
		||||
#Variables and defaults
 | 
			
		||||
STATE_OK=0              # define the exit code if status is OK
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +66,7 @@ STATE_WARNING=1         # define the exit code if status is Warning
 | 
			
		|||
STATE_CRITICAL=2        # define the exit code if status is Critical
 | 
			
		||||
STATE_UNKNOWN=3         # define the exit code if status is Unknown
 | 
			
		||||
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin # Set path
 | 
			
		||||
version=1.12.1
 | 
			
		||||
version=1.12.0
 | 
			
		||||
port=9200
 | 
			
		||||
httpscheme=http
 | 
			
		||||
unit=G
 | 
			
		||||
| 
						 | 
				
			
			@ -500,10 +499,6 @@ readonly) # Check Readonly status on given indexes
 | 
			
		|||
      elif [[ $? -eq 28 ]]; then
 | 
			
		||||
        echo "ES SYSTEM CRITICAL - server did not respond within ${max_time} seconds"
 | 
			
		||||
        exit $STATE_CRITICAL
 | 
			
		||||
      elif [[ "$settings" =~ "is unauthorized" ]]; then
 | 
			
		||||
        errormsg=$(echo "$settings" | json_parse -r -q -c -x error -x reason)
 | 
			
		||||
        echo "ES SYSTEM CRITICAL - Access denied ($errormsg)"
 | 
			
		||||
        exit $STATE_CRITICAL
 | 
			
		||||
      fi
 | 
			
		||||
      rocount=$(echo $settings | json_parse -r -q -c -a -x settings -x index -x blocks -x read_only | grep -c true)
 | 
			
		||||
      roadcount=$(echo $settings | json_parse -r -q -c -a -x settings -x index -x blocks -x read_only_allow_delete | grep -c true)
 | 
			
		||||
| 
						 | 
				
			
			@ -528,12 +523,11 @@ readonly) # Check Readonly status on given indexes
 | 
			
		|||
      elif [[ $settingsrc -eq 28 ]]; then
 | 
			
		||||
        echo "ES SYSTEM CRITICAL - server did not respond within ${max_time} seconds"
 | 
			
		||||
        exit $STATE_CRITICAL
 | 
			
		||||
      elif [[ -n $(echo "$settings" | grep -i "unable to authenticate") ]]; then
 | 
			
		||||
      elif [[ -n $(echo $esstatus | grep -i "unable to authenticate") ]]; then
 | 
			
		||||
        echo "ES SYSTEM CRITICAL - Unable to authenticate user $user for REST request"
 | 
			
		||||
        exit $STATE_CRITICAL
 | 
			
		||||
      elif [[ "$settings" =~ "is unauthorized" ]]; then
 | 
			
		||||
        errormsg=$(echo "$settings" | json_parse -r -q -c -x error -x reason)
 | 
			
		||||
        echo "ES SYSTEM CRITICAL - Access denied ($errormsg)"
 | 
			
		||||
      elif [[ -n $(echo $esstatus | grep -i "unauthorized") ]]; then
 | 
			
		||||
        echo "ES SYSTEM CRITICAL - User $user is unauthorized"
 | 
			
		||||
        exit $STATE_CRITICAL
 | 
			
		||||
      fi
 | 
			
		||||
      rocount=$(echo $settings | json_parse -r -q -c -a -x settings -x index -x blocks -x read_only | grep -c true)
 | 
			
		||||
| 
						 | 
				
			
			@ -1,18 +0,0 @@
 | 
			
		|||
#!/bin/bash
 | 
			
		||||
echo "Test Elasticsearch status"
 | 
			
		||||
./check_es_system.sh -H 127.0.0.1 -P 9200 -t disk
 | 
			
		||||
output=$(./check_es_system.sh -H 127.0.0.1 -P 9200 -t disk)
 | 
			
		||||
 | 
			
		||||
if [[ $? -eq 0 ]]; then
 | 
			
		||||
  echo -e "\e[1m\e[32m✔ Test 3.1 OK: Disk check worked and shows green\e[0m"
 | 
			
		||||
  exitcode=0
 | 
			
		||||
else
 | 
			
		||||
  echo -e "\e[1m\e[31m✘ Test 3.1 ERROR: Disk check has not worked\e[0m"
 | 
			
		||||
  exitcode=1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if ! [[ "${output}" =~ "ES SYSTEM OK - Disk usage is at 0%" ]]; then
 | 
			
		||||
  exitcode=1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
exit $exitcode
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
Uploaders: Jan Wagner <waja@cyconet.org>
 | 
			
		||||
Recommends: curl, jshon | jq
 | 
			
		||||
Version: 1.12.1
 | 
			
		||||
Version: 1.12.0
 | 
			
		||||
Homepage: https://github.com/Napsty/check_es_system/
 | 
			
		||||
Watch: https://github.com/Napsty/check_es_system/tags .*/v?(\d\S+)\.tar\.gz
 | 
			
		||||
Description: Plugin script to check the status of an ElasticSearch cluster node.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1 +1 @@
 | 
			
		|||
check_es_system-1.12.1/
 | 
			
		||||
check_es_system-1.12.0/
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +22,7 @@
 | 
			
		|||
# Copyright (c) 2008 David Ligeret
 | 
			
		||||
# Copyright (c) 2009 Joshua Daniel Franklin
 | 
			
		||||
# Copyright (c) 2010 Branden Schneider
 | 
			
		||||
# Copyright (c) 2010-2022 Claudio Kuenzler
 | 
			
		||||
# Copyright (c) 2010-2021 Claudio Kuenzler
 | 
			
		||||
# Copyright (c) 2010 Samir Ibradzic
 | 
			
		||||
# Copyright (c) 2010 Aaron Rogers
 | 
			
		||||
# Copyright (c) 2011 Ludovic Hutin
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +38,6 @@
 | 
			
		|||
# Copyright (c) 2015 Stefan Roos
 | 
			
		||||
# Copyright (c) 2018 Peter Newman
 | 
			
		||||
# Copyright (c) 2020 Luca Berra
 | 
			
		||||
# Copyright (c) 2022 Marco Markgraf
 | 
			
		||||
#
 | 
			
		||||
# The VMware 4.1 CIM API is documented here:
 | 
			
		||||
#   http://www.vmware.com/support/developer/cim-sdk/4.1/smash/cim_smash_410_prog.pdf
 | 
			
		||||
| 
						 | 
				
			
			@ -285,14 +284,7 @@
 | 
			
		|||
#@ Author : Claudio Kuenzler
 | 
			
		||||
#@ Reason : Fix TLSv1 usage (issue #51)
 | 
			
		||||
#@---------------------------------------------------
 | 
			
		||||
#@ Date   : 20220509
 | 
			
		||||
#@ Author : Marco Markgraf
 | 
			
		||||
#@ Reason : Added JSON-output (Zabbix needs it)
 | 
			
		||||
#@---------------------------------------------------
 | 
			
		||||
#@ Date   : 20221230
 | 
			
		||||
#@ Author : Claudio Kuenzler
 | 
			
		||||
#@ Reason : Fix bug when missing S/N (issue #68)
 | 
			
		||||
#@---------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from __future__ import print_function
 | 
			
		||||
import sys
 | 
			
		||||
| 
						 | 
				
			
			@ -300,10 +292,9 @@ import time
 | 
			
		|||
import pywbem
 | 
			
		||||
import re
 | 
			
		||||
import pkg_resources
 | 
			
		||||
import json
 | 
			
		||||
from optparse import OptionParser,OptionGroup
 | 
			
		||||
 | 
			
		||||
version = '20221230'
 | 
			
		||||
version = '20210809'
 | 
			
		||||
 | 
			
		||||
NS = 'root/cimv2'
 | 
			
		||||
hosturl = ''
 | 
			
		||||
| 
						 | 
				
			
			@ -351,7 +342,6 @@ sensor_Type = {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
data = []
 | 
			
		||||
xdata = {}
 | 
			
		||||
 | 
			
		||||
perf_Prefix = {
 | 
			
		||||
  1:'Pow',
 | 
			
		||||
| 
						 | 
				
			
			@ -383,10 +373,6 @@ vendor='unknown'
 | 
			
		|||
# verbose
 | 
			
		||||
verbose=False
 | 
			
		||||
 | 
			
		||||
# output json
 | 
			
		||||
format='string'
 | 
			
		||||
pretty=False
 | 
			
		||||
 | 
			
		||||
# Produce performance data output for nagios
 | 
			
		||||
perfdata=False
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -532,20 +518,12 @@ def verboseoutput(message) :
 | 
			
		|||
 | 
			
		||||
# ----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
def xdataprint():
 | 
			
		||||
  if format == 'json' and not pretty:
 | 
			
		||||
    print(json.dumps(xdata, sort_keys=True))
 | 
			
		||||
  if format == 'json' and pretty:
 | 
			
		||||
    print(json.dumps(xdata, sort_keys=True, indent=4))
 | 
			
		||||
 | 
			
		||||
# ----------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
def getopts() :
 | 
			
		||||
  global hosturl,hostname,cimport,sslproto,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,regex,get_power,get_volts,get_current,get_temp,get_fan,get_lcd,get_intrusion,format,pretty
 | 
			
		||||
  global hosturl,hostname,cimport,sslproto,user,password,vendor,verbose,perfdata,urlise_country,timeout,ignore_list,regex,get_power,get_volts,get_current,get_temp,get_fan,get_lcd,get_intrusion
 | 
			
		||||
  usage = "usage: %prog -H hostname -U username -P password [-C port -S proto -V vendor -v -p -I XX -i list,list -r]\n" \
 | 
			
		||||
    "example: %prog -H hostname -U root -P password -C 5989 -V auto -I uk\n\n" \
 | 
			
		||||
    "or, verbosely:\n\n" \
 | 
			
		||||
    "usage: %prog --host=hostname --user=username --pass=password [--cimport=port --sslproto=version --vendor=system --verbose --perfdata --html=XX --format=json --pretty]\n"
 | 
			
		||||
    "usage: %prog --host=hostname --user=username --pass=password [--cimport=port --sslproto=version --vendor=system --verbose --perfdata --html=XX]\n"
 | 
			
		||||
 | 
			
		||||
  parser = OptionParser(usage=usage, version="%prog "+version)
 | 
			
		||||
  group1 = OptionGroup(parser, 'Mandatory parameters')
 | 
			
		||||
| 
						 | 
				
			
			@ -586,10 +564,6 @@ def getopts() :
 | 
			
		|||
      help="don't collect lcd/front display status")
 | 
			
		||||
  group2.add_option("--no-intrusion", action="store_false", dest="get_intrusion", default=True, \
 | 
			
		||||
      help="don't collect chassis intrusion status")
 | 
			
		||||
  group2.add_option("--format", dest="format", help="'string' (default) or 'json'", \
 | 
			
		||||
      metavar="FORMAT", type='choice', choices=['string','json'],default="string")
 | 
			
		||||
  group2.add_option("--pretty", action="store_true", dest="pretty", default=False, \
 | 
			
		||||
      help="return data as a pretty-printed json-array")
 | 
			
		||||
 | 
			
		||||
  parser.add_option_group(group1)
 | 
			
		||||
  parser.add_option_group(group2)
 | 
			
		||||
| 
						 | 
				
			
			@ -636,16 +610,14 @@ def getopts() :
 | 
			
		|||
    user=options.user
 | 
			
		||||
    password=options.password
 | 
			
		||||
    cimport=options.cimport
 | 
			
		||||
    ignore_list=options.ignore.split(',')
 | 
			
		||||
    format=options.format
 | 
			
		||||
    pretty=options.pretty
 | 
			
		||||
    perfdata=options.perfdata
 | 
			
		||||
    regex=options.regex
 | 
			
		||||
    sslproto=options.sslproto
 | 
			
		||||
    timeout=options.timeout
 | 
			
		||||
    urlise_country=options.urlise_country.lower()
 | 
			
		||||
    vendor=options.vendor.lower()
 | 
			
		||||
    verbose=options.verbose
 | 
			
		||||
    perfdata=options.perfdata
 | 
			
		||||
    urlise_country=options.urlise_country.lower()
 | 
			
		||||
    timeout=options.timeout
 | 
			
		||||
    ignore_list=options.ignore.split(',')
 | 
			
		||||
    regex=options.regex
 | 
			
		||||
    get_power=options.get_power
 | 
			
		||||
    get_volts=options.get_volts
 | 
			
		||||
    get_current=options.get_current
 | 
			
		||||
| 
						 | 
				
			
			@ -687,7 +659,7 @@ if os_platform != "win32":
 | 
			
		|||
# Use non-default CIM port
 | 
			
		||||
if cimport:
 | 
			
		||||
  verboseoutput("Using manually defined CIM port "+cimport)
 | 
			
		||||
  hosturl += ':'+cimport
 | 
			
		||||
  hosturl += ':'+cimport 
 | 
			
		||||
 | 
			
		||||
# Use non-default SSL protocol version
 | 
			
		||||
if sslproto:
 | 
			
		||||
| 
						 | 
				
			
			@ -806,7 +778,7 @@ for classe in ClassesToCheck :
 | 
			
		|||
  verboseoutput("Check classe "+classe)
 | 
			
		||||
  try:
 | 
			
		||||
    instance_list = wbemclient.EnumerateInstances(classe)
 | 
			
		||||
  except pywbem._cim_operations.CIMError as args:
 | 
			
		||||
  except pywbem.cim_operations.CIMError as args:
 | 
			
		||||
    if ( args[1].find('Socket error') >= 0 ):
 | 
			
		||||
      print("UNKNOWN: {}".format(args))
 | 
			
		||||
      sys.exit (ExitUnknown)
 | 
			
		||||
| 
						 | 
				
			
			@ -819,7 +791,7 @@ for classe in ClassesToCheck :
 | 
			
		|||
    GlobalStatus = ExitUnknown
 | 
			
		||||
    print("UNKNOWN: {}".format(args))
 | 
			
		||||
    sys.exit (GlobalStatus)
 | 
			
		||||
  except pywbem._cim_http.AuthError as arg:
 | 
			
		||||
  except pywbem.cim_http.AuthError as arg:
 | 
			
		||||
    verboseoutput("Global exit set to UNKNOWN")
 | 
			
		||||
    GlobalStatus = ExitUnknown
 | 
			
		||||
    print("UNKNOWN: Authentication Error")
 | 
			
		||||
| 
						 | 
				
			
			@ -851,8 +823,6 @@ for classe in ClassesToCheck :
 | 
			
		|||
            + str(instance[u'ReleaseDate'].datetime.date())
 | 
			
		||||
        verboseoutput("    VersionString = "+instance[u'VersionString'])
 | 
			
		||||
 | 
			
		||||
        xdata['Bios Info'] = bios_info
 | 
			
		||||
 | 
			
		||||
      elif elementName == 'Chassis' :
 | 
			
		||||
        man = instance[u'Manufacturer']
 | 
			
		||||
        if man is None :
 | 
			
		||||
| 
						 | 
				
			
			@ -867,7 +837,7 @@ for classe in ClassesToCheck :
 | 
			
		|||
          model = instance[u'Model']
 | 
			
		||||
          if model:
 | 
			
		||||
            verboseoutput("    Model = "+model)
 | 
			
		||||
            server_info +=  model
 | 
			
		||||
            server_info +=  model + ' s/n:'
 | 
			
		||||
 | 
			
		||||
      elif elementName == 'Server Blade' :
 | 
			
		||||
        SerialNumber = instance[u'SerialNumber']
 | 
			
		||||
| 
						 | 
				
			
			@ -875,8 +845,6 @@ for classe in ClassesToCheck :
 | 
			
		|||
          verboseoutput("    SerialNumber = "+SerialNumber)
 | 
			
		||||
          isblade = "yes"
 | 
			
		||||
 | 
			
		||||
      xdata['SerialNumber'] = SerialNumber
 | 
			
		||||
 | 
			
		||||
      # Report detail of Numeric Sensors and generate nagios perfdata
 | 
			
		||||
 | 
			
		||||
      if classe == "CIM_NumericSensor" :
 | 
			
		||||
| 
						 | 
				
			
			@ -918,33 +886,27 @@ for classe in ClassesToCheck :
 | 
			
		|||
            if units == 7:            # Watts
 | 
			
		||||
              if get_power:
 | 
			
		||||
                data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),1) )
 | 
			
		||||
                xdata[perf_el] = { 'Unit': 'Watt', 'Value': cr, 'warn' : utnc, 'crit': utc }
 | 
			
		||||
            elif units == 6:          # Current
 | 
			
		||||
              if get_current:
 | 
			
		||||
                data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),3) )
 | 
			
		||||
                xdata[perf_el] = { 'Unit': 'Ampere', 'Value': cr, 'warn' : utnc, 'crit': utc }
 | 
			
		||||
 | 
			
		||||
          # PSU Voltage
 | 
			
		||||
          elif sensorType == 3:               # Voltage
 | 
			
		||||
            if get_volts:
 | 
			
		||||
              data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),2) )
 | 
			
		||||
              xdata[perf_el] = { 'Unit': 'Volt', 'Value': cr, 'warn' : utnc, 'crit': utc }
 | 
			
		||||
 | 
			
		||||
          # Temperatures
 | 
			
		||||
          elif sensorType == 2:               # Temperature
 | 
			
		||||
            if get_temp:
 | 
			
		||||
              data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),4) )
 | 
			
		||||
              xdata[perf_el] = { 'Value': cr, 'warn' : utnc, 'crit': utc }
 | 
			
		||||
 | 
			
		||||
          # Fan speeds
 | 
			
		||||
          elif sensorType == 5:               # Tachometer
 | 
			
		||||
            if get_fan:
 | 
			
		||||
              if units == 65:                 # percentage
 | 
			
		||||
              if units == 65:           # percentage
 | 
			
		||||
                data.append( ("%s=%g%%;%g;%g " % (perf_el, cr, utnc, utc),6) )
 | 
			
		||||
                xdata[perf_el] = { 'Unit': '%', 'Value': cr, 'warn' : utnc, 'crit': utc }
 | 
			
		||||
              else:
 | 
			
		||||
                data.append( ("%s=%g;%g;%g " % (perf_el, cr, utnc, utc),5) )
 | 
			
		||||
                xdata[perf_el] = { 'Value': cr, 'warn' : utnc, 'crit': utc }
 | 
			
		||||
 | 
			
		||||
      elif classe == "CIM_Processor" :
 | 
			
		||||
        verboseoutput("    Family = %d" % instance['Family'])
 | 
			
		||||
| 
						 | 
				
			
			@ -1040,7 +1002,6 @@ if (urlise_country != '') :
 | 
			
		|||
# If this is a blade server, also output chassis serial number as additional info
 | 
			
		||||
if (isblade == "yes") :
 | 
			
		||||
  SerialNumber += " Chassis S/N: %s " % (SerialChassis)
 | 
			
		||||
  xdata['ChassisSerialNumber'] = SerialChassis
 | 
			
		||||
 | 
			
		||||
# Output performance data
 | 
			
		||||
perf = '|'
 | 
			
		||||
| 
						 | 
				
			
			@ -1066,24 +1027,13 @@ if perf == '|':
 | 
			
		|||
if sslproto:
 | 
			
		||||
  os.remove(sslconfpath)
 | 
			
		||||
 | 
			
		||||
xdata['GlobalStatus'] = GlobalStatus
 | 
			
		||||
 | 
			
		||||
if GlobalStatus == ExitOK :
 | 
			
		||||
  if format == 'string':
 | 
			
		||||
    print("OK - Server: %s s/n: %s %s%s" % (server_info, SerialNumber, bios_info, perf))
 | 
			
		||||
  else:
 | 
			
		||||
    xdataprint()
 | 
			
		||||
  print("OK - Server: %s %s %s%s" % (server_info, SerialNumber, bios_info, perf))
 | 
			
		||||
 | 
			
		||||
elif GlobalStatus == ExitUnknown :
 | 
			
		||||
  if format == 'string':
 | 
			
		||||
    print("UNKNOWN: %s" % (ExitMsg)) #ARR
 | 
			
		||||
  else:
 | 
			
		||||
    xdataprint()
 | 
			
		||||
  print("UNKNOWN: %s" % (ExitMsg)) #ARR
 | 
			
		||||
 | 
			
		||||
else:
 | 
			
		||||
  if format == 'string':
 | 
			
		||||
    print("%s - Server:  %s %s %s%s" % (ExitMsg, server_info, 's/n: ' + SerialNumber, bios_info, perf))
 | 
			
		||||
  else:
 | 
			
		||||
    xdataprint()
 | 
			
		||||
  print("%s - Server:  %s %s %s%s" % (ExitMsg, server_info, SerialNumber, bios_info, perf))
 | 
			
		||||
 | 
			
		||||
sys.exit (GlobalStatus)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
Uploaders: Jan Wagner <waja@cyconet.org>
 | 
			
		||||
Recommends: python3-minimal, python-pywbem
 | 
			
		||||
Version: 20221230
 | 
			
		||||
Version: 20210809
 | 
			
		||||
Homepage: https://github.com/Napsty/check_esxi_hardware
 | 
			
		||||
Watch: https://github.com/Napsty/check_esxi_hardware/tags .*/v?(\d\S+)\.tar\.gz
 | 
			
		||||
Description: Plugin for checking global health of VMware ESX/ESXi host
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,7 +81,7 @@ while [ "$1" != "" ]; do
 | 
			
		|||
done
 | 
			
		||||
 | 
			
		||||
# Config and commands
 | 
			
		||||
STAT_FILE='/var/run/keepalived.status'
 | 
			
		||||
STAT_FILE='/tmp/keepalived.status'
 | 
			
		||||
PID_FILE='/run/keepalived.pid'
 | 
			
		||||
PID=$("${CAT}" "${PID_FILE}" 2>/dev/null)
 | 
			
		||||
SERVICE=$("${PG}" keepalived)
 | 
			
		||||
| 
						 | 
				
			
			@ -92,13 +92,8 @@ CHECK_HAIP2=$("${IP}" 2>/dev/null addr sh "${IFACE2}" | "${GREP}" "${HAIP2}" | "
 | 
			
		|||
# Check files are valid
 | 
			
		||||
if [ ! -e "${STAT_FILE}" ]
 | 
			
		||||
then
 | 
			
		||||
	if [ -e /tmp/keepalived.status ]
 | 
			
		||||
	then
 | 
			
		||||
		STAT_FILE='/tmp/keepalived.status'
 | 
			
		||||
	else
 | 
			
		||||
		echo "CRITICAL: Generated status file is missing. State could not be determined."
 | 
			
		||||
		exit "${CRITICAL}"
 | 
			
		||||
	fi
 | 
			
		||||
	echo "CRITICAL: Generated status file is missing. State could not be determined."
 | 
			
		||||
	exit "${CRITICAL}"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
FILE_CONT=$("${CAT}" "${STAT_FILE}" 2>/dev/null)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,11 @@
 | 
			
		|||
# Nagios/Centron check | Nextcloud serverinfo
 | 
			
		||||
# check_nextcloud
 | 
			
		||||
 | 
			
		||||
Nagios/Centreon plugin for nextcloud serverinfo API (https://github.com/nextcloud/serverinfo)
 | 
			
		||||
 | 
			
		||||
This branch contains the check for Python 3. A version for Python 2.7 can be found [here](https://github.com/BornToBeRoot/check_nextcloud/tree/stable-python2.7).
 | 
			
		||||
 | 
			
		||||
## Syntax / Help
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
./check_nextcloud.py -u username -p password -H cloud.example.com -c [system|storage|shares|webserver|php|database|users|apps]
 | 
			
		||||
./check_nextcloud.py -u username -p password -H cloud.example.com -c [system|storage|shares|webserver|php|database|users]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Options:
 | 
			
		||||
| 
						 | 
				
			
			@ -18,14 +16,12 @@ Options:
 | 
			
		|||
                        on the nextcloud server
 | 
			
		||||
  -p PASSWORD, --password=PASSWORD
 | 
			
		||||
                        Password of the user
 | 
			
		||||
  -t TOKEN, --nc-token=TOKEN
 | 
			
		||||
                        NC-Token for the Serverinfo API
 | 
			
		||||
  -H HOSTNAME, --hostname=HOSTNAME
 | 
			
		||||
                        Nextcloud server address (make sure that the address
 | 
			
		||||
                        is a trusted domain in the config.php)
 | 
			
		||||
  -c CHECK, --check=CHECK
 | 
			
		||||
                        The thing you want to check
 | 
			
		||||
                        [system|storage|shares|webserver|php|database|activeUsers|uploadFilesize|apps]
 | 
			
		||||
                        [system|storage|shares|webserver|php|database|activeUsers|uploadFilesize]
 | 
			
		||||
  --upload-filesize     Filesize in MiB, GiB without spaces (default="512.0GiB")
 | 
			
		||||
  --protocol=PROTOCOL   Protocol you want to use [http|https]
 | 
			
		||||
                        (default="https")
 | 
			
		||||
| 
						 | 
				
			
			@ -80,77 +76,3 @@ OK - Upload max filesize: 2.0GiB
 | 
			
		|||
CRITICAL - Upload max filesize is set to 512.0MiB, but should be 2.0GiB
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Icinga config example
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Adjust the command path to your local situation.
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
object CheckCommand "check_nextcloud" {
 | 
			
		||||
  command = [ "/var/lib/nagios/src/check_nextcloud/check/check_nextcloud.py" ]
 | 
			
		||||
  arguments = {
 | 
			
		||||
    "--nc-token" = {
 | 
			
		||||
      value = "$nextcloud_token$"
 | 
			
		||||
      description = "NC-Token for the Serverinfo API"
 | 
			
		||||
    }
 | 
			
		||||
    "--hostname" = {
 | 
			
		||||
      value = "$nextcloud_hostname$"
 | 
			
		||||
      description = "Hostname"
 | 
			
		||||
    }
 | 
			
		||||
    "--api-url" = {
 | 
			
		||||
      value = "$nextcloud_api_url$"
 | 
			
		||||
      set_if = "$nextcloud_api_url$"
 | 
			
		||||
      description = "Api-url"
 | 
			
		||||
    }
 | 
			
		||||
    "--check" = {
 | 
			
		||||
      value = "$nextcloud_check$"
 | 
			
		||||
      description = "Which check to run"
 | 
			
		||||
    }
 | 
			
		||||
    "--perfdata-format" = {
 | 
			
		||||
      value = "nagios"
 | 
			
		||||
      description = "The perfdata format we like"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
apply Service for (checkname in ["system","storage","shares","webserver","php","database","activeUsers","uploadFilesize","apps"]) {
 | 
			
		||||
  import "generic-service"
 | 
			
		||||
  name = "check-nextcloud-" + checkname
 | 
			
		||||
  check_interval = 30m
 | 
			
		||||
  retry_interval = 10m
 | 
			
		||||
  display_name = "Nextcloud monitor " + checkname
 | 
			
		||||
  vars.notification_interval = 1d
 | 
			
		||||
 | 
			
		||||
  vars.nextcloud_check = checkname
 | 
			
		||||
  vars.nextcloud_hostname = host.vars.nextcloud_hostname
 | 
			
		||||
  vars.nextcloud_token = host.vars.nextcloud_token
 | 
			
		||||
  vars.nextcloud_api_url = host.vars.nextcloud_api_url
 | 
			
		||||
  vars.notification["mail"] = {  }
 | 
			
		||||
  check_command = "check_nextcloud"
 | 
			
		||||
 | 
			
		||||
  assign where (host.address || host.address6) && host.vars.nextcloud_token
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
object Host "server42.example.com" {
 | 
			
		||||
 | 
			
		||||
  display_name = "My Nextcloud server"
 | 
			
		||||
  address = "<IP>"
 | 
			
		||||
 | 
			
		||||
  ...
 | 
			
		||||
 | 
			
		||||
  # The token can be set with: occ config:app:set serverinfo token --value yourtoken
 | 
			
		||||
  vars.nextcloud_token = "XXX"
 | 
			
		||||
  vars.nextcloud_hostname = "nextcloud.example.com"
 | 
			
		||||
 | 
			
		||||
  # Optional if you e.g. use a subdirectory.
 | 
			
		||||
  vars.nextcloud_api_url = "/subdir/ocs/v2.php/apps/serverinfo/api/v1/info"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ parser.add_option('--upload-filesize', dest='upload_filesize', default='512.0MiB
 | 
			
		|||
parser.add_option('--protocol', dest='protocol', choices=['https', 'http'], default='https', help='Protocol you want to use [http|https] (default="https")')
 | 
			
		||||
parser.add_option('--ignore-proxy', dest='ignore_proxy', default=False, action='store_true', help='Ignore any configured proxy server on this system for this request (default="false")')
 | 
			
		||||
parser.add_option('--ignore-sslcert', dest='ignore_sslcert', default=False, action='store_true', help='Ignore ssl certificate (default="false")')
 | 
			
		||||
parser.add_option('--api-url', dest='api_url', type='string', default='/ocs/v2.php/apps/serverinfo/api/v1/info?skipApps=false&skipUpdate=false', help='Url of the api (default="/ocs/v2.php/apps/serverinfo/api/v1/info?skipApps=false&skipUpdate=false")')
 | 
			
		||||
parser.add_option('--api-url', dest='api_url', type='string', default='/ocs/v2.php/apps/serverinfo/api/v1/info', help='Url of the api (default="/ocs/v2.php/apps/serverinfo/api/v1/info")')
 | 
			
		||||
 | 
			
		||||
(options, args) = parser.parse_args()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -283,10 +283,7 @@ if options.check == 'uploadFilesize':
 | 
			
		|||
if options.check == 'apps':
 | 
			
		||||
	xml_apps = xml_root.find('data').find('nextcloud').find('system').find('apps')
 | 
			
		||||
 | 
			
		||||
	if xml_apps is not None:
 | 
			
		||||
		xml_apps_num_updates_available = int(xml_apps.find('num_updates_available').text)
 | 
			
		||||
	else:
 | 
			
		||||
		xml_apps_num_updates_available = 0
 | 
			
		||||
	xml_apps_num_updates_available = int(xml_apps.find('num_updates_available').text)
 | 
			
		||||
 | 
			
		||||
	if xml_apps_num_updates_available == 0:
 | 
			
		||||
		print('OK - No apps requiring update')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,5 +2,6 @@ Uploaders: Jan Wagner <waja@cyconet.org>
 | 
			
		|||
Recommends: python3-minimal
 | 
			
		||||
Version: 2.0
 | 
			
		||||
Homepage: https://github.com/BornToBeRoot/check_nextcloud
 | 
			
		||||
#Watch: https://raw.githubusercontent.com/BornToBeRoot/check_nextcloud/master/check/check_nextcloud.py \#\ \~\~\ Version\ '([0-9.]+)'
 | 
			
		||||
Watch: https://raw.githubusercontent.com/BornToBeRoot/check_nextcloud/master/check/check_nextcloud.py #  ~~ Version ([0-9.]+) ~~
 | 
			
		||||
Description: Plugin script to monitor your nextcloud serverinfo API
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,124 +1,3 @@
 | 
			
		|||
* 2024-01-05 11.2.4
 | 
			
		||||
  add mode ha-status for Palo Alto
 | 
			
		||||
* 2023-12-16 11.2.3
 | 
			
		||||
  add perfdata for the mode interface-nat-rejects
 | 
			
		||||
* 2023-12-16 11.2.2.1
 | 
			
		||||
  fix Makefile.am and git add the cisco and arista pm files which i had forgotten
 | 
			
		||||
* 2023-11-30 11.2.2
 | 
			
		||||
  add mode interface-errdisabled (Cisco and Arista only)
 | 
			
		||||
* 2023-11-15 11.2.1.2
 | 
			
		||||
  require, not use Net::Ping for F5 checks
 | 
			
		||||
* 2023-10-27 11.2.1.1
 | 
			
		||||
  drecksmacoctetbinaerschlonz
 | 
			
		||||
* 2023-10-27 11.2.1
 | 
			
		||||
  add mode list-arp-cache
 | 
			
		||||
* 2023-10-06 11.2.0.4
 | 
			
		||||
  PR #324, detect Ivanti devices (formerly identifying themselves as Pulse Secure). Thx c-kr
 | 
			
		||||
* 2023-09-29 11.2.0.3
 | 
			
		||||
  show vlans only on demand, --report short+vlan
 | 
			
		||||
* 2023-09-15 11.2.0.2
 | 
			
		||||
  more runtime reduction for huawei, cpu and mem
 | 
			
		||||
* 2023-09-15 11.2.0.1
 | 
			
		||||
  suppress output of empty vlans
 | 
			
		||||
* 2023-09-15 11.2
 | 
			
		||||
  cache huawei entities to avoid hitting the device's snmp rate limit
 | 
			
		||||
  cache vlan configs
 | 
			
		||||
* 2023-09-14 11.1
 | 
			
		||||
  show vlans with interface-status
 | 
			
		||||
* 2023-07-27 11.0.1.1
 | 
			
		||||
  C9800 fix
 | 
			
		||||
  PR #318 from lgmu, typo in --lookup vs. --lookback
 | 
			
		||||
* 2023-07-27 11.0.1
 | 
			
		||||
  support new C9800 wlan controller
 | 
			
		||||
* 2023-07-25 11.0
 | 
			
		||||
  new structure suitble for epn
 | 
			
		||||
* 2023-07-25 10.13.1
 | 
			
		||||
  reduce amount of data in cisco fru
 | 
			
		||||
* 2023-07-10 10.13.0.1
 | 
			
		||||
  bugfix in traffic thresholds, do not use warning/critical def. thresholds
 | 
			
		||||
* 2023-07-10 10.13
 | 
			
		||||
  implement traffic thresholds for interface-usage, correctly calc the less-than perfdata thresholds.
 | 
			
		||||
* 2023-06-12 10.12.1.8
 | 
			
		||||
  reduce runtime for HOST-RESOURCES-MIB disk and device tables
 | 
			
		||||
* 2023-06-12 10.12.1.7
 | 
			
		||||
  don't walk cefcFRUPowerSupplyGroupTable, it's unused anyway
 | 
			
		||||
* 2023-05-28 10.12.1.6
 | 
			
		||||
  PR 310/311 for Fortigte HW
 | 
			
		||||
* 2023-05-12 10.12.1.5
 | 
			
		||||
  bugfix in bluecat productname detection
 | 
			
		||||
  update glplugin (another epn fix, ::pluginname, ::plugin)
 | 
			
		||||
* 2023-05-11 10.12.1.4
 | 
			
		||||
  update glplugin (another epn fix)
 | 
			
		||||
* 2023-05-04 10.12.1.3
 | 
			
		||||
  bugfix in Huawei Wlan Controller (just a perl warning, not serious)
 | 
			
		||||
  these recent perl warnings appeared after i heavily used the
 | 
			
		||||
  embedded perl feature of mod-gearman. it is much more strict than
 | 
			
		||||
  running the plugin as a standalone process)
 | 
			
		||||
* 2023-05-02 10.12.1.2
 | 
			
		||||
  bugfix in Pulse Secure (just a perl warning, not serious)
 | 
			
		||||
* 2023-04-21 10.12.1.1
 | 
			
		||||
  bugfix in Huawei bgp modes (just a perl warning, not serious)
 | 
			
		||||
* 2023-04-20 10.12.1
 | 
			
		||||
  add a cluster-check for cisco sdwan
 | 
			
		||||
* 2023-04-20 10.12
 | 
			
		||||
  reduced runtime and amount of transferred data for bgp-related checks
 | 
			
		||||
* 2023-04-03 10.11.0.2
 | 
			
		||||
  reduce runtime in Huwaei accesspoint modes
 | 
			
		||||
* 2023-03-29 10.11.0.1
 | 
			
		||||
  bugfix in Huawei hardware-health. Discard temperatures of 2147483647 deg.
 | 
			
		||||
* 2023-03-28 10.11
 | 
			
		||||
  improve Huawei hardware-health
 | 
			
		||||
* 2023-03-20 10.10
 | 
			
		||||
  add filters to sdwan-check (name=dstip,name2=localcolor)
 | 
			
		||||
* 2023-03-10 10.9.1.3
 | 
			
		||||
  bugfix in Cisco Envmon notfunctioning
 | 
			
		||||
* 2023-03-08 10.9.1.2
 | 
			
		||||
  bugfix again, exists plus defined
 | 
			
		||||
* 2023-03-08 10.9.1.1
 | 
			
		||||
  bugfix in CISCO-ENVMON-MIB temperature (catch "notPresent")
 | 
			
		||||
* 2023-02-23 10.9.1
 | 
			
		||||
  bugfix in Checkpoint Management-Status
 | 
			
		||||
* 2023-02-23 10.9
 | 
			
		||||
  bugfix in Versa Peersubsystem
 | 
			
		||||
  prepare some cisco sdwan stuff
 | 
			
		||||
* 2023-02-20 10.8.0.3
 | 
			
		||||
  tweak huawei Entity-Table snmp parameters
 | 
			
		||||
* 2023-02-03 10.8.0.2
 | 
			
		||||
  force interface-vlan-count-macs to cache vlans
 | 
			
		||||
* 2023-02-03 10.8.0.1
 | 
			
		||||
  fix an undef in interface-vlan-count-macs
 | 
			
		||||
* 2023-02-03 10.8
 | 
			
		||||
  add mode interface-vlan-count-macs
 | 
			
		||||
* 2023-01-19 10.7.1
 | 
			
		||||
  tune snmp maxreps for bgp
 | 
			
		||||
* 2023-01-19 10.7
 | 
			
		||||
  rewrite detection of Juniper
 | 
			
		||||
* 2023-01-11 10.6.1
 | 
			
		||||
  pull request 304 improves ios hardware checks (thanks dhoffend)
 | 
			
		||||
* 2023-01-10 10.6
 | 
			
		||||
  add support for Viptela
 | 
			
		||||
* 2022-12-16 10.5.1
 | 
			
		||||
  bugfix in Cisco WLC, skip unused mobile stations
 | 
			
		||||
* 2022-10-09 10.5
 | 
			
		||||
  add a temporary check for Cisco Viptela SDWAN (not for public use yet, sorry)
 | 
			
		||||
* 2022-10-08 10.4
 | 
			
		||||
  add Huawei wlan controller (not finished yet)
 | 
			
		||||
* 2022-10-08 10.3.0.3
 | 
			
		||||
  improve arista power supply/cord status checks
 | 
			
		||||
* 2022-09-27 10.3.0.2
 | 
			
		||||
  fix an uninitialized value in Arista HW check
 | 
			
		||||
* 2022-09-20 10.3.0.1
 | 
			
		||||
  fix issue #231, thanks log1-c
 | 
			
		||||
* 2022-07-29 10.3
 | 
			
		||||
  add mode check-rtt (cisco-rttmon-mib slas)
 | 
			
		||||
* 2022-07-21 10.2.1
 | 
			
		||||
  increase cpu thresholds for linux, separate user/system/etc from iowait
 | 
			
		||||
* 2022-07-20 10.2
 | 
			
		||||
  update glplugin, better get_table fallback handling
 | 
			
		||||
* 2022-05-05 10.1.0.3
 | 
			
		||||
  fix a pull-request. Und das war damit auch der letzte Pull-Request, den ich in meinem Leben angenommen habe.
 | 
			
		||||
* 2022-05-04 10.1.0.2
 | 
			
		||||
  use JSON::XS in Interface.pm to avoid misleading UNKNOWN error message
 | 
			
		||||
* 2022-02-23 10.1.0.1
 | 
			
		||||
  suppress unknown arista sensors which are not marked as faulty
 | 
			
		||||
* 2022-02-18 10.1
 | 
			
		||||
| 
						 | 
				
			
			@ -22,14 +22,14 @@ eval {
 | 
			
		|||
  $Data::Dumper::Sparseseen = 1;
 | 
			
		||||
};
 | 
			
		||||
our $AUTOLOAD;
 | 
			
		||||
*VERSION = \'5.18';
 | 
			
		||||
*VERSION = \'5.0.1.1';
 | 
			
		||||
 | 
			
		||||
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  our $mode = undef;
 | 
			
		||||
  our $plugin = undef;
 | 
			
		||||
  our $pluginname = undef;
 | 
			
		||||
  our $pluginname = basename($ENV{'NAGIOS_PLUGIN'} || $0);
 | 
			
		||||
  our $blacklist = undef;
 | 
			
		||||
  our $info = [];
 | 
			
		||||
  our $extendedinfo = [];
 | 
			
		||||
| 
						 | 
				
			
			@ -48,8 +48,6 @@ sub new {
 | 
			
		|||
      if ! grep /BEGIN/, keys %Monitoring::GLPlugin::Item::;
 | 
			
		||||
  require Monitoring::GLPlugin::TableItem
 | 
			
		||||
      if ! grep /BEGIN/, keys %Monitoring::GLPlugin::TableItem::;
 | 
			
		||||
  $params{plugin} ||= basename($ENV{'NAGIOS_PLUGIN'} || $0);
 | 
			
		||||
  $Monitoring::GLPlugin::pluginname = $params{plugin};
 | 
			
		||||
  $Monitoring::GLPlugin::plugin = Monitoring::GLPlugin::Commandline->new(%params);
 | 
			
		||||
  return $self;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1064,25 +1062,6 @@ sub get_level {
 | 
			
		|||
  return $code;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub worst_level {
 | 
			
		||||
  my ($self, @levels) = @_;
 | 
			
		||||
  my $level = 0;
 | 
			
		||||
  foreach (@levels) {
 | 
			
		||||
    if ($_ == 2) {
 | 
			
		||||
      $level = 2;
 | 
			
		||||
    } elsif ($_ == 1) {
 | 
			
		||||
      if ($level == 0 || $level == 3) {
 | 
			
		||||
        $level = 1;
 | 
			
		||||
      }
 | 
			
		||||
    } elsif ($_ == 3) {
 | 
			
		||||
      if ($level == 0) {
 | 
			
		||||
        $level = 3;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return $level;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#########################################################
 | 
			
		||||
# blacklisting
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -1110,7 +1089,6 @@ sub is_blacklisted {
 | 
			
		|||
  }
 | 
			
		||||
  # FAN:459,203/TEMP:102229/ENVSUBSYSTEM
 | 
			
		||||
  # FAN_459,FAN_203,TEMP_102229,ENVSUBSYSTEM
 | 
			
		||||
  # ALERT:(The Storage Center is not able to access Tiebreaker)/TEMP:102229
 | 
			
		||||
  if ($self->opts->blacklist =~ /_/) {
 | 
			
		||||
    foreach my $bl_item (split(/,/, $self->opts->blacklist)) {
 | 
			
		||||
      if ($bl_item eq $self->internal_name()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1127,14 +1105,6 @@ sub is_blacklisted {
 | 
			
		|||
            $self->{blacklisted} = 1;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      } elsif ($bl_items =~ /^(\w+):\((.*)\)$/ and $self->can("internal_content")) {
 | 
			
		||||
        my $bl_type = $1;
 | 
			
		||||
        my $bl_pattern = qr/$2/;
 | 
			
		||||
        if ($self->internal_name() =~ /^${bl_type}_/) {
 | 
			
		||||
          if ($self->internal_content() =~ /$bl_pattern/) {
 | 
			
		||||
            $self->{blacklisted} = 1;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      } elsif ($bl_items =~ /^(\w+)$/) {
 | 
			
		||||
        if ($bl_items eq $self->internal_name()) {
 | 
			
		||||
          $self->{blacklisted} = 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -1757,7 +1727,7 @@ sub AUTOLOAD {
 | 
			
		|||
    $self->{components}->{$subsystem}->check();
 | 
			
		||||
    $self->{components}->{$subsystem}->dump()
 | 
			
		||||
        if $self->opts->verbose >= 2;
 | 
			
		||||
  } elsif ($AUTOLOAD =~ /^.*::(status_code|check_messages|nagios_exit|html_string|perfdata_string|selected_perfdata|check_thresholds|get_thresholds|mod_threshold|opts|pandora_string|strequal)$/) {
 | 
			
		||||
  } elsif ($AUTOLOAD =~ /^.*::(status_code|check_messages|nagios_exit|html_string|perfdata_string|selected_perfdata|check_thresholds|get_thresholds|opts|pandora_string|strequal)$/) {
 | 
			
		||||
    return $Monitoring::GLPlugin::plugin->$1(@params);
 | 
			
		||||
  } elsif ($AUTOLOAD =~ /^.*::(reduce_messages|reduce_messages_short|clear_messages|suppress_messages|add_html|add_perfdata|override_opt|create_opt|set_thresholds|force_thresholds|add_pandora)$/) {
 | 
			
		||||
    $Monitoring::GLPlugin::plugin->$1(@params);
 | 
			
		||||
| 
						 | 
				
			
			@ -36,9 +36,9 @@ sub new {
 | 
			
		|||
    $self->{$_} = $params{$_};
 | 
			
		||||
  }
 | 
			
		||||
  bless $self, $class;
 | 
			
		||||
  $self->{plugin} ||= $Monitoring::GLPlugin::pluginname;
 | 
			
		||||
  $self->{name} = $self->{plugin};
 | 
			
		||||
 | 
			
		||||
  $self
 | 
			
		||||
  $Monitoring::GLPlugin::plugin = $self;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub AUTOLOAD {
 | 
			
		||||
| 
						 | 
				
			
			@ -599,34 +599,6 @@ sub check_thresholds {
 | 
			
		|||
  return $level;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub mod_threshold {
 | 
			
		||||
  # this method can be used to modify/multiply thresholds or upper and lower
 | 
			
		||||
  # limit of a threshold range. For example, we have thresholds for an
 | 
			
		||||
  # interface usage together with the maximum bandwidth and want to
 | 
			
		||||
  # create thresholds for bitrates.
 | 
			
		||||
  my ($self, $threshold, $func) = @_;
 | 
			
		||||
  if (! $threshold) {
 | 
			
		||||
    return "";
 | 
			
		||||
  } elsif ($threshold =~ /^([-+]?[0-9]*\.?[0-9]+)$/) {
 | 
			
		||||
    # 10
 | 
			
		||||
    return &{$func}($1);
 | 
			
		||||
  } elsif ($threshold =~ /^([-+]?[0-9]*\.?[0-9]+):$/) {
 | 
			
		||||
    # 10:
 | 
			
		||||
    return &{$func}($1).":";
 | 
			
		||||
  } elsif ($threshold =~ /^~:([-+]?[0-9]*\.?[0-9]+)$/) {
 | 
			
		||||
    # ~:10
 | 
			
		||||
    return "~:".&{$func}($1);
 | 
			
		||||
  } elsif ($threshold =~ /^([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) {
 | 
			
		||||
    # 10:20
 | 
			
		||||
    return &{$func}($1).":".&{$func}($2);
 | 
			
		||||
  } elsif ($threshold =~ /^@([-+]?[0-9]*\.?[0-9]+):([-+]?[0-9]*\.?[0-9]+)$/) {
 | 
			
		||||
    # @10:20
 | 
			
		||||
    return "@".&{$func}($1).":".&{$func}($2);
 | 
			
		||||
  } else {
 | 
			
		||||
    return $threshold."scheise";
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub strequal {
 | 
			
		||||
  my($self, $str1, $str2) = @_;
 | 
			
		||||
  return 1 if ! defined $str1 && ! defined $str2;
 | 
			
		||||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ use File::Basename;
 | 
			
		|||
use Getopt::Long qw(:config no_ignore_case bundling);
 | 
			
		||||
 | 
			
		||||
# Standard defaults
 | 
			
		||||
our %DEFAULT = (
 | 
			
		||||
my %DEFAULT = (
 | 
			
		||||
  timeout => 15,
 | 
			
		||||
  verbose => 0,
 | 
			
		||||
  license =>
 | 
			
		||||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ It may be used, redistributed and/or modified under the terms of the GNU
 | 
			
		|||
General Public Licence (see http://www.fsf.org/licensing/licenses/gpl.txt).",
 | 
			
		||||
);
 | 
			
		||||
# Standard arguments
 | 
			
		||||
our @ARGS = ({
 | 
			
		||||
my @ARGS = ({
 | 
			
		||||
    spec => 'usage|?',
 | 
			
		||||
    help => "-?, --usage\n   Print usage information",
 | 
			
		||||
  }, {
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ our @ARGS = ({
 | 
			
		|||
  },
 | 
			
		||||
);
 | 
			
		||||
# Standard arguments we traditionally display last in the help output
 | 
			
		||||
our %DEFER_ARGS = map { $_ => 1 } qw(timeout verbose);
 | 
			
		||||
my %DEFER_ARGS = map { $_ => 1 } qw(timeout verbose);
 | 
			
		||||
 | 
			
		||||
sub _init {
 | 
			
		||||
  my ($self, %params) = @_;
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ sub _init {
 | 
			
		|||
    usage => 1,
 | 
			
		||||
    version => 0,
 | 
			
		||||
    url => 0,
 | 
			
		||||
    plugin => undef,
 | 
			
		||||
    plugin => { default => $Monitoring::GLPlugin::pluginname },
 | 
			
		||||
    blurb => 0,
 | 
			
		||||
    extra => 0,
 | 
			
		||||
    'extra-opts' => 0,
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +64,9 @@ sub _init {
 | 
			
		|||
          if ref ($self->{_attr}->{$_}) eq 'HASH' &&
 | 
			
		||||
              exists $self->{_attr}->{$_}->{default};
 | 
			
		||||
    }
 | 
			
		||||
    chomp $self->{_attr}->{$_} if exists $self->{_attr}->{$_};
 | 
			
		||||
  }
 | 
			
		||||
  # Chomp _attr values
 | 
			
		||||
  chomp foreach values %{$self->{_attr}};
 | 
			
		||||
 | 
			
		||||
  # Setup initial args list
 | 
			
		||||
  $self->{_args} = [ grep { exists $_->{spec} } @ARGS ];
 | 
			
		||||
| 
						 | 
				
			
			@ -393,7 +393,7 @@ sub init {
 | 
			
		|||
        push(@credentials, "-l authPriv");
 | 
			
		||||
      } elsif (grep(/-A/, @credentials)) {
 | 
			
		||||
        push(@credentials, "-l authNoPriv");
 | 
			
		||||
      } elsif (! grep(/-c/, @credentials)) {
 | 
			
		||||
      } else {
 | 
			
		||||
        push(@credentials, "-l noAuthNoPriv");
 | 
			
		||||
      }
 | 
			
		||||
      my $credentials = join(" ", @credentials);
 | 
			
		||||
| 
						 | 
				
			
			@ -892,27 +892,6 @@ sub init {
 | 
			
		|||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        } elsif ($sym =~ /Table/ and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}->{$sym =~ s/Table/Entry/gr}) {
 | 
			
		||||
          # fuer die Pappenheimer von QNAP, die nennen ihren Krempel
 | 
			
		||||
          # kakaTable und kakaTableEntry
 | 
			
		||||
          # oder noch schlauer: systemIfTable und ifEntry
 | 
			
		||||
          if (my @table = $self->get_snmp_table_objects($mib, $sym)) {
 | 
			
		||||
            my $oid = $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}->{$sym};
 | 
			
		||||
            $confirmed->{$oid} = sprintf '%s::%s', $mib, $sym;
 | 
			
		||||
            $self->add_rawdata($oid, '--------------------');
 | 
			
		||||
            foreach my $line (@table) {
 | 
			
		||||
              if ($line->{flat_indices}) {
 | 
			
		||||
                foreach my $column (grep !/(flat_indices)|(indices)/, keys %{$line}) {
 | 
			
		||||
                  my $oid = $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}->{$column};
 | 
			
		||||
                  if (exists $unknowns->{$oid.'.'.$line->{flat_indices}}) {
 | 
			
		||||
                    $confirmed->{$oid.'.'.$line->{flat_indices}} =
 | 
			
		||||
                        sprintf '%s::%s.%s = %s', $mib, $column, $line->{flat_indices}, $line->{$column};
 | 
			
		||||
                    delete $unknowns->{$oid.'.'.$line->{flat_indices}};
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1019,11 +998,6 @@ sub check_snmp_and_model {
 | 
			
		|||
        delete $response->{$oid};
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    # Achtung!! Der schnippelt von einem Hex-STRING, der mit 20 aufhoert,
 | 
			
		||||
    # das letzte Byte weg. Das muss beruecksichtigt werden, wenn man 
 | 
			
		||||
    # spaeter MAC-Adressen o.ae. zueueckrechnet.
 | 
			
		||||
    # } elsif ($self->{hwWlanRadioMac} && unpack("H12", $self->{hwWlanRadioMac}." ") =~ /(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})/) {
 | 
			
		||||
    # siehe Classes::Huawei::Component::WlanSubsystem::Radio
 | 
			
		||||
    map { $response->{$_} =~ s/^\s+//; $response->{$_} =~ s/\s+$//; }
 | 
			
		||||
        keys %$response;
 | 
			
		||||
    $self->set_rawdata($response);
 | 
			
		||||
| 
						 | 
				
			
			@ -1064,27 +1038,25 @@ sub check_snmp_and_model {
 | 
			
		|||
          scalar localtime (time - $sysUptime),
 | 
			
		||||
          $self->human_timeticks($sysUptime));
 | 
			
		||||
    }
 | 
			
		||||
    my $best_uptime = undef;
 | 
			
		||||
    if ($hrSystemUptime) {
 | 
			
		||||
      # Bei Linux-basierten Geraeten wird snmpEngineTime viel zu haeufig
 | 
			
		||||
      # durchgestartet, also lieber das hier.
 | 
			
		||||
      $best_uptime = $hrSystemUptime;
 | 
			
		||||
      # Es sei denn, snmpEngineTime ist tatsaechlich groesser, dann gilt
 | 
			
		||||
      # wiederum dieses. Mag sein, dass der zahlenwert hier manchmal huepft
 | 
			
		||||
      # und ein Performancegraph Zacken bekommt, aber das ist mir egal.
 | 
			
		||||
      # es geht nicht um Graphen in Form einer ansteigenden Geraden, sondern
 | 
			
		||||
      # um das Erkennen von spontanen Reboots und das Vermeiden von
 | 
			
		||||
      # falschen Alarmen.
 | 
			
		||||
      if ($snmpEngineTime && $snmpEngineTime > $hrSystemUptime) {
 | 
			
		||||
        $best_uptime = $snmpEngineTime;
 | 
			
		||||
    if (defined $sysUptime && defined $sysDescr) {
 | 
			
		||||
      if ($hrSystemUptime) {
 | 
			
		||||
        # Bei Linux-basierten Geraeten wird snmpEngineTime viel zu haeufig
 | 
			
		||||
        # durchgestartet, also lieber das hier.
 | 
			
		||||
        $self->{uptime} = $hrSystemUptime;
 | 
			
		||||
        # Es sei denn, snmpEngineTime ist tatsaechlich groesser, dann gilt
 | 
			
		||||
        # wiederum dieses. Mag sein, dass der zahlenwert hier manchmal huepft
 | 
			
		||||
        # und ein Performancegraph Zacken bekommt, aber das ist mir egal.
 | 
			
		||||
        # es geht nicht um Graphen in Form einer ansteigenden Geraden, sondern
 | 
			
		||||
        # um das Erkennen von spontanen Reboots und das Vermeiden von
 | 
			
		||||
        # falschen Alarmen.
 | 
			
		||||
        if ($snmpEngineTime && $snmpEngineTime > $hrSystemUptime) {
 | 
			
		||||
          $self->{uptime} = $snmpEngineTime;
 | 
			
		||||
        }
 | 
			
		||||
      } elsif ($snmpEngineTime) {
 | 
			
		||||
        $self->{uptime} = $snmpEngineTime;
 | 
			
		||||
      } else {
 | 
			
		||||
        $self->{uptime} = $sysUptime;
 | 
			
		||||
      }
 | 
			
		||||
    } elsif ($snmpEngineTime) {
 | 
			
		||||
      $best_uptime = $snmpEngineTime;
 | 
			
		||||
    } else {
 | 
			
		||||
      $best_uptime = $sysUptime;
 | 
			
		||||
    }
 | 
			
		||||
    if (defined $best_uptime && defined $sysDescr) {
 | 
			
		||||
      $self->{uptime} = $best_uptime;
 | 
			
		||||
      $self->{productname} = $sysDescr;
 | 
			
		||||
      $self->{sysobjectid} = $self->get_snmp_object('MIB-2-MIB', 'sysObjectID', 0);
 | 
			
		||||
      $self->debug(sprintf 'uptime: %s', $self->{uptime});
 | 
			
		||||
| 
						 | 
				
			
			@ -1118,11 +1090,11 @@ sub check_snmp_and_model {
 | 
			
		|||
        }
 | 
			
		||||
        if (! $mein_lieber_freund_und_kupferstecher) {
 | 
			
		||||
          $self->add_message(UNKNOWN,
 | 
			
		||||
              'got neither sysUptime and sysDescr nor any other useful information, is this snmp agent working correctly?');
 | 
			
		||||
              'got neither sysUptime nor sysDescr nor any other useful information, is this snmp agent working correctly?');
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        $self->add_message(UNKNOWN,
 | 
			
		||||
            'Did not receive both sysUptime and sysDescr, is this snmp agent working correctly?');
 | 
			
		||||
            'got neither sysUptime nor sysDescr, is this snmp agent working correctly?');
 | 
			
		||||
      }
 | 
			
		||||
      $Monitoring::GLPlugin::SNMP::session->close if $Monitoring::GLPlugin::SNMP::session;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1207,8 +1179,7 @@ sub establish_snmp_session {
 | 
			
		|||
    *STDERR = *ERR;
 | 
			
		||||
    my ($session, $error) = Net::SNMP->session(%params);
 | 
			
		||||
    *STDERR = *SAVEERR;
 | 
			
		||||
    if (($stderrvar && $error && $error =~ /Time synchronization failed/) ||
 | 
			
		||||
        ($error && $error =~ /Received usmStatsUnknownEngineIDs.0 Report-PDU with value \d+ during synchronization/)) {
 | 
			
		||||
    if ($stderrvar && $error && $error =~ /Time synchronization failed/) {
 | 
			
		||||
      # This is what you get when you have
 | 
			
		||||
      # - an APC ups with a buggy firmware.
 | 
			
		||||
      # - no chance to update it.
 | 
			
		||||
| 
						 | 
				
			
			@ -1314,7 +1285,7 @@ sub establish_snmp_secondary_session {
 | 
			
		|||
sub reset_snmp_max_msg_size {
 | 
			
		||||
  my ($self) = @_;
 | 
			
		||||
  $self->debug(sprintf "reset snmp_max_msg_size to %s",
 | 
			
		||||
      $Monitoring::GLPlugin::SNMP::max_msg_size) if $Monitoring::GLPlugin::SNMP::session;
 | 
			
		||||
      $Monitoring::GLPlugin::SNMP::max_msg_size);
 | 
			
		||||
  $Monitoring::GLPlugin::SNMP::session->max_msg_size($Monitoring::GLPlugin::SNMP::max_msg_size) if $Monitoring::GLPlugin::SNMP::session;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1330,7 +1301,7 @@ sub bulk_baeh_reset {
 | 
			
		|||
  my ($self, $maxrepetitions) = @_;
 | 
			
		||||
  $self->reset_snmp_max_msg_size();
 | 
			
		||||
  $Monitoring::GLPlugin::SNMP::maxrepetitions =
 | 
			
		||||
      int($Monitoring::GLPlugin::SNMP::session->max_msg_size() * 0.017) if $Monitoring::GLPlugin::SNMP::session;
 | 
			
		||||
      int($Monitoring::GLPlugin::SNMP::session->max_msg_size() * 0.017);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub bulk_is_baeh {
 | 
			
		||||
| 
						 | 
				
			
			@ -1364,11 +1335,7 @@ sub no_such_mode {
 | 
			
		|||
    $self->init();
 | 
			
		||||
  } else {
 | 
			
		||||
    eval {
 | 
			
		||||
      if (exists $self->{generic_class}) {
 | 
			
		||||
        bless $self, $self->{generic_class};
 | 
			
		||||
      } else {
 | 
			
		||||
        bless $self, "Classes::Generic";
 | 
			
		||||
      }
 | 
			
		||||
      bless $self, "Classes::Generic";
 | 
			
		||||
      $self->init();
 | 
			
		||||
    };
 | 
			
		||||
    if ($@) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1677,15 +1644,7 @@ sub update_entry_cache {
 | 
			
		|||
        $self->opts->hostname, $self->opts->mode, $mib, $table);
 | 
			
		||||
    $self->{$cache} = {};
 | 
			
		||||
    foreach my $entry ($self->get_snmp_table_objects($mib, $table, undef, $key_attrs)) {
 | 
			
		||||
      # HUAWEI-L2MAM-MIB/hwMacVlanStatisticsTable hat hwMacVlanStatisticsVlanId, welches aber nicht
 | 
			
		||||
      # existiert. Id ist nichts anderes als der Index. sub finish() wuerde das Attribut
 | 
			
		||||
      # anlegen, aber das ist hier noch nicht gelaufen. $entry->{$_} ist daher undef
 | 
			
		||||
      # bei key_attrs==hwMacVlanStatisticsVlanId. Aber was noch geht:
 | 
			
		||||
      # Leerstring, dann heißt es ""-//-index => index statt blubb-//-index => index
 | 
			
		||||
      # Weil hwMacVlanStatisticsVlanId kein Text ist, sondern der Index, wird das Holen
 | 
			
		||||
      # aus dem Cache funktionieren, weil wenn --name numerisch ist, wird mit dem Index
 | 
			
		||||
      # aus ""-//-index verglichen und die leere Description ist Wurst.
 | 
			
		||||
      my $key = join('#', map { exists $entry->{$_} ? $entry->{$_} : "" } @{$key_attrs});
 | 
			
		||||
      my $key = join('#', map { $entry->{$_} } @{$key_attrs});
 | 
			
		||||
      my $hash = $key . '-//-' . join('.', @{$entry->{indices}});
 | 
			
		||||
      $self->{$cache}->{$hash} = $entry->{indices};
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -1784,47 +1743,6 @@ sub get_snmp_tables {
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub get_snmp_tables_cached {
 | 
			
		||||
  my ($self, $mib, $infos, $retention) = @_;
 | 
			
		||||
  $retention ||= 3600;
 | 
			
		||||
  my $from_file = {};
 | 
			
		||||
  foreach my $info (@{$infos}) {
 | 
			
		||||
    my $table = $info->[1];
 | 
			
		||||
    my $statefile = $self->create_entry_cache_file($mib, $table, "tablecache");
 | 
			
		||||
    my @fileinfo = stat($statefile);
 | 
			
		||||
    if (@fileinfo and time - $fileinfo[9] < $retention) {
 | 
			
		||||
      # exist und recent
 | 
			
		||||
      my $cache = sprintf "%s_%s_%s_cache", $mib, $table, "tablecache";
 | 
			
		||||
      $self->load_cache($mib, $table, ["tablecache"]);
 | 
			
		||||
      if (exists $self->{$cache} and defined $self->{$cache} and
 | 
			
		||||
          ((ref($self->{$cache}) eq "HASH" and keys %{$self->{$cache}}) or
 | 
			
		||||
           (ref($self->{$cache}) eq "ARRAY" and @{$self->{$cache}}))) {
 | 
			
		||||
        $Monitoring::GLPlugin::SNMP::tablecache->{$mib}->{$table} = $self->{$cache};
 | 
			
		||||
        $from_file->{$cache} = 1 if exists $self->{$cache};
 | 
			
		||||
        $self->debug(sprintf "get_snmp_tables_cached loaded file for %s %s", $mib, $table);
 | 
			
		||||
      } else {
 | 
			
		||||
        $self->debug(sprintf "get_snmp_tables_cached loaded empty file for %s %s", $mib, $table);
 | 
			
		||||
      }
 | 
			
		||||
      delete $self->{$cache} if exists $self->{$cache};
 | 
			
		||||
    } else {
 | 
			
		||||
      $self->debug(sprintf "get_snmp_tables_cached has no (or outdated) file for %s %s", $mib, $table);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  $self->get_snmp_tables($mib, $infos);
 | 
			
		||||
  foreach my $info (@{$infos}) {
 | 
			
		||||
    my $table = $info->[1];
 | 
			
		||||
    if (exists $Monitoring::GLPlugin::SNMP::tablecache->{$mib} and
 | 
			
		||||
        exists $Monitoring::GLPlugin::SNMP::tablecache->{$mib}->{$table}) {
 | 
			
		||||
      my $cache = sprintf "%s_%s_%s_cache", $mib, $table, "tablecache";
 | 
			
		||||
      next if exists $from_file->{$cache};
 | 
			
		||||
      $self->{$cache} =
 | 
			
		||||
          $Monitoring::GLPlugin::SNMP::tablecache->{$mib}->{$table};
 | 
			
		||||
      $self->save_cache($mib, $table, ["tablecache"]);
 | 
			
		||||
      delete $self->{$cache};
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub merge_tables {
 | 
			
		||||
  my ($self, $into, @from) = @_;
 | 
			
		||||
  my $into_indices = {};
 | 
			
		||||
| 
						 | 
				
			
			@ -2554,7 +2472,6 @@ sub get_table {
 | 
			
		|||
    if (! defined $result || (defined $result && ! %{$result})) {
 | 
			
		||||
      $self->debug(sprintf "get_table error: %s", 
 | 
			
		||||
          $Monitoring::GLPlugin::SNMP::session->error());
 | 
			
		||||
      my $fallback = 0;
 | 
			
		||||
      if ($Monitoring::GLPlugin::SNMP::session->error() =~ /message size exceeded.*buffer maxMsgSize/i) {
 | 
			
		||||
        # bei irrsinnigen maxrepetitions
 | 
			
		||||
        $self->debug(sprintf "buffer exceeded");
 | 
			
		||||
| 
						 | 
				
			
			@ -2566,32 +2483,12 @@ sub get_table {
 | 
			
		|||
        } else {
 | 
			
		||||
          $self->mult_snmp_max_msg_size(2);
 | 
			
		||||
        }
 | 
			
		||||
        $fallback = 1;
 | 
			
		||||
      } elsif ($Monitoring::GLPlugin::SNMP::session->error() =~ /No response from remote host/i) {
 | 
			
		||||
        # some agents can not handle big loads
 | 
			
		||||
        if ($params{'-maxrepetitions'}) {
 | 
			
		||||
          $params{'-maxrepetitions'} = int($params{'-maxrepetitions'} / 2);
 | 
			
		||||
          $self->debug(sprintf "reduce maxrepetitions to %d",
 | 
			
		||||
              $params{'-maxrepetitions'});
 | 
			
		||||
          $fallback = 1;
 | 
			
		||||
        }
 | 
			
		||||
      } elsif ($Monitoring::GLPlugin::SNMP::session->error() =~ /Received tooBig/i) {
 | 
			
		||||
        # some agents can not handle big loads
 | 
			
		||||
        if ($params{'-maxrepetitions'}) {
 | 
			
		||||
          $params{'-maxrepetitions'} = int($params{'-maxrepetitions'} / 4) + 1;
 | 
			
		||||
          $self->debug(sprintf "toobig reduce maxrepetitions to %d",
 | 
			
		||||
              $params{'-maxrepetitions'});
 | 
			
		||||
          $fallback = 1;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      if ($fallback) {
 | 
			
		||||
        $self->debug("get_table error: try fallback");
 | 
			
		||||
        $self->debug(sprintf "get_table %s", Data::Dumper::Dumper(\%params));
 | 
			
		||||
        $tic = time;
 | 
			
		||||
        $result = $Monitoring::GLPlugin::SNMP::session->get_table(%params);
 | 
			
		||||
        $tac = time;
 | 
			
		||||
        $self->debug(sprintf "get_table returned %d oids in %ds", scalar(keys %{$result}), $tac - $tic);
 | 
			
		||||
      }
 | 
			
		||||
      $self->debug("get_table error: try fallback");
 | 
			
		||||
      $self->debug(sprintf "get_table %s", Data::Dumper::Dumper(\%params));
 | 
			
		||||
      $result = $Monitoring::GLPlugin::SNMP::session->get_table(%params);
 | 
			
		||||
      $tac = time;
 | 
			
		||||
      $self->debug(sprintf "get_table returned %d oids in %ds", scalar(keys %{$result}), $tac - $tic);
 | 
			
		||||
      if (! defined $result || ! %{$result}) {
 | 
			
		||||
        $self->debug(sprintf "get_table error: %s", 
 | 
			
		||||
            $Monitoring::GLPlugin::SNMP::session->error());
 | 
			
		||||
| 
						 | 
				
			
			@ -2599,7 +2496,6 @@ sub get_table {
 | 
			
		|||
          $params{'-maxrepetitions'} = 1;
 | 
			
		||||
          $self->debug("get_table error: try getnext fallback");
 | 
			
		||||
          $self->debug(sprintf "get_table %s", Data::Dumper::Dumper(\%params));
 | 
			
		||||
          $tic = time;
 | 
			
		||||
          $result = $Monitoring::GLPlugin::SNMP::session->get_table(%params);
 | 
			
		||||
          $tac = time;
 | 
			
		||||
          $self->debug(sprintf "get_table returned %d oids in %ds", scalar(keys %{$result}), $tac - $tic);
 | 
			
		||||
| 
						 | 
				
			
			@ -3128,86 +3024,6 @@ sub get_cache_indices {
 | 
			
		|||
  return map { join('.', ref($_) eq "ARRAY" ? @{$_} : $_) } @indices;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub get_cache_indices_by_value {
 | 
			
		||||
  # we have a table like
 | 
			
		||||
  #  [TABLEITEM_40 in dot1dBasePortTable]
 | 
			
		||||
  #  dot1dBasePort: 40 (-> index in dot1qPortVlanTable)
 | 
			
		||||
  #  dot1dBasePortCircuit: .0.0
 | 
			
		||||
  #  dot1dBasePortIfIndex: 46  -> ifIndex in ifTable
 | 
			
		||||
  # $self->update_entry_cache(0, 'BRIDGE-MIB', 'dot1dBasePortTable', ['dot1dBasePort', "dot1dBasePortIfIndex"]);
 | 
			
		||||
  # creates entries like
 | 
			
		||||
  # '40#46-//-40' => [
 | 
			
		||||
  #   '40'
 | 
			
		||||
  # ],
 | 
			
		||||
  # get_cache_indices only works with --name
 | 
			
		||||
  #  '40#46-//-40' will be split into descr=40#46 and index=40
 | 
			
		||||
  #  descr would then be compared to --name and the value (which is [indices])
 | 
			
		||||
  #  be added to the return list. (the index 40 can also be a flat_indices)
 | 
			
		||||
  # we can't use dot1dBasePortIfIndex as the key_attr, as it is not unique
 | 
			
		||||
  # i ho an dot1dBasePortIfIndex und mou aussafina, wos fir index das aaf
 | 
			
		||||
  # dem hizoing.
 | 
			
		||||
  # zammbaut ho i dem zaech mied ['dot1dBasePort', "dot1dBasePortIfIndex"]
 | 
			
		||||
  # also woas i das descr vo dene zammgsetzt is und da wecha wos is.
 | 
			
		||||
  # na moue sched get_cache_indices_by_value('BRIDGE-MIB', 'dot1dBasePortTable', ['dot1dBasePort', "dot1dBasePortIfIndex"], "dot1dBasePortIfIndex", $pifidx)
 | 
			
		||||
  # aafruafa.
 | 
			
		||||
  # Liefert flache zruck.
 | 
			
		||||
  my ($self, $mib, $table, $key_attr, $cmp_attr, $cmp_value) = @_;
 | 
			
		||||
  if (ref($key_attr) ne "ARRAY") {
 | 
			
		||||
    $key_attr = [$key_attr];
 | 
			
		||||
  }
 | 
			
		||||
  if (ref($cmp_value) ne "ARRAY") {
 | 
			
		||||
    $cmp_value = [$cmp_value];
 | 
			
		||||
  }
 | 
			
		||||
  my $cache = sprintf "%s_%s_%s_cache",
 | 
			
		||||
      $mib, $table, join('#', @{$key_attr});
 | 
			
		||||
  my @indices = ();
 | 
			
		||||
  foreach my $key (keys %{$self->{$cache}}) {
 | 
			
		||||
    my ($descr, $index) = split('-//-', $key, 2);
 | 
			
		||||
    # descr was join('#', map { exists $entry->{$_} ? $entry->{$_} : "" } @{$key_attrs});
 | 
			
		||||
    my @values = split(/#/, $descr);
 | 
			
		||||
    my %cmp = map { $key_attr->[$_] => $values[$_] } 0 .. $#values;
 | 
			
		||||
    for my $cmp_val (@{$cmp_value}) {
 | 
			
		||||
      if ($cmp{$cmp_attr} && $cmp{$cmp_attr} eq $cmp_val) {
 | 
			
		||||
        push(@indices, $index);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return @indices;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub get_cache_values_by_indices {
 | 
			
		||||
  my ($self, $mib, $table, $key_attr, $indices) = @_;
 | 
			
		||||
  # -> indices is an array of flat_indices
 | 
			
		||||
# records are
 | 
			
		||||
# val1#val#2#flat_index-//-flat_index => [indices]
 | 
			
		||||
# val1#val2 represent join(#, @key_attr)
 | 
			
		||||
  if (ref($key_attr) ne "ARRAY") {
 | 
			
		||||
    $key_attr = [$key_attr];
 | 
			
		||||
  }
 | 
			
		||||
  if (ref($indices) ne "ARRAY") {
 | 
			
		||||
    $indices = [$indices];
 | 
			
		||||
  }
 | 
			
		||||
  my $cache = sprintf "%s_%s_%s_cache",
 | 
			
		||||
      $mib, $table, join('#', @{$key_attr});
 | 
			
		||||
  my @results = ();
 | 
			
		||||
  foreach my $key (keys %{$self->{$cache}}) {
 | 
			
		||||
    my ($descr, $index) = split('-//-', $key, 2);
 | 
			
		||||
    my @values = split('#', $descr);
 | 
			
		||||
    foreach my $flat_indices (@{$indices}) {
 | 
			
		||||
      if ($flat_indices eq $index) {
 | 
			
		||||
        my $element = {
 | 
			
		||||
          flat_indices => $flat_indices,
 | 
			
		||||
        };
 | 
			
		||||
        foreach my $descr_idx (0 .. $#values) {
 | 
			
		||||
          $element->{$key_attr->[$descr_idx]} = $values[$descr_idx];
 | 
			
		||||
        }
 | 
			
		||||
        push(@results, $element);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return @results;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub get_entities {
 | 
			
		||||
  my ($self, $class, $filter) = @_;
 | 
			
		||||
  foreach ($self->get_sub_table('ENTITY-MIB', [
 | 
			
		||||
| 
						 | 
				
			
			@ -268,8 +268,7 @@ $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{'CISCO-LWAPP-HA-MIB::201
 | 
			
		|||
    '5' => 'timeout',
 | 
			
		||||
  },
 | 
			
		||||
  cLHaPeerHotStandbyEvent => {
 | 
			
		||||
    '0' => 'down',
 | 
			
		||||
    '1' => 'up',
 | 
			
		||||
    '1' => 'haPeerHotstandby',
 | 
			
		||||
  },
 | 
			
		||||
  cLHaBulkSyncCompleteEvent => {
 | 
			
		||||
    '1' => 'bulkSyncComplete',
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue