This is Reed Switch or Magnetic Control Switch with Normally Open Contact.
When the device is exposed to a magnetic field, the two ferrous pins inside the switch pull together and the switch closes. When the magnetic field is removed, The Reed Switch separates and the switch opens. This makes for a great non-contact switch.
This small and easy to use module can be used in variety of environmental conditions, it operates very reliably in the -50°C to +140°C temperature range.