• 查看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 "$@"
    
    clear
    cat $filename
    

      

  • 相关阅读:
    ThinkPHP模版验证要注意的地方
    js关闭子页面刷新父页面
    js替换字符指定字符方法
    Ubuntu安装后的一些配置
    Docker入门
    RabbitMQ 基本概念和使用
    JAX-WS注解
    Linux 常用命令
    ubuntu16.04 搭建 Mysql服务器
    ubuntu 安装 Tomcat
  • 原文地址:https://www.cnblogs.com/jycjy/p/8316031.html
Copyright © 2020-2023  润新知