Having some spare time to spend, I have completely rewritten (well, more or 
less) the program whch collects ip accounting info out of Cisco routers.
I have a long list of disasters due to this beast, and I cannot stand anymore 
(the last one was a suble undocumented "feature" which caused "ciscotalk" to 
stop working when we changed the Cisco internal prompt!).

In the new program everything is done via SNMP (isn't it the right way?), 
thanks to the new cisco MIB extentions which allow to do a "ip accounting 
clear" via a SNMP SET command.

Recipe:
1) configure SNMP on Cisco:
	snmp-server community <KNOWN-PASSWORD> RO
	snmp-server community <SECRET_PASSWORD> RW 2
	snmp-server host <SNMP-SERVER> <KNOWN-PASSWORD>

  where "2" is a suitable, very restricted, access list (you need just
  a logger machine, and possibly a backup one):
	access-list 2 permit <LOGHOST>
	access-list 2 permit <LOG2HOST>

2) get a copy of the latest cmu-snmp2 package from "lancaster.andrew.cmu.edu" 
(and you will be ready for SNMP2, BTW).

3) build a new "/etc/mib.txt" file from the CMU mib.txt one and the mib.txt91 
from "ftp.cisco.com" (there's some editing to do, to make the parser happy, ask
for my -quick-hacked- copy if you want).

(all the step up to now are for general setup, and may be useful for other 
needs: have a look at snmpgraph in the cmu package, f.i.).

4) compile the program "cisco-acct.c" under the "apps" subdirectory of 
cmu-snmp2.

5) install cisco-acct in a suitable place (/usr/local/etc, f.i.), and run it 
from cron (say, every our), with the following command:
	cisco-acct <router> <secret-password> >> /var/log/ipacct
("/var/log/ipacct" is the file where the the logs are kept, to be stored away 
daily, weekly, monthly accordingly to the size of the file).


How it works:
cisco-acct SNMP_GET&SNMP_SET  the "local.lip.acctCheckPoint" variable of Cisco 
private MIB; every time the variable is written, the IP acct table is moved to 
the checkpoint table and the variable is incremented.
The checkpoint table is then downloaded by SNMPGETNEXT messages (thanks to 
"gwacc" from UCB).
The acctCheckPoint variable is printed in the heading of the output (along with
the time of day); in this way you can keep track of any error in the mechanism.
I don't care to "double clear" the accounting table (as in the old script): 
reading fromn the checkpoint table is more accurate (specially under heavy load
or very long tables) and the only thing you lose is some 100kB of memory in the
router (well, now that I have a CSC4 I can be so lenient about memory...).


				Joy

P.S. You can find a copy of the program in
 	ftp.iunet.it:network/cisco/cisco-acct.tar.Z
     The CMU package can also be found in
	 ftp.iunet.it:network/snmp/cmu-snmp2.1.2.tar.Z

P.P.S. I still have on the wish list a version of this program that sums up 
accounting data into a DBM file, to be run as daemon. Next iteration.


