python-hospital / hospital

Tools to diagnose Python projects (supervision, monitoring).
Other
40 stars 8 forks source link

assert_ping relies on the os ping binary #56

Open brunobord opened 10 years ago

brunobord commented 10 years ago

The current ping util relies on the ping command line util. I'm not sure it's a good idea to rely on the operating system and subprocess command output there. I've searched a bit and found a pure-python implementation of the ping (ICMP) protocol.

If you are okay with this idea, I may try to see if it's doable to replace the ping call with it (at the moment, it's not very clear).

benoitbryon commented 10 years ago

The current ping util relies on the ping command line util. I'm not sure it's a good idea to rely on the operating system and subprocess command output there.

Agreed. It could be improved.

I've searched a bit and found a pure-python implementation of the ping (ICMP) protocol. If you are okay with this idea, I may try to see if it's doable to replace the ping call with it.

I'm ok with the idea. Also have a look at https://pypi.python.org/pypi?%3Aaction=search&term=ping&submit=search

Notice that some sources (like https://pypi.python.org/pypi/pyping/0.0.4) mention that "ICMP messages can only be sent from processes running as root"... If I have to choose between using subprocess VS running as root, I would keep on running subprocess ;)

Or perhaps have a look at scapy's ping features. Hospital may not depend on scapy, but perhaps we could document recipes to use scapy's features within healthchecks.

brunobord commented 10 years ago

I knew ping wasn't easy.

I've tested pyping with or without the udp flag, same result: Permission denied. You have to be root. I agree: having to run ping checks as root is a no-go. Maybe this feature is not a good idea after all...

But I'm wondering: if you have to be root to send ICMP packages, how is it possible to run "ping" as a normal user and get results?