Article Title: typical application of shell scripts in System Management (1 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Server System Status Monitoring
-------------------
Case Description:
To continuously observe the running status of the server on a daily basis, you need to periodically track and record the server's cpu load, memory, swap space, disk usage, and other information in conjunction with shell scripts and scheduled tasks.
Implementation Method: use shell scripts
Specific design ideas:
1. Write the script monitor. sh.
#! /Bin/bash
# This is the second script!
Day_time = 'date + "% F % R "'
Cpu_test = 'uptime'
Mem_test = 'free-m | grep "mem" | awk '{print $2 }''
Swap_test = 'free-m | grep "mem" | awk '{print $4 }''
Disk_test = 'df-hT'
User_test = 'last-n 10'
Echo "now is $ day_time"
Echo "% cpu is $ cpu_test"
Echo "Numbet of Mem size (MB) is $ mem_test"
Echo "Number of swap size (MB) is $ swap_test"
Echo "the disk shiyong qingkuang is $ disk_test"
Echo "the users login qingkuang is $ user_test"
2. Set a cron task
*/15 * bash/monitor. sh
55 23 *** tar cxf/var/log/runrec/var/log/running. today & -- remove-files
Note: The cron scheduled task is set to execute this script from time to monitor the system status and log in to facilitate better system management!