Skip to content

Instantly share code, notes, and snippets.

@shellscriptx
Last active March 4, 2018 19:46
Show Gist options
  • Save shellscriptx/1ff438053b129e07efae81c029662b42 to your computer and use it in GitHub Desktop.
Save shellscriptx/1ff438053b129e07efae81c029662b42 to your computer and use it in GitHub Desktop.
[BASHSRC] Obtendo informações da interface de rede.
#!/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