查看linux系统的信息

Posted 求知若饥,虚心若愚。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查看linux系统的信息相关的知识,希望对你有一定的参考价值。

#!/bin/sh
##################################################
#function:get host‘s information
#Author:eric-chen

export filename
filename=linuxHostInfo.dat
datadir=./
echo -n "">$datadir$filename
function WriteIndex()
{ 
  datadir=./
  time=`date +%Y-%m-%d" "%H:%M:%S`
  firstipadd=`ifconfig -a|grep "inet addr"|awk -F ":" ‘{print $2}‘|awk ‘{if ( NR==1 )print $1}‘`
  echo -e  ",,$firstipadd,Linux,$2,$3,$time,$1|">>$datadir$filename
}	

export -f WriteIndex

function GetHostinfo()
{
  HostOS=`cat /etc/issue |sed -n ‘1p‘`
  #echo $HostOS
  WriteIndex "$HostOS" "" HostOS
  HostModel=`dmidecode|grep "Product Name"|sed -n ‘1p‘|awk -F ":" ‘{print $2}‘`
  WriteIndex "$HostModel" "" HostModel
  HostName=`hostname`
  WriteIndex $HostName "" HostName
  IPAddress=`ifconfig -a|grep "inet addr"|awk -F ":" ‘{print $2}‘|awk ‘{if ( NR==1 )print $1}‘`
  WriteIndex $IPAddress "" IPAddress
  KernelVersion=`cat /proc/version|awk ‘{print $3}‘`
  WriteIndex $KernelVersion "" KernelVersion
  OSBits=`getconf LONG_BIT`
  WriteIndex $OSBits "" OSBits
  CpuNumber=`cat /proc/cpuinfo|grep "processor"|wc -l`
  WriteIndex $CpuNumber "" CpuNumber
  Uptime=`cat /proc/uptime| awk -F. ‘{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;printf("%d天%d小时%d分",run_days,run_hour,run_minute)}‘`
  WriteIndex $Uptime "" Uptime
  HostTime=`date +%Y-%m-%d" "%H:%M:%S`
  WriteIndex "$HostTime" "" HostTime
  RemoteTime=$1
  HostSecondTime=`date +%s`
  Deviation=`echo $(($HostSecondTime-$RemoteTime))|awk -F. ‘{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("%d天%d小时%d分%d秒",run_days,run_hour,run_minute,run_second)}‘`
  WriteIndex "$Deviation" "" HostTimeDeviation
}

GetHostinfo "[email protected]"

clear
cat $filename

  

以上是关于查看linux系统的信息的主要内容,如果未能解决你的问题,请参考以下文章

linux中怎么查看mysql数据库版本

Linux系统glibc库版本信息查看

linux系统怎么查看电脑硬件信息

Linux进程管理

怎么查看linux系统硬件信息

如何查看linux系统CPU信息