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. Ak máte linuxový server beží vo vašej kancelárii alebo v dátovom centre, pre ktorú sú zodpovední, chcete udržať prevádzkyschopnosť ako takmer sto percent. In such a case you want to make sure you keep an eye on how the system is running. V takom prípade, že chcete dbajte na to, ako oko systém beží. 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. Aby som bol presný, ktoré chcete sledovať všetky systémové prostriedky, ktoré prispievajú k systému, beží bez problémov, ktoré potom vedie k vysokej prevádzkyschopnosti. Memory, CPU, disk usage… are some of the things you want to observe. Pamäte, procesora, využitie disku ... sú niektoré z vecí, ktoré chcete sledovať. 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. By sme bežne používajú kombináciu nástrojov, ktoré prichádzajú s Linux alebo UNIX zariadenia, ako sú "zadarmo", "hore", "vmstat" ... ja vás predstavím nástroj, ktorý vám len o všetky údaje, ktoré iné nástroje, kombinovanej vám, to všetko pod jednou strechou - Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. Autor tohto nástroj príkazového riadka, Dag Wieers, to nazýva "univerzálna náhradou vmstat, iostat, netstat a 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. Dodáva, že "Dstat prekonáva niektoré ich obmedzenia a pridáva niektoré funkcie navyše ..." Pre mňa Dstat je matkou všetkých nástrojov príkazového riadka systému monitorovania. 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. Je to jednoduché inštalácii, jednoduché používanie, môže byť vylepšený s ľahkosťou a generuje správy o sprisahanie, ktoré môžete ako graf urobiť dojem na vášho šéfa.
Installing Dstat Inštalácia Dstat
Start by downloading the Dstat installer. Začnite stiahnutím inštalačného Dstat. Point your web browser to the Dstat project's homepage – Bod Vašom webovom prehliadači projekte Dstat stránka -- 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. Prejdite nadol na časti stránky, kde sú uvedené súbory na prevzatie. Pick the flavor of Linux on which you want to install the application and click on the download link. Vyberte variantu Linux, na ktorý chcete nainštalovať aplikáciu a kliknite na odkaz na stiahnutie. Now download the latest version of Dstat for the version of the Linux distribution you are running. Stiahnuť najnovšiu verziu Dstat pre verziu linuxové distribúcie beží. I'll show you how to do it for a Red Hat Enterprise Linux version 4 machine: Ja vám ukážem, ako to urobiť pre Red Hat Enterprise Linux verzie 4 stroje:
# 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: Teraz nainštalujte 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. Ak sa inštalácia išla ale bez chýb, to je ono, máte Dstat nainštalovaný a pripravený na použitie. If there were some dependencies that came up during the installation just install the required packages and try again. Keby existovala nejaká závislosť, ktorá prišla v priebehu inštalácie stačí nainštalovať potrebné balíčky a skúste to znova. I don't think that Dstat has too many dependencies, so you should not face any problems. Nemyslím si, že Dstat má príliš veľa závislostí, takže by nemal žiadne problémy.
Using Dstat Použitie Dstat
With Dstat installed on your system you should be good to go. S Dstat nainštalovaný na vašom systéme, ktorý by mal byť dobré ísť. Begin by launching the command from a terminal: Začnite spustení príkazu z terminálu:
# dstat # Dstat
The output would be something like the following. Výstup by bol niečo ako nasledujúci. Hit the key combination of ctrl+c to exit. Stlačíte kombináciu Ctrl + C pre výstup.
# dstat # Dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Celkom-cpu-použitie - -disk/total -net/total--stránkovacího--system --
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sys idl wai hiq SIQ | _read napíšte | _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. Existuje rad možností pre Dstat. As I mentioned earlier Dstat is quite easy to tweak. Ako som už spomenul Dstat je pomerne jednoduché vyladiť. So if you want to limit the data reading to the CPU, disk, and network, run the following command: Takže ak chcete obmedziť čítanie dát do procesora, disku a siete, spustite nasledujúci príkaz:
# dstat -CDN # Dstat-CDN
-disk/total -net/total- —paging– —system– -disk/total -net/total--stránkovacího--system --
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read napíšte | _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: Môžete si nájsť viac možností v žiadosti o pomoc dokumente, ktorý získate prístup zadaním nasledujúce:
# dstat -h # Dstat-h
Play with the options a little so you get comfortable with them. Hrajte s možnosťou malý, takže sa dostanete pohodlne sa s nimi. The default interval between data reads is two seconds. Predvolený interval medzi údajmi čitateľov sú dve sekundy. You can change that interval if you need to. Môžete zmeniť tento interval, ak potrebujete. To increase the interval to ten seconds enter the following: Ak chcete predĺžiť interval až desať sekúnd, zadajte nasledujúce:
# dstat 10 # Dstat 10
Another useful feature is to get aggregated updates for each entry. Ďalšou užitočnou funkciou je získať súhrnné aktualizácie pre každú položku. 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. Takže môžete mať Dstat vám aktualizácie každých desať sekúnd na nový riadok, ale ako údaje zmení vaša linka sám sa aktualizuje každú sekundu.
You might optionally want Dstat to give you five updates with a frequency of three seconds. By ste mohli chcieť voliteľne Dstat dať päť aktualizácia s frekvenciou troch sekúnd. Here's how you would go about doing that: Tu je návod, ako by to o tom, že:
# dstat 3 5 # Dstat 3 5
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Celkom-cpu-použitie - -disk/total -net/total--stránkovacího--system --
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ usr sys idl wai hiq SIQ | _read napíšte | _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. Vlastnosť, že ma najužitočnejšie je výstup. 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 umožňuje mať výstup zasadnutia písomne do oddelené čiarkami súbor, ktorý môže neskôr byť dovážať do tabuľkového kalkulátora ako napríklad Microsoft Excel, a tieto údaje môžu byť vykreslená do grafu. Here is how it can be used. Tu je, ako je možné ju použiť.
# dstat –output /tmp/dstat_data.csv -CDN # Dstat-výstup / tmp / dstat_data.csv-CDN
Let the above command run while you run your applications or do your testing on this machine. Let nad spustiť príkaz pri spustení aplikácie, alebo sa na testovanie na tomto počítači. Hit the key combination of ctrl+c when you are done. Stlačíte kombináciu ctrl + c, keď všetko je nastavené. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. Otvorte súbor s dstat_data.csv tabuľkového kalkulátora ako napríklad Microsoft Excel alebo Open Office. You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic. Potom môžete vybrať stĺpce, ktoré chcete vynesú do grafu a nechajte tabuľkového procesora do mágie.
Get a Report by Mail Získajte Správa Mail
There may be cases wherein you want to observe how your server is performing over a period of time. Môžu nastať prípady, v ktorých chcete sledovať, ako váš server vedie v priebehu času. 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. Môžete nastaviť pozadie procesu v Linuxe, že vám čítanie s určitým intervalom, generovať správy, a pošta sa vám súbor. This can be especially useful during a stress-test. To môže byť užitočné najmä pri strese-test. Here's how you could do that. Tu je návod, ako by ste mohli urobiť. 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. Nasledujúci skript Dstat bude prebiehať po dobu troch hodín, čítanie dát každých 30 sekúnd, a bude z pošty správu me@myemailid.com.
#!/bin/bash #! / Bin / bash
dstat –output /tmp/dstat_data_mail.csv -CDN 30 360 dstat-výstup / 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 správa za 3 hodiny run" 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: Vyššie uvedený skript uložiť do súboru s názvom dstat_script.sh na vašom serveri, dať spustiteľný povolenie a spustite ho ako proces na pozadí:
# chmod +x dstat_script.sh # Chmod + x dstat_script.sh
# nohup ./dstat_script.sh & # Nohup. / Dstat_script.sh &
Done. Hotovo. Yes, it's that simple. Áno, je to tak jednoduché. You will now be mailed this report after it's done running. Teraz budete poštou túto správu po tom, čo je to urobiť, beží. You can optionally schedule this script as a daily cron job so that you can receive this data every day. Voliteľne môžete naplánovať skript ako denný cronu, aby bolo možné tieto dáta prijímať každý deň.
As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. Ako ste si možno už zrealizovali Dstat je skvelý nástroj, ak sa týkajú monitorovania výkonnosti a ladenie. The granularity, frequency, and nature of the data collected are completely up to you. Zrnitosť, frekvencia a charakter zozbierané údaje sú úplne na vás. Dstat empowers you to know what is going on on your server. Dstat umožňuje, aby ste vedeli, čo sa deje na vašom serveri. Used wisely this power can result in a lot less sleepless nights for you. Použité múdro táto sila môže mať za následok oveľa menej bezsenných nocí pre vás.























Nice article. Pekný článok.
I've just found a little discrepancy between dstat and dd regarding the I/O: Práve som našiel trochu rozpor medzi dstat a dd, pokiaľ ide o I / O:
ifx@ids:/opt/informix/devices$ dd if=file_20GB of=/dev/null bs=2048 count=10000000 IFX @ ids: / opt / Informix / zariadenia, $ dd if = file_20GB of = / dev / null bs = 2048 count = 10000000
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: Shell bežiaci dstat zároveň mi ukázal:
-dsk/total—-dsk/hdc—–dsk/hdd– -dsk/total--dsk/hdc--dsk/hdd-
read writ: read writ: read writ prečítajte si súdny príkaz: prečítajte si súdny príkaz: čítajte súdny príkaz
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: 68m 8192B
So it looks like we all should use dstat if we want to impress people with big numbers. Takže to vyzerá, že všetci by sme mali používať dstat, ak chceme zapôsobiť na ľudí s veľkými číslami.
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. Vyzerá to tiež, ako by ste nemali porovnávať dstat na niečo iného, ako dstat či naozaj chcete porovnávať systémy, pochybuju, budem používať viac pre tento druh vecí viac.