/////
Search
๐Ÿคฉ

Monitoring

ย 1. Wall

wall ๋ช…๋ น์–ด๋Š” ๋ฆฌ๋ˆ…์Šค ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉ์ž์˜ ํ„ฐ๋ฏธ๋„๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜์ด๋‹ค.
ํ„ฐ๋ฏธ๋„์— ์ ‘์† ๋œ ์‚ฌ์šฉ์ž๋ผ๋ฉด ๋ˆ„๊ตฌ๋“ ์ง€ wall ๋ช…๋ น์–ด๋กœ ํ„ฐ๋ฏธ๋„์— ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค.
util-linux ํŒจํ‚ค์ง€์—์„œ ๊ด€๋ฆฌ๋˜๊ณ  ์‚ฌ์šฉ๋˜๋Š” ๋ช…๋ น์–ด์ด๋ฉฐ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ค์น˜๋˜์–ด ์žˆ๋‹ค.

ย Usage

$ wall
Shell
๋ณต์‚ฌ
wall ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ž…๋ ฅ ๋ชจ๋“œ๋กœ ์ง„์ž…ํ•œ๋‹ค.
์ „์†กํ•˜๊ณ ์ž ํ•˜๋Š” Message๋ฅผ ์ž…๋ ฅํ•œ ๋’ค Ctrl + D๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ž…๋ ฅ์„ ์ •์ƒ ์ข…๋ฃŒํ•œ๋‹ค.
์ „์†กํ•œ ๋ฉ”์‹œ์ง€๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

Reference

ย 2. cron

ย Summary

cron์€ UNIX๊ณ„์—ด ์šด์˜ ์ฒด์ œ์˜ ์‹œ๊ฐ„ ๊ธฐ๋ฐ˜ ์žก ์Šค์ผ€์ค„๋Ÿฌ์ด๋‹ค. ์†Œํ”„ํŠธ์›จ์–ด ํ™˜๊ฒฝ์„ ์„ค์ •ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ์‚ฌ๋žŒ๋“ค์€ ์ž‘์—…์„ ๊ณ ์ •๋œ ์‹œ๊ฐ„, ๋‚ ์งœ, ๊ฐ„๊ฒฉ์— ์ฃผ๊ธฐ์ ์œผ๋กœ ์‹คํ–‰ ํ•  ์ˆ˜ ์žˆ๋„๋ก ์Šค์ผ€์ค„๋ง ํ•˜๊ธฐ ์œ„ํ•ด cron์„ ์‚ฌ์šฉํ•œ๋‹ค.
์‰ฝ๊ฒŒ ๋งํ•ด ์–ด๋–ค ์ž‘์—…์„ ์ฃผ๊ธฐ์ ์œผ๋กœ ์ž๋™์œผ๋กœ ์‹คํ–‰ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด cron์„ ์‚ฌ์šฉํ•˜์—ฌ ์Šค์ผ€์ค„๋ง ์ž‘์—…์„ ํ•œ๋‹ค.

ย Description

cron์€ crontab(cron table) ํŒŒ์ผ์— ์˜ํ•ด ๊ตฌ๋™๋œ๋‹ค. ์ด ํŒŒ์ผ์€ Shell ๋ช…๋ น์–ด๋“ค์ด ์ฃผ์–ด์ง„ ์ผ์ •์— ์ฃผ๊ธฐ์ ์œผ๋กœ ์‹คํ–‰ํ•˜๋„๋ก ๊ทœ์ • ํ•ด๋†“์€ ํŒŒ์ผ์ด๋‹ค.
crontab path : /etc/crontab
์‚ฌ์šฉ์ž๋ฅผ ์œ„ํ•œ ๊ตฌ์„ฑ ํŒŒ์ผ์€ crontab -e ๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ํŽธ์ง‘ ํ•  ์ˆ˜ ์žˆ๋‹ค.
์‚ฌ์šฉ ์‹œ ๋ฌธ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
# ๋งค์ผ 20์‹œ (์˜คํ›„ 8์‹œ)์— export_dump.sh๋ผ๋Š” shell ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ 0 20 * * * /home/oracle/scripts/export_dump.sh
Shell
๋ณต์‚ฌ
๋‚ด crontab
*/10 * * * * bash /root/monitoring.sh | wall
Shell
๋ณต์‚ฌ

Shell File

Location
/root
File Name
monitoring.sh
โ†’ The architecture of your operating system and its kernel version.
$ uname -a
Shell
๋ณต์‚ฌ
โ†’ The number of physical processors.
$ grep "physical id" /proc/cpuinfo | sort | uniq | wc -l
Shell
๋ณต์‚ฌ
โ†’ The number of virtual processors.
$ cat /proc/cpuinfo | grep processor | wc -l
Shell
๋ณต์‚ฌ
โ†’ The current available RAM on your server and its utilization rate as a percentage.
$ free -m | grep Mem | awk '{printf "%d/%dMB (%.2f%%)\n", $3, $2, $3/$2 * 100.0}'
Shell
๋ณต์‚ฌ
โ†’ The current available memory on your server and its utilization rate as a percentage.
$ df -h | awk '$NF=="/"{printf "%d/%dGB (%s)\n", $3, $2, $5}'
Shell
๋ณต์‚ฌ
โ†’ The current utilization rate of your processors as a percentage.
$ top -bn1 | grep load | awk '{printf "%.2f%%\n", $(NF-2)}'
Shell
๋ณต์‚ฌ
โ†’ The date and time of the last reboot.
$ who | awk '{print $3" "$4}'
Shell
๋ณต์‚ฌ
โ†’ Whether LVM is active or not.
$ cat /proc/net/tcp | wc -l | awk '{print $1-1 " ESTABLISHED"}'
Shell
๋ณต์‚ฌ
โ†’ The IPv4 address of your server and its MAC (Media Access Control) address.
$ hostname -I | tr -d '\n''' && ip link | grep "ether " | awk '{print "("$2")"}'
Shell
๋ณต์‚ฌ
โ†’ The number of commands executed with the sudo program.
$ cat /var/log/auth.log | grep -c 'COMMAND=' | tr -d '\n'
Shell
๋ณต์‚ฌ

Reference

Shell Script Reference