The 49ers have signed restricted free agent linebacker Ahmad Brooks to a two-year contract. Brooks had received a second-round tender, but was able to reach a longer-term deal to stay in San Francisco.