#!/bin/sh################################################## #function: Get host ' s information# Author:eric-chenexport filenamefilename=linuxhostinfo.datdatadir=./echo-n "" > $datadir $filenamefunction Writeindex () {datadir=./time= ' date +%y-%m-%d ""%h:%m:%s ' firstipadd= ' ifconfig-a|grep "inet addr" |awk-f ":" ' {print $ ' |awk ' {if (nr==1) print ' "Echo-e", $firstipadd, Linux,$2,$3, $time, $1| " >> $datadir $filename}export-f writeindexfunction gethostinfo () {hostos= ' cat/etc/issue |sed-n ' 1p ' #echo $HostOS Writeindex "$HostOS" "" Hostos hostmodel= ' Dmidecode|grep "Product Name" |sed-n ' 1p ' |awk-f ": ' {print $} ' Writeinde X "$HostModel" "" Hostmodel hostname= ' HostName ' writeindex $HostName "" HostName ipaddress= ' Ifconfig-a|grep "inet addr "|awk-f": ' {print $} ' |awk ' {if (nr==1) print '} ' Writeindex $IPAddress "" IPAddress kernelversion= ' cat/proc/vers Ion|awk ' {print $} ' 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= ($ 86400)/3600;run_minute= ($ 3600)/60;printf ("%d days%d hours%d minutes", Run_days,run_ Hour,run_minute} "Writeindex $Uptime" "Uptime hosttime= ' date +%y-%m-%d" "%h:%m:%s ' Writeindex" $HostTime "" "Hosttim E remotetime=$1 hostsecondtime= ' date +%s ' deviation= ' echo $ (($HostSecondTime-$RemoteTime)) |awk-f. ' {run_days=$1/8640 0;run_hour= ($ 86400)/3600;run_minute= ($ 3600)/60;run_second=$1% 60;printf ("%d days%d hours%d minutes%d seconds", Run_days,run_hour, Run_minute,run_second)} "Writeindex" $Deviation "" "Hosttimedeviation}gethostinfo" [email protected] "Clearcat $filename
View information for Linux systems