DICE: Monitoring Global Invariants with Wireless Sensor Networks