Shell Auto-Collection server hardware system information displayed via Web page

Source: Internet
Author: User

1. Script section #!/bin/bash#auto get system infoecho -e  "\033[34m\033[1m" cat <<EOF++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++welcome to  use system coolect++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++eofip_info= ' ifconfig eth1|grep  "bcast" |awk  ' {print $2} '   |cut -d: -f 2 ' cpu_info1= ' cat /proc/cpuinfo |grep  "Model name"  |awk  -F:  ' {print $2} ' |sed  ' s/^//g ' |awk  ' {print $1,$3,$4, $NF} ' cpu_info2= ' cat / proc/cpuinfo |grep  "Physical id" |sort|uniq -c|wc -l ' serv_info= ' Hostname |tail  -1 ' disk_info= ' fdisk -l|grep  "Disk" | grep -v  "identifier" |awk  ' {print  $2,$3,$4} ' | sed  ' s/,//g ' mem_info= ' free -m |grep  ' mem ' |awk  ' {print  ' total ', $1,$2 "M"} ' load_info= ' uptime|awk  ' {print  "currentload: " $ (NF-2)} ' |sed  ' s/\,//g ' make_info= ' BeiJing_IDC ' echo  -e  "\033[32m-------------------------------------\033[1m" echo ipaddr:${ip_info}echo  HOSTNAME: $serv _infoecho cpu_info:${cpu_info1}x${cpu_info2}echo disk_info: $disk _infoecho mem_ INFO: $mem _infoecho load_info: $load _infoecho -e -n  "\033[36m you want to  write the data to the databases?\033[1m ";read ensureif [ " $ Ensure " ==  yes"  -o  "$ensure"  ==  "y"  -o  "$ensure"  ==  "Y"  ];thenecho  "------------------------" #echo  -e  ' \033[31mmysql -uroot -p  123456 -d audit -e '   ' insert into audit_audit_system values (', ${ip_info} ' , ' $serv _info ', ' ${cpu_info1}x${cpu_info2} ', ' $disk _info ', ' $mem _info ', ' $load _info ', ' $make _info ') '   '  \ 033[0m ' Mysql -uroot -proot -d zzx -e  "insert into systeminfo values (' ', ' ${ip_info} ', ' $serv _info ', ' ${ Cpu_info1}x${cpu_info2} ', ' $disk _info ', ' $mem _info ', ' $load _info ', ' $make _info '); elseecho  "What exit" exitfi# inserting data into the database #mysql -uroot -proot -e  ' Use zzx;select  * from syslog; ' | sed  ' s/-//g ' |grep -v  "id" 2. Database creation create table  ' systeminfo '   (   ' id ')  int (one)  NOT NULL AUTO_INCREMENT,   ' Ip_info '  varchar ( not null) ,  //host ip   ' Serv_info '  varchar ( not null,//hostname    ' cpu_info '   varchar ( not null,//cup) model    ' Disk_info '  varchar ()  not null,//disk     ' Mem_info '  varchar ( not null,//) memory    ' Load_info '  varchar ( not)  null,//load    ' Mark_info '  varchar (a)  not null,//remarks   primary key   (' id '),   unique key  ' Ip_info '   (' ip_info '),  unique key  ' ip_info_2 '   (' ip_info '))  engine=myisam default charset=latin1;3.web page display 

Show Results:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/F7/wKioL1ZGFUfjycNEAAA1k0jKwpc199.png "title=" 1.png " alt= "Wkiol1zgfufjycneaaa1k0jkwpc199.png"/>

Shell Auto-Collection server hardware system information displayed via Web page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.