How is the visibility at airports measured?
The visibility is measured alongside the runway, usually at various positions, and is called the Runway Visual Range (RVR). 

RVR is defined as the range over which the pilot of an aircraft on the centre line of a runway can see the runway surface markings or the lights delineating the runway or identifying its centre line.

RVR is measured using so called transmissometers. 



source: keesfloor.nl

These units transmit a beam of light (usually using laser) to a detector. In some case the transmitter and detector are in the same unit and a reflector is used. The ratio of the transmitted energy and the detected energy is a measure of how much light is absorbed in the fog. From this the RVR can be calculated.

Another type of sensor used to measure the visibility on airports is a forward scatter sensor. This type of sensor can be mounted on a single mast and gives more accurate results for visibilities > 2 km. This kind of sensor is used for both determining RVR and Meteorological Optical Range (MOR).




source: KNMI (PDF)

This type of sensor works by detecting how much of the transmitted light is scattered into a detector which is placed off-axis. 



Aircraft don't have means to measure the visibility other than the pilot Mk 1 eyeball.