How to use dstat to monitor your Linux/UNIX server Como usar dstat de monitorar o Linux / Unix servidor

by Sukrit Dhandhania on November 13, 2008 por Sukrit Dhandhania em 13 de novembro de 2008

Linux

If you have a Linux server running at your office or at a data center for which you are responsible, you want to maintain an uptime of as close to a hundred percent. Se você tiver um servidor Linux executando em seu escritório ou em um centro de dados para que você é responsável, que pretende manter um uptime de tão perto de cem por cento. In such a case you want to make sure you keep an eye on how the system is running. Em tal caso, você quer ter certeza que você mantenha um olho sobre o modo como o sistema está executando. To be precise you want to monitor all the system resources that contribute to the system running fine which then results in a high uptime. Para ser mais preciso que você deseja monitorar todos os recursos do sistema que contribuem para o sistema a funcionar de multa, em seguida, que resulta em um alto uptime. Memory, CPU, disk usage… are some of the things you want to observe. Memória, CPU, utilização do disco ... são algumas das coisas que você deseja observar. We would usually use a combination of the tools that come with a Linux or UNIX installation, such as “free”, “top”, “vmstat”… I’ll introduce you to a tool that gives you just about all the info that the other tools combined give you, all under one roof - Dstat. Queremos, normalmente usam uma combinação de ferramentas que vêm com uma instalação Linux ou UNIX, tais como "livre", "top", "vmstat" ... Eu vou te apresentar uma ferramenta que lhe dá, praticamente, todas as informações que o outras ferramentas combinadas dão-lhe, todos sob o mesmo teto - Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. O desenvolvedor desta linha de comando ferramenta, Dag Wieers, chama-lhe "um substituto para o versátil vmstat, iostat, netstat e ifstat". He adds that “Dstat overcomes some of their limitations and adds some extra features…” To me Dstat is the mother of all command line system monitoring tools. Ele acrescenta que "Dstat supera algumas das suas limitações e adiciona alguns recursos extras ..." Para mim Dstat é a mãe de todas as ferramentas de linha de comando sistema de monitoramento. It’s simple to install, easy to use, can be tweaked with ease, and it generates reports that you can plot as a graph to impress your boss. É simples de instalar, fácil de utilizar, podemos tweaked se com facilidade, e isso gera relatórios que podem ser enredo como um gráfico para impressionar seu chefe.

Installing Dstat Instalando Dstat

Start by downloading the Dstat installer. Faça o download do instalador Dstat. Point your web browser to the Dstat project’s homepage - Aponte seu navegador para a página inicial do projeto Dstat -- http://dag.wieers.com/home-made/dstat/ . Scroll down to the section of the page where the downloads are listed. Role para a seção da página onde estão listados os ativos. Pick the flavor of Linux on which you want to install the application and click on the download link. Escolha o sabor do Linux em que você deseja instalar o aplicativo e clique sobre o link de download. Now download the latest version of Dstat for the version of the Linux distribution you are running. Agora, baixe a última versão do Dstat para a versão da distribuição Linux que você está correndo. I’ll show you how to do it for a Red Hat Enterprise Linux version 4 machine: Vou te mostrar como fazê-lo para uma versão Red Hat Enterprise Linux 4 máquina:

# wget http://dag.wieers.com/rpm/packages/dstat/dstat-0.6.6-1.el4.rf.noarch.rpm # Wget http://dag.wieers.com/rpm/packages/dstat/dstat-0.6.6-1.el4.rf.noarch.rpm

Now install Dstat: Agora instale Dstat:

# rpm -Uvh dstat-0.6.6-1.el4.rf.noarch.rpm # Rpm-Uvh dstat-0.6.6-1.el4.rf.noarch.rpm

If the installation went though without errors, that’s it, you have Dstat installed and ready for use. Se a instalação foi embora sem erros, e é isto, você tem Dstat instalado e pronto para uso. If there were some dependencies that came up during the installation just install the required packages and try again. Se houvesse alguma dependências que surgiram durante a instalação basta instalar os pacotes requeridos e tente novamente. I don’t think that Dstat has too many dependencies, so you should not face any problems. Não creio que Dstat tem muitas dependências, pelo que não deverá enfrentar qualquer problema.

Using Dstat Usando Dstat

With Dstat installed on your system you should be good to go. Com Dstat instalado em seu sistema você deverá estar pronto. Begin by launching the command from a terminal: Começar por lançar o comando a partir de um terminal:

# dstat # Dstat

The output would be something like the following. A saída seria algo como o seguinte. Hit the key combination of ctrl+c to exit. Aperte a tecla combinação de ctrl + c para sair.

# dstat # Dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Total-cpu-uso - -disk/total -net/total--paginação--system -
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sys idl Wai HiQ siq | _read escrever | _recv _send | __in_ _out_ | _int_ _csw_
7 1 91 1 0 0| 0 0 | 0 0 | 0 0 | 0 0 7 1 91 1 0 0 | 0 0 | 0 0 | 0 0 | 0 0
1 0 99 0 0 0| 0 0 | 0 0 | 0 0 |1051 1945 1 0 99 0 0 0 | 0 0 | 0 0 | 0 0 | 1051 1945
0 0 100 0 0 0| 0 12k|2269B 11.2k| 0 0 |1031 1923 0 0 100 0 0 0 | 0 12k | 2269B 11.2k | 0 0 | 1031 1923
1 0 99 0 0 0| 0 40k| 0 0 | 0 0 |1078 2235 1 0 99 0 0 0 | 0 40k | 0 0 | 0 0 | 1078 2235
0 0 100 0 0 0| 0 16k|6027B 21.5k| 0 0 |1008 2219 0 0 100 0 0 0 | 0 16k | 6027B 21.5k | 0 0 | 1008 2219

There are a number of options available for Dstat. Há uma série de opções disponíveis para Dstat. As I mentioned earlier Dstat is quite easy to tweak. Como mencionei anteriormente Dstat é bastante fácil de ajustar. So if you want to limit the data reading to the CPU, disk, and network, run the following command: Então se você quiser limitar a leitura de dados para a CPU, discos e rede, execute o seguinte comando:

# dstat -CDN # Dstat-CDN
-disk/total -net/total- —paging– —system– -disk/total -net/total--paginação--system -
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read escrever | _recv _send | __in_ _out_ | _int_ _csw_
0 0 | 0 0 | 0 0 | 0 0 0 0 | 0 0 | 0 0 | 0 0
0 12k|2295B 9603B| 0 0 |1053 1957 0 12k | 2295B 9603B | 0 0 | 1053 1957
0 0 | 594B 0 | 0 0 |1002 1893 0 0 | 594B 0 | 0 0 | 1002 1893
0 960k| 292B 3346B| 0 0 |1072 2012 0 960k | 292B 3346B | 0 0 | 1072 2012
0 4096B| 64B 0 | 0 0 |1031 1939 0 4096B | 64B 0 | 0 0 | 1031 1939

You can find more options in the application’s help document which you can access by entering the following: Você pode encontrar mais opções na aplicação da ajuda do documento que você pode acessar, digitando o seguinte:

# dstat -h # Dstat-h

Play with the options a little so you get comfortable with them. Brinque com as opções de modo que você começa um pouco confortável com eles. The default interval between data reads is two seconds. O intervalo padrão entre os dados se lê dois segundos. You can change that interval if you need to. Você pode alterar esse intervalo, se necessário. To increase the interval to ten seconds enter the following: Para aumentar o intervalo de dez segundo digitar o seguinte:

# dstat 10 Dstat # 10

Another useful feature is to get aggregated updates for each entry. Outra característica é útil para obter atualizações agregadas para cada entrada. So you can have Dstat give you an update every ten seconds in a new line, but as the data changes your line itself gets updated every second. Então você pode ter Dstat dar-lhe uma atualização a cada dez segundos em uma nova linha, mas como os dados em si fica muda sua linha atualizada a cada segundo.

You might optionally want Dstat to give you five updates with a frequency of three seconds. Você pode opcionalmente Dstat quero dar-lhe cinco atualizações com uma freqüência de três segundos. Here’s how you would go about doing that: Veja como você iria sobre fazer o seguinte:

# dstat 3 5 # Dstat 3 5
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Total-cpu-uso - -disk/total -net/total--paginação--system -
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sys idl Wai HiQ siq | _read escrever | _recv _send | __in_ _out_ | _int_ _csw_
3 1 95 2 0 0| 0 0 | 0 0 | 0 0 | 0 0 3 1 95 2 0 0 | 0 0 | 0 0 | 0 0 | 0 0
2 11 87 1 0 0| 0 180k|2581B 3239B| 0 0 |1136 697 2 11 87 1 0 0 | 0 180k | 2581B 3239B | 0 0 | 1136 697
7 8 85 0 0 0| 0 0 | 115k 106k| 0 0 |1603 3985 7 8 85 0 0 0 | 0 0 | 115k 106k | 0 0 | 1603 3985
2 1 98 0 0 0| 0 0 |77.5k 170k| 0 0 |1744 3856 2 1 98 0 0 0 | 0 0 | 77.5k 170k | 0 0 | 1744 3856
1 0 100 0 0 0| 0 0 |3451B 9993B| 0 0 |1045 149 1 0 100 0 0 0 | 0 0 | 3451B 9993B | 0 0 | 1045 149
2 1 94 4 0 0| 0 276k|20.4k 31.1k| 0 0 |1219 804 2 1 94 4 0 0 | 0 276k | 20.4k 31.1k | 0 0 | 1219 804

The feature that I find most useful is the output. A característica que eu considero mais útil é a saída. Dstat allows you to have the output of a session written into a comma separated file which can later be imported into a spreadsheet application such as Microsoft Excel and the data can be plotted into a graph. Dstat permite-lhe ter a saída de uma sessão escrita em um arquivo separado por vírgula que mais tarde pode ser importada para um aplicativo de planilha como o Microsoft Excel e os dados podem ser plotados em um gráfico. Here is how it can be used. Aqui está como ele pode ser usado.

# dstat –output /tmp/dstat_data.csv -CDN # Dstat-output / tmp / dstat_data.csv-CDN

Let the above command run while you run your applications or do your testing on this machine. Deixa o comando acima funcionar enquanto você executar seus aplicativos ou fazer o seu teste nesta máquina. Hit the key combination of ctrl+c when you are done. Aperte a combinação de teclas Ctrl + C de quando você está feito. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. Abra o arquivo dstat_data.csv com um aplicativo de planilha como o Microsoft Excel ou OpenOffice. You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic. Você pode então selecionar as colunas que deseja plotados em um gráfico e deixe a sua aplicação de planilha fazer a mágica.

Get a Report by Mail Obter um relatório por e-mail

There may be cases wherein you want to observe how your server is performing over a period of time. Pode haver casos em que pretende observar como o seu servidor está executando ao longo de um período de tempo. You can setup a background process in Linux that will give you a reading with a certain interval, generate a report, and mail out the file to you. Você pode configurar um processo em background Linux, que lhe dará uma leitura com um certo intervalo de tempo, gerar um relatório, e de fora da mail arquivo para você. This can be especially useful during a stress-test. Isso pode ser especialmente útil durante um teste de esforço. Here’s how you could do that. Veja como você poderia fazer isso. The following script will run Dstat for three hours, reading the data every 30 seconds, and will mail out the report to me@myemailid.com. O seguinte script será executado Dstat durante três horas, a leitura dos dados a cada 30 segundos, e vai ao correio electrónico fora do relatório me@myemailid.com.

#!/bin/bash #! / bin / bash
dstat –output /tmp/dstat_data_mail.csv -CDN 30 360 dstat-output / tmp / dstat_data_mail.csv-CDN 30 360
mutt -a /tmp/dstat_data_mail.csv -s “Dstat Report for 3 hour run” me@myemailid.com < /dev/null mutt-a / tmp / dstat_data_mail.csv-s "Dstat Relatório 3 horas para executar o" me@myemailid.com </ dev / null

Save the above script in a file called dstat_script.sh on your server, give it executable permission and then run it as a background process: Salve o script acima em um arquivo chamado dstat_script.sh em seu servidor, dar-lhe permissão executável e, em seguida, execute-o como um processo de fundo:

# chmod +x dstat_script.sh # Chmod + x dstat_script.sh
# nohup ./dstat_script.sh & # Nohup. / Dstat_script.sh &

Done. Feito. Yes, it’s that simple. Sim, ele é tão simples. You will now be mailed this report after it’s done running. Você vai agora ser enviada pelo correio após este relatório pode fazê-lo correr. You can optionally schedule this script as a daily cron job so that you can receive this data every day. Cionalmente pode agendar o script como um diário job cron para que você possa receber esses dados todos os dias.

As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. Como talvez já tenham percebido Dstat é uma ferramenta maravilhosa quando aplicado o acompanhamento do desempenho e depuração. The granularity, frequency, and nature of the data collected are completely up to you. A granularidade, frequência e natureza dos dados recolhidos são completamente até você. Dstat empowers you to know what is going on on your server. Dstat habilita você para saber o que está acontecendo no seu servidor. Used wisely this power can result in a lot less sleepless nights for you. Usado sabiamente este poder pode resultar numa lotes menos noites sem dormir por você.

Related Posts: Posts Relacionados:
  • How to monitor your Mac laptop’s battery health Como acompanhar o seu Mac bateria do laptop de saúde
  • How to share a keyboard and mouse with multiple computers Como partilhar um teclado e mouse com vários computadores
  • How to monitor your Internet bandwidth usage in OS X Como monitorar seu uso na Internet de banda OS X
  • 5 More OS X Dashbooard Widgets for Bloggers Mais 5 ósmio X Dashbooard widgets para blogueiros
  • How to monitor your Internet bandwidth usage in OS X, redux Como monitorar seu uso na Internet de banda OS X, redux
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Obter Ajuda Simples tutoriais apenas como um presente em seu correio eletrônico todos os dias - gratuitamente! Just enter your email address below: Basta digitar o seu endereço de e-mail abaixo:

    You can always opt out of this email subscription at any time. Você pode optar por sair semper deste e-mail subscrição a qualquer momento.


    Bookmark and Share Favoritos e Partilhar

    { 0 comments… (0 comentários ... add one now adicionar um agora } )

    Leave a Comment Deixe um comentário

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> Você pode usar esses atributos e tags HTML: <a href="" title="Avião"> <abbr title="Avião"> <acronym title="Avião"> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>