The model year of a MacBook Pro is available at Apple menu > About This Mac.
An Early 2008 through mid 2009 MacBook Pro can be upgraded to El Capitan 10.11.6 but no later version.
A late 2009 through mid 2011 iMac can be upgraded to High Sierra 10.13.6 but no later version.
For all of the above, see instructions in: How to download and install macOS - Apple Support
Also see the following from Identify your iMac model - Apple Support
iMac (27-inch, Late 2009)
Model Identifier: iMac10,1
Part Number: MB952xx/A, MB953xx/A
Newest compatible operating system: macOS High Sierra
Tech Specs for iMac (27-inch, Late 2009)
User Guide for iMac (27-inch, Late 2009) (PDF)
iMac (21.5-inch, Late 2009)
Model Identifier: iMac10,1
Part Number: MB950xx/A, MC413xx/A
Newest compatible operating system: macOS High Sierra
Tech Specs for iMac (21.5-inch, Late 2009)
User Guide for iMac (21.5-inch, Late 2009) (PDF)
iMac (24-inch, Early 2009)
Model Identifier: iMac9,1
Part Number: MB418xx/A, MB419xx/A
Newest compatible operating system: OS X El Capitan
Tech Specs for iMac (24-inch, Early 2009)
iMac (20-inch, Early 2009)
Model Identifier: iMac9,1
Part Number: MB417xx/A, MC019xx/A
Newest compatible operating system: OS X El Capitan
Tech Specs for iMac (20-inch, Early 2009)