Skip to content

Commit

Permalink
net
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyleite committed Feb 27, 2015
1 parent 1870bab commit dd8f9c8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/nets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
""" network informations interfaces, connections.
it should be improved!
"""
# *-* coding: utf-8 *-*
from flask import Blueprint, jsonify
import psutil
Expand All @@ -10,6 +13,11 @@
@net.route('/net/iface/<interface>', methods=['GET'])
@auth.login_required
def ifaces(interface=all):
""" show all network interfaces.
/net/iface
show the interface of statistic eth0
/net/iface/eth0
"""
lIface=[]
dIface=psutil.net_io_counters(pernic=True)
for v,k in enumerate(dIface):
Expand All @@ -24,4 +32,8 @@ def ifaces(interface=all):
@net.route('/net/connections', methods=['GET'])
@auth.login_required
def connections():
return jsonify(connections=[str(x) for x in psutil.net_connections()])
""" Show all connections on the time
"""
return jsonify(
connections=[str(x) for x in psutil.net_connections()]
)

0 comments on commit dd8f9c8

Please sign in to comment.