How do I get ping values to use in a widget?

can you tell me how you got the Get ping in ms to work ?