Skip to content
Snippets Groups Projects
Commit bd99efcb authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

allow multiple hosts per line in snmp.cfg

parent 8bbb8220
No related branches found
No related tags found
1 merge request!71allow multiple hosts per line in snmp.cfg
...@@ -186,7 +186,7 @@ $_methods ...@@ -186,7 +186,7 @@ $_methods
CONFIG FILE: CONFIG FILE:
The config file can be multiline and has the syntax The config file can be multiline and has the syntax
[SNMPTARGET]:[auth parameters] [SNMPTARGET[,target2]]:[auth parameters]
The auth parameters set the version and all needed values to connect. The auth parameters set the version and all needed values to connect.
Snmp v2 uses a community string. Snmp v2 uses a community string.
Snmp v3 is highly recommended (you should disable Snmp v2) and needs Snmp v3 is highly recommended (you should disable Snmp v2) and needs
......
...@@ -35,10 +35,14 @@ read_config(){ ...@@ -35,10 +35,14 @@ read_config(){
SNMPAUTH="-v $SNMPVERSION -c $SNMPCOMMUNITY" SNMPAUTH="-v $SNMPVERSION -c $SNMPCOMMUNITY"
if [ -r "$SNMPCONFIG" ]; then if [ -r "$SNMPCONFIG" ]; then
if grep "^${SNMPTARGET}:" "$SNMPCONFIG" >/dev/null; then SNMPAUTH="$( grep -v "^#" "$SNMPCONFIG" | grep "^,*${SNMPTARGET}[,:]" | cut -f 2- -d ':' )"
SNMPAUTH="$( grep "^${SNMPTARGET}:" "$SNMPCONFIG" | cut -f 2- -d ':' )" if [ -z "$SNMPAUTH" ]; then
else
SNMPAUTH="$( grep "^DEFAULT:" "$SNMPCONFIG" | cut -f 2- -d ':' )" SNMPAUTH="$( grep "^DEFAULT:" "$SNMPCONFIG" | cut -f 2- -d ':' )"
if [ -z "$SNMPAUTH" ]; then
ph.setStatus "unknown"
echo "ERROR: No authentication data were found for [${SNMPTARGET}] in config file [$SNMPCONFIG]."
ph.exit
fi
fi fi
else else
ph.setStatus "unknown" ph.setStatus "unknown"
......
...@@ -96,7 +96,7 @@ OPTIONS: ...@@ -96,7 +96,7 @@ OPTIONS:
CONFIG FILE: CONFIG FILE:
The config file can be multiline and has the syntax The config file can be multiline and has the syntax
[SNMPTARGET]:[auth parameters] [SNMPTARGET[,target2]]:[auth parameters]
The auth parameters set the version and all needed values to connect. The auth parameters set the version and all needed values to connect.
Snmp v2 uses a community string. Snmp v2 uses a community string.
Snmp v3 is highly recommended (you should disable Snmp v2) and needs Snmp v3 is highly recommended (you should disable Snmp v2) and needs
......
...@@ -325,8 +325,8 @@ function ph.getFileAge(){ ...@@ -325,8 +325,8 @@ function ph.getFileAge(){
function ph._getStorefile(){ function ph._getStorefile(){
local varName=$1 local varName=$1
local mydir="/tmp/icinga_counter_$( whoami )" local mydir="/tmp/icinga_counter_${USER}"
test -n "$dir_data" && mydir="${dir_data}/_counter_$( whoami )" test -n "$dir_data" && mydir="${dir_data}/_counter_${USER}"
local _basename local _basename
_basename=$(basename $0) _basename=$(basename $0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment