just as example
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
run show interfaces
exit
configure
set service snmp script-extensions extension-name bgp1 script ‘bgp-rt1a.sh’
execute test from host and got an erros
snmpwalk -v2c -c public X.X.X.X nsExtendOutput1
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.“bgp1” = STRING: Failed to set up config session
NET-SNMP-EXTEND-MIB::nsExtendOutputFull.“bgp1” = STRING: Failed to set up config session
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines.“bgp1” = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendResult.“bgp1” = INTEGER: 1
Actually I want to run
/usr/bin/vtysh -c ‘show ip bgp neighbors X.X.X.X prefix-counts’ | grep PfxCt: | awk ‘{print $2}’
but runnig /usr/bin/vtysh inside script had a escalation problem
snmpwalk -v2c -c public X.X.X.X nsExtendOutput1
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.“bgp1” = STRING: % Can’t open configuration file /etc/frr/vtysh.conf due to ‘Permission denied’.
NET-SNMP-EXTEND-MIB::nsExtendOutputFull.“bgp1” = STRING: % Can’t open configuration file /etc/frr/vtysh.conf due to ‘Permission denied’.
Exiting: failed to connect to any daemons.
Hint: if this seems wrong, try running me as a privileged user!
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines.“bgp1” = INTEGER: 3
NET-SNMP-EXTEND-MIB::nsExtendResult.“bgp1” = INTEGER: 0
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.“bgp-rt1a” = STRING:
NET-SNMP-EXTEND-MIB::nsExtendOutputFull.“bgp-rt1a” = STRING:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines.“bgp-rt1a” = INTEGER: 9
NET-SNMP-EXTEND-MIB::nsExtendResult.“bgp-rt1a” = INTEGER: 0