The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
 "Aforetime you were used," etc.--This story the Master told in Pubbārāma, about some Brethren who were rude and rough in their manners. These Brethren, who lived on the floor below that where the Master was, talked of what they had seen and heard, and were quarrelsome and abusive. The Master called Mahāmoggallāna to him, and bade him go startle them. The Elder rose in the air, and just touched the foundation of the house with his great toe. It shook to the furthest edge of ocean! The Brothers were frightened to death, and came and stood outside. Their rough behaviour became known among the Brethren. One day they got to talking about it in the Hall of Truth. "Friend, there are some Brethren who have retired to this house of salvation, who are rough and rude; they do not see the impermanence, sorrow and unreality of the world, nor do their duty." The Master came in, and asked what they were discussing as they sat there. They told him. "This is not the first time, Brethren," said he, "that they have been rough and rude. They were the same before." And he told them an old-world tale.
Once upon a time, when Brahmadatta reigned king in Benares, the Bodhisatta was born as a brahmin's son in a village. They named him Komāyaputta. By and bye he went out and embraced the religious life in the region of Himalaya. There were some frivolous ascetics who had made a hermitage in that region, and there they lived. But they did not take the means to induce religious ecstasy. They fetched the fruits from the woods, to eat; then they spent the time laughing and joking together. They had a monkey, rude-mannered like themselves, which gave them endless amusement by his grimaces and antics.
Long they lived in this place, till they had to go amongst men again to get salt and condiments. After they went away, the Bodhisatta lived in their dwelling-place. The monkey played his pranks for him as he had done for the others. The Bodhisatta snapt his fingers at him, and gave him a lecture, saying, "One who lives with well-trained ascetics 
ought to behave properly, ought to be well-advised in his actions, and devoted to meditation." After that, the monkey was always virtuous and well-behaved.
After this, the Bodhisatta moved away. The other ascetics returned with their salt and condiments. But the monkey no longer played his pranks for them. "What's this, my friend?" they asked. "Why don't you make sport, as you used to do?" One of them repeated the first stanza:
On hearing this, the Monkey repeated the second stanza:
Hereupon the anchorite repeated the third:
 When the Master had ended this discourse, he declared the Truths, and identified the Birth: "At that time these Brothers were the frivolous anchorites, but Komāyaputta was I myself."
305:1 Folk-Lore Journal, 3. 254.