Somme Parade was blocked off by police from Quick Avenue onwards for about an hour.
Stoneman has two children who attend Churton School, with whom he is not allowed contact, Judge Cameron said.
He was previously served with a trespass order by the school.
The armed offenders squad and police from Wanganui and Palmerston North were deployed "due to the serious concerns that there could be an active shooter at the school".
Judge Cameron said an "active shooter" was defined as "an individual actively engaged in killing or attempting to kill people in a confined and populated area". The children were locked in their rooms as police searched the school.
The incident caused "great concern" to those involved, he said.
Stoneman was arrested later that day, and refused on two occasions to allow police to fingerprint and photograph him. He was also verbally abusive.
Judge Cameron said Stoneman had an extensive criminal history in the adult court, beginning in 1984, including convictions for breaching protection orders, behaving threateningly and threatening to kill.
Judge Cameron said in his sentencing he needed to deter others from "this kind of extraordinary behaviour which smacks of exhibitionism".
He sentenced Stoneman to three months in prison and ordered him to pay $1400 reparation to the police.