read args to commands synchronous, async is not faster in this case
This commit is contained in:
@@ -446,7 +446,6 @@ function return_oid() {
|
|||||||
#
|
#
|
||||||
function main() {
|
function main() {
|
||||||
local buf line cmd oid req next
|
local buf line cmd oid req next
|
||||||
local -a args
|
|
||||||
|
|
||||||
echo "waiting for all data gathering functions to return data" >&$LOG
|
echo "waiting for all data gathering functions to return data" >&$LOG
|
||||||
update_oid_cache true
|
update_oid_cache true
|
||||||
@@ -473,18 +472,7 @@ function main() {
|
|||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
echo "< $line" >&$DEBUGLOG
|
echo "< $line" >&$DEBUGLOG
|
||||||
if [ -z $cmd ]; then
|
|
||||||
cmd=$line
|
cmd=$line
|
||||||
args=()
|
|
||||||
elif [ -z $line ]; then
|
|
||||||
cmd=""
|
|
||||||
args=()
|
|
||||||
echo "empty argument" >&$DEBUGLOG
|
|
||||||
snmp_echo NONE
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
args+=("$line")
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "${cmd,,}" in
|
case "${cmd,,}" in
|
||||||
ping)
|
ping)
|
||||||
@@ -493,14 +481,18 @@ function main() {
|
|||||||
;;
|
;;
|
||||||
set)
|
set)
|
||||||
# we need to args here, 'oid' and 'type_and_value'
|
# we need to args here, 'oid' and 'type_and_value'
|
||||||
(( ${#args[@]} < 2 )) && continue
|
|
||||||
cmd=""
|
cmd=""
|
||||||
|
read -r -u $STDIN
|
||||||
|
read -r -u $STDIN
|
||||||
snmp_echo not-writable
|
snmp_echo not-writable
|
||||||
;;
|
;;
|
||||||
get)
|
get)
|
||||||
(( ${#args[@]} < 1 )) && continue
|
|
||||||
cmd=""
|
cmd=""
|
||||||
oid=${args[0]}
|
read -r -u $STDIN oid
|
||||||
|
if [ -z "$oid" ]; then
|
||||||
|
echo "received empty oid" >&2
|
||||||
|
snmp_echo NONE
|
||||||
|
fi
|
||||||
req_from_oid $oid req || continue
|
req_from_oid $oid req || continue
|
||||||
if [[ ! -v OIDDATA[$req] ]]; then
|
if [[ ! -v OIDDATA[$req] ]]; then
|
||||||
echo "$oid not found" >&$DEBUGLOG
|
echo "$oid not found" >&$DEBUGLOG
|
||||||
@@ -510,9 +502,12 @@ function main() {
|
|||||||
return_oid "$req"
|
return_oid "$req"
|
||||||
;;
|
;;
|
||||||
getnext)
|
getnext)
|
||||||
(( ${#args[@]} < 1 )) && continue
|
|
||||||
cmd=""
|
cmd=""
|
||||||
oid=${args[0]}
|
read -r -u $STDIN oid
|
||||||
|
if [ -z "$oid" ]; then
|
||||||
|
echo "received empty oid" >&2
|
||||||
|
snmp_echo NONE
|
||||||
|
fi
|
||||||
req_from_oid $oid req || continue
|
req_from_oid $oid req || continue
|
||||||
next=$(printf "%s\n" ${!OIDDATA[@]} $req | sort -V | grep -A1 -E "^$req\$" | tail -n 1)
|
next=$(printf "%s\n" ${!OIDDATA[@]} $req | sort -V | grep -A1 -E "^$req\$" | tail -n 1)
|
||||||
echo "evaluated next candidate: [requested: '$req', next: '$next']" >&$DEBUGLOG
|
echo "evaluated next candidate: [requested: '$req', next: '$next']" >&$DEBUGLOG
|
||||||
|
|||||||
Reference in New Issue
Block a user