How to use dstat to monitor your Linux/UNIX server Come usare dstat per monitorare il vostro server Linux / Unix

by Sukrit Dhandhania on November 13, 2008 da Sukrit Dhandhania il 13 novembre 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 si dispone di un server Linux in esecuzione al vostro ufficio o in un centro dati per i quali siete responsabili, che si desidera mantenere un uptime di più vicino ad un cento per cento. In such a case you want to make sure you keep an eye on how the system is running. In tal caso si desidera assicurarsi di mantenere un occhio sul modo in cui il sistema è in esecuzione. 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. Per essere precisi si desidera monitorare tutte le risorse di sistema che contribuiscono al sistema in esecuzione ammenda che poi traduce in un elevato uptime. Memory, CPU, disk usage… are some of the things you want to observe. Memoria, CPU, disco d'uso ... sono alcune delle cose che si desidera osservare. 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. Noi di solito utilizzare una combinazione di strumenti che vengono con un Linux o Unix installazione, come "libero", "superiore", "vmstat" ... farò di introdurre uno strumento che ti consente solo di tutte le informazioni che la altri strumenti combinati dare a voi, tutti sotto lo stesso tetto - Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. Lo sviluppatore di questo strumento della riga di comando, Dag Wieers, la chiama "una versatile per la sostituzione 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. Egli aggiunge che "Dstat supera alcuni dei loro limiti e aggiunge alcune funzioni extra ..." Per me Dstat è la madre di tutte le riga di comando sistema di strumenti di monitoraggio. 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. E 'semplice da installare, facile da usare, può essere ottimizzato con facilità, e che genera relazioni che è possibile tracciare un grafico per impressionare il vostro capo.

Installing Dstat Installazione Dstat

Start by downloading the Dstat installer. Inizia scaricando il Dstat di installazione. Point your web browser to the Dstat project’s homepage - Punto il browser web per la Dstat nella home page del progetto -- http://dag.wieers.com/home-made/dstat/ . Scroll down to the section of the page where the downloads are listed. Scorri la pagina fino alla sezione della pagina in cui il download sono elencati. Pick the flavor of Linux on which you want to install the application and click on the download link. Scegli il sapore di Linux su cui si desidera installare l'applicazione e fare clic sul link di download. Now download the latest version of Dstat for the version of the Linux distribution you are running. Ora scaricare l'ultima versione di Dstat per la versione della distribuzione Linux è in esecuzione. I’ll show you how to do it for a Red Hat Enterprise Linux version 4 machine: Vi mostrerò come fare per Red Hat Enterprise Linux versione 4 macchina:

# 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: Ora installare 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 l'installazione è andato senza errori, che è tutto, avete Dstat installato e pronto per l'uso. If there were some dependencies that came up during the installation just install the required packages and try again. Se non vi sono state alcune dipendenze che si avvicinò durante l'installazione è sufficiente installare i pacchetti necessari e riprovare. I don’t think that Dstat has too many dependencies, so you should not face any problems. Non credo che Dstat ha troppe dipendenze, in modo che non debbano far fronte a qualsiasi problema.

Using Dstat Uso Dstat

With Dstat installed on your system you should be good to go. Con Dstat installati sul vostro sistema si dovrebbe andare bene. Begin by launching the command from a terminal: Iniziate con il lancio del comando da un terminale:

# dstat # Dstat

The output would be something like the following. Il risultato sarebbe qualcosa di simile a quanto segue. Hit the key combination of ctrl+c to exit. Premete il tasto di combinazione Ctrl + C per uscire.

# dstat # Dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Totale cpu-uso - -disk/total -net/total--paging-sistema -
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ sys usr IDL wai HiQ SIQ | _read scrivere | _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. Ci sono un certo numero di opzioni disponibili per Dstat. As I mentioned earlier Dstat is quite easy to tweak. Come ho già detto in precedenza Dstat è abbastanza facile da perfezionare. So if you want to limit the data reading to the CPU, disk, and network, run the following command: Quindi, se volete limitare la lettura dei dati per la CPU, disco e rete, eseguire il seguente comando:

# dstat -CDN # Dstat-CDN
-disk/total -net/total- —paging– —system– -disk/total -net/total--paging-sistema -
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read scrivere | _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 | 64 ter 0 | 0 0 | 1031 1939

You can find more options in the application’s help document which you can access by entering the following: Potete trovare ulteriori opzioni nella domanda di aiuto del documento a cui è possibile accedere inserendo il seguente:

# dstat -h # Dstat-h

Play with the options a little so you get comfortable with them. Gioca con le opzioni in modo un po 'si ottiene confortevole con loro. The default interval between data reads is two seconds. Il valore predefinito intervallo di tempo tra letture di dati è di due secondi. You can change that interval if you need to. È possibile modificare l'intervallo che, se necessario. To increase the interval to ten seconds enter the following: Per aumentare l'intervallo di dieci secondi inserire il seguente:

# dstat 10 Dstat # 10

Another useful feature is to get aggregated updates for each entry. Un'altra caratteristica utile è quello di ottenere aggregati aggiornamenti per ogni voce. 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. In modo che tu possa avere Dstat darvi un aggiornamento ogni dieci secondi in una nuova linea, ma i dati come cambia la tua stessa linea viene aggiornata ogni secondo.

You might optionally want Dstat to give you five updates with a frequency of three seconds. Potrebbe essere facoltativamente desidera Dstat per darvi cinque aggiornamenti con una frequenza di tre secondi. Here’s how you would go about doing that: Ecco come si va facendo che:

# dstat 3 5 # Dstat 3 5
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Totale cpu-uso - -disk/total -net/total--paging-sistema -
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ sys usr IDL wai HiQ SIQ | _read scrivere | _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 caratteristica che trovo più utile è l'uscita. 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 vi permette di avere l'output di una sessione scritto in un file separati da virgola che può essere successivamente importato in un foglio di calcolo applicazione, come ad esempio Microsoft Excel e i dati possono essere tracciate in un grafico. Here is how it can be used. Ecco come può essere utilizzato.

# 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. Lasciate che i sopra i comandi utilizzati durante l'esecuzione delle applicazioni o fare il tuo test su questa macchina. Hit the key combination of ctrl+c when you are done. Premete il tasto di combinazione Ctrl + C quando si è fatto. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. Aprire il file dstat_data.csv con un foglio di calcolo applicazione come 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. È quindi possibile selezionare le colonne che si desidera tracciare in un grafico e lasciate che il vostro foglio di calcolo applicazione fare la magia.

Get a Report by Mail Prendi un rapporto via e-mail

There may be cases wherein you want to observe how your server is performing over a period of time. Vi possono essere casi in cui si desidera osservare come il tuo server è il rendimento nel corso di un periodo di 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. È possibile impostare un processo in background Linux che vi darà una lettura con un certo intervallo di tempo, generare una relazione, e-mail il file a voi. This can be especially useful during a stress-test. Questo può essere particolarmente utile durante una delle prove di stress. Here’s how you could do that. Ecco come si potrebbe fare. 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. Il seguente script verrà eseguito Dstat per tre ore, la lettura dei dati ogni 30 secondi, e sarà posta la relazione di 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 Relazione per 3 ore gira" 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: Salvare lo script qui sopra in un file chiamato dstat_script.sh sul tuo server, dare il permesso eseguibile e quindi eseguire come un processo di fondo:

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

Done. Fatto. Yes, it’s that simple. Sì, è così semplice. You will now be mailed this report after it’s done running. Lei verrà ora inviato questa relazione dopo che è stato fatto in esecuzione. You can optionally schedule this script as a daily cron job so that you can receive this data every day. E 'inoltre possibile programmare questo script come un job in cron giornaliero in modo che tu possa ricevere questi dati ogni giorno.

As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. Come si può già realizzato Dstat è un meraviglioso strumento in caso di applicazione di controllo di prestazioni e di debugging. The granularity, frequency, and nature of the data collected are completely up to you. La granularità, la frequenza e la natura dei dati raccolti sono completamente da te. Dstat empowers you to know what is going on on your server. Dstat autorizza a voi conoscere che cosa sta succedendo sul tuo server. Used wisely this power can result in a lot less sleepless nights for you. Usato saggiamente questo potere può tradursi in una partita meno notti insonni per voi.

Related Posts: Related Interventi:
  • How to monitor your Mac laptop’s battery health Come controllare il vostro Mac portatile della batteria salute
  • How to share a keyboard and mouse with multiple computers Come condividere una tastiera e un mouse con più computer
  • How to monitor your Internet bandwidth usage in OS X Come monitorare il vostro Internet utilizzo della larghezza di banda in OS X
  • 5 More OS X Dashbooard Widgets for Bloggers 5 più Dashbooard OS X Widget per i blogger
  • How to monitor your Internet bandwidth usage in OS X, redux Come monitorare il vostro Internet utilizzo della larghezza di banda in OS X, Redux
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Ottieni Aiuto tutorial semplice come questo nella tua casella di posta tutti i giorni - gratuitamente! Just enter your email address below: Basta inserire il tuo indirizzo email qui sotto:

    You can always opt out of this email subscription at any time. È possibile scegliere di questa e-mail di iscrizione in qualsiasi momento.


    Bookmark and Share Favoriti e Condividi

    { 0 comments… (0 commenti ... add one now aggiungere uno ora } )

    Leave a Comment Lascia un tuo commento

    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> È possibile utilizzare questi tag HTML e gli attributi: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>