How does your body know when it is infected with a virus or bacteria so it can invoke a fever or ramp up the immune system?
During infection certain macromolecules present in the pathogens (pathogen associated molecular patterns) such as lipopolysaccharide launch the innate immune response, through toll like receptors. This leads to production of pro-inflammatory cytokines and also other inflammatory mediators like prostaglandins, thereby causing inflammation and fever.
An opinion by non-technical observer.
If you know the function of a hive, you know that bees communicate with each other, touching and rubbing chemical information. In a few minutes the information reaches the center of the hive and returns to individuals which are caring of it. It is widely accepted that a hive is a unique individual, composed of thousands of insects each with its own function.
I believe that we can make the observation reverse. The man (and animals) are agglomerations of cells that pass chemically information to each other. Information reaches the central system, which responds by activating the necessary functions.
In case of infection, viral or bacterial, blood flow to the affected place very quickly, scrolling faster and thus raising the temperature. Similarly in the blood activates the necessary antibodies, which communicate with each other chemically referring where necessary. Pile up in the affected areas, resulting in swelling.
Other functions, such as sweating, vomiting or pus, are ways to excrete toxins (such should not be blocked). If we imagine the human body as a great hive where each cell is a member that transmits information and responds to stimulation of central system, acting in cooperation, the operation according to me is very clear.
How do the bees know that they are dying, if not passing to collecting companions honey too thick? Sorry for non-technical opinion, if not useful delete it.