There is certainly a machine which can monitor oxygen concentration in exhaled air. By combining that with a very large soft balloon which collects all exhaled air without producing any significant resistance to exhalation, one can calculate the total amount of oxygen extracted from the inhaled air in a given time (the oxygen content of atmospheric air must also be measured accurately of course in this calculation). What we would be able to tell from such a procedure is simply "oxygen consumed" which in turn would reflect the fuel burned in the cells of the subject's body in that time. We could put the subject on a tread mill with its incline and speed increased gradually until the rate of work became so intense that the subject could not continue or until the person became exhausted. If we did this, while we constantly monitored oxygen concentration of exhaled air, we would observe a point during the increasing intensity of the treadmill running, at which the percentage of oxygen in the exhaled air stopped decreasing. That would be the point at which the subject was burning fuels (mostly glucose) aerobically as intensely as they could. That point is called the rate of maximal oxygen uptake and the procedure is called the maximal oxygen uptake test (VO2 max). It reflects several qualities: the mass of muscle the person has, the portion of that muscle which is specialized for aerobic (oxygen consuming) metabolism (endurance muscle), the capacity of the heart to pump blood, the oxygen-carrying capacity of the blood (hemoglobin concentration), and finally, the capacity of the lungs to make oxygen available to the blood.
Your question relates to this last issue. Most people have no problem in their lung function. They move as much air into and out of the lungs as they need to, the blood that passes through their lungs (this takes about a second) is pretty much saturated with oxygen (97-98%) when it leaves the lungs, the membranes allow the oxygen to move easily from the space of the lung (the alveolus) to the blood. This test (VO2 max) won't tell you where the problem is (low muscle mass, low proportion of aerobic muscles, poor heart function, anemia, lung problems, etc.) if your reading is low compared to normal. The other thing to bear in mind is that lung function is, of all the things you will train when you work on fitness, for example, the least changed or changeable. This means that training focuses on the conditioning of muscle, in this case probably the aerobic-specialized components in muscle, the pumping action of the heart, responsive vessels which easily accommodate to the delivery of blood to the tissues, hemoglobin content of blood, blood volume to a small degree far more than lung function.
To test lung function directly many things are done. A spirometer measures the volumes of air moved into and out of the lungs. This way you can measure total lung capacity (total volume of air the lungs can contain, normally about 6 liters), the "vital capacity" (the total volume of air which can be moved into or out of the lungs in one breath, normally about 4.8 liters), and other measures. One of the most telling of tests is the forced expiratory volume in one second (FEV1, the volume which you can blow out of your full lungs in one second, usually about 80%). This reacts to the common disease of chronic bronchitis because of the mucus. It will also be dramatically affected by emphysema, in which lung tissue is destroyed. During forced exhalation the small airways of the person with emphysema collapse, slowing the exhalation and reducing the FEV1 %. There are some very rare disease which interfere with the diffusion of oxygen from the alveolus to the blood. Asthma interferes with both inhalation and exhalation. Severe scoliosis could impair breathing and thereby oxygenation. If you measured your vital capacity and FEV1 before starting training for a marathon and before you successfully won the Boston Marathon, you would find that these had improved less than practically anything else you could measure about your conditioning and performance.
The thing to bear in mind is that the body only extracts the oxygen that it actually consumes in metabolic (particularly aerobic) activities. If you are just sitting, almost all of your energy production is this aerobic form and the oxygen consumption would very accurately reflect energy production. As you increase your rate of activity a portion of that increased energy is provided by metabolism which is not immediately oxygen consuming, that is "anaerobic". The VO2 max test oxygen consumption levels off when the subject reaches the point at which their body is extracting and using oxygen at the maximum rate of which it is capable. The subject will be able to increase his exertions beyond this point for a short period of time by drawing the necessary energy from anaerobic sources. Very quickly the muscles accumulate the products of anaerobic metabolism and stop working.