-
腳本文件查看全部
-
網(wǎng)絡(luò)信息查看全部
-
系統(tǒng)信息監(jiān)控腳本 腳本:system_monitor.sh 功能一、提取操作系統(tǒng)信息(內(nèi)核、系統(tǒng)版本、網(wǎng)絡(luò)地址等) 功能二、分析系統(tǒng)的運(yùn)行狀態(tài)(CPU負(fù)載、內(nèi)存及磁盤使用率等)查看全部
-
系統(tǒng)使用內(nèi)存和應(yīng)用使用內(nèi)存區(qū)別查看全部
-
內(nèi)存中cache和buffer區(qū)別查看全部
-
#!/bin/bash #系統(tǒng)磁盤分析腳本 clear if [[ $# -eq 0 ]] then #Define Variable reset terminal reset_terminal=$(tput sgr0) diskaveage=$(df -hP | grep -vE 'Filesystem | tmpfs' | awk '{print $1 " " $5}') echo -e '\E[32m'"Operating System Disk Averages :" $reset_terminal $diskaveage fi查看全部
-
#!/bin/bash #系統(tǒng)負(fù)載分析腳本 clear if [[ $# -eq 0 ]] then #Define Variable reset terminal reset_terminal=$(tput sgr0) loadaverage=$(top -n 1 -b | grep "load average:" | awk '{print $10 $11 $12}') echo -e '\E[32m'"Operating System Load Averages :" $reset_terminal $loadaverage fi查看全部
-
#!/bin/bash #系統(tǒng)內(nèi)存分析腳本 clear if [[ $# -eq 0 ]] then #Define Variable reset terminal reset_terminal=$(tput sgr0) system_mem_usages=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}END{print (total-free)/1024}' /proc/meminfo) app_mem_usages=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}/^Cached/{cached=$2}/Buffers/{buffers=$2}END{print (total-free-cached-buffers)/1024}' /proc/meminfo) echo -e '\E[32m'"Operating System Memuserages :" $reset_terminal $system_mem_usages echo -e '\E[32m'"Operating System App Memuserages :" $reset_terminal $app_mem_usages fi查看全部
-
內(nèi)存中cache和buffer的區(qū)別查看全部
-
系統(tǒng)信息監(jiān)控腳本查看全部
-
#Check DNS nameservers=$(cat /etc/resolv.conf | grep -E "\<nameserver[ ]+" | awk '{print $NF}') echo -e '\E[32m'"Operating System DNS :" $reset_terminal $nameservers #ping -c 2 imooc.com &> /dev/null && echo "Internet:Connected" || echo "Internet:Disconnected" #Check Logged In Users who > /tmp/who.log echo -e '\E[32m'"Operating System Logged In Users :" $reset_terminal && cat /tmp/who.log rm -f /tmp/who fi查看全部
-
#Check OS Release Version and Name os_name=$(cat /etc/issue | grep -e "Server") echo -e '\E[32m'"Operating System Release Version and Name :" $reset_terminal $os_name #Check Architecture architecture=$(uname -m) echo -e '\E[32m'"Operating System Architecture :" $reset_terminal $architecture #Check Kernel Release kernelrelease=$(uname -r) echo -e '\E[32m'"Operating System Kernel Release :" $reset_terminal $kernelrelease #Check hostname $HOSTNAME echo -e '\E[32m'"Operating System Hostname :" $reset_terminal $HOSTNAME #Check Internal IP internalip=$(hostname -I) echo -e '\E[32m'"Operating System Internal IP :" $reset_terminal $internalip #Check External IP externalip=$(curl -s http://ipecho.net/plain) echo -e '\E[32m'"Operating System External IP :" $reset_terminal $externalip查看全部
-
#!/bin/bash #系統(tǒng)信息腳本 clear if [[ $# -eq 0 ]] then #Define Variable reset terminal reset_terminal=$(tput sgr0) #check OS Type os=$(uname -o) echo -e '\E[32m'"Operating System Type :" $reset_terminal $os #Check OS Release Version and Name os_name=$(cat /etc/issue | grep -e "Server") echo -e '\E[32m'"Operating System Release Version and Name :" $reset_terminal $os_name #Check Architecture architecture=$(uname -m) echo -e '\E[32m'"Operating System Architecture :" $reset_terminal $architecture #Check Kernel Release kernelrelease=$(uname -r) echo -e '\E[32m'"Operating System Kernel Release :" $reset_terminal $kernelrelease #Check hostname $HOSTNAME then #Define Variable reset terminal reset_terminal=$(tput sgr0) #check OS Type os=$(uname -o) echo -e '\E[32m'"Operating System Type :" $reset_terminal $os查看全部
-
if [ $# -eq 0 ]; then #$1,$2等等分別表示第一個(gè)、第二個(gè)參數(shù) #$@, $*表示所有的參數(shù) #$#表示位置參數(shù)的數(shù)目(對(duì)腳本來說,是運(yùn)行腳本時(shí)所帶的參數(shù);對(duì)函數(shù)來說,是函數(shù)調(diào)用時(shí)傳入的參數(shù))。數(shù)值的比較用 -eq ,字符串的比較才用 = #腳本的意思就是判斷是否有參數(shù),如果沒有的話執(zhí)行then后面的命令查看全部
-
/dev/null 2>&1這條命令的意思是將標(biāo)準(zhǔn)輸出和錯(cuò)誤輸出全部重定向到/dev/null中,即將產(chǎn)生的所有信息丟棄. command > file 2>file VS command > file 2>&1 首先 command > file 2>file 的意思是將命令所產(chǎn)生的標(biāo)準(zhǔn)輸出信息,和錯(cuò)誤的輸出信息送到file中 command > file 2>file 這樣的寫法,stdout和stderr都直接送到file中, file會(huì)被打開兩次,這樣stdout和stderr會(huì)互相覆蓋,這樣寫相當(dāng)使用了FD1和FD2兩個(gè)同時(shí)去搶占file 的管道.而command >file 2>&1 這條命令就將stdout直接送向file, stderr 繼承了FD1管道后,再被送往file,此時(shí),file 只被打開了一次,也只使用了一個(gè)管道FD1,它包括了stdout和stderr的內(nèi)容.從IO效率上,前一條命令的效率要比后面一條的命令效率要低 關(guān)于shell中:>/dev/null 2>&1 詳解 1:> 代表重定向到哪里,例如:echo "123" > /home/123.txt 2:/dev/null 代表空設(shè)備文件 3:2> 表示stderr標(biāo)準(zhǔn)錯(cuò)誤 4:& 表示等同于的意思,2>&1,表示2的輸出重定向等同于1 5:1 表示stdout標(biāo)準(zhǔn)輸出,系統(tǒng)默認(rèn)值是1,所以">/dev/null"等同于 "1>/dev/null" 因此,>/dev/null 2>&1也可以寫成“1> /dev/null 2> &1” PS:Command >/dev/null 2>&1 相當(dāng)于stdout="/dev/null" stderr="$stdout" 這時(shí),stderr也等于"/dev/null"了 結(jié)果是標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)錯(cuò)誤都指向了/dev/null, 也就是所有的輸出都被我們丟棄 Command 2>&1 >/dev/null 相當(dāng)于stderr="$stdout" stderr指向了屏幕,因?yàn)閟tdout這時(shí)還是指向屏幕!stdout="/dev/null" stdout指向了/dev/null,但不會(huì)影響到 stderr的指向 結(jié)果是標(biāo)準(zhǔn)錯(cuò)誤仍然被打印到屏幕上, 而標(biāo)準(zhǔn)輸出被丟棄A=100; B=A和 B=A, A=100查看全部
舉報(bào)
0/150
提交
取消