How to use dstat to monitor your Linux/UNIX server Cómo utilizar dstat para vigilar su Linux / UNIX servidor

by Sukrit Dhandhania on November 13, 2008 por Sukrit Dhandhania el 13 de noviembre, 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. Si tienes un servidor Linux corriendo en su oficina o en un centro de datos para los que son responsables, que desea mantener un tiempo de actividad de lo más cercano a un cien por ciento. In such a case you want to make sure you keep an eye on how the system is running. En tal caso de que quiera asegurarse de que mantener un ojo sobre la forma en que el sistema se está ejecutando. 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 más precisos que desea controlar todos los recursos del sistema que contribuyen a que el sistema ejecuta multa que luego se traduce en un elevado tiempo de actividad. Memory, CPU, disk usage… are some of the things you want to observe. La memoria, CPU, uso de disco ... son algunas de las cosas que desea 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. Nos suelen utilizar una combinación de las herramientas que vienen con un Linux o UNIX la instalación, tales como "libre", "top", "vmscat" ... Voy a presentarle a una herramienta que le da casi toda la información que el otras herramientas combinadas le dan, todos bajo un mismo techo - Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. El desarrollador de esta herramienta de línea de comandos, Dag Wieers, lo llama "un versátil reemplazo para vmscat, iostat, netstat y 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. Agrega que "Dstat supera algunas de sus limitaciones y añade algunas características extra ..." Para mí Dstat es la madre de todos los sistema de línea de comando herramientas de seguimiento. 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. Es muy sencillo de instalar, fácil de usar, puede ser tweaked con facilidad, y que genera informes que usted puede parcela como un gráfico para impresionar a su jefe.

Installing Dstat Instalación de Dstat

Start by downloading the Dstat installer. Comience por Dstat descargar el instalador. Point your web browser to the Dstat project’s homepage - Apunte su navegador web a la Dstat la página principal del proyecto -- http://dag.wieers.com/home-made/dstat/ . Scroll down to the section of the page where the downloads are listed. Desplácese hasta la sección de la página en la que las descargas se enumeran. Pick the flavor of Linux on which you want to install the application and click on the download link. Elija el sabor de Linux en la que desea instalar la aplicación y haga clic en el enlace de descarga. Now download the latest version of Dstat for the version of the Linux distribution you are running. Ahora descargar la última versión de Dstat para la versión de la distribución de Linux que se estén ejecutando. I’ll show you how to do it for a Red Hat Enterprise Linux version 4 machine: Le mostraré cómo hacerlo de una Red Hat Enterprise Linux versión 4 de la 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: Ahora 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. Si la instalación fue sin errores, eso es todo, usted tiene Dstat instalado y listo para su uso. If there were some dependencies that came up during the installation just install the required packages and try again. Si hubo algunas dependencias que surgieron durante la instalación sólo tiene que instalar los paquetes requeridos y vuelve a intentarlo. I don’t think that Dstat has too many dependencies, so you should not face any problems. No creo que Dstat tiene demasiadas dependencias, por lo que no deberían hacer frente los problemas.

Using Dstat Uso de Dstat

With Dstat installed on your system you should be good to go. Con Dstat instalado en el sistema debe ser bueno para ir. Begin by launching the command from a terminal: Comience por el lanzamiento de un terminal:

# dstat # Dstat

The output would be something like the following. La salida sería algo como lo siguiente. Hit the key combination of ctrl+c to exit. Pulsa la combinación de teclas Ctrl + C para salir.

# dstat # Dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Total-cpu-uso - -disk/total -net/total--paginación--sistema -
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sistema idl wai HiQ siq | _read escribir | _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. Hay una serie de opciones disponibles para Dstat. As I mentioned earlier Dstat is quite easy to tweak. Como he mencionado anteriormente Dstat es bastante fácil de modificar. So if you want to limit the data reading to the CPU, disk, and network, run the following command: Por lo tanto, si usted quiere limitar la lectura de datos a la CPU, disco, y de la red, ejecute el comando siguiente:

# dstat -CDN # Dstat-CDN
-disk/total -net/total- —paging– —system– -disk/total -net/total--paginación--sistema -
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read escribir | _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: Usted puede encontrar más opciones en la ayuda de la aplicación documento en el que se puede acceder introduciendo el texto siguiente:

# dstat -h # Dstat-h

Play with the options a little so you get comfortable with them. Juega con las opciones un poco para que te cómodo con ellos. The default interval between data reads is two seconds. El valor por defecto intervalo entre lecturas de datos es de dos segundos. You can change that interval if you need to. Puede cambiar el intervalo de que si es necesario. To increase the interval to ten seconds enter the following: Para aumentar el intervalo de diez segundos para entrar en el texto siguiente:

# dstat 10 Dstat # 10

Another useful feature is to get aggregated updates for each entry. Otra característica útil es agregada para obtener actualizaciones 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. Por lo tanto, usted puede tener Dstat darle una actualización cada diez segundos en una nueva línea, pero como los cambios de los datos de su propia línea se actualiza cada segundo.

You might optionally want Dstat to give you five updates with a frequency of three seconds. Usted puede, opcionalmente, Dstat desea darle cinco actualizaciones con una frecuencia de tres segundos. Here’s how you would go about doing that: A continuación le indicamos cómo le iría haciendo que:

# dstat 3 5 Dstat # 3 5
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Total-cpu-uso - -disk/total -net/total--paginación--sistema -
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sistema idl wai HiQ siq | _read escribir | _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. La característica que me parece más útil es la salida. 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 le permite tener la salida de una reunión por escrito en un archivo separados por comas que más tarde pueden ser importados en una aplicación de hoja de cálculo como Microsoft Excel y los datos pueden representar en un gráfico. Here is how it can be used. Aquí está la forma en que se puede utilizar.

# 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. Deje que el comando anterior ejecuta mientras ejecuta sus aplicaciones o hacer sus pruebas en este equipo. Hit the key combination of ctrl+c when you are done. Pulsa la combinación de teclas Ctrl + C cuando haya terminado. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. Abra el archivo dstat_data.csv con una aplicación de hoja de cálculo como Microsoft Excel o Open Office. You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic. A continuación, puede seleccionar las columnas que desea en un trazado gráfico y deje que su aplicación de hoja de cálculo hacer la magia.

Get a Report by Mail Obtener un Informe por correo

There may be cases wherein you want to observe how your server is performing over a period of time. Puede haber casos en que desea observar la forma en que su servidor está realizando durante un período de tiempo. 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. Puede configurar un segundo proceso en Linux que te dará una lectura con un cierto intervalo de tiempo, generar un informe, y correo el archivo. This can be especially useful during a stress-test. Esto puede ser especialmente útil durante una prueba de estrés. Here’s how you could do that. A continuación le indicamos cómo puede hacer eso. 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. El siguiente script para ejecutar Dstat tres horas, la lectura de los datos cada 30 segundos, y correo el informe a 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 Informe 3 horas para ejecutar" 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: Guardar la secuencia de comandos en un archivo llamado dstat_script.sh en su servidor, le dan permiso ejecutable y, a continuación, ejecutarlo como un proceso de fondo:

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

Done. Hecho. Yes, it’s that simple. Sí, es así de simple. You will now be mailed this report after it’s done running. Ahora será enviado después de este informe se hace ejecutando. You can optionally schedule this script as a daily cron job so that you can receive this data every day. Opcionalmente se puede programar este script como una tarea diaria para que usted pueda recibir estos datos cada día.

As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. Como es posible que ya se han dado cuenta de Dstat es una herramienta maravillosa cuando se aplica a la supervisión de la ejecución y la depuración. The granularity, frequency, and nature of the data collected are completely up to you. La granularidad, la frecuencia y la naturaleza de los datos recogidos son completamente de usted. Dstat empowers you to know what is going on on your server. Dstat le permite saber lo que está sucediendo en su servidor. Used wisely this power can result in a lot less sleepless nights for you. Utilizado sabiamente este poder puede resultar en una mucho menos noches de insomnio para usted.

Related Posts: Puestos relacionados con:
  • How to monitor your Mac laptop’s battery health Cómo controlar tu Mac portátil de la pila de la salud
  • How to share a keyboard and mouse with multiple computers Cómo compartir un teclado y un ratón con varios ordenadores
  • How to monitor your Internet bandwidth usage in OS X ¿Cómo controlar su uso de ancho de banda de Internet en OS X
  • 5 More OS X Dashbooard Widgets for Bloggers 5 más OS X Dashbooard widgets para bloggers
  • How to monitor your Internet bandwidth usage in OS X, redux ¿Cómo controlar su uso de ancho de banda de Internet en OS X, redux
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Simple tutoriales de ayuda al igual que este un mensaje de correo electrónico en su bandeja de entrada cada día - para libre! Just enter your email address below: Sólo tienes que introducir tu dirección de correo electrónico a continuación:

    You can always opt out of this email subscription at any time. Usted siempre puede optar por salir de este mensaje de correo electrónico de suscripción en cualquier momento.


    Bookmark and Share Favoritos y Compartir

    { 0 comments… (0 comentarios ... add one now añadir ahora una } )

    Leave a Comment Déjanos tu comentario

    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> Puede utilizar estas etiquetas HTML y atributos: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>