SAN FRANCISCO - A type of fish so common that practically every American kid who ever dropped a fishing line and a bobber into a pond has probably caught one is being enlisted in the fight against terrorism.

San Francisco, New York, Washington and other big cities are using bluegills — also known as sunfish or bream — as a sort of canary in a coal mine to safeguard their drinking water.

Small numbers of the fish are kept in tanks constantly replenished with water from the municipal supply, and sensors in each tank work around the clock to register changes in the breathing, heartbeat and swimming patterns of the bluegills that occur in the presence of toxins.

"Nature's given us pretty much the most powerful and reliable early warning center out there," said Bill Lawler, co-founder of Intelligent Automation Corporation, a Southern California company that makes and sells the bluegill monitoring system. "There's no known manmade sensor that can do the same job as the bluegill."

Since Sept. 11, the government has taken very seriously the threat of attacks on the U.S. water supply. Federal law requires nearly all community water systems to assess their vulnerability to terrorism.

Big cities employ a range of safeguards against chemical and biological agents, constantly monitoring, testing and treating the water. But electronic protection systems can trace only the toxins they are programmed to detect, Lawler said.

Bluegills — a hardy species about the size of a human hand — are considered more versatile. They are highly attuned to chemical disturbances in their environment, and when exposed to toxins, they experience the fish version of coughing, flexing their gills to expel unwanted particles.

The computerized system in use in San Francisco and elsewhere is designed to detect even slight changes in the bluegills' vital signs and send an e-mail alert when something is wrong.

San Francisco's bluegills went to work about a month ago, guarding the drinking water of more than 1 million people from substances such as cyanide, diesel fuel, mercury and pesticides. Eight bluegills swim in a tank deep in the basement of a water treatment plant south of the city.

"It gave us the best of both worlds, which is basically all the benefits that come from nature and the best of high-tech," said Susan Leal, general manager of the San Francisco Public Utilities Commission.

New York City has been testing its system since 2002 and is seeking to expand it. The New York City Department of Environmental Protection reported at least one instance in which the system caught a toxin before it made it into the water supply: The fish noticed a diesel spill two hours earlier than any of the agency's other detection devices.

They do have limitations. While the bluegills have successfully detected at least 30 toxic chemicals, they cannot reliably detect germs. And they are no use against other sorts of attacks — say, the bombing of a water main, or an attack by computer hackers on the systems that control the flow of water.

Still, Lawler said more than a dozen other cities have ordered the anti-terror apparatus, called the Intelligent Aquatic BioMonitoring System, which was originally developed for the Army and starts at around $45,000.

San Francisco plans to install two more bluegill tanks.

"It provides us an added level of detection of the unknown," said Tony Winnicker, a spokesman for the city's Public Utilities Commission. "There's no computer that's as sophisticated as a living being."