1a1083fa44a7ab4dafdc6d241cc9407a5a9faa81
David Blume first commit.

David Blume authored 5 years ago

1) #!/usr/bin/python3
2) #
3) # Since this is meant to be run as a daemon, do not use #!/usr/bin/env python3,
4) # because the process name would then be python3, not based on __FILE__.
5) #
6) # [filename] -d 3 192.168.1.1 192.168.1.12 &
7) # disown [jobid]
8) import os
9) import sys
10) import subprocess
11) import time
12) from argparse import ArgumentParser
13) import threading
14) import queue
15) 
David Blume Serialize the reading and w...

David Blume authored 5 years ago

16) pinger_lock = threading.Lock()
17) 
David Blume first commit.

David Blume authored 5 years ago

18) 
19) def pinger(host):
20)     """Executes one ping, prints if there was a change, exits thread."""
21)     now = time.localtime()
22)     success = ping(host)
David Blume Serialize the reading and w...

David Blume authored 5 years ago

23)     with pinger_lock:
24)         # Access to _results needs to be serialized
25)         need_update = success != _results[host]
26)         if need_update:
27)             _results[host] = success
28)     if need_update: