BEGIN { FS = " " syntax = "" access = "" status = "" oid = "" oidname = "" oidfound = 0 group = "" desc = "" cnt = 0 dstype = "**" snmp = "snmp://%snmp%/" ds = "" view = "" targettype = "" targets = "" statemachine = "start" } /^-- / { oid = $2 statemachine = "newoid" oidfound = 1 } $1 ~ /SYNTAX/ { syntax = $2 if ( $2 ~ /INTEGER/ ) dstype = "GAUGE" if ( $2 ~ /COUNTER64/ ) dstype = "COUNTER" } $1 ~ /ACCESS/ { access = $2 } $1 ~ /STATUS/ { status = $2 } $1 ~ /DESCRIPTION/ { desc = $0 } $2 ~ /OBJECT/ && $3 ~ /IDENTIFIER/ { statemachine = "groupdef" } $2 ~ /OBJECT-TYPE/ { oidname = $1 statemachine = "objectdef" } /::=/ { group = $3 if ( group != targettype && "" != oidname ) { if ( "" != ds ) { printf "\ntargetType\t%s\n", targettype printf "\tds\t=\t\"%s\"\n", ds printf "\tview\t=\t\"%s: %s\"\n", targettype, view targets = targets "\ntarget " targettype "\n target-type " targettype "\n" targettype = group ds = "" view = "" } targettype = group } if ( statemachine ~ /objectdef/ && 1 == oidfound ) { if ( "" != ds ) ds = ds ", " ds = ds oidname if ( "" != view ) view = view " " view = view oidname printf "\n#%s\nOID\t%s\t%s\n", desc, oidname, oid printf "dataSource %s\n\tds-source\t=\t%s%s\n", oidname, snmp, oidname printf "\trrd-ds-type = %s\n", dstype cnt++ oid = "" group = "" syntax = "" status = "" desc = "" oidname = "" dstype = "**" } } END { if ( "" != ds ) { printf "\ntargetType\t%s\n", targettype printf "\tds\t=\t\"%s\"\n", ds printf "\tview\t=\t\"%s: %s\"\n", targettype, view targettype = group ds = "" view = "" } # printf "count: %d\n", cnt print print "*** for the device specific Defaults file ***" print targets }