ben-bradley / leonidas

A distributed, transparent SNMP caching proxy app.
6 stars 2 forks source link

Don't see any evidence of caching #5

Closed DrDaveD closed 6 years ago

DrDaveD commented 6 years ago

I found that on the poller machine this is a more interesting snmpget than the one given in the README

snmpget -v2c -c public 192.168.20.3 1.3.6.1.2.1.1.3.0 -r 0

(the address ends in .3 with pr #2) because it returns a different value each time, Timeticks, which appears to be the hours, minutes, and seconds since boot time. However, I expected to see the same answer for 30 seconds because of caching, but it changes every time.

Also, if I kill "node app.js" on the router I expected the snmpget wouldn't work because there would be nothing to forward and cache the packets, but it works even when node app.js isn't running.

How should I be able to see evidence of caching the answers?

DrDaveD commented 6 years ago

The problem was that I was getting this message from vagrant:

==> router: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> router: flag to force provisioning. Provisioners marked to run always will still run.

I was getting it from all 3 VMs, preventing them from setting up the routing with the startup scripts in the Vagrantfile. The solution is to add an option run: "always" to the vm.provision lines. I have now included this in pr #2. Before starting node app.js the traffic is routed straight through. Starting node app.js reroutes through it, and I see the timeticks getting cached for 30 seconds.

DrDaveD commented 6 years ago

FYI, Ben, after getting the demo working I decided not to use this tool. The reasons were: 1) I couldn't figure out how to get iptables to redirect all outgoing UDP packets from localhost, which is the case I wanted it for. 2) I didn't like that it had to add a new iptable route for every destination. I suppose that's the only way to do it, but I didn't realize that, and I have hundreds of destinations and didn't like the idea of all those iptables entries 3) I figured out a simpler way to avoid duplicate SNMP queries: using MRTG External Monitoring Scripts which I could get away with because all my SNMP queries are done from MRTG on a single machine. I just wrote a small script to read the latest data points from other MRTG output directories.