Not what you want to hear, I am afraid, but the first thing that comes to mind is that a 2nd Gen Time Capsule is at least 6 years old, and as much as 7 depending on when the product was placed into service.
The average useful life of a 2nd Gen Time Capsule was about 3 years, so you have done far better than most of the rest of us. Congrats on that.
As a last gasp measure, you could try resetting the Time Capsule back to factory default settings and then attempt to set it up again. The default reset will not affect any of the data on the Time Capsule hard drive.....only the network settings will be reset.
If you decide to proceed, and need more details about this, post back at your convenience.
I'm assuming that you have already checked the Ethernet port on the iMac by connecting to another device.....like a modem....to make sure that the port is working. It would be extremely rare that an Ethernet port would fail, but it can happen.