The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
 "A foolish monkey," etc.--This story the Master told at Jetavana, about a king of Kosala.
One rainy season, disaffection broke out on his borders. The troops stationed there, after two or three battles in which they failed to conquer their adversaries, sent a message to the king. Spite of the season, spite of the rains he took the field, and encamped before Jetavana Park. Then he began to ponder. "’Tis a bad season for an expedition; every crevice and hollow is full of water; the road is heavy: I'll go visit the Master. He will be sure to ask 'whither away'; then I'll tell him. It is not only in things of the future life that our Master protects me, but he protects in the things which we now see. So if my going is not to prosper, he will say 'It is a bad time to go, Sire'; but if I am to prosper, he will say nothing." So into the Park he came, and after greeting the Master sat down on one side.
"Whence come you, O King," asked the Master, "at this unseasonable hour?" "Sir," he replied, "I am on my way to quell a border rising; and I come first to bid you farewell." To this the Master said, "So it happened before, that mighty monarchs, before setting out for war, have listened to the word of the wise, and turned back from an unseasonable expedition." Then, at the king's request, he told an old story.
Once upon a time, when Brahmadatta was reigning in Benares, he had a Councillor who was his right-hand man and gave him advice in things spiritual and temporal. There was a rising on the frontier, and the
troops there stationed sent the king a letter. The king started, rainy season though it was, and formed a camp in his park. The Bodhisatta stood before the king. At that moment the people had steamed some peas for the horses, and poured them out into a trough. One of the monkeys that lived in the park jumped down from a tree, filled his mouth and hands with the peas, then up again, and sitting down in the tree he began to eat. As he ate, one pea fell from his hand upon the ground. Down dropped at once all the peas from his hands and mouth,  and down from the tree he cause, to hunt for the lost pea. But that pea he could not find; so he climbed up his tree again, and sat still, very glum, looking like some one who had lost a thousand in some lawsuit.
The king observed how the monkey had done, and pointed it out to the Bodhisatta. "Friend, what do you think of that?" he asked. To which the Bodhisatta made answer: "King, this is what fools of little wit are wont to do; they spend a pound to win a penny;" and he went on to repeat the first stanza:
Then the Bodhisatta approached the king, and addressing him again, repeated the second stanza:
 On hearing this address the king turned and went straight back to Benares. And the outlaws hearing that the king had set forth from his capital to make mincemeat of his enemies, hurried away from the borders.
At the time when this story was told, the outlaws ran away in just the sane fashion. The king, after listening to the Master's utterances, rose and took his leave, and went back to Sāvatthi.
The Master, after this discourse was at an end, identified the Birth: "In those days Ānanda was the king, and the wise councillor was I myself."