Knock Sensor

A knock sensor detects the vibrations of pre-detonation(knock), and allows the PCM to retard the timing, allowing the engine to run at optimum timing advance most of the time.

They fail in a few ways. Over time they can stop registering knock, become increasingly less sensitive, hyper sensitive, or they can fail electrically. Also if your engine mounts are worn out, the contact between the metal pieces can be sensed as knock.

You can test using a scanner, or by connecting a timing light to watch for the computer to retard the timing when you tap the front of the block with something metal.

When you are installing a new one, you should clean the threads in the block, the new sensor usually has sealant on it, don't use anything else that could insulate the sensor from the block and only torque to specs as you can damage the sensor if over-torqued.