Last active
March 4, 2018 19:46
-
-
Save shellscriptx/1ff438053b129e07efae81c029662b42 to your computer and use it in GitHub Desktop.
[BASHSRC] Obtendo informações da interface de rede.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source builtin.sh | |
source net.sh | |
# Implementação | |
var dados ifacestat_t | |
var ifa inet_t | |
# Interface de rede | |
ether=<nome_da_interface> | |
# Obtem informações da interface e salva na estrutura 'ifa'. | |
net.getifaddr "$ether" ifa | |
while :; do | |
clear | |
# Lê as estatitiscas e salva na estrutura 'dados'. | |
net.getifstats "$ether" dados | |
# Exibe as informações da interface. | |
echo "Interface: $ether" | |
echo "IP:" $(ifa.addr) | |
echo "Máscara:" $(ifa.mask) | |
echo "==== Bytes ====" | |
echo "Transmitidos:" $(dados.tx_bytes) | |
echo "Recebidos:" $(dados.rx_bytes) | |
# Invervalo | |
sleep 1.5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment