Hey sponger, I've had a bit more time to play with this. What you provided works really well, both snmpet and dig outputs are perfect.
I think because of how the NMAP output matching is done, it currently returns the IP address as $host. e.g.:
10.1.1.1,10.1.1.1
The NMAP output looks like this, with the OS detection section varying depending on what it finds:
# nmap -Pn -F -sS -sU -O -T4 -R --max-retries 3 10.1.1.1
Starting Nmap 5.35DC1 ( http://nmap.org ) at 2011-11-02 10:02 CST
Nmap scan report for 10.1.1.1
Host is up (0.00090s latency).
Not shown: 100 open|filtered ports, 99 filtered ports
PORT STATE SERVICE
x/x closed x
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: switch|firewall|broadband router
Running: producta, productb, productc
OS details: producta, productb, productc
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 6.78 seconds
OS detection examples:
# nmap -Pn -F -sS -sU -O -T4 -R --max-retries 3 10.1.1.1 | egrep "OS:|OS details:"
OS:SCAN(V=5.35DC1%D=11/2%OT=21%CT=7%CU=7%PV=Y%DS=4%DC=I%G=Y%TM=4EB08387%P=i
OS:686-redhat-linux-gnu)SEQ(SP=100%GCD=1%ISR=100%TI=BI%TS=7)SEQ(TS=9)SEQ(TI
OS:=RI%TS=8)OPS(O1=M5B4ST11NW0%O2=M5B4ST11NW0%O3=M5B4NNT11NW0%O4=M5B4ST11NW
OS:0%O5=M5B4ST11NW0%O6=M5B4ST11)WIN(W1=16A0%W2=16A0%W3=16A0%W4=16A0%W5=16A0
OS:%W6=16A0)ECN(R=N)T1(R=Y%DF=Y%T=41%S=O%A=S+%F=AS%RD=0%Q=)T1(R=Y%DF=Y%T=41
OS:%S=O%A=O%F=AS%RD=0%Q=)T1(R=N)T2(R=N)T3(R=N)T4(R=N)T5(R=Y%DF=Y%T=7F%W=0%S
OS:=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=N)T7(R=N)U1(R=Y%DF=N%T=7F%IPL=164%UN=0%RIPL
OS:=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=N)
# nmap -Pn -F -sS -sU -O -T4 -R --max-retries 3 10.1.1.2 | egrep "OS:|OS details:"
OS details: producta, productb, productc
Would it be possible to output the "OS details" line if it exists else null?, e.g.:
10.1.1.1,host1
10.1.1.2,host2
10.1.1.3,OS details: producta, productb, productc
10.1.1.4,host4
Also, the other thing I was wondering is if it would be possible to print the method in between $IP & $host? e.g.
10.1.1.1,DNS,host1
10.1.1.2,SNMP,host2
I tried adding it in to the host= line but it didn't like my attempted syntax :(