관리-도구
편집 파일: plugin_net.cpython-36.pyc
3 �<�e�Z � @ sp d dl Z ddlmZ ddlT d dlZd dlmZ d dlm Z d dl Z d dlZejj � ZdZG dd � d ej�ZdS ) � N� )�hotplug)�*)�ethcard)�commandsZpumbagsdc s. e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z edd� �Zedd� �Z edd� �Zedd� �Zedd� �Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zed(d)� �Zed*d+d,�d-d.� �Zed*�did0d1��Zed2�d3d4� �Zed2�d5d6� �Zg fd7d8�Zdjd:d;�Z ed<d+d,�d=d>� �Z!d?d@� Z"ed<�dkdAdB��Z#edCd+d,�dDdE� �Z$edC�dldFdG��Z%dHdI� Z&dJdK� Z'dLdM� Z(dNdO� Z)dPdQ� Z*dRdS� Z+dTdU� Z,dmdVdW�Z-dXdY� Z.e/dZd+d,�d[d\� �Z0e/d]d+d,�d^d_� �Z1e/d`d+d,�dadb� �Z2e/dcd+d,�ddde� �Z3e/dfd+d,�dgdh� �Z4� Z5S )n�NetTuningPlugina� `net`:: Configures network driver, hardware and Netfilter settings. Dynamic change of the interface speed according to the interface utilization is also supported. The dynamic tuning is controlled by the [option]`dynamic` and the global [option]`dynamic_tuning` option in `tuned-main.conf`. + The [option]`wake_on_lan` option sets wake-on-lan to the specified value as when using the `ethtool` utility. + .Set Wake-on-LAN for device eth0 on MagicPacket(TM) ==== ---- [net] devices=eth0 wake_on_lan=g ---- ==== + The [option]`coalesce` option allows changing coalescing settings for the specified network devices. The syntax is: + [subs="+quotes,+macros"] ---- coalesce=__param1__ __value1__ __param2__ __value2__ ... __paramN__ __valueN__ ---- Note that not all the coalescing parameters are supported by all network cards. For the list of coalescing parameters of your network device, use `ethtool -c device`. + .Setting coalescing parameters rx/tx-usecs for all network devices ==== ---- [net] coalesce=rx-usecs 3 tx-usecs 16 ---- ==== + The [option]`features` option allows changing the offload parameters and other features for the specified network devices. To query the features of your network device, use `ethtool -k device`. The syntax of the option is the same as the [option]`coalesce` option. + .Turn off TX checksumming, generic segmentation and receive offload ==== ---- [net] features=tx off gso off gro off ---- ==== The [option]`pause` option allows changing the pause parameters for the specified network devices. To query the pause parameters of your network device, use `ethtool -a device`. The syntax of the option is the same as the [option]`coalesce` option. + .Disable autonegotiation ==== ---- [net] pause=autoneg off ---- ==== + The [option]`ring` option allows changing the rx/tx ring parameters for the specified network devices. To query the ring parameters of your network device, use `ethtool -g device`. The syntax of the option is the same as the [option]`coalesce` option. + .Change the number of ring entries for the Rx/Tx rings to 1024/512 respectively ===== ----- [net] ring=rx 1024 tx 512 ----- ===== + The [option]`channels` option allows changing the numbers of channels for the specified network device. A channel is an IRQ and the set of queues that can trigger that IRQ. To query the channels parameters of your network device, use `ethtool -l device`. The syntax of the option is the same as the [option]`coalesce` option. + .Set the number of multi-purpose channels to 16 ===== ----- [net] channels=combined 16 ----- ===== + A network device either supports rx/tx or combined queue mode. The [option]`channels` option automatically adjusts the parameters based on the mode supported by the device as long as a valid configuration is requested. + The [option]`nf_conntrack_hashsize` option sets the size of the hash table which stores lists of conntrack entries by writing to `/sys/module/nf_conntrack/parameters/hashsize`. + .Adjust the size of the conntrack hash table ==== ---- [net] nf_conntrack_hashsize=131072 ---- ==== + The [option]`txqueuelen` option allows changing txqueuelen (the length of the transmit queue). It uses `ip` utility that is in package iproute recommended for TuneD, so the package needs to be installed for its correct functionality. To query the txqueuelen parameters of your network device use `ip link show` and the current value is shown after the qlen column. + .Adjust the length of the transmit queue ==== ---- [net] txqueuelen=5000 ---- ==== + The [option]`mtu` option allows changing MTU (Maximum Transmission Unit). It uses `ip` utility that is in package iproute recommended for TuneD, so the package needs to be installed for its correct functionality. To query the MTU parameters of your network device use `ip link show` and the current value is shown after the MTU column. + .Adjust the size of the MTU ==== ---- [net] mtu=9000 ---- ==== c s6 t t| �j||� d| _d| _t� | _i | _d| _d S )Ng�������?� T) �superr �__init__�_load_smallest�_level_stepsr �_cmd�_re_ip_link_show�_use_ip)�self�args�kwargs)� __class__� � /usr/lib/python3.6/plugin_net.pyr � s zNetTuningPlugin.__init__c C sh d| _ t� | _t� | _tjd�}x.| jjd�D ]}|j|j �r.| jj |j� q.W tj dt| j� � d S )NTz(?!.*/virtual/.*)�netzdevices: %s)Z_devices_supported�setZ _free_devicesZ_assigned_devices�re�compile�_hardware_inventoryZget_devices�matchZdevice_path�addZsys_name�log�debug�str)r Zre_not_virtual�devicer r r � _init_devices� s zNetTuningPlugin._init_devicesc s � fdd�|D �S )Nc s g | ]}� j jd |��qS )r )r Z get_device)�.0�x)r r r � <listcomp>� s z7NetTuningPlugin._get_device_objects.<locals>.<listcomp>r )r Zdevicesr )r r �_get_device_objects� s z#NetTuningPlugin._get_device_objectsc C sX d|_ | j|jd �r<d|_| jjd|j�|_i |_i |_ nd|_d |_d |_d |_ d S )NT�dynamicr F) Z_has_static_tuningZ_option_boolZoptionsZ_has_dynamic_tuning�_monitors_repositoryZcreateZassigned_devices� _load_monitor�_idle�_stats)r �instancer r r �_instance_init� s zNetTuningPlugin._instance_initc C s"