(a) If there is just reason to fear the commission of an offense, the defendant must be required to give security to keep the peace, in such sum as the circuit, district or municipal court judge may direct, towards all the people of this state, particularly the person against whom or whose property there is reason to fear the offense may be committed, for such time as the judge may direct, though not more than 12 nor less than six months; but the defendant must not be required to appear at any court unless he has actually committed an offense cognizable in such court.
(b) The undertaking to keep the peace may be, in substance, as follows:
Approved, L. M., (Circuit, District or Municipal) Judge.”