I think he had excess mucus in his respiratory tracts and was trying to shake it off. He was making a noise too on & off, sounded horrible, like a deep gurgle, as if he was full of fluid, but it didn't actually seem to bother him that much. He's hasn't lacked energy, appetite, responsiveness or anything. He's doing a lot better now. I got him old as a rescue/foster, age 2+, have had him 2 months now so will have to keep close watch.
So, head shaking is typically a sign that there is something going on in the ear. It could be an outer or inner ear infection or impacted ear wax, which can give off a funky odor as well. Considering that your buddy is also dealing with what sounds like an active lower respiratory infection, it's very possible that he has an inner ear infection brewing as well.
Ear infections can begin with or without an active respiratory infection. Sometimes an ear infection or symptoms of an ear infection may manifest first before you notice respiratory involvement. The gurgling and chest noises are really concerning. Please keep in mind that rats are incredible at hiding just how sick they really are and you often won't observe outright symptoms like hunched posture w/ piloerection (rat looks prickly or poofy), lethargy, labored breathing and decreased food/water intake until the infection has progressed to the point that the rat can no longer mask symptoms.
Your rattie really needs veterinary intervention so that he can begin antibiotic therapy. Depending on how advanced the respiratory infection is he may need a combination of enrofloxicin and doxycycline; if the infection has progressed to pneumonia he will require an antibiotic combination of enrofloxicin and azithromycin. He may benefit from meloxicam (NSAID) to calm inflammation in
the tissues of the lungs and respiratory tract. Lasix (a diuretic) may also be added if he has pulmonary edema. Pulmonary edema (fluid in the lungs) is very serious and will lead to respiratory distress and possible respiratory failure if left untreated. Untreated active mycoplasmosis infections as well as unresolved pulmonary
edema can place unnecessary strain on the heart which could raise the risk of the rat developing congestive heart failure later in life.
There's always the possibility, due to his age, that you're observing symptoms of a disorder of the heart which would require a veterinary evaluation to determine whether this is a respiratory infection or an undiagnosed cardiovascular disorder. In addition to assisting in clearing fluid from the lungs, Lasix is also an excellent diagnostic tool in combination with Enalapril (ACE inhibitor; heart med) that can help determine if an underlying heart condition if it exists.
I'd strongly recommend scheduling an appointment with your veterinarian as soon as possible. Please keep us updated on how your senior rattie is doing.