mirror of
https://github.com/nicolargo/glances.git
synced 2026-03-13 03:17:12 -04:00
Add the public IP information to the WebUI #2105
This commit is contained in:
@@ -25,5 +25,6 @@ export default function GlancesPluginIpController($scope, GlancesStats, ARGUMENT
|
||||
vm.mask = ipStats.mask;
|
||||
vm.maskCidr = ipStats.mask_cidr;
|
||||
vm.publicAddress = ipStats.public_address
|
||||
vm.publicInfo = ipStats.public_info_human
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<section id="ip" ng-if="vm.address != undefined && !vm.arguments.disable_ip">
|
||||
- <span class="title">IP</span> <span>{{ vm.address }}/{{ vm.maskCidr }}</span> <span
|
||||
ng-if="vm.publicAddress" class="title">Pub</span> <span>{{ vm.publicAddress }}</span>
|
||||
-
|
||||
<span ng-if="vm.address != undefined" class="title">IP</span>
|
||||
<spanng-if="vm.address != undefined">{{ vm.address }}/{{ vm.maskCidr }}</span>
|
||||
<span ng-if="vm.publicAddress" class="title">Pub</span>
|
||||
<span ng-if="vm.publicAddress">{{ vm.publicAddress }}</span>
|
||||
<span ng-if="vm.publicInfo">({{ vm.publicInfo }})</span>
|
||||
</section>
|
||||
|
||||
BIN
glances/outputs/static/public/glances.js
vendored
BIN
glances/outputs/static/public/glances.js
vendored
Binary file not shown.
BIN
glances/outputs/static/public/glances.map.js
vendored
BIN
glances/outputs/static/public/glances.map.js
vendored
Binary file not shown.
@@ -128,6 +128,7 @@ class Plugin(GlancesPlugin):
|
||||
else:
|
||||
stats['public_address'] = self.public_address
|
||||
stats['public_info'] = self.public_info
|
||||
stats['public_info_human'] = self.public_info_for_human(stats['public_info'])
|
||||
|
||||
elif self.input_method == 'snmp':
|
||||
# Not implemented yet
|
||||
@@ -174,23 +175,30 @@ class Plugin(GlancesPlugin):
|
||||
ret.append(self.curse_add_line(msg, 'TITLE', optional=True))
|
||||
ret.append(self.curse_add_line(msg_pub, optional=True))
|
||||
|
||||
if 'public_info' in self.stats and self.stats['public_info']:
|
||||
field_result = []
|
||||
for f in self.censys_fields:
|
||||
field = f.split(':')
|
||||
if len(field) == 1 and field[0] in self.stats['public_info']:
|
||||
field_result.append('{}'.format(self.stats['public_info'][field[0]]))
|
||||
elif (
|
||||
len(field) == 2
|
||||
and field[0] in self.stats['public_info']
|
||||
and field[1] in self.stats['public_info'][field[0]]
|
||||
):
|
||||
field_result.append('{}'.format(self.stats['public_info'][field[0]][field[1]]))
|
||||
ret.append(self.curse_add_line(' ', optional=True))
|
||||
ret.append(self.curse_add_line('/'.join(field_result), optional=True))
|
||||
if self.stats['public_info_human']:
|
||||
ret.append(self.curse_add_line(' {}'.format(self.stats['public_info_human']),
|
||||
optional=True))
|
||||
|
||||
return ret
|
||||
|
||||
def public_info_for_human(self, public_info):
|
||||
"""Return the data to pack to the client."""
|
||||
if not public_info:
|
||||
return ''
|
||||
|
||||
field_result = []
|
||||
for f in self.censys_fields:
|
||||
field = f.split(':')
|
||||
if len(field) == 1 and field[0] in public_info:
|
||||
field_result.append('{}'.format(public_info[field[0]]))
|
||||
elif (
|
||||
len(field) == 2
|
||||
and field[0] in public_info
|
||||
and field[1] in public_info[field[0]]
|
||||
):
|
||||
field_result.append('{}'.format(public_info[field[0]][field[1]]))
|
||||
return '/'.join(field_result)
|
||||
|
||||
@staticmethod
|
||||
def ip_to_cidr(ip):
|
||||
"""Convert IP address to CIDR.
|
||||
|
||||
Reference in New Issue
Block a user