Forum Discussion

Angel_Lopez_116's avatar
Angel_Lopez_116
Icon for Altostratus rankAltostratus
Apr 01, 2014

Exec of awk to return value of custom snmp oid

Hi,

 

I've defined a custom oid in /config/snmp/custom_mib.tcl as follows:

 

register_mib ".1" limitconn GAUGE

 

proc limitconn {} { set status [catch {exec tail -1 /var/log/irule_limitconn | tr -s \ | cut -d\ -f11} result] return $result }

 

It works fine, but when I redefine the command to use awk (to handling easily the whitespace as field separator):

 

exec tail -1 /var/log/irule_limitconn | awk '{print $11}'

 

It doesn't work, I always get 0 as result.

 

I've tried different escape sequences for the ' and { in the awk command as:

 

exec tail -1 /var/log/irule_limitconn | awk \'{print $11}\'

 

without any luck... can't I use awk here?

 

Thanks!

 

  • Were you ever able to get this script working from anything other than the command line? I've had difficulty using awk as well in 11.4 as it seems the bash interpreter has problems with this command running as a script.

     

    I have verified this with support but have yet to see a solution or "feature request" to resolve it. The only suggestion was to embed the commands and call it like an alias, but this only proceeded to take down my appliance and required a physical power cycle of the unit. :(

     

  • Actually in my situation it wasn't a problem with awk, instead the bash interpreter did not like any quotes when used with part of a grep statement. Have you tried not escaping the single quotes to see if the command runs properly?