در این سری مقاله سعی من بر این است تا ابزارهای مونیتورینگ که در این قسمت (۱) بیشتر کنسولی هستند را معرفی کنم و همچنین سیستم عامل رو من debian در نظر گرفتم که شما میتونید با نیازهای خودتون تغییراتی بدین.ابزارهای این شماره بنظر ساده میان ولی بسیار کاربردی هستند,در ضمن من ابزارهای متفاوتی معرفی میکنم که شما باید بهترین اونو انتخاب کنید.
در این شماره تمرکزمون رو روی مونیتورینگ cpu , ram , swap , mount points , network interfaces از طریق کنسول و یصورت لوکال نه ریموت یعنی منابع از روی کامیپوتر دیگه گرفته نمیشه هر چند که شما میتونید از طریق putty نتایج رو از هر جای دیگه هم ببینید.
در شماره های آینده به معرفی و نصب برنامه های پیشرفته تری میپردازیم.
بعضی از لغات اگرترجمه بشن معنی خودشون رو از دست میدن پس من از این کار خودداری میکنم,همچنین از مشخصه های یک مدیر شبکه آشنایی با زبان انگلیسی در حد لازم برای برطرف کردن نیازهاش میباشد.


مقدمه :
امروزه نظارت برسیستم و منابع سیستم یکی از اساسی ترین نیازهای هر شبکه و مدیر شبکه ای برای بررسی میزان کارایی اون شبکه و سیستم میباشد.اگر منابع سیستم کم باشد یا به مرور مشکلاتی برای سیستم به وجود آمده باشد عدم آگاهی از این رخددادها عواقب وخیمی درآینده در پی خواهد داشت.
منابع سیستم هم بوسیله کاربر می تواند مصرف شود هم بواسطه سرویس هایی که بر روی سرور قرار دارنداز قبیل وب یا میل .توانایی در جهت شناخت اتفاقاتی که در معرض روی دادن است می تواند به تشخیص اینکه سیستم احتیاج به بروزرسانی دارد یا نه کمک شایانی کند یا حتی اگر سیستم نیاز دارد تا یک سرویس به سرور دیگری منتقل شود.

۱-free
نمایش دهنده میزانmemory آزاد و مصرف شده
free is a UNIX command which displays the total amount of free and used physical and swap memory in the system, as well as the shared memory and buffers used by the kernel.
free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay ] [-c count ]
***************************************
۲-top
امکان مشاهده پروسه هایی که در cpu و memroy در حال انجام هست رو فراهم میکنه
top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can sort the tasks by CPU usage, memory usage and runtime. can be better configured than the standard top from the procps suite. Most features can either be selected by an interactive command or by specifying the feature in the personal or system-wide configuration file. See below for more information.
top [-] [d delay] [p pid] [q] [c] [C] [S] [s] [i] [n iter] [b]

***************************************
۳-htop
htop تو مایه های top هستش ولی خیلی بهتر و interactive تر هست.همونطور که از عکسش معلومه براحتی میتونید پروسه ها رو Kill کنید و…من توصیه میکنم ازبجای top از این استفاده کنید منتها برای استفاده از htop باید نصبش کنید روی سیستمتون
htop is a very competent interactive process viewer for the shell, providing all the functionality - and more - that the top utility does, in an easier and more intuitive way. htop provides easy-to-use menus for most operations and also has support for using a mouse.
htop is an easier to use and friendlier version of top. While it hasn’t as much time behind it and therefore is less tested, it seems to work very well both locally and over SSH, and it’s well worth taking it for a spin. It’s just one of those small utilities that makes life a bit easier.
نصب :
#apt-get install htop

Comparison between htop and top
In ‘htop’ you can scroll the list vertically and horizontally to see all processes and complete command lines.
In ‘top’ you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
‘htop’ starts faster (’top’ seems to collect data for a while before displaying anything).
In ‘htop’ you don’t need to type the process number to kill a process, in ‘top’ you do.
In ‘htop’ you don’t need to type the process number or the priority value to renice a process, in ‘top’ you do.
‘htop’ supports mouse operation, ‘top’ doesn’t
‘top’ is older, hence, more used and tested.
***************************************
۴-slmon
Slmon هم برنامه جالبیه که میزان مصرف cpu ,ram همچین مقدار فضای خالی یا مصرفی mount ها ازقبیل هارد, فلش و… رو نشون میده.برای دیدن پروسه هایی که در حال انجام هستن باید روی p کیک کنید تا پروسه های لیست بشه براتون…
SLmon is a tool for monitoring a system's performance. It displays results using a nice and easilyreadable text-based UI. It has the ability to monitor CPU load (SMP is supported), memory/filesystems usage, network interfaces, uptime, date and time, and the number of logged in users.
نصب :
#apt-get install slmon
***************************************
۵-sysstat
sysstat حاوی sar,mpstat,iostat هستش که هر کدوم کاری انجام میدن.(منکه اصلا باهاش حال نکردم)
نصب :
#apt-get install sysstat
sar command
The sar command collects and reports system activity information. The statistics reported by sar concern I/O transfer rates, paging activity, process-related activities, interrupts, network activity, memory and swap space utilization, CPU utilization, kernel activities and TTY statistics, among others. Both UP and SMP machines are fully supported.
mpstat command
The mpstat command reports global and per-processor statistics

iostat command
The iostat will display the current CPU load average and disk I/O information. This is a great command to monitor your disk I/O usage.
For ۲.۴ kernels the devices is names using the device's major and minor number. In this case the device listed is SCSI. To have iostat print this out for you, use the -x.
***************************************
۶-ps
ps لیستی از پروسه هایی که الان در حال اجراست را نشان میده
The ps will provide you a list of processes currently running. There is a wide variety of options that this command gives you.
ps [-a] [-A] [-c] [-d] [-e] [-f] [-j] [-l] [-L] [-P] [-y] [ -g grplist ] [ -n namelist ] [-o format ] [ -p proclist ] [ -s sidlist ] [ -t term] [ -u uidlist ] [ -U uidlist ] [ -G gidlist ]





برای اینکه لیست تمام پروسه هایی که در حال انجام هست رو ببینیم از دستور زیر استفاده میکنیم
#ps -ef

برای اینکه پروسه های یک کاربر خاص رو ببینیم از دستور زیر استفاده میکنیم
#ps -u(defualt is current user)
#ps -u zabbix

از kill میتونیم بهمراه ps برای پابان دادن به یک پروسه استفاده کنیم..مثلا pid یه پروسه در عکس آخر ۱۱۳۸ هستش..ما برای اینکه فاتحه!! این پروسه رو بخونیم به این طریق عمل میکنیم
#kill -۹ ۱۱۳۸
۹ هم برای اطمینان از اجرا شدن مینویسیم
***************************************
۷-pstree
pstree لیست پروسه هایی که الان در حال انجام هستند رو نشون میده
pstree - display a tree of processes
pstree [ -a ] [ -c ] [ -h | -H pid ] [ -l ] [ -n ] [ -p ] [ -u ][ -A | -G | -U ] [ pid | user]
برای نمایش پروسه ها بدین طریق عمل میکنیم
#pstree
#pstree -p(show PIDs; implies -c)
#pstree -n(sort output by PID)
#pstree pid(start at pid, default ۱ (init))

#pstree user(show only trees rooted at processes of that user)
***************************************
۸-jmon
jmon درصد استفاده cpu, memory , swap رو بهمون نشون میده
The jmon tool monitors selected resources (memory, cpu, I/O) used by a running batch job on a particular machine, as well as overall machine activities.
jmon [ -interval <seconds> ] [ -count <count> ] [ -outfile <file> ] [ -path <path> ] [ -(no)fg ] [ -version ] [ -help|? ] <jobstep-id>
برای مشاهده خروجی :
#jmon
***************************************
۹-dstat
dstat میتونه یک جایگزین خوب برای vmsta , iostat , ifstat باشه که چند محدودیت اونها رو حل کرده وچندین قابلیت هم اضافه شده.بنظرم اگه سیستمون دچار bottleneck شده dstat میتونه کمک خوبی باشه براتون تا در یک زمان تمام منابع سیستمتون از قبیل cpu , disk usage , network bandwidth ,…. رو میتونید ببینید
stat allows you to view all of your system resources instantly, you can eg. compare disk usage in combination with interrupts from your IDE controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).
dstat [-afv] [-cdgilmnpsty] [-D..] [-I..] [-N..] [delay [count]]
برای مشاهده خروجی
#dstat
***************************************
۱۰-vmstat
اطلاعاتی در مورد پروسه ها , memory, cpu,swap, io ,procs در اختیارمون میزاره
vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.
vmstat [-V] [-n] [delay [count]]
FIELD DESCRIPTIONS
Procs

r: The number of processes waiting for run time.
b: The number of processes in uninterruptable sleep.
w: The number of processes swapped out but otherwise runnable. This
field is calculated, but Linux never desperation swaps.
Memory
swpd: the amount of virtual memory used (kB).
free: the amount of idle memory (kB).
buff: the amount of memory used as buffers (kB). Swap
si: Amount of memory swapped in from disk (kB/s).
so: Amount of memory swapped to disk (kB/s).
IO
bi: Blocks sent to a block device (blocks/s).
bo: Blocks received from a block device (blocks/s).
System
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.
These are percentages of total CPU time.
us: user time
sy: system time
id: idle time

***************************************
۱۱-vnstat
اگه دنبال یه راه مگیردید که ترافیک کارت شبکه هاتون رو کنترل کنید این یه ابزاره خوبه که باکنسول کار میکنه و بصور روزانه و ماهیانه براتون لاگ برداری میکنه
vnStat is a console-base network traffic monitor that keeps a log of daily and monthly network traffic for the selected interface(s). However, it isn't a packet sniffer. The traffic information is analyzed from the proc(۵) -filesystem, so that vnStat can be used without root permissions.
نصب :
# apt-get install vnstat

برای فعال کردن vnstat و ساختن دیتابیس مثلا بر روی eth۰ بدین طریق عمل میکنیم

# vnstat -u -i eth۰
u مجبور میکنه که دیتابیس آپدیت بشه یا اگه دیتابیسی وجود نداره اونو میسازه
vnstat شروع به جمع آوری دیتا از طریق cronjob میکنه که موقع نصب بصورت خودکار اصافه میشه
۰-۵۵/۵ * * * * root /usr/bin/vnstat -u
برای دیدن اطلاعات بدیدن طریق عمل میکنیم
#vnstat
#vnstat -h(Show traffic for the last ۲۴ hours)
#vnstat -d(Show traffic for days)
#vnstat -w(Show traffic for ۷ days, current and previous week)
#vnstat -m(Show traffic for months)
#vnstat -t (Show all time top۱۰ traffic days)
#vnstat –help


***************************************
۱۲-bwm
bwm یک برنامه کوچولی مونیتورینگ پهنای باند هست که تا ۱۶ تا کارت شبکه رو همزمان میتونه پشتیبانی کنه
This is a very tiny bandwidth monitor (not X۱۱). Can monitor up to ۱۶ interfaces in the in the same time, and shows totals too.
نصب :
#apt-get install bwm
برای اینکه خروجی رو ببینید بدین طریق عمل کنبد
#bwm
***************************************
۱۳-ethstats
ethstats خروجی کارت شبکه ها رو براساس مگابیت بر ثانیه و پکت بر ثانیه نشان میده..البته همچین با حال نیست!!
ethstats works by parsing the /proc/net/dev file that the Linux kernel maintains, and thus utilizes a negligible amount of CPU time. ethstats shows the throughput of each device in both megabits per second and packets per second.
نصب :
#apt-get install ethstats
برای مشاهده خروجی این طور عمل میکنیم
#ethstats

***************************************
۱۴-ethstatus
Ethstatus is a console-based monitoring utility for displaying statistical data of the ethernet interface on a quantity basis. It is similar to iptraf but is meant to run as a permanent console task to monitor the network load.
نصب :
#apt-get install ethstatus
برای مشاهده خروجی این طور عمل میکنیم
#ethstatus
د
***************************************
۱۵-ifstat
ifstat is a tool to report network interfaces bandwith just like vmstat/iostat do for other system counters. It can monitor local interfaces by polling the kernel counters, or remote hosts interfaces using SNMP.
نصب:
#apt-get install ifstat
برای مشاهده خروجی
#ifstat
***************************************
۱۶-iftop
iftop به کارت شبکه هامون گوش میده و بر اساس ip و host و میزان مصرف هر کدام لیست میکنه…که اگر عکس رو نگاه کنید کاملا مشهوده
iftop does for network usage what top(۱) does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts. Handy for answering the question "why is our ADSL link so slow?".
نصب :

#apt-get install iftop
برای مشاهده خروجی بدین طریق عمل میکنیم

#iftop -h | [-nNpbBP] [-i interface] [-f filter code] [-F net/mask]
or
#iftop

***************************************
۱۷-iog
IOG is a network I/O byte grapher made to graph cumulative KB/MB/GB totals for hours/days and months. It is intended to be simple, fast (support thousands of hosts) and integrate well with MRTG. Data for each host is updated hourly and HTML graphs are created. It uses a data consolidation algorithm which allows for a small, non-growing database file for each host. No external graphing libs or executables are required.
نصب :
#apt-get install iog
برای مشاهده خروجی بدین طریق عمل میکنیم
#iog
بعد در مرورگر این آدرس رو میزنیم

***************************************
۱۸-phpsyinfo
phpsysinfo اسکریپت php هست که اطلاعاتی در مورد سیستم از قبیل cpu,memory,uptime,network usage,.. در اختیارمون میزاره
phpSysInfo is a customizable PHP script that parses various files in /proc and displays them. It will display information about system facts like Uptime, CPU, Memory, SCSI, IDE, PCI, Ethernet, Floppy, and Video. It now has full internationalization support along with customizable templates.
نصب :
این برنامه چون تحت وب هست میباست apache همراه با php رو قبلا نصب کرده باشیم, ولی در حال بدین صورت قابل انجامه
#apt-get install apache php۴
#apt-get install phpsysinfo
موقع نصب ۴ تا سوال ازتون میپرسه که هر جور که دوست دارین باید جواب بدید این عکس های ۲ تا از سوالات مهمش هست

بعد از نصب یه دایکتوری بنام phpsysinfo در /var/www/ ساخته میشه
برای دیدن کافیه این آدرس رو در مرورگرتون بزنید


***************************************
۱۹-df
df به شما میگه که چه مقدار فضای آزاد و اشغال شده در هر کدام از mount های خودتون دارید از قبیل هارددیسک , فلش , ….
The df command is used to show the amount of disk space that is free on file systems.
df [ -F FSType ] [-a [-b] [-e] [-g] [-k] [-l] [-n] [-t] [-V ] [ -o FSTypespecific_options ] [block_device | directory | file | resource … ] [-P]
برای دیدن اطلاعات بدیدن طریق عمل میکنیم
#df
#df -m(type size in mega)

#df -a(all-includinf file system having ۰ block)
#df - h(human-readable)
#df –help
با حالترین کامندش اینه بنظرم البته من ترجمه نمکنم و متن انگلسیشو میزارم تا با این انگلیسی دست و پاشکستم معنی و مفهمومشو خراب نکنم
#df -i
This option instructs df to display information about inodes rather that file blocks. Even though you think of directory entries as pointers to files, they are just a convenience for humans. An inode is what the Linux file system uses to identify each file. When a file system is created (using the mkfs command), the file system is created with a fixed number of inodes. If all these inodes become used, a file system cannot store any more files even though there may be free disk space. The df -i command can be used to check for such a problem.
پس اگر دیدید فضای خالی دارید ولی نمیتونید چیزی رو اضافه کنید حتما از این دستور استفاده کنید,شاید یه لبخند رو لبتون اومد و باعث شادی روح اینجانب شد.
***************************************
۲۰-discus
discus هم مثل df برای دیدن مقدار فضای آزاد یا اشغال شده mountها کاربرد داره که فکر کنم امکاناتش از df کمتر و فقط یه گراف اضافه کرده ,همچین باید نصبش کرد.
Discus is a GPL text-mode disk space usage program.Discus aims to make df prettier. Features include color, bar graphs, and smart formatting of numbers (automatically choosing the most suitable size from kilobytes, megabytes, gigabytes, or terabytes). Or choose your own size, along with specifying the number of decimal places.
نصب :
#apt-get install discus
برای دیدن اطلاعات بدین طریق عمل میکنیم
#discus
#discus -m
#discus -p number(number of digits to right of decimal place)
#discus –help
***************************************
۲۱-du
du نمدونم بشه بهش مونیتورینگ گفت یا نه ولی تو حال و هوای همین ۲ تا برنامه اخیر هست گفتم معرفیش ضرر نداره که هیچ شاید کلی هم شود داشته باشه…خوب از حاشیه بیام بیرون باید بگم که این دستور برای نمایش دادن میزان فضایی که هر فایل اشغال کرده استفاده میشه
Tells you how much space a file occupies.
du [-a] [-k] [-s] [-d] [-L] [-o] [-r] [-x] directories
بدین طریق عمل میکنیم
#du
#du -s *.conf (Would report the size of each conf file in the current directory)
#du -h *.conf(Display the size of the conf files in a friendly size format listing)
#du-c(see total capacity of all the files combined)
توجه داشته باشین که شما میتونید این subcommand ها رو با هم ترکیب کنید تا جواب بهتری بگیرید,همچنین میتونید سایز یه فایل خاص رو نگاه کنید,مثلا:
#du -ch reza.zip
***************************************
نکته:
توجه کنید که از slmon هم میتونید برای نمایش میزان فضای استفاده شده و فضای آزاد استفاده کنید
***************************************