SNMPGET help

What I am trying to do is have nagios alert if the ratio of two snmp values is below a certain percent.

I have the OID values - one for total devices another for devices online.

I assume I need a shell script similar to :
Cmtotal=snmpget ...
Cmactive=snmpget ...
Cmperc=$cmtotal/$cmactive
If $cmperc < 80 ]; then

But this is where I am stumped. I have teh correct SNMPGET commands to find the values I need but where do I create this script and how do I tell it to alert Nagios if the ratio is below 80% for example??
Anyone have any idea where to start?