mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-26 02:31:36 +03:00
No Offline status for timeouted ports? #1084
This commit is contained in:
parent
3c42bb929b
commit
5d647aea3f
1
NEWS
1
NEWS
@ -18,6 +18,7 @@ Bugs corrected:
|
||||
* Some FS and LAN metrics fail to export correctly to StatsD (issue #1068)
|
||||
* Problem with non breaking space in file system name (issue #1065)
|
||||
* TypeError: string indices must be integers (Network plugin) (issue #1054)
|
||||
* No Offline status for timeouted ports? (issue #1084)
|
||||
|
||||
Version 2.9.1
|
||||
=============
|
||||
|
@ -32,7 +32,7 @@ try:
|
||||
except ImportError:
|
||||
requests_tag = False
|
||||
|
||||
from glances.globals import WINDOWS
|
||||
from glances.globals import WINDOWS, MACOS, BSD
|
||||
from glances.ports_list import GlancesPortsList
|
||||
from glances.web_list import GlancesWebList
|
||||
from glances.timer import Timer, Counter
|
||||
@ -271,7 +271,22 @@ class ThreadScanner(threading.Thread):
|
||||
# Create the ping command
|
||||
# Use the system ping command because it already have the steacky bit set
|
||||
# Python can not create ICMP packet with non root right
|
||||
cmd = ['ping', '-n' if WINDOWS else '-c', '1', self._resolv_name(port['host'])]
|
||||
if WINDOWS:
|
||||
timeout_opt = '-w'
|
||||
count_opt = '-n'
|
||||
elif MACOS or BSD:
|
||||
timeout_opt = '-t'
|
||||
count_opt = '-c'
|
||||
else:
|
||||
# Linux and co...
|
||||
timeout_opt = '-W'
|
||||
count_opt = '-c'
|
||||
# Build the command line
|
||||
# Note: Only string are allowed
|
||||
cmd = ['ping',
|
||||
count_opt, '1',
|
||||
timeout_opt, str(self._resolv_name(port['timeout'])),
|
||||
self._resolv_name(port['host'])]
|
||||
fnull = open(os.devnull, 'w')
|
||||
|
||||
try:
|
||||
@ -281,6 +296,9 @@ class ThreadScanner(threading.Thread):
|
||||
port['status'] = counter.get()
|
||||
else:
|
||||
port['status'] = False
|
||||
except subprocess.CalledProcessError as e:
|
||||
# Correct issue #1084: No Offline status for timeouted ports
|
||||
port['status'] = False
|
||||
except Exception as e:
|
||||
logger.debug("{}: Error while pinging host {} ({})".format(self.plugin_name, port['host'], e))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user