How to use dstat to monitor your Linux/UNIX server Как использовать dstat контролировать ваш Linux / UNIX серверов

by Sukrit Dhandhania on November 13, 2008 по Sukrit Dhandhania по 13 ноябрь 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. Если у вас есть Linux-сервер работает в офисе или в центр обработки данных, для которых вы несете ответственность, вы хотите сохранить работает как почти сто процентов. In such a case you want to make sure you keep an eye on how the system is running. В таком случае, если вы хотите убедиться, что вы держите глаза от того, как система работает. 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. Чтобы быть точным, вы хотите контролировать все системные ресурсы, которые способствуют система работает штраф, который затем приводит к высокой работает. Memory, CPU, disk usage… are some of the things you want to observe. Память процессора, использования дискового ... некоторые вещи вы хотите наблюдать. 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. Мы хотели бы, как правило, используют комбинацию инструментов, которые поставляются с Linux или UNIX установку, таких, как "свободный", "сверху", "vmstat" ... Я познакомить вас с инструментом, который дает вам только о всех информацию о том, что другие инструменты в сочетании даю вам, все под одной крышей - Dstat. The developer of this command line tool, Dag Wieers, calls it “a versatile replacement for vmstat, iostat, netstat and ifstat”. Разработчик этого утилиту командной строки, Даг Wieers, называет это "универсальный заменитель vmstat, iostat, NETSTAT и 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. Он добавляет, что "Dstat преодолевает некоторые из своих ограничений и добавляет некоторые дополнительные функции ..." Для меня Dstat является матерью всех командной строки система мониторинга инструментов. 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. Она проста в установке, проста в использовании, может быть оптимальной с легкостью и генерирует отчеты, которые можно сюжет, как граф для впечатлить ваших босса.

Installing Dstat Установка Dstat

Start by downloading the Dstat installer. Начните с загрузки Dstat установки. Point your web browser to the Dstat project’s homepage - Центр веб-браузер для Dstat проекта на главной странице -- http://dag.wieers.com/home-made/dstat/ . Scroll down to the section of the page where the downloads are listed. Перейдите в раздел страницы, где загружает перечислены. Pick the flavor of Linux on which you want to install the application and click on the download link. Выберите нужный Linux, на котором вы хотите установить приложение и нажмите на ссылку "Загрузка". Now download the latest version of Dstat for the version of the Linux distribution you are running. Теперь скачать последнюю версию Dstat для версии Linux распределение вы работаете. I’ll show you how to do it for a Red Hat Enterprise Linux version 4 machine: Я покажу вам как это сделать для Red Hat Enterprise Linux версии 4 машины:

# 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: Теперь установите Dstat:

# rpm -Uvh dstat-0.6.6-1.el4.rf.noarch.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. Если установка пошла, хотя без ошибок, которые его, у Вас есть Dstat установлено и готово к использованию. If there were some dependencies that came up during the installation just install the required packages and try again. Если имеется ряд зависимостей, которые пришли во время установки просто установить требуемые пакеты и попробуйте еще раз. I don’t think that Dstat has too many dependencies, so you should not face any problems. Я не думаю, что Dstat слишком много зависимостей, так что вы не должны сталкиваться с какими-либо проблемами.

Using Dstat Использование Dstat

With Dstat installed on your system you should be good to go. Что Dstat установлены на вашей системе вы должны быть хорошо идти. Begin by launching the command from a terminal: Начните с начала команду из терминала:

# dstat # Dstat

The output would be something like the following. В результате будет нечто вроде следующего. Hit the key combination of ctrl+c to exit. Нажмите клавишу сочетание Ctrl + C для выхода.

# dstat # Dstat
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Всего-CPU-USAGE - -disk/total -net/total--пейджинг-систем
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ системах IDL USR WAI hiq siq | _read написать | _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. Существуют ряд опций для Dstat. As I mentioned earlier Dstat is quite easy to tweak. Как я упоминал ранее Dstat довольно легко настроить. So if you want to limit the data reading to the CPU, disk, and network, run the following command: Так что если вы хотите ограничить чтения данных для процессора, диска и сети, запустите следующую команду:

# dstat -CDN # Dstat-CDN
-disk/total -net/total- —paging– —system– -disk/total -net/total--пейджинг-систем
_read write|_recv _send|__in_ _out_|_int_ _csw_ _read написать | _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Б 0 | 0 0 | 1031 1939

You can find more options in the application’s help document which you can access by entering the following: Вы можете найти больше вариантов применения помощью документа, который можно получить доступ, введя следующие:

# dstat -h # Dstat-ч

Play with the options a little so you get comfortable with them. Играть в эту мало, поэтому вы сможете получить комфортно с ними. The default interval between data reads is two seconds. По умолчанию интервал между данными читает это две секунды. You can change that interval if you need to. Вы можете изменить интервал, что, если вам нужно. To increase the interval to ten seconds enter the following: Чтобы увеличить интервал до десяти секунд введите следующие:

# dstat 10 Dstat # 10

Another useful feature is to get aggregated updates for each entry. Еще одна полезная функция заключается в том, чтобы получить агрегированные обновления для каждой записи. 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. Таким образом, вы можете иметь Dstat дать вам обновлять каждые десять секунд в новую линию, но, как данные изменения вашей строке запускается сам обновляется раз в секунду.

You might optionally want Dstat to give you five updates with a frequency of three seconds. Вы можете опционально Dstat хотим дать вам пять обновлений с частотой три секунды. Here’s how you would go about doing that: Вот как вы бы идти о том, что делать:

# dstat 3 5 # Dstat 3 5
—-total-cpu-usage—- -disk/total -net/total- —paging– —system– - Всего-CPU-USAGE - -disk/total -net/total--пейджинг-систем
usr sys idl wai hiq siq|_read write|_recv _send|__in_ _out_|_int_ _csw_ системах IDL USR WAI hiq siq | _read написать | _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. Функция, что я нахожу наиболее полезным является выход. 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 позволяет вам иметь мощность сессии в письменном виде, разделенных запятыми файл, который впоследствии может быть импортирован в электронную таблицу приложения, такие, как Microsoft Excel и данные могут быть заговор в графике. Here is how it can be used. Вот как это можно использовать.

# dstat –output /tmp/dstat_data.csv -CDN # Dstat-вывода / TMP / dstat_data.csv-CDN

Let the above command run while you run your applications or do your testing on this machine. Пусть выше команду запуска при запуске ваших заявок или же ваших испытаний на этой машине. Hit the key combination of ctrl+c when you are done. Нажмите клавишу сочетание Ctrl + C, когда вы сделали. Open the file dstat_data.csv with a spreadsheet application such as Microsoft Excel or Open Office. Откройте файл dstat_data.csv с таблицами, такие как Microsoft Excel или Open Office. You can then select the columns you want plotted into a graph and let your spreadsheet application do the magic. Затем можно выбрать столбцы вы хотите заговор в графике и пусть ваши таблицы делать магии.

Get a Report by Mail Получить отчет по почте

There may be cases wherein you want to observe how your server is performing over a period of time. Там могут быть случаи, когда вы хотите наблюдать, как ваш сервер работает в течение определенного периода времени. 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. Вы можете настроить фон процесса в Linux, что даст вам чтения с определенным интервалом, создайте отчет, и почту из файла к вам. This can be especially useful during a stress-test. Это может быть особенно полезно во время стресс-тест. Here’s how you could do that. Вот как это можно сделать. 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. Следующий сценарий будет проходить Dstat в течение трех часов, чтение данных, каждые 30 секунд, и почти в докладе me@myemailid.com.

#!/bin/bash #! / BIN / Bash
dstat –output /tmp/dstat_data_mail.csv -CDN 30 360 dstat-вывода / 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 собачонка-/ TMP / dstat_data_mail.csv-S "Dstat отчет за 3 часа Выполнить" me@myemailid.com </ Dev / нуль

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: Сохранить выше сценария в файл с именем dstat_script.sh на вашем сервере, дайте его исполняемым разрешения, а затем запустить ее в качестве фона процесса:

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

Done. Готово. Yes, it’s that simple. Да, это так просто. You will now be mailed this report after it’s done running. Теперь по почте после этого доклада он сделал работу. You can optionally schedule this script as a daily cron job so that you can receive this data every day. Вы можете опционально график этот скрипт как ежедневно хрон работу так, что вы можете получить эти данные каждый день.

As you may already have realized Dstat is a wonderful tool when applied to performance monitoring and debugging. Как вы, возможно, уже осознали Dstat является прекрасным инструментом, когда применяется для выполнения мониторинга и отладки. The granularity, frequency, and nature of the data collected are completely up to you. Гранулярности, частоту и характер этих данных, собранных полностью за вами. Dstat empowers you to know what is going on on your server. Dstat дает вам знать, что происходит на вашем сервере. Used wisely this power can result in a lot less sleepless nights for you. Б мудро эта власть может привести к гораздо меньше бессонных ночей для вас.

Related Posts: Связанные Сообщений:
  • How to monitor your Mac laptop’s battery health Как контролировать ваш ноутбук Mac аккумулятора здоровье
  • How to share a keyboard and mouse with multiple computers Как бы поделиться клавиатуры и мыши с несколькими компьютерами
  • How to monitor your Internet bandwidth usage in OS X Как контролировать ваш Интернет-трафик в OS X
  • 5 More OS X Dashbooard Widgets for Bloggers Еще 5 OS X Dashbooard виджетов для блоггеров
  • How to monitor your Internet bandwidth usage in OS X, redux Как контролировать ваш Интернет-трафик в OS X, redux
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! Получить справки Простые уроки точно так же, как это в свое сообщение Входящие каждый день - бесплатно! Just enter your email address below: Просто введите свой адрес электронной почты ниже:

    You can always opt out of this email subscription at any time. Вы всегда можете отказаться от подписки это сообщение в любой момент.


    Bookmark and Share Закладка и Поделитесь

    { 0 comments… (0 комментарии ... add one now Добавить сейчас } )

    Leave a Comment Оставить комментарий

    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> Вы можете использовать эти теги HTML и атрибуты: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>