在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    如何查看服務器配置信息

    學習Linux命令,我們需要有一臺Linux服務器。有了服務器,就想看看它的性能怎樣。翻出自己較早前寫的一個腳本,一鍵查看系統(tǒng)大部分參數(shù)。在這個基礎上,對命令進行了注釋,方便。

    This is an old script used to display the hardware information of a server. Generated infos include hostname, IP, Bits-of-OS, CPU, memory, disk .etc.

    #!/bin/bash# -*- coding: UTF-8 -*-#屏幕輸出echo “This lists the information of this computer.”#輸出空行echo##tput setaf [0-7] –使用ANSI轉(zhuǎn)義設置前景色#Color Code for tput: ?#0 – Black ?#1 – Red ?#2 – Green ?#3 – Yellow ?#4 – Blue ?#5 – Magenta ?#6 – Cyan ?#7 – White ?##tput sgr0 – Turn off all attributes ##`hostname` 返回主機名#`/sbin/ifconfig` ifconfig是linux中用于顯示或配置網(wǎng)絡設備(網(wǎng)絡接口卡)的命令# sed -n ‘2p’ 顯示文件的第2行# cut是一個選取命令,就是將一段數(shù)據(jù)經(jīng)過分析,取出我們想要的內(nèi)容# -d :自定義分隔符,默認為制表符。-f :與-d一起使用,指定顯示哪個區(qū)域。echo “Hostname is $(tput setaf 3)`hostname`$(tput sgr0),Ip address is $(tput setaf 3)`/sbin/ifconfig | sed -n ‘2p’ | cut -d ‘:’ -f 2 | cut -d ‘ ‘ -f 1`.$(tput sgr0)”#—————————————————————————#uname -a :顯示系統(tǒng)名、節(jié)點名稱、操作系統(tǒng)的發(fā)行版號、操作系統(tǒng)版本、運行系統(tǒng)的機器 ID 號。# Linux ehbio 2.6.32-642.4.2.el6.x86_64 #1 SMP Tue Aug 23 19:58:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux#nuclear=`uname -a | cut -d ‘ ‘ -f 3`bitInfo=`uname -a | cut -d ‘ ‘ -f 12`# if語句,判斷系統(tǒng)是64位還是32位if test $bitInfo == “x86_64”; then ? ?bit=64else ? ?bit=32fi#tput bold – Set bold mode #head -n ? ?打印每個文件的前n行,而不是打印默認的前10行# /etc/issue 查看系統(tǒng)登陸信息、發(fā)行版本信息#echo “The $(tput bold)${bit}$(tput sgr0) bt operating system is $(tput bold) `head -n 1 /etc/issue`$(tput sgr0), Nuclear info is $(tput setaf 1)${nuclear}$(tput sgr0).”#打印空行echo# `sed -n ‘5p’ /proc/cpuinfo 得到如下結(jié)果model name ? ?: Intel(R) Xeon(R) CPU G7-4809 v2 @ 4.90GHz#sed ‘s/[ ] */ /g’貌似什么也沒做啊,這是不對的,這句話是把多個相連空格變?yōu)閱蝹€空格echo “The CPU is$(tput setaf 4)`sed -n ‘5p’ /proc/cpuinfo | cut -d ‘:’ -f 2 | sed ‘s/[ ] */ /g’`$(tput sgr0).”echoecho “There are $(tput setaf 5)`cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l`$(tput sgr0) physical cpu, each physical cpu has$(tput setaf 5)`sed -n ’12p’ /proc/cpuinfo | cut -d ‘:’ -f 2`$(tput sgr0) cores,$(tput setaf 5)`sed -n ’10p’ /proc/cpuinfo | cut -d ‘:’ -f 2`$(tput sgr0) threads.”echoecho “There are $(tput setaf 5)`cat /proc/cpuinfo | grep “cpu cores” | wc -l`$(tput sgr0) logical cpu.”# sed元字符集 ^ 匹配行開始,如:/^sed/匹配所有以sed開頭的行。* 匹配0個或多個字符,如:/ *sed/匹配所有模板是一個或多個空格后緊跟sed的行。#sed ‘s/^ *//g’ 刪除開頭的空格#bc命令是一種支持任意精度的交互執(zhí)行的計算器語言 bc -l 定義使用的標準數(shù)學庫mem=`head -n 1 /proc/meminfo | cut -d ‘:’ -f 2 | sed ‘s/^ *//g’ | cut -d ‘ ‘ -f 1`memInM=$(echo “$mem/1024/1024” | bc -l)echoecho “The memory of this server is $(tput setaf 5)${memInM}$(tput sgr0)G.”echoecho “The disk information is :”#linux中df命令的功能是用來檢查linux服務器的文件系統(tǒng)的磁盤空間占用情況??梢岳迷撁顏慝@取硬盤被占用了多少空間,目前還剩下多少空間等信息。#-h 方便閱讀方式顯示echo “`df -h`”

    鄭重聲明:本文內(nèi)容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場,版權(quán)歸原作者所有,如有侵權(quán)請聯(lián)系管理員(admin#wlmqw.com)刪除。
    上一篇 2022年6月18日 12:05
    下一篇 2022年6月18日 12:05

    相關推薦

    聯(lián)系我們

    聯(lián)系郵箱:admin#wlmqw.com
    工作時間:周一至周五,10:30-18:30,節(jié)假日休息