Skip to content Skip to content


How to use dstat to monitor your Linux/UNIX server Kā lietot dstat uzraudzīt jūsu Linux / UNIX serveris

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. Ja jums ir Linux servera, kurā darbojas jūsu birojā vai datu centru, par kuru Jūs esat atbildīgs, vēlaties saglabāt uptime ir tik tuvu simts procentiem. In such a case you want to make sure you keep an eye on how the system is running. Šādā gadījumā jūs vēlaties, lai pārliecinātos, paturēt acīs par to, kā sistēma darbojas. 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. Lai varētu precīzi vēlaties kontrolēt visas sistēmas resursiem, kas veicina sistēmas darbību naudas sodu, kas tam rada lielu uptime. Memory, CPU, disk usage… are some of the things you want to observe. Atmiņu, CPU, diska izmantošana ... ir dažas lietas, kuru vēlaties novērot. 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. Mēs parasti izmanto kopā ar instrumentu, kas nāk ar Linux vai UNIX iekārtas, tādas kā "bezmaksas", "top", "vmstat" ... Es jūs iepazīstināt ar rīku, kas sniedz jums tikai par visu info, kas citi rīki kopā jums, visi zem viena jumta - Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. Attīstītājs šīs komandrindas rīks, Dag Wieers, sauc to par "daudzpusīgu nomaiņa vmstat, iostat, netstat un 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. Viņš piebilst, ka "Dstat pārvarēt dažus no saviem ierobežojumiem un pievieno dažas papildus funkcijas ..." Man Dstat ir māte visiem komandrindas sistēmas kontroles instrumenti. 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. Tas ir vienkārši uzstādīt, viegli lietot, var tweaked viegli, un tas rada pārskatus, kurus jūs varat laukumu, kā grafikā pārsteigt savus boss.

Installing Dstat Instalēšana Dstat

Start by downloading the Dstat installer. Uz sākumu, lejupielādējot Dstat uzstādītājam. Point your web browser to the Dstat project's homepage – Punkts jūsu interneta pārlūkprogrammā Dstat projekta mājas lapā -- http://dag.wieers.com/home-made/dstat/ http://dag.wieers.com/home-made/dstat/ . . Scroll down to the section of the page where the downloads are listed. Ritiniet uz leju līdz sadaļā lapā, kur lejupielāde ir uzskaitītas. Pick the flavor of Linux on which you want to install the application and click on the download link. Pick aromāts Linux uz kuru vēlaties instalēt pieteikumu un noklikšķiniet uz download saiti. Now download the latest version of Dstat for the version of the Linux distribution you are running. Lejupielādēt jaunāko versiju Dstat uz versija Linux izplatīšanas jūs strādājat. I'll show you how to do it for a Red Hat Enterprise Linux version 4 machine: Es tev parādīšu, kā to izdarīt to Red Hat Enterprise Linux versija 4 mašīna:

# 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: Tagad uzstādīt 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. Ja iekārta devās tomēr bez kļūdām, tas ir tas, kas jums ir Dstat uzstādīti un gatavi lietošanai. If there were some dependencies that came up during the installation just install the required packages and try again. Ja būtu dažas kolonijas, kas nāca klajā laikā, uzstādīšana tikai instalēt nepieciešamo iepakojumu un mēģiniet vēlreiz. I don't think that Dstat has too many dependencies, so you should not face any problems. Es nedomāju, ka Dstat ir pārāk daudz atkarību, lai jums nevajadzētu saskarties ar problēmām.

Using Dstat Izmantojot Dstat

With Dstat installed on your system you should be good to go. Ar Dstat instalēta jūsu sistēmā, Jums ir jābūt labi iet. Begin by launching the command from a terminal: Sākt uzsākot komandu no gala:

# dstat # Dstat

The output would be something like the following. Rezultātiem būtu kaut kā šādi. Hit the key combination of ctrl+c to exit. Hit taustiņu kombināciju Ctrl + C, lai izietu.

# dstat # Dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Kopējais CPU patēriņa - -disk/total -net/total--peidžeru--sistēmas
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sys IDL wai hiq SIQ | _read uzrakstiet | _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 | 1.051 1.945
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 | 1.031 1.923
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 | 1.078 2.235
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 | 1.008 2.219

There are a number of options available for Dstat. Ir alternatīvas, lai Dstat numuru. As I mentioned earlier Dstat is quite easy to tweak. Kā jau iepriekš minēju Dstat ir samērā viegli nomainīt. So if you want to limit the data reading to the CPU, disk, and network, run the following command: Tātad, ja vēlaties ierobežot datu lasījumā CPU, diska un tīkla, palaidiet komandu:

# dstat -CDN # Dstat-CDN
-disk/total -net/total- —paging– —system– -disk/total -net/total--peidžeru--sistēmas
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read uzrakstiet | _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 | 1.053 1.957
0 0 | 594B 0 | 0 0 |1002 1893 0 0 | 594B 0 | 0 0 | 1.002 1.893
0 960k| 292B 3346B| 0 0 |1072 2012 0 960k | 292B 3346B | 0 0 | 1.072 2.012
0 4096B| 64B 0 | 0 0 |1031 1939 0 4096B | 64B 0 | 0 0 | 1.031 1.939

You can find more options in the application's help document which you can access by entering the following: Jūs varat atrast iespējas lietojumprogrammas palīdzību dokuments, kas var piekļūt, ievadot tekstu:

# dstat -h # Dstat-h

Play with the options a little so you get comfortable with them. Play with iespējas maz, lai Jums ērti ar viņiem. The default interval between data reads is two seconds. Default intervāls starp datu teksts ir divas sekundes. You can change that interval if you need to. Jūs varat mainīt šo intervālu, ja jums nepieciešams. To increase the interval to ten seconds enter the following: Lai palielinātu intervālu desmit sekundēm ieraksta šādu tekstu:

# dstat 10 # Dstat 10

Another useful feature is to get aggregated updates for each entry. Vēl viena noderīga funkcija ir iegūt apkopotus atjauninājumus katru ierakstu. 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. Tātad jūs varat būt Dstat jums ik pēc desmit sekundēm atjauninājumu jaunu līniju, bet gan kā datu izmaiņām jūsu pozīcija pati kļūst atjaunota katru sekundi.

You might optionally want Dstat to give you five updates with a frequency of three seconds. Jūs varētu pēc izvēles vēlaties Dstat sniegt jums pieciem atjauninājumiem ar frekvenci trīs sekundes. Here's how you would go about doing that: Lūk, kā jūs varētu iet to darīt, ka:

# dstat 3 5 # Dstat 3 5
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Kopējais CPU patēriņa - -disk/total -net/total--peidžeru--sistēmas
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sys IDL wai hiq SIQ | _read uzrakstiet | _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 | 1.603 3.985
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 | 1.744 3.856
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 | 1.219 804

The feature that I find most useful is the output. Īpašība, kas man šķiet ļoti noderīga ir izeja. 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 ļauj jums produkcija sesija iestrādātas komatu atdalītu failu, kas vēlāk var importēt izklājlapu lietojumprogrammu, piemēram, Microsoft Excel un datus var atzīmē vērā grafiku. Here is how it can be used. Lūk, kā to var izmantot.

# 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. Ļaujiet iepriekš minēto komandu darboties, kamēr jūs izmantojat savu pieteikumu vai izdarīt savus eksperimentus ar šo mašīnu. Hit the key combination of ctrl+c when you are done. Hit taustiņu kombināciju Ctrl + c, kad tas ir paveikts. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. Open dstat_data.csv failu ar izklājlapu lietojumprogrammu, piemēram, Microsoft Excel vai Open Office. You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic. Jūs varat izvēlēties kolonnu atzīmē stāšanās grafiku un ļaujiet izklājlapu lietojumprogrammā do magic.

Get a Report by Mail Get ziņojums Mail

There may be cases wherein you want to observe how your server is performing over a period of time. Var būt gadījumi, kur vēlaties novērot, kā jūsu serveris ir veikt vairāk nekā laika periodā. 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. Jūs varat setup fona process Linux, kas dos Jums lasījumā ar noteiktu intervālu, veidot ziņojumu un pasta veic failu jums. This can be especially useful during a stress-test. Tas var būt īpaši noderīga laikā stresa testu. Here's how you could do that. Lūk, kā jūs varētu darīt. 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. Šādu skriptu darbosies Dstat trīs stundas, lasot datus ik pēc 30 sekundēm, un pasta out ziņojumu 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 stulbenis-/ tmp / dstat_data_mail.csv-s "Dstat ziņojumu par 3 stundu palaist" 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: Saglabāt iepriekš skriptu failu ar nosaukumu dstat_script.sh jūsu serverī, kā arī tā izpildāmā atļauju un tad palaist to kā fona process:

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

Done. Izdarīts. Yes, it's that simple. Jā, tas ir tik vienkārši. You will now be mailed this report after it's done running. Jums tagad būs nosūtīts šo ziņojumu pēc tam, kad ir izdarīts darbojas. You can optionally schedule this script as a daily cron job so that you can receive this data every day. Pēc izvēles var grafiks šo skriptu, kā ikdienas cron darbs, lai Jūs varētu saņemt šos datus katru dienu.

As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. Kā jūs jau sapratāt Dstat ir brīnišķīgs instruments, ko piemēro darbības uzraudzību un atkļūdošanu. The granularity, frequency, and nature of the data collected are completely up to you. Detalizācijas, biežumu un veidu datus, kas savākti, ir pilnībā atkarīgs no jums. Dstat empowers you to know what is going on on your server. Dstat pilnvaro jūs zināt, kas notiek uz servera. Used wisely this power can result in a lot less sleepless nights for you. Lietotie gudri šīs pilnvaras var novest pie daudz mazāk bezmiega naktis jums.

Posted in Posted in Guest Blogger Viesu Blogger , , Linux Linux . .

Get Simple Help tutorials just like this one in your email inbox every day - for free! Get Simple Palīdzība konsultācijas tāpat kā šo vienu savā e-pastā ik dienas - bez maksas! Just enter your email address below: Vienkārši ievadiet savu e-pasta adresi:

You can always opt out of this email subscription at any time. Jūs vienmēr varat atteikties no šīs e-pasta abonementu jebkurā laikā.

2 Responses 2 Atbildes

Stay in touch with the conversation, subscribe to the Uzturēt kontaktus ar sarunu, abonēt RSS feed for comments on this post RSS barību komentārus par šo ziņu . .

  1. perfector perfector says saka

    Nice article. Nice article.

  2. oberförster says oberförster saka

    I've just found a little discrepancy between dstat and dd regarding the I/O: Esmu tikko konstatēja nelielu neatbilstību starp dstat un dd attiecībā uz I / O:

    ifx@ids:/opt/informix/devices$ dd if=file_20GB of=/dev/null bs=2048 count=10000000 IFX @ ID: / opt / Informix ierīcēm $ dd if = file_20GB of = / dev / null bs = 2.048 count = 10.000.000
    10000000+0 Datensätze ein 10000000 0 Datensätze ein
    10000000+0 Datensätze aus 10000000 0 Datensätze aus
    20480000000 Bytes (20 GB) kopiert, 261,738 s, 78,2 MB/s 20480000000 Bytes (20 GB) kopiert, 261.738 s, 78,2 MB / s

    A shell running dstat at the same time showed me: Apvalks darbojas dstat pie pašā laikā parādīja mani:

    -dsk/total—-dsk/hdc—–dsk/hdd– -dsk/total--dsk/hdc--dsk/hdd-
    read writ: read writ: read writ lasīt pavēsti: lasīt raksta: lasīt raksta
    140M 104k: 62M 24k:7960k 28k 140M 104k: 62m 24k: 7960k 28k
    150M 0 : 64M 0 : 12M 0 150M 0: 64M 0: 12M 0
    160M 0 : 0 0 : 80M 0 160m 0: 0 0: 80M 0
    154M 0 : 43M 0 : 34M 0 154M 0: 43m 0: 34m 0
    150M 0 : 75M 0 : 0 0 150M 0: 75m 0: 0 0
    153M 56k:8384k 20k: 68M 8192B 153M 56K: 8384k 20k: 68 miljoni 8192B

    So it looks like we all should use dstat if we want to impress people with big numbers. Tā izskatās, ka mums visiem vajadzētu lietot dstat, ja mēs vēlamies pārsteigt cilvēkus ar lielu skaitu.

    Looks also like you shouldn't compare dstat to something else than dstat if you really want to compare systems, I doubt I'll use it any more for this kind of stuff any more. Izskatās arī, piemēram, jūs nedrīkstat salīdzināt dstat uz kaut ko citu nekā dstat ja jūs patiešām vēlaties salīdzināt sistēmas, es šaubos, es ņemšu to izmantot vairāk par šāda veida sīkumi vairāk.



Some HTML is OK Daži HTML ir OK

or, reply to this post via vai, atbildot uz šo ziņu izmantojot trackback Trackback . .