├── LICENSE ├── Linux系统测评之家设计文档.doc ├── README ├── README.md ├── systemtest_0.1_amd64.deb ├── systemtest_0.1_i386.deb ├── 测试文档_Linux系统测评之家.doc └── 源代码 ├── systemtest ├── about_us.cpp ├── about_us.h ├── boot_start_time.cpp ├── boot_start_time.h ├── buttom_widget.cpp ├── buttom_widget.h ├── common.cpp ├── common.h ├── dfdf.qrc ├── drop_shadow_widget.cpp ├── drop_shadow_widget.h ├── get_point.h ├── hardwareinfo.sh ├── hardwareinfo.sh~ ├── input_pwd.cpp ├── input_pwd.h ├── main.cpp ├── main_menu.cpp ├── main_menu.h ├── main_page_five.cpp ├── main_page_five.h ├── main_page_four.cpp ├── main_page_four.h ├── main_page_one.cpp ├── main_page_one.h ├── main_page_serven.cpp ├── main_page_serven.h ├── main_page_six.cpp ├── main_page_six.h ├── main_page_three.cpp ├── main_page_three.h ├── main_page_two.cpp ├── main_page_two.h ├── main_widget.cpp ├── main_widget.h ├── net_speed.cpp ├── net_speed.h ├── netspeed.sh ├── push_button.cpp ├── push_button.h ├── show_percent_page.cpp ├── show_percent_page.h ├── sources │ ├── 1_big.jpg │ ├── 2_big.png │ ├── 3_big.jpg │ ├── 4_big.jpg │ ├── 5_big.jpg │ ├── 6_big.jpg │ ├── 7_big.jpg │ ├── 8_big.png │ ├── arrow_down.png │ ├── check.png │ ├── close.png │ ├── close_hover.png │ ├── close_pressed.png │ ├── cpu1.jpg │ ├── cpu2.jpg │ ├── disk1.jpg │ ├── disk2.jpg │ ├── disk3.jpg │ ├── disk4.jpg │ ├── feedback.png │ ├── feedback_hover.png │ ├── feedback_pressed.png │ ├── func1.png │ ├── func2.png │ ├── func3.png │ ├── func4.png │ ├── func5.png │ ├── func6.png │ ├── func7.png │ ├── func8.png │ ├── html │ │ ├── index.html │ │ └── picture │ │ │ ├── 1.jpg │ │ │ ├── new_1.png │ │ │ ├── new_10.png │ │ │ ├── new_11.jpg │ │ │ ├── new_12.png │ │ │ ├── new_13.jpg │ │ │ ├── new_14.png │ │ │ ├── new_15.jpg │ │ │ ├── new_16.png │ │ │ ├── new_2.png │ │ │ ├── new_3.png │ │ │ ├── new_4.png │ │ │ ├── new_5.png │ │ │ ├── new_6.jpg │ │ │ ├── new_7.png │ │ │ ├── new_8.jpg │ │ │ └── new_9.jpg │ ├── img │ │ ├── loading.png │ │ └── skin │ │ │ ├── 12_big.png │ │ │ ├── 13.png │ │ │ ├── 13_big.png │ │ │ ├── 14.png │ │ │ ├── 14_big.png │ │ │ ├── 15.jpg │ │ │ ├── 15_big.jpg │ │ │ ├── 16.jpg │ │ │ ├── 16_big.jpg │ │ │ ├── 17.jpg │ │ │ ├── 17_big.jpg │ │ │ ├── 18.jpg │ │ │ ├── 18_big.jpg │ │ │ ├── 19.jpg │ │ │ ├── 19_big.jpg │ │ │ ├── 20.jpg │ │ │ ├── 20_big.jpg │ │ │ ├── 21.jpg │ │ │ ├── 21_big.jpg │ │ │ ├── 22.jpg │ │ │ ├── 22_big.jpg │ │ │ ├── 23.jpg │ │ │ ├── 23_big.jpg │ │ │ └── 9.png │ ├── index.html │ ├── logo.ico │ ├── logo.png │ ├── logo1.png │ ├── logo1.rc │ ├── logo1.rc~ │ ├── menu.png │ ├── menu_hover.png │ ├── menu_pressed.png │ ├── min.png │ ├── min_hover.png │ ├── min_pressed.png │ ├── net1.jpg │ ├── net2.jpg │ ├── net3.jpg │ ├── net4.jpg │ ├── os1.jpg │ ├── os2.jpg │ ├── os3.jpg │ ├── power.png │ ├── resources.qrc │ ├── score.gif │ ├── score.png │ ├── security_1.png │ ├── security_2.png │ ├── security_3.png │ ├── security_4.png │ ├── skin.png │ ├── skin_hover.png │ ├── skin_pressed.png │ └── sys_test.ts ├── sys_test_widget.cpp ├── sys_test_widget.h ├── systemtest.pro ├── systemtest.pro.user ├── systemtest.pro.user.18 ├── systemtest.pro.user.3.2-pre1 ├── test.h~ ├── testpwd.sh ├── title_widget.cpp ├── title_widget.h ├── tool_button.cpp ├── tool_button.h ├── user_msg.cpp ├── user_msg.h ├── wait_dialog.cpp └── wait_dialog.h └── 脚本 ├── README ├── README~ ├── boot_start ├── time1.sh └── time1.sh~ ├── cpu_show ├── cpu_cal_rate.sh ├── cpu_show1.sh └── cpu_show2.sh ├── disk ├── diskinfo.sh ├── diskinfosu.sh ├── disktool │ ├── dd_test.sh │ ├── dd_test.sh~ │ ├── disk_hdparm.sh │ ├── disk_hdparm.sh~ │ ├── hddtemp_install.sh │ ├── hddtemp_judge.sh │ ├── hddtemp_judge.sh~ │ ├── hddtemp_remove.sh │ ├── hddtemp_remove.sh~ │ ├── hddtemp_tool.sh │ ├── hddtemp_tool.sh~ │ ├── install_hddtemp.sh~ │ ├── install_sysstat.sh~ │ ├── iostat_tool.sh │ ├── iostat_tool.sh~ │ ├── remove_hddtemp.sh~ │ ├── remove_sysstat.sh~ │ ├── sysstat_install.sh │ ├── sysstat_judge.sh │ ├── sysstat_judge.sh~ │ └── sysstat_remove.sh └── io_diskstats.sh ├── flush_percent ├── cpu-mem.sh ├── cpu-mem.sh~ ├── cpu_rate.sh └── mem_rate.sh ├── home_info ├── ethnetspeedhome.sh ├── homeinfo_btime.sh ├── homeinfousr.sh ├── netspeedhome.sh └── wlannetspeedhome.sh ├── mem_show ├── mem_show1.sh └── mem_show2.sh ├── netinfo ├── 1 │ ├── netinfo.sh │ ├── netinfo.sh~ │ ├── netinfosu.sh │ └── netinfosu.sh~ ├── 2 │ ├── ethavgflow.sh │ ├── ethavgflow.sh~ │ ├── netavg.sh~ │ ├── netspeed.sh │ ├── netspeed.sh~ │ ├── tcp_rrate.sh~ │ ├── tcp_udp.sh │ ├── tcp_udp.sh~ │ ├── test_netlink.sh │ ├── wlanavgflow.sh │ ├── wlanavgflow.sh~ │ └── wlanethavgflow.sh~ ├── 3 │ ├── firewall.sh │ └── net_secure.sh └── 4 │ ├── eth.sh │ ├── eth.sh~ │ ├── wlan.sh │ └── wlan.sh~ ├── otherinfo ├── hardwareinfo.sh ├── hardwareinfomore.sh ├── startup.sh ├── startup.sh~ ├── systeminfo.sh └── systemrun.sh ├── security ├── 1 │ ├── 1.sh │ ├── 2.sh │ └── 2.sh~ ├── 2 │ ├── 1.sh │ └── 2.sh ├── 3 │ ├── part1.sh │ ├── part1.sh~ │ ├── part2.sh │ ├── part2.sh~ │ ├── part3.sh │ └── part3.sh~ ├── 4 │ ├── part1.sh │ ├── part1.sh~ │ ├── remove.sh │ ├── remove.sh~ │ ├── test.sh │ ├── test.sh~ │ ├── test1.sh │ └── test1.sh~ ├── 5 │ ├── bin.2015-01-20_15_55_38.file │ ├── part1.sh │ ├── part1.sh~ │ ├── remove.sh │ ├── remove.sh~ │ ├── test.sh │ ├── test.sh~ │ ├── test1.sh │ └── test1.sh~ └── 6 │ ├── part1.sh │ ├── part1.sh~ │ ├── remove.sh │ ├── remove.sh~ │ ├── test.sh │ ├── test.sh~ │ ├── test1.sh │ └── test1.sh~ ├── sys_test ├── arp_secure.sh ├── checkdisk.sh ├── cpu_hyper.sh ├── cpu_iowait.sh ├── cpu_run_threads.sh ├── cpu_sys_rate.sh ├── cpu_user_rate.sh ├── cpu_virtual.sh ├── earntime.sh ├── firefox_cookies.sh ├── google_cookies.sh ├── google_history.sh ├── init_arp.sh ├── io_await.sh ├── io_reqnum.sh ├── io_svctm.sh ├── io_util.sh ├── junk_files.sh ├── mem_user.sh ├── recent_used.sh └── 体检 │ ├── get_point.h │ └── 一键测评 │ ├── arp_secure.sh │ ├── arp_secure.sh~ │ ├── await.sh~ │ ├── checkdisk.sh │ ├── checkdisk.sh~ │ ├── checkroot.sh │ ├── checkroot.sh~ │ ├── cpu_evaluation │ ├── cpu_hyper.sh │ ├── cpu_hyper.sh~ │ ├── cpu_iowait.sh │ ├── cpu_iowait.sh~ │ ├── cpu_run_threads.sh │ ├── cpu_run_threads.sh~ │ ├── cpu_sys_rate.sh │ ├── cpu_sys_rate.sh~ │ ├── cpu_user_rate.sh │ ├── cpu_user_rate.sh~ │ ├── cpu_virtual.sh │ └── cpu_virtual.sh~ │ ├── cpu_hyper.sh │ ├── cpu_iowait.sh │ ├── cpu_run_threads.sh │ ├── cpu_sys_rate.sh │ ├── cpu_user_rate.sh │ ├── cpu_virtual.sh │ ├── earntime.sh │ ├── firefox_cookies.sh │ ├── firefox_cookies.sh~ │ ├── google_cookies.sh │ ├── google_cookies.sh~ │ ├── google_history.sh │ ├── google_history.sh~ │ ├── init_arp.sh │ ├── init_arp.sh~ │ ├── io_await.sh │ ├── io_await.sh~ │ ├── io_reqnum.sh │ ├── io_reqnum.sh~ │ ├── io_svctm.sh │ ├── io_svctm.sh~ │ ├── io_util.sh │ ├── io_util.sh~ │ ├── iptables_judge.sh │ ├── junk_files.sh │ ├── junk_files.sh~ │ ├── mem_evaluation │ ├── mem_user.sh │ └── mem_user.sh~ │ ├── mem_user.sh │ ├── recent_used.sh │ ├── recent_used.sh~ │ ├── startup_items.sh │ ├── startup_items.sh~ │ ├── 开机时间 │ └── earntime.sh │ ├── 测评标准 │ └── 测评标准~ ├── sys_test_result ├── show_result.sh ├── show_result.sh~ └── test.sh~ └── testpwd └── testpwd.sh /Linux系统测评之家设计文档.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/Linux系统测评之家设计文档.doc -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 32位机systemtest_0.1_i386.deb 2 | 64位机systemtest_0.1_amd64.deb 3 | 4 | 安装命令: 5 | sudo dpkg -i xxx.deb 6 | 卸载命令: 7 | sudo dpkg -r xxx 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Le-SystemDetection 2 | 这是一款适用于Ubuntu系统的操作系统测评软件,名为乐测评, 主要对系统进行如下六个方面的性能检测:CPU、内存、磁盘&IO、网络、开机速度、系统安全,软硬件方面都会进行较全面的检测。每个方面先检测操作系统基本信息,让用户对自己的系统有个基本了解。然后进行比较专业的性能测试,网络方面还有安全测试。总体上我们的功能很全,系统性能测试是主体,还有很多系统基本信息,给用户提供了比较全面的服务。 3 | -------------------------------------------------------------------------------- /systemtest_0.1_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/systemtest_0.1_amd64.deb -------------------------------------------------------------------------------- /systemtest_0.1_i386.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/systemtest_0.1_i386.deb -------------------------------------------------------------------------------- /测试文档_Linux系统测评之家.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/测试文档_Linux系统测评之家.doc -------------------------------------------------------------------------------- /源代码/systemtest/about_us.cpp: -------------------------------------------------------------------------------- 1 | #include "about_us.h" 2 | #include "push_button.h" 3 | #include "common.h" 4 | #include 5 | #include 6 | 7 | About_Us::About_Us(QWidget *parent) : QWidget(parent) 8 | { 9 | this->setFixedSize(520,290); 10 | this->setGeometry(400,400,400,400); 11 | this->setWindowTitle("关于Le测评"); 12 | //this->setContentsMargins(170,170,170,170); 13 | QVBoxLayout *layout = new QVBoxLayout(); 14 | 15 | QFont ft; 16 | ft.setPointSize(18); 17 | ft.setBold(true); 18 | content = new QLabel("LE乐测评系统监测"); 19 | content->setFont(ft); 20 | 21 | QFont ft1; 22 | ft1.setPointSize(11); 23 | ft1.setBold(true); 24 | //content = new QLabel("Linux evaluation 软件是一款集中测试,评估于一体的系统性能测试软件,快来感受一下吧!"); 25 | lastly = new QLabel("lastly:2014-1-8"); 26 | lastly->setFont(ft1); 27 | 28 | 29 | 30 | version = new QLabel("version:1.0.0.0"); 31 | version->setFont(ft1); 32 | 33 | chmod = new QLabel("copyright Linux Evaluation.All rights Reserved."); 34 | chmod->setFont(ft1); 35 | 36 | 37 | layout->addWidget(content); 38 | layout->addWidget(lastly); 39 | layout->addWidget(version); 40 | layout->addWidget(chmod); 41 | layout->addStretch(); 42 | layout->setContentsMargins(10,0,5,0); 43 | setLayout(layout); 44 | } 45 | 46 | About_Us::~About_Us() 47 | { 48 | 49 | } 50 | -------------------------------------------------------------------------------- /源代码/systemtest/about_us.h: -------------------------------------------------------------------------------- 1 | /* 2 | *关于我们 3 | */ 4 | #ifndef ABOUT_US_H 5 | #define ABOUT_US_H 6 | 7 | #include 8 | #include 9 | #include "drop_shadow_widget.h" 10 | class About_Us : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit About_Us(QWidget *parent = 0); 15 | ~About_Us(); 16 | 17 | signals: 18 | 19 | public slots: 20 | private: 21 | QLabel *content,*lastly,*version,*chmod; 22 | }; 23 | 24 | #endif // ABOUT_US_H 25 | -------------------------------------------------------------------------------- /源代码/systemtest/boot_start_time.h: -------------------------------------------------------------------------------- 1 | /* 2 | 显示开机时间项 3 | */ 4 | 5 | #ifndef BOOT_START_TIME_H 6 | #define BOOT_START_TIME_H 7 | 8 | #include "drop_shadow_widget.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class Boot_Start_Time : public DropShadowWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit Boot_Start_Time(QWidget *parent = 0); 20 | ~Boot_Start_Time(); 21 | 22 | protected: 23 | QPushButton *close_button; 24 | QTextBrowser *show_msg; 25 | QString skin_name; 26 | QProcess *pro; 27 | QString out; 28 | 29 | virtual void paintEvent(QPaintEvent *event); 30 | 31 | public slots: 32 | // void close_myself(); 33 | }; 34 | 35 | 36 | #endif // BOOT_START_TIME_H 37 | -------------------------------------------------------------------------------- /源代码/systemtest/buttom_widget.cpp: -------------------------------------------------------------------------------- 1 | #include "buttom_widget.h" 2 | 3 | Buttom_Widget::Buttom_Widget(QWidget *parent) : 4 | QWidget(parent) 5 | { 6 | QFont ft; 7 | // ft.setBold(true); 8 | bottom_layout = new QHBoxLayout(); 9 | contract_label = new QLabel("请联系我们@LE乐测评"); 10 | contract_label->setStyleSheet("color:#27408B"); 11 | contract_label->setFont(ft); 12 | bottom_layout->addWidget(contract_label,0,Qt::AlignCenter); 13 | bottom_layout->setContentsMargins(5,0,0,0); 14 | setLayout(bottom_layout); 15 | // this->setLayout(main_Layout); 16 | } 17 | -------------------------------------------------------------------------------- /源代码/systemtest/buttom_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | 底部窗口栏 3 | */ 4 | #ifndef BUTTOM_WIDGET_H 5 | #define BUTTOM_WIDGET_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class Buttom_Widget : public QWidget 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit Buttom_Widget(QWidget *parent = 0); 16 | 17 | protected: 18 | QLabel *learn_Label; 19 | QLabel *officer; 20 | 21 | signals: 22 | 23 | public slots: 24 | private: 25 | QHBoxLayout *bottom_layout; 26 | QLabel *contract_label; 27 | }; 28 | 29 | #endif // BUTTOM_WIDGET_H 30 | -------------------------------------------------------------------------------- /源代码/systemtest/common.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | QString PWD; 4 | int Flag_Read_Pwd; 5 | int Flag_Read_Pwd_times; 6 | int Flag_skin = 0; 7 | int Flag_Cancel; 8 | int Flag_Sys_Test_Page = 0; 9 | 10 | //int pp = 0; 11 | int Flag_Current_Main_Page; 12 | -------------------------------------------------------------------------------- /源代码/systemtest/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | 系统全局变量 3 | */ 4 | #ifndef COMMON_H 5 | #define COMMON_H 6 | 7 | #include 8 | 9 | #define DEFAULT_SKIN ":/skin/7_big" 10 | /*保存密码*/ 11 | extern QString PWD; 12 | /*密码操作标志*/ 13 | extern int Flag_Read_Pwd;//密码可读 14 | extern int Flag_Read_Pwd_times; 15 | 16 | extern int Flag_skin; //皮肤改变 17 | extern int Flag_Cancel; //取消操作 18 | 19 | extern int Flag_Sys_Test_Page;//是否一键检测页面 20 | 21 | //extern int pp; 22 | extern int Flag_Current_Main_Page; 23 | 24 | #endif // COMMON_H 25 | -------------------------------------------------------------------------------- /源代码/systemtest/dfdf.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /源代码/systemtest/drop_shadow_widget.cpp: -------------------------------------------------------------------------------- 1 | #include "drop_shadow_widget.h" 2 | DropShadowWidget::DropShadowWidget(QWidget *parent) 3 | : QDialog(parent) 4 | { 5 | setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); 6 | setAttribute(Qt::WA_TranslucentBackground); 7 | 8 | //初始化为未按下鼠标左键 9 | mouse_press = false; 10 | } 11 | 12 | DropShadowWidget::~DropShadowWidget() 13 | { 14 | 15 | } 16 | 17 | void DropShadowWidget::paintEvent(QPaintEvent *) 18 | { 19 | QPainterPath path; 20 | path.setFillRule(Qt::WindingFill); 21 | path.addRect(10, 10, this->width()-20, this->height()-20); 22 | 23 | QPainter painter(this); 24 | painter.setRenderHint(QPainter::Antialiasing, true); 25 | painter.fillPath(path, QBrush(Qt::white)); 26 | 27 | QColor color(0, 0, 0, 50); 28 | for(int i=0; i<10; i++) 29 | { 30 | QPainterPath path; 31 | path.setFillRule(Qt::WindingFill); 32 | path.addRect(10-i, 10-i, this->width()-(10-i)*2, this->height()-(10-i)*2); 33 | color.setAlpha(150 - qSqrt(i)*50); 34 | painter.setPen(color); 35 | painter.drawPath(path); 36 | } 37 | } 38 | 39 | void DropShadowWidget::mousePressEvent(QMouseEvent *event) 40 | { 41 | //只能是鼠标左键移动和改变大小 42 | if(event->button() == Qt::LeftButton) 43 | { 44 | mouse_press = true; 45 | } 46 | 47 | //窗口移动距离 48 | move_point = event->globalPos() - pos(); 49 | } 50 | 51 | void DropShadowWidget::mouseReleaseEvent(QMouseEvent *) 52 | { 53 | mouse_press = false; 54 | } 55 | 56 | void DropShadowWidget::mouseMoveEvent(QMouseEvent *event) 57 | { 58 | //移动窗口 59 | if(event->y() > 50) 60 | return; 61 | if(mouse_press) 62 | { 63 | QPoint move_pos = event->globalPos(); 64 | move(move_pos - move_point); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /源代码/systemtest/drop_shadow_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | 设置阴影边框 鼠标移动 3 | */ 4 | #ifndef DROP_SHADOW_WIDGET_H 5 | #define DROP_SHADOW_WIDGET_H 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class DropShadowWidget : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | 20 | explicit DropShadowWidget(QWidget *parent = 0); 21 | ~DropShadowWidget(); 22 | 23 | protected: 24 | 25 | void mousePressEvent(QMouseEvent *event); 26 | void mouseReleaseEvent(QMouseEvent *event); 27 | void mouseMoveEvent(QMouseEvent *event); 28 | virtual void paintEvent(QPaintEvent *event); 29 | 30 | private: 31 | 32 | QPoint move_point; //移动的距离 33 | bool mouse_press; //按下鼠标左键 34 | 35 | }; 36 | 37 | #endif // DROP_SHADOW_WIDGET_H 38 | -------------------------------------------------------------------------------- /源代码/systemtest/hardwareinfo.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: hardwareinfo.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 19时23分25秒 6 | ######################################################################### 7 | #!/bin/bash 8 | echo "33333333333" 9 | echo $1 |sudo -S echo "" 2> /dev/null 10 | if [ $? == 0 ];then 11 | echo 主板:lspci |grep Host | head -1 | awk '{for(i=4;i<=NF;i++) printf $i " "}' 12 | echo 主板厂商:`echo $1 | sudo -S dmidecode | grep -A 10 "Base Board Information" |grep Manufacturer | awk '{print $2,$3,$4}'` 13 | echo 版本:` echo $1 |sudo -S dmidecode | grep -A 10 "Base Board Information" | grep 'Version' | awk '{print $2 " " $3 " " $4}'` 14 | echo 序列号:`echo $1 | sudo -S dmidecode | grep -A 10 "Base Board Information" | grep 'Serial' | awk '{print $3}'` 15 | echo BIOS版本:`echo $1 | sudo -S dmidecode | grep -A 28 "BIOS Information" | grep 'Version' | awk '{print $2}'` 16 | echo BIOS日期:` echo $1 |sudo -S dmidecode | grep -A 28 "BIOS Information" | grep 'Release' | awk '{print $3}'` 17 | echo 集显生产厂商:`lspci | grep -i 'VGA'| sed '2d'| awk '{ print $5,$6 } '` 18 | echo 集显显卡型号:`lspci | grep -i 'VGA' | sed '2d' |awk '{for(i=5;i<=14;i++)printf $i""FS;print""}'` 19 | echo 独显型号`lspci | grep -i 'VGA' | sed '1d' | awk '{for(i=5;i<=9;i++)printf $i""FS;print""}'` 20 | echo "显卡:`lspci | grep VGA | cut -f2 -d "." |cut -f2 -d "0"`" 21 | echo "声卡:`lspci |grep Audio | cut -f3 -d ":"`" 22 | echo 声卡版本号: `alsactl -v | awk ' { print $3} '` 23 | echo 声卡音频设备: `lspci | grep -i audio | grep Intel | cut -f3 -d ":"` 24 | echo "网卡:`lspci | grep Ethernet | cut -f3 -d ":"`" 25 | 26 | cat /proc/cpuinfo | grep name | uniq | awk '$1="处理器",$2=null' 27 | echo "`cat /proc/cpuinfo | grep MHz | sort | uniq |awk '$1="运行速度 ",$2=null'| grep 运行速度` MHz" 28 | 29 | echo "USB:`lspci |grep USB | cut -f3 -d ":" | head -1`" 30 | echo "usb生产厂商:` lsusb | sort -k4r |head -1 | awk '{ print $7.$8,$9 }'`" 31 | echo "共有usb设备:` lsusb | sort -k2r | head -1 |awk '{ print $2 }'|cut -f3 -d "0"` 个" 32 | else 33 | echo "密码输入错误!" 34 | fi 35 | 36 | 37 | -------------------------------------------------------------------------------- /源代码/systemtest/hardwareinfo.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: hardwareinfo.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 19时23分25秒 6 | ######################################################################### 7 | #!/bin/bash 8 | echo $1 |sudo -S echo "" 2> /dev/null 9 | if [ $? == 0 ];then 10 | echo 主板:lspci |grep Host | head -1 | awk '{for(i=4;i<=NF;i++) printf $i " "}' 11 | echo 主板厂商:`echo $1 | sudo -S dmidecode | grep -A 10 "Base Board Information" |grep Manufacturer | awk '{print $2,$3,$4}'` 12 | echo 版本:` echo $1 |sudo -S dmidecode | grep -A 10 "Base Board Information" | grep 'Version' | awk '{print $2 " " $3 " " $4}'` 13 | echo 序列号:`echo $1 | sudo -S dmidecode | grep -A 10 "Base Board Information" | grep 'Serial' | awk '{print $3}'` 14 | echo BIOS版本:`echo $1 | sudo -S dmidecode | grep -A 28 "BIOS Information" | grep 'Version' | awk '{print $2}'` 15 | echo BIOS日期:` echo $1 |sudo -S dmidecode | grep -A 28 "BIOS Information" | grep 'Release' | awk '{print $3}'` 16 | echo 集显生产厂商:`lspci | grep -i 'VGA'| sed '2d'| awk '{ print $5,$6 } '` 17 | echo 集显显卡型号:`lspci | grep -i 'VGA' | sed '2d' |awk '{for(i=5;i<=14;i++)printf $i""FS;print""}'` 18 | echo 独显型号`lspci | grep -i 'VGA' | sed '1d' | awk '{for(i=5;i<=9;i++)printf $i""FS;print""}'` 19 | echo "显卡:`lspci | grep VGA | cut -f2 -d "." |cut -f2 -d "0"`" 20 | echo "声卡:`lspci |grep Audio | cut -f3 -d ":"`" 21 | echo 声卡版本号: `alsactl -v | awk ' { print $3} '` 22 | echo 声卡音频设备: `lspci | grep -i audio | grep Intel | cut -f3 -d ":"` 23 | echo "网卡:`lspci | grep Ethernet | cut -f3 -d ":"`" 24 | 25 | cat /proc/cpuinfo | grep name | uniq | awk '$1="处理器",$2=null' 26 | echo "`cat /proc/cpuinfo | grep MHz | sort | uniq |awk '$1="运行速度 ",$2=null'| grep 运行速度` MHz" 27 | 28 | echo "USB:`lspci |grep USB | cut -f3 -d ":" | head -1`" 29 | echo "usb生产厂商:` lsusb | sort -k4r |head -1 | awk '{ print $7.$8,$9 }'`" 30 | echo "共有usb设备:` lsusb | sort -k2r | head -1 |awk '{ print $2 }'|cut -f3 -d "0"` 个" 31 | else 32 | echo "密码输入错误!" 33 | fi 34 | 35 | 36 | -------------------------------------------------------------------------------- /源代码/systemtest/input_pwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | 密码检测系统 3 | */ 4 | #ifndef INPUT_PWD_H 5 | #define INPUT_PWD_H 6 | 7 | #include "drop_shadow_widget.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class Input_Pwd: public DropShadowWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit Input_Pwd(QDialog *parent = 0); 20 | ~Input_Pwd(); 21 | 22 | private: 23 | QLabel *tips; 24 | QLabel *remind; 25 | QLineEdit *pwd_edit; 26 | QPushButton *submit; 27 | QPushButton *cancel; 28 | 29 | QProcess *pro_pwd; 30 | QString out_pwd; 31 | 32 | protected: 33 | virtual void paintEvent(QPaintEvent *event); 34 | 35 | protected slots: 36 | void Set_Pwd(); 37 | void Set_Cancel(); 38 | public slots: 39 | 40 | }; 41 | 42 | #endif // INPUT_PWD_H 43 | -------------------------------------------------------------------------------- /源代码/systemtest/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main_widget.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | QApplication a(argc, argv); 13 | 14 | // QTranslator translator; 15 | // translator.load(QString(":")); 16 | // a.installTranslator(&translator); 17 | 18 | 19 | 20 | QSplashScreen splash(QPixmap(":/boot/img/loading.png")); 21 | splash.show(); 22 | a.processEvents(); 23 | Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop; 24 | splash.showMessage(QObject::tr("Setting up the MainWindow..."), topRight, Qt::white); 25 | 26 | QTest::qSleep(1000); 27 | splash.showMessage(QObject::tr("Loading modules..."), topRight, Qt::white); 28 | QTest::qSleep(1000); 29 | 30 | 31 | main_widget w; 32 | w.show(); 33 | splash.finish(&w); 34 | 35 | return a.exec(); 36 | } 37 | -------------------------------------------------------------------------------- /源代码/systemtest/main_menu.cpp: -------------------------------------------------------------------------------- 1 | #include "main_menu.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | Main_Menu::Main_Menu(QWidget *parent) : QMenu(parent) 9 | { 10 | this->setObjectName("menu"); 11 | about_us_widget = new About_Us; 12 | 13 | action_help_online = new QAction(this); 14 | action_help_online->setText("网上咨询"); 15 | action_about_us = new QAction(this); 16 | action_about_us->setText("关于我们"); 17 | 18 | // this->addSeparator(); 19 | this->addAction(action_help_online); 20 | this->addSeparator(); 21 | this->addAction(action_about_us); 22 | 23 | // connect(action_setting,SIGNAL(triggered()),this,SLOT(system_tips())); 24 | connect(action_help_online,SIGNAL(triggered()),this,SLOT(online_consultation())); 25 | connect(action_about_us,SIGNAL(triggered()),this,SLOT(showAboutUs())); 26 | 27 | } 28 | 29 | Main_Menu::~Main_Menu() 30 | { 31 | 32 | } 33 | void Main_Menu::online_consultation() 34 | { 35 | QString page; 36 | page = QString("http://linux.cn/article-3684-1.html"); 37 | QUrl url(page); 38 | QDesktopServices::openUrl(url); 39 | } 40 | void Main_Menu::showAboutUs() 41 | { 42 | about_us_widget->show(); 43 | } 44 | -------------------------------------------------------------------------------- /源代码/systemtest/main_menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | 主菜单 3 | */ 4 | #ifndef MAIN_MENU_H 5 | #define MAIN_MENU_H 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "about_us.h" 12 | 13 | class Main_Menu : public QMenu 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit Main_Menu(QWidget *parent = 0); 18 | ~Main_Menu(); 19 | 20 | signals: 21 | private: 22 | About_Us *about_us_widget; 23 | QAction *action_about_us,*action_help_online; 24 | //void create_menu(); 25 | public slots: 26 | private slots: 27 | void online_consultation(); 28 | void showAboutUs(); 29 | }; 30 | 31 | #endif // MAIN_MENU_H 32 | -------------------------------------------------------------------------------- /源代码/systemtest/main_page_one.h: -------------------------------------------------------------------------------- 1 | /* 2 | 首页 3 | */ 4 | #ifndef MAIN_PAGE_ONE_H 5 | #define MAIN_PAGE_ONE_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "user_msg.h" 20 | #include "net_speed.h" 21 | 22 | class Main_Page_One : public QDialog 23 | { 24 | Q_OBJECT 25 | public: 26 | explicit Main_Page_One(QWidget *parent = 0); 27 | ~Main_Page_One(); 28 | 29 | protected: 30 | 31 | QSplitter *main_splitter; 32 | /*左侧窗口*/ 33 | QWidget *left_widget; 34 | QLabel *label; 35 | QLabel *time_label; 36 | // QLabel *system_safe_label; 37 | QPushButton *sys_test_button; //立即体检按钮 38 | QProcess *pro; 39 | QString out; 40 | void home_btime(); 41 | QSplitter *right_splitter; 42 | 43 | User_Msg *right_top_widget; 44 | 45 | show_percent_page *right_center_widget; 46 | 47 | Net_Speed *right_bottom_widget; 48 | 49 | private: 50 | void initLeft(); 51 | void initRightTop(); 52 | void initRightCenter(); 53 | void initRightBottom(); 54 | void initRight(); 55 | 56 | 57 | signals: 58 | void go_sys_test_page(); 59 | public slots: 60 | 61 | }; 62 | 63 | #endif // MAIN_PAGE_ONE_H 64 | -------------------------------------------------------------------------------- /源代码/systemtest/main_page_serven.h: -------------------------------------------------------------------------------- 1 | /* 2 | 系统安全检测项 3 | */ 4 | #ifndef MAIN_PAGE_SERVEN_H 5 | #define MAIN_PAGE_SERVEN_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "input_pwd.h" 18 | #include "common.h" 19 | 20 | class main_page_serven : public QWidget 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit main_page_serven(QWidget *parent = 0); 25 | ~main_page_serven(); 26 | 27 | signals: 28 | private: 29 | QStackedWidget *stack; 30 | QWidget *widget_1,*widget_2,*widget_3,*widget_4,*widget_5,*widget_6; 31 | QListWidget *list; 32 | QTextBrowser *text_1,*edit_1,*edit_2,*edit_3 ,*broswer_1,*broswer_2; 33 | QString out; 34 | QProcess *pro; 35 | QPushButton *button_1,*button_2; 36 | QHBoxLayout *layout_1; 37 | QVBoxLayout *layout_2; 38 | QLabel *line_0,*line_1,*line_2,*line_3; 39 | Input_Pwd *input_pwd_widget ; 40 | void init_widget1(),init_widget2(),init_widget3(),init_widget4(),init_widget5(),init_widget6(); 41 | void show_edit_1(); 42 | //void user_show_1(),user_show_2(); 43 | QTextBrowser *widget4_text,*widget5_text,*widget6_text; 44 | 45 | public slots: 46 | private slots: 47 | void dentry(); 48 | void compare(); 49 | void user_show_1(); 50 | void user_show_2(); 51 | void init_bash(int n); 52 | //void check_sysstat(); 53 | //第4个界面 54 | void check1(); 55 | void compare1(); 56 | //void remove1(); 57 | void check2(); 58 | void compare2(); 59 | void check3(); 60 | void compare3(); 61 | 62 | protected: 63 | 64 | bool eventFilter(QObject *obj, QEvent *event); 65 | }; 66 | 67 | #endif // MAIN_PAGE_SERVEN_H 68 | -------------------------------------------------------------------------------- /源代码/systemtest/main_page_six.h: -------------------------------------------------------------------------------- 1 | /* 2 | 系统检测项 3 | */ 4 | #ifndef MAIN_PAGE_SIX_H 5 | #define MAIN_PAGE_SIX_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "qprocess.h" 13 | #include "common.h" 14 | #include "input_pwd.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | class Main_Page_six : public QWidget 24 | { 25 | Q_OBJECT 26 | public: 27 | explicit Main_Page_six(QWidget *parent = 0); 28 | 29 | protected: 30 | /*列表窗口*/ 31 | void init_list_widget(); 32 | QListWidget *list; 33 | QStackedWidget *stack; 34 | /*密码*/ 35 | Input_Pwd *input_pwd_widget; 36 | QProcess *pro; 37 | QString out; 38 | /*页面一*/ 39 | void init_widget_1(); 40 | QWidget *widget_1; 41 | QLabel *os_info; 42 | QPushButton *re_test_os; 43 | QLabel *line_label_1; 44 | QTextBrowser *wid_1_show_info; 45 | /*页面二*/ 46 | void init_widget_2(); 47 | QWidget *widget_2; 48 | QLabel *hardware_info; 49 | QPushButton *re_test_hard; 50 | QPushButton *more_detail_hard; 51 | QLabel *line_label_2; 52 | QTextBrowser *wid_2_show_info; 53 | /*页面三*/ 54 | void init_widget_3(); 55 | QWidget *widget_3; 56 | QLabel *os_run_info; 57 | QPushButton *re_test_os_run; 58 | QPushButton *more_detail_os_run; 59 | QLabel *line_label_3; 60 | QTextBrowser *wid_3_show_info; 61 | protected: 62 | bool eventFilter(QObject *obj, QEvent *event); 63 | 64 | signals: 65 | 66 | protected slots: 67 | /*widget-1*/ 68 | void re_test_os_slots(); 69 | /*widget-2*/ 70 | void re_test_hard_slots(); 71 | void more_detail_hard_slots(); 72 | /*widget-3*/ 73 | void re_test_os_run_slots(); 74 | void more_detail_os_run_slots(); 75 | /*init_widget_bash*/ 76 | void init_widget_bash(int n); 77 | public slots: 78 | 79 | }; 80 | 81 | #endif // MAIN_PAGE_SIX_H 82 | -------------------------------------------------------------------------------- /源代码/systemtest/main_page_three.h: -------------------------------------------------------------------------------- 1 | /* 2 | 内存检测项 3 | */ 4 | #ifndef MAIN_PAGE_THREE_H 5 | #define MAIN_PAGE_THREE_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "qprocess.h" 13 | #include "common.h" 14 | #include "input_pwd.h" 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | class Main_Page_three : public QWidget 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit Main_Page_three(QWidget *parent = 0); 25 | 26 | protected: 27 | /*列表窗口*/ 28 | QListWidget *list; 29 | QStackedWidget *stack; 30 | /*布局窗口*/ 31 | QWidget *work_window; 32 | QPushButton *re_test; 33 | QLabel *test_options; 34 | QLabel *line_label; 35 | QTextBrowser *show_msg; 36 | /*密码弹窗*/ 37 | Input_Pwd *Input_Pwd_Widget; 38 | 39 | /*进程*/ 40 | QProcess *pro; 41 | QString out; 42 | int current_bash;//标志位(当前页面) 43 | 44 | protected: 45 | 46 | bool eventFilter(QObject *obj, QEvent *event); 47 | 48 | signals: 49 | 50 | protected slots: 51 | void change_widget_cfg(int n); 52 | void show_msg_to_browser(); 53 | void flush_msg(); 54 | public slots: 55 | 56 | }; 57 | 58 | #endif // MAIN_PAGE_THREE_H 59 | -------------------------------------------------------------------------------- /源代码/systemtest/main_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | 主窗口,用于构建所有窗口 3 | */ 4 | #ifndef MAIN_WIDGET_H 5 | #define MAIN_WIDGET_H 6 | 7 | #include 8 | #include "drop_shadow_widget.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "title_widget.h" 16 | #include "boot_start_time.h" 17 | #include "input_pwd.h" 18 | #include "sys_test_widget.h" 19 | #include "buttom_widget.h" 20 | #include "main_page_one.h" 21 | #include "main_page_two.h" 22 | #include "main_page_three.h" 23 | #include "main_page_four.h" 24 | #include "main_page_five.h" 25 | #include "main_page_six.h" 26 | #include "main_page_serven.h" 27 | //#include "main_page_eight.h" 28 | #include "main_menu.h" 29 | 30 | class main_widget : public DropShadowWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | main_widget(QWidget *parent = 0); 36 | ~main_widget(); 37 | 38 | signals: 39 | 40 | private slots: 41 | void turnPage(int current_page); 42 | void show_start_time(); 43 | void hide_start_time(); 44 | void show_input_pwd_widget(); 45 | void change_skin(QString new_skin_name); 46 | void go_sys_test_page(); 47 | void show_main_menu(); 48 | private: 49 | QTimer *tmr_show_start_time; 50 | QTimer *tmr_hide_start_time; 51 | QTimer *tmr_input_pwd; 52 | 53 | QStackedWidget *stacked_widget; 54 | TitleWidget *title_widget; 55 | Main_Page_One *one_widget; 56 | Main_Page_two *two_widget; 57 | Main_Page_three *three_widget; 58 | Main_Page_four *four_widget; 59 | Main_Page_five *five_widget; 60 | Main_Page_six *six_widget; 61 | main_page_serven *serven_widget; 62 | //main_page_eight *eight_widget; 63 | Boot_Start_Time *start_time_widget; 64 | Input_Pwd *input_pwd_widget; 65 | 66 | Sys_Test_Widget *sys_test_widget; 67 | Buttom_Widget *button_widget; 68 | QSystemTrayIcon *myTrayIcon; 69 | QAction *restoreWinAction,*quitAction; 70 | QMenu *myMenu; 71 | QString skin_name;//主窗口背景图片的名称 72 | Main_Menu *main_menu; 73 | void createMenu(); 74 | void showNormal(); 75 | protected: 76 | virtual void paintEvent(QPaintEvent *event); 77 | }; 78 | 79 | #endif // MAIN_WIDGET_H 80 | -------------------------------------------------------------------------------- /源代码/systemtest/net_speed.cpp: -------------------------------------------------------------------------------- 1 | #include "net_speed.h" 2 | 3 | My_Obj_speed_test::My_Obj_speed_test() 4 | { 5 | out = ""; 6 | proc = new QProcess(); 7 | timer = new QTimer(); 8 | connect(timer, SIGNAL(timeout()), this, SLOT(start_timer())); 9 | timer->start(500); 10 | } 11 | 12 | void My_Obj_speed_test::start_timer() 13 | { 14 | QString program = "bash"; 15 | QStringList arguments_1,arguments_2; 16 | out = ""; 17 | arguments_1<<"/usr/bin/home_info/ethnetspeedhome.sh"; 18 | arguments_2<<"/usr/bin/home_info/wlannetspeedhome.sh"; 19 | proc->start(program, arguments_1); 20 | if(!proc->waitForStarted()) 21 | { 22 | return; 23 | } 24 | while(!proc->waitForFinished(0)) 25 | { 26 | out += proc->readAll(); 27 | } 28 | proc->start(program, arguments_2); 29 | if(!proc->waitForStarted()) 30 | { 31 | return; 32 | } 33 | while(!proc->waitForFinished(0)) 34 | { 35 | out += proc->readAll(); 36 | } 37 | emit set_info(out); 38 | } 39 | 40 | Net_Speed::Net_Speed(QWidget *parent) : 41 | QWidget(parent) 42 | { 43 | show_user_msg = new QTextBrowser(); 44 | QFont ft = this->font(); 45 | ft.setPointSize(9); 46 | show_user_msg->setFont(ft); 47 | show_user_msg->setStyleSheet("border-color:white"); 48 | 49 | QHBoxLayout main_layout; 50 | main_layout.addWidget(show_user_msg); 51 | main_layout.setContentsMargins(1,1,1,1); 52 | this->setLayout(&main_layout); 53 | 54 | My_Obj_speed_test_object = new My_Obj_speed_test(); 55 | my_thread = new QThread(); 56 | My_Obj_speed_test_object->moveToThread(my_thread); 57 | connect(My_Obj_speed_test_object, SIGNAL(set_info(QString)), this, SLOT(set_text(QString))); 58 | my_thread->start(); 59 | 60 | } 61 | 62 | void Net_Speed::set_text(QString str) 63 | { 64 | show_user_msg->setText(str); 65 | } 66 | -------------------------------------------------------------------------------- /源代码/systemtest/net_speed.h: -------------------------------------------------------------------------------- 1 | /* 2 | 动态监控网速 3 | */ 4 | #ifndef NET_SPEED_H 5 | #define NET_SPEED_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | class My_Obj_speed_test: public QObject 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit My_Obj_speed_test(); 22 | protected: 23 | QProcess *proc; 24 | QString out; 25 | QTimer *timer; 26 | signals: 27 | void set_info(QString str); 28 | protected slots: 29 | void start_timer(); 30 | }; 31 | 32 | class Net_Speed : public QWidget 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit Net_Speed(QWidget *parent = 0); 37 | 38 | protected: 39 | QTextBrowser *show_user_msg; 40 | My_Obj_speed_test *My_Obj_speed_test_object; 41 | QThread *my_thread; 42 | 43 | signals: 44 | 45 | public slots: 46 | void set_text(QString str); 47 | 48 | }; 49 | 50 | #endif // NET_SPEED_H 51 | -------------------------------------------------------------------------------- /源代码/systemtest/netspeed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $1 | sudo -S echo "" 2> /dev/null 3 | if [ $? == 0 ];then 4 | ethtool wlan0 | grep "Link detected: yes" > /dev/null #判断是否是无线网 5 | if [ $? -eq 0 ] #判断网卡 6 | then 7 | eth=wlan0 8 | echo "当前网络类型:无线网" > netspeed 9 | echo "ip地址 `LC_ALL=C ifconfig wlan0 | grep 'inet addr:'| grep -v '127.0.0.1' |cut -d: -f2 | awk '{ print $1}'`" 10 | else 11 | eth=eth0 12 | echo "当前网络类型:有线网" 13 | echo "ip地址 `LC_ALL=C ifconfig eth0 | grep 'inet addr:'| grep -v '127.0.0.1' |cut -d: -f2 | awk '{print $1}'`" 14 | fi 15 | 16 | #提取下载速度 17 | #求出一秒前后流量的差值,作为这一秒的下载网速, 从/proc/net/dev文件中. 18 | RXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') 19 | #sleep 1 20 | RXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') 21 | 22 | RX=$((${RXnext}-${RXpre})) 23 | 24 | #流量单位转换 25 | if [[ $RX -lt 1024 ]];then 26 | RX="${RX}B/s" 27 | elif [[ $RX -gt 1048576 ]];then 28 | RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}') 29 | else 30 | RX=$(echo $RX | awk '{print $1/1024 "KB/s"}') 31 | fi 32 | #输出下载速度 33 | echo -e "当前下载速度为 $RX" 34 | 35 | #提取上传速度 36 | #求出一秒前后流量的差值,作为这一秒的上传网速, 从/proc/net/dev文件中 37 | TXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') 38 | #sleep 1 39 | TXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') 40 | TX=$((${TXnext}-${TXpre})) 41 | #流量单位转换 42 | if [[ $TX -lt 1024 ]];then 43 | TX="${TX}B/s" 44 | elif [[ $TX -gt 1048576 ]];then 45 | TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}') 46 | else 47 | TX=$(echo $TX | awk '{print $1/1024 "KB/s"}') 48 | fi 49 | #输出下载速度 50 | echo -e "当前上传速度为 $TX" 51 | 52 | 53 | #下载总流量 54 | a=`ifconfig $eth | awk -F"[()]" NR==8'{print $2}'` #修改分隔符,并得出下载总流量 55 | 56 | echo -e "下载总流量:$a" 57 | 58 | #上传总流量 59 | b=`ifconfig $eth | awk -F"[()]" NR==8'{print $4}'` #修改分隔符并得出上传总流量 60 | 61 | echo -e "上传总流量:$b" 62 | else 63 | echo "密码输入错误!" 64 | fi 65 | -------------------------------------------------------------------------------- /源代码/systemtest/push_button.cpp: -------------------------------------------------------------------------------- 1 | #include "push_button.h" 2 | 3 | PushButton::PushButton(QWidget *parent) 4 | :QPushButton(parent) 5 | { 6 | status = NORMAL; 7 | mouse_press = false; 8 | } 9 | 10 | PushButton::~PushButton() 11 | { 12 | 13 | } 14 | 15 | void PushButton::setPicName(QString pic_name) 16 | { 17 | this->pic_name = pic_name; 18 | setFixedSize(QPixmap(pic_name).size()); 19 | } 20 | 21 | void PushButton::enterEvent(QEvent *) 22 | { 23 | status = ENTER; 24 | update(); 25 | } 26 | 27 | void PushButton::mousePressEvent(QMouseEvent *event) 28 | { 29 | //若点击鼠标左键 30 | if(event->button() == Qt::LeftButton) 31 | { 32 | mouse_press = true; 33 | status = PRESS; 34 | update(); 35 | } 36 | } 37 | 38 | void PushButton::mouseReleaseEvent(QMouseEvent *event) 39 | { 40 | //若点击鼠标左键 41 | if(mouse_press && this->rect().contains(event->pos())) 42 | { 43 | mouse_press = false; 44 | status = ENTER; 45 | update(); 46 | emit clicked(); 47 | } 48 | } 49 | 50 | void PushButton::leaveEvent(QEvent *) 51 | { 52 | status = NORMAL; 53 | update(); 54 | } 55 | 56 | void PushButton::paintEvent(QPaintEvent *) 57 | { 58 | QPainter painter(this); 59 | QPixmap pixmap; 60 | switch(status) 61 | { 62 | case NORMAL: 63 | { 64 | pixmap.load(pic_name); 65 | break; 66 | } 67 | case ENTER: 68 | { 69 | pixmap.load(pic_name + QString("_hover")); 70 | break; 71 | } 72 | case PRESS: 73 | { 74 | pixmap.load(pic_name + QString("_pressed")); 75 | break; 76 | } 77 | case NOSTATUS: 78 | { 79 | pixmap.load(pic_name); 80 | break; 81 | } 82 | default: 83 | pixmap.load(pic_name); 84 | } 85 | 86 | painter.drawPixmap(rect(), pixmap); 87 | } 88 | 89 | -------------------------------------------------------------------------------- /源代码/systemtest/push_button.h: -------------------------------------------------------------------------------- 1 | /* 2 | 新建pushbutton类。设置属性 3 | */ 4 | #ifndef PUSH_BUTTON_H 5 | #define PUSH_BUTTON_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class PushButton : public QPushButton 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | 17 | explicit PushButton(QWidget *parent = 0); 18 | ~PushButton(); 19 | void setPicName(QString pic_name); 20 | 21 | protected: 22 | 23 | void enterEvent(QEvent *); 24 | void leaveEvent(QEvent *); 25 | void mousePressEvent(QMouseEvent *event); 26 | void mouseReleaseEvent(QMouseEvent *event); 27 | void paintEvent(QPaintEvent *); 28 | 29 | private: 30 | 31 | //枚举按钮的几种状态 32 | enum ButtonStatus{NORMAL, ENTER, PRESS, NOSTATUS}; 33 | ButtonStatus status; 34 | QString pic_name; 35 | 36 | int btn_width; //按钮宽度 37 | int btn_height; //按钮高度 38 | bool mouse_press; //按钮左键是否按下 39 | }; 40 | 41 | #endif //PUSH_BUTTON_H 42 | 43 | -------------------------------------------------------------------------------- /源代码/systemtest/show_percent_page.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpu 内存检测项,动态刷新 3 | */ 4 | #ifndef SHOW_PERCENT_PAGE_H 5 | #define SHOW_PERCENT_PAGE_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | /*定义object for thread*/ 18 | class Thread_obj: public QObject 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit Thread_obj(); 23 | protected: 24 | QProcess *pro; 25 | QString out; 26 | QTimer *timer; 27 | QStringList arguments_cpu; 28 | QStringList arguments_mem; 29 | QStringList arguments_top; 30 | signals: 31 | void change_value_cpu(QString str);//cpu 32 | void change_value_mem(QString str);//mem 33 | void change_top_show(QString str);//top 10 34 | protected slots: 35 | void process_start(); 36 | }; 37 | 38 | class show_percent_page : public QWidget 39 | { 40 | Q_OBJECT 41 | public: 42 | explicit show_percent_page(QWidget *parent = 0); 43 | 44 | signals: 45 | 46 | public slots: 47 | 48 | protected slots: 49 | // void set_percent_value();//定时器超时函数 50 | /*槽--接收线程的信号用来刷新*/ 51 | void chang_value_cpu(QString str); 52 | void chang_value_mem(QString str); 53 | void chang_top_show(QString str); 54 | 55 | protected: 56 | QProgressBar *cpu_percent; 57 | QProgressBar *mem_percent; 58 | QLabel *cpu_Label; 59 | QLabel *mem_Label; 60 | QLabel *suggest_Label; 61 | QTextBrowser *show_top_info; 62 | Thread_obj *my_thread_obj; 63 | }; 64 | 65 | #endif // SHOW_PERCENT_PAGE_H 66 | -------------------------------------------------------------------------------- /源代码/systemtest/sources/1_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/1_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/2_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/2_big.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/3_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/3_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/4_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/4_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/5_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/5_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/6_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/6_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/7_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/7_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/8_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/8_big.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/arrow_down.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/check.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/close.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/close_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/close_hover.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/close_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/close_pressed.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/cpu1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/cpu1.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/cpu2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/cpu2.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/disk1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/disk1.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/disk2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/disk2.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/disk3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/disk3.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/disk4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/disk4.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/feedback.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/feedback_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/feedback_hover.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/feedback_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/feedback_pressed.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func1.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func2.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func3.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func4.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func5.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func6.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func7.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/func8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/func8.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/1.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_1.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_10.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_11.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_12.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_13.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_14.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_15.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_16.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_2.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_3.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_4.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_5.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_6.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_7.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_8.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/html/picture/new_9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/html/picture/new_9.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/loading.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/12_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/12_big.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/13.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/13_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/13_big.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/14.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/14_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/14_big.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/15.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/15_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/15_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/16.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/16_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/16_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/17.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/17_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/17_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/18.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/18_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/18_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/19.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/19_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/19_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/20.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/20_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/20_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/21.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/21_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/21_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/22.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/22_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/22_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/23.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/23_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/23_big.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/img/skin/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/img/skin/9.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /源代码/systemtest/sources/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/logo.ico -------------------------------------------------------------------------------- /源代码/systemtest/sources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/logo.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/logo1.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/logo1.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "logo1.ico" 2 | -------------------------------------------------------------------------------- /源代码/systemtest/sources/logo1.rc~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/logo1.rc~ -------------------------------------------------------------------------------- /源代码/systemtest/sources/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/menu.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/menu_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/menu_hover.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/menu_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/menu_pressed.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/min.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/min_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/min_hover.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/min_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/min_pressed.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/net1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/net1.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/net2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/net2.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/net3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/net3.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/net4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/net4.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/os1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/os1.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/os2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/os2.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/os3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/os3.jpg -------------------------------------------------------------------------------- /源代码/systemtest/sources/power.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/power.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/score.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/score.gif -------------------------------------------------------------------------------- /源代码/systemtest/sources/score.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/score.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/security_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/security_1.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/security_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/security_2.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/security_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/security_3.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/security_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/security_4.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/skin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/skin.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/skin_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/skin_hover.png -------------------------------------------------------------------------------- /源代码/systemtest/sources/skin_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/systemtest/sources/skin_pressed.png -------------------------------------------------------------------------------- /源代码/systemtest/sys_test_widget.h: -------------------------------------------------------------------------------- 1 | /******* 2 | 系统检测界面 此界面用线程和进程实现 3 | 4 | *********/ 5 | 6 | #ifndef SYS_TEST_WIDGET_H 7 | #define SYS_TEST_WIDGET_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "net_speed.h" 21 | /* 一键测试评分object 供线程使用 */ 22 | class My_Obj_get_score: public QObject 23 | { 24 | Q_OBJECT 25 | public: 26 | explicit My_Obj_get_score(); 27 | 28 | protected: 29 | QProcess *proc; 30 | QProcess *proc_ret; 31 | QString ret; 32 | QTimer *timer; 33 | QStringList qlist;//脚本 34 | QStringList list_finish;//脚本执行完成需要输出 35 | QStringList list_unfinish;//脚本正在执行时输出提示信息 36 | QStringList argus;//c语言脚本第一个参数 37 | QString setout; 38 | QString getout; 39 | double score; 40 | int n; 41 | signals: 42 | void set_score(double scores);//发送分值信号 43 | void set_text_show(QString str);// 发送输出信号 44 | void set_bar_value(int n);//设置进度条值 45 | void please_stop(); 46 | public slots: 47 | void start_get_score();// 48 | }; 49 | 50 | class Sys_Test_Widget: public QDialog 51 | { 52 | Q_OBJECT 53 | 54 | public: 55 | explicit Sys_Test_Widget(QWidget *parent = 0); 56 | ~Sys_Test_Widget(); 57 | 58 | protected: 59 | 60 | QSplitter *main_splitter; 61 | /*左侧窗口*/ 62 | QWidget *left_widget; 63 | 64 | QProgressBar *progressBar; 65 | QTextBrowser *text_show; 66 | QString getout; 67 | QProcess *proc; 68 | QPushButton *re_test; 69 | 70 | QSplitter *right_splitter; 71 | 72 | QWidget *right_top_widget; 73 | QLabel *score_label; 74 | 75 | show_percent_page *right_center_widget; 76 | 77 | Net_Speed *right_bottom_widget; 78 | 79 | My_Obj_get_score *obj_get_score; 80 | QThread *thread_get_score; 81 | 82 | private: 83 | void initLeft(); 84 | void initRightTop(); 85 | void initRightCenter(); 86 | void initRightBottom(); 87 | void initRight(); 88 | 89 | 90 | protected slots: 91 | // void set_score(double scores);//发送分值信号 92 | void set_text_show(QString str);// 发送输出信号 93 | void set_bar_value(int n);//设置进度条值 94 | void get_score(double score); 95 | public slots: 96 | void start_timer(); 97 | 98 | }; 99 | 100 | 101 | #endif // SYS_TEST_WIDGET_H 102 | -------------------------------------------------------------------------------- /源代码/systemtest/systemtest.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-01-08T16:32:22 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = systemtest 12 | TEMPLATE = app 13 | 14 | QT += widgets network 15 | QT += testlib 16 | CONFIG += thread 17 | 18 | 19 | #QT += widgets 20 | QT += webkit 21 | #QT += webkitwidgets/webview 22 | #QT += network 23 | 24 | SOURCES += main.cpp\ 25 | main_widget.cpp \ 26 | tool_button.cpp \ 27 | drop_shadow_widget.cpp \ 28 | title_widget.cpp \ 29 | boot_start_time.cpp \ 30 | input_pwd.cpp \ 31 | common.cpp \ 32 | push_button.cpp \ 33 | sys_test_widget.cpp \ 34 | buttom_widget.cpp \ 35 | show_percent_page.cpp \ 36 | main_page_one.cpp \ 37 | main_page_two.cpp \ 38 | main_page_three.cpp \ 39 | main_page_four.cpp \ 40 | main_page_five.cpp \ 41 | main_page_six.cpp \ 42 | user_msg.cpp \ 43 | net_speed.cpp \ 44 | main_page_serven.cpp \ 45 | main_menu.cpp \ 46 | about_us.cpp 47 | 48 | HEADERS += main_widget.h \ 49 | tool_button.h \ 50 | drop_shadow_widget.h \ 51 | title_widget.h \ 52 | boot_start_time.h \ 53 | common.h \ 54 | input_pwd.h \ 55 | push_button.h \ 56 | sys_test_widget.h \ 57 | buttom_widget.h \ 58 | show_percent_page.h \ 59 | main_page_one.h \ 60 | main_page_two.h \ 61 | main_page_three.h \ 62 | main_page_four.h \ 63 | main_page_five.h \ 64 | main_page_six.h \ 65 | user_msg.h \ 66 | net_speed.h \ 67 | main_page_serven.h \ 68 | main_menu.h \ 69 | about_us.h 70 | 71 | RESOURCES += \ 72 | sources/resources.qrc 73 | QT += widgets 74 | QT += webkit 75 | QT += network 76 | 77 | 78 | TRANSLATIONS += sources/sys_test.ts 79 | RC_FILE = logo1.rc 80 | -------------------------------------------------------------------------------- /源代码/systemtest/test.h~: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | /*此程序对每个检测项进行打分*/ 4 | /*所有评分函数的返回值为int*/ 5 | 6 | /*CPU用户占用率评分函数*/ 7 | int get_cpu_user(float percent) 8 | { 9 | if(percent > 70) 10 | { 11 | return 5; 12 | } 13 | else if(percent >= 65 && percent <= 70) 14 | { 15 | return 0; 16 | } 17 | else if(percent >= 60 && percent < 65) 18 | { 19 | return 2; 20 | } 21 | else if(percent >= 50 && percent < 60) 22 | { 23 | return 3; 24 | } 25 | else 26 | { 27 | return 4; 28 | } 29 | 30 | return 0; 31 | } 32 | 33 | /*CPU系统占用率评分函数*/ 34 | int get_cpu_sys(float percent) 35 | { 36 | if(percent > 70) 37 | { 38 | return 5; 39 | } 40 | else if(percent >= 60 && percent <= 70) 41 | { 42 | return 4; 43 | } 44 | else if(percent > 35 && percent < 60) 45 | { 46 | return 3; 47 | } 48 | else if(percent >= 30 && percent <= 35 ) 49 | { 50 | return 0; 51 | } 52 | else 53 | { 54 | return 4; 55 | } 56 | 57 | return 0; 58 | } 59 | 60 | /*CPU虚拟化评分函数*/ 61 | int get_cpu_virtual(int flag) 62 | { 63 | switch(flag) 64 | { 65 | case 0: //不支持虚拟化 66 | return 2; 67 | break; 68 | case 1: //支持AMD提供的虚拟化 69 | return 1; 70 | break; 71 | case 2: //支持Intel提供的虚拟化 72 | return 0; 73 | break; 74 | default: 75 | break; 76 | } 77 | } 78 | 79 | /*对指定项评分函数*/ 80 | int get_point(char *str,void *val) 81 | { 82 | if(!strncmp("cpuuser",str,7)) 83 | { 84 | float num = *((float*)val); 85 | return get_cpu_user(num); 86 | } 87 | 88 | if(!strncmp("cpusys",str,6)) 89 | { 90 | float num1 = *((float*)val); 91 | return get_cpu_sys(num1); 92 | } 93 | 94 | if(!strncmp("cpuvirtual",str,10)) 95 | { 96 | int num2 = *((int*)val); 97 | printf("num2=%d\n",num2); 98 | return get_cpu_virtual(num2); 99 | } 100 | 101 | return 0; 102 | } 103 | -------------------------------------------------------------------------------- /源代码/systemtest/testpwd.sh: -------------------------------------------------------------------------------- 1 | 2 | ######################################################################### 3 | # File Name: hardwareinfo.sh 4 | # Author: liujing 5 | # mail: 2510034575@qq.com 6 | # Created Time: 2015年01月07日 星期三 19时23分25秒 7 | ######################################################################### 8 | #!/bin/bash 9 | echo $1 |sudo -S echo "" 2> /dev/null 10 | if [ $? == 0 ] 11 | then 12 | echo "Y" 13 | else 14 | echo "N" 15 | fi 16 | 17 | 18 | -------------------------------------------------------------------------------- /源代码/systemtest/title_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | 标题栏 3 | */ 4 | #ifndef TITLE_WIDGET_H 5 | #define TITLE_WIDGET_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "tool_button.h" 14 | #include "push_button.h" 15 | 16 | class TitleWidget : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit TitleWidget(QWidget *parent = 0); 22 | ~TitleWidget(); 23 | 24 | signals: 25 | void turnPage(int current_page);//页码 标号 26 | void change_skin(QString new_skin_name);//皮肤 27 | void close_window();//关闭程序 28 | void hide_window();//(隐藏)最小化 29 | void show_main_menu();//显示主菜单 30 | 31 | public slots: 32 | void turnPage(QString current_page); 33 | void change_skin(); 34 | 35 | private: 36 | QLabel *version_title; //标题 37 | PushButton *skin_button; //换肤 38 | PushButton *main_menu_button; //主菜单 39 | PushButton *min_button; //最小化 40 | PushButton *close_button; //关闭 41 | 42 | QLabel *sys_test_logo; //logo 43 | QLabel *sys_team;//team name 44 | QLabel *sys_test; //系统检测 45 | 46 | QList button_list;//QList 设置按钮 47 | }; 48 | 49 | #endif // TITLE_WIDGET_H 50 | -------------------------------------------------------------------------------- /源代码/systemtest/tool_button.cpp: -------------------------------------------------------------------------------- 1 | #include "tool_button.h" 2 | 3 | ToolButton::ToolButton(QString pic_name, QWidget *parent) 4 | :QToolButton(parent) 5 | { 6 | //设置文本颜色 7 | QPalette text_palette = palette(); 8 | text_palette.setColor(QPalette::ButtonText, QColor(230, 230, 230)); 9 | setPalette(text_palette); 10 | 11 | //设置文本粗体 12 | QFont &text_font = const_cast(font()); 13 | text_font.setWeight(QFont::Bold); 14 | 15 | setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 16 | 17 | //设置图标 18 | QPixmap pixmap(pic_name); 19 | setIcon(pixmap); 20 | setIconSize(pixmap.size()); 21 | 22 | //设置大小 23 | setFixedSize(pixmap.width()+25, pixmap.height()+25); 24 | setAutoRaise(true); 25 | setObjectName("transparentToolButton"); 26 | 27 | mouse_over = false; 28 | mouse_press = false; 29 | } 30 | 31 | ToolButton::~ToolButton() 32 | { 33 | 34 | } 35 | 36 | void ToolButton::enterEvent(QEvent *) 37 | { 38 | mouse_over = true; 39 | } 40 | 41 | void ToolButton::leaveEvent(QEvent *) 42 | { 43 | mouse_over = false; 44 | } 45 | 46 | void ToolButton::mousePressEvent(QMouseEvent *event) 47 | { 48 | if(event->button() == Qt::LeftButton) 49 | { 50 | emit clicked(); 51 | } 52 | } 53 | 54 | void ToolButton::setMousePress(bool mouse_press) 55 | { 56 | this->mouse_press = mouse_press; 57 | update(); 58 | } 59 | 60 | void ToolButton::paintEvent(QPaintEvent *event) 61 | { 62 | if(mouse_over) 63 | { 64 | //绘制鼠标移到按钮上的按钮效果 65 | painterInfo(0, 100, 150); 66 | } 67 | else 68 | { 69 | if(mouse_press) 70 | { 71 | painterInfo(0, 100, 150); 72 | } 73 | } 74 | 75 | QToolButton::paintEvent(event); 76 | } 77 | 78 | void ToolButton::painterInfo(int top_color, int middle_color, int bottom_color) 79 | { 80 | QPainter painter(this); 81 | QPen pen(Qt::NoBrush, 1); 82 | painter.setPen(pen); 83 | QLinearGradient linear(rect().topLeft(), rect().bottomLeft()); 84 | linear.setColorAt(0, QColor(230, 230, 230, top_color)); 85 | linear.setColorAt(0.5, QColor(230, 230, 230, middle_color)); 86 | linear.setColorAt(1, QColor(230, 230, 230, bottom_color)); 87 | painter.setBrush(linear); 88 | painter.drawRect(rect()); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /源代码/systemtest/tool_button.h: -------------------------------------------------------------------------------- 1 | /* 2 | 新建toolbutton类按钮事件。设置属性 3 | */ 4 | #ifndef TOOL_BUTTON_H 5 | #define TOOL_BUTTON_H 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class ToolButton : public QToolButton 12 | { 13 | 14 | public: 15 | 16 | explicit ToolButton(QString pic_name, QWidget *parent = 0); 17 | ~ToolButton(); 18 | void setMousePress(bool mouse_press); 19 | 20 | protected: 21 | 22 | void enterEvent(QEvent *);//enter 23 | void leaveEvent(QEvent *);//leave 24 | void mousePressEvent(QMouseEvent *event);//press 25 | void paintEvent(QPaintEvent *event);//paint 26 | void painterInfo(int top_color, int middle_color, int bottom_color); 27 | 28 | public: 29 | 30 | bool mouse_over; //鼠标是否移过 31 | bool mouse_press; //鼠标是否按下 32 | }; 33 | 34 | 35 | #endif // TOOL_BUTTON_H 36 | -------------------------------------------------------------------------------- /源代码/systemtest/user_msg.cpp: -------------------------------------------------------------------------------- 1 | #include "user_msg.h" 2 | #include 3 | #include 4 | User_Msg::User_Msg(QWidget *parent) : 5 | QWidget(parent) 6 | { 7 | show_user_msg = new QTextBrowser(); 8 | QFont ft = this->font(); 9 | ft.setPointSize(16); 10 | show_user_msg->setFont(ft); 11 | show_user_msg->setStyleSheet("border-color:white"); 12 | QVBoxLayout main_layout; 13 | main_layout.addWidget(show_user_msg); 14 | main_layout.setContentsMargins(1,1,1,1); 15 | this->setLayout(&main_layout); 16 | pro = new QProcess(); 17 | out = ""; 18 | QString program = "bash"; 19 | QStringList arguments; 20 | arguments<<"/usr/bin/home_info/homeinfousr.sh"; 21 | pro->start(program, arguments); 22 | while(pro->waitForReadyRead()) 23 | { 24 | out += pro->readAll(); 25 | } 26 | show_user_msg->setText(out); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /源代码/systemtest/user_msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | 显示用户名信息 3 | */ 4 | #ifndef USER_MSG_H 5 | #define USER_MSG_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | class User_Msg : public QWidget 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit User_Msg(QWidget *parent = 0); 19 | 20 | protected: 21 | QTextBrowser *show_user_msg;//msg textbrowser 22 | QProcess *pro;//process 23 | QString out;//get msg from StandardOutput 24 | 25 | signals: 26 | 27 | public slots: 28 | 29 | }; 30 | 31 | #endif // USER_MSG_H 32 | -------------------------------------------------------------------------------- /源代码/systemtest/wait_dialog.cpp: -------------------------------------------------------------------------------- 1 | #include "wait_dialog.h" 2 | #include 3 | 4 | Waiting_Dialog::Waiting_Dialog(QWidget *parent): 5 | QDialog(parent) 6 | { 7 | setWindowFlags(Qt::WindowStaysOnTopHint); 8 | m_Timer = new QTimer(); 9 | m_ProgressBar = new QProgressBar(this); 10 | m_CurrentValue = m_MaxValue = m_UpdateInterval = 0; 11 | m_ProgressBar->setRange(0, 100); 12 | connect(m_Timer, SIGNAL(timeout()), this, SLOT(UpdateSlot())); 13 | m_ProgressBar->setTextVisible(false); 14 | 15 | QHBoxLayout *layout = new QHBoxLayout(); 16 | layout->addWidget(m_ProgressBar); 17 | setLayout(layout); 18 | 19 | } 20 | 21 | Waiting_Dialog::~Waiting_Dialog() 22 | { 23 | 24 | } 25 | 26 | void Waiting_Dialog::UpdateSlot() 27 | { 28 | m_CurrentValue++; 29 | if( m_CurrentValue == m_MaxValue ) 30 | m_CurrentValue = 0; 31 | m_ProgressBar->setValue(m_CurrentValue); 32 | 33 | } 34 | 35 | void Waiting_Dialog::Start(int interval, int maxValue) 36 | { 37 | m_UpdateInterval = interval; 38 | m_MaxValue = maxValue; 39 | m_Timer->start(m_UpdateInterval); 40 | m_ProgressBar->setRange(0, m_MaxValue); 41 | m_ProgressBar->setValue(0); 42 | } 43 | 44 | void Waiting_Dialog::Stop() 45 | { 46 | m_Timer->stop(); 47 | } 48 | -------------------------------------------------------------------------------- /源代码/systemtest/wait_dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef WAIT_DIALOG_H 2 | #define WAIT_DIALOG_H 3 | #include 4 | #include 5 | #include 6 | 7 | class Waiting_Dialog : public QDialog 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | explicit Waiting_Dialog(QWidget *parent = 0); 13 | ~Waiting_Dialog(); 14 | 15 | private: 16 | int m_CurrentValue; 17 | int m_UpdateInterval; 18 | int m_MaxValue; 19 | QTimer *m_Timer; 20 | QProgressBar *m_ProgressBar; 21 | 22 | public: 23 | void Start(int interval, int maxValue); 24 | void Stop(); 25 | 26 | private slots: 27 | void UpdateSlot(); 28 | }; 29 | 30 | 31 | #endif // WAIT_DIALOG_H 32 | -------------------------------------------------------------------------------- /源代码/脚本/README: -------------------------------------------------------------------------------- 1 | 执行脚本放到绝对路径 /usr/bin/ 下面 2 | -------------------------------------------------------------------------------- /源代码/脚本/README~: -------------------------------------------------------------------------------- 1 | 执行脚本放到绝对路径 /usr/bin/ 下面 2 | -------------------------------------------------------------------------------- /源代码/脚本/cpu_show/cpu_cal_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | ##计算CPU的运算速度(浮点运算) (单位:浮点运算/秒) 3 | num=5000 4 | export TIMEFORMAT=$'real:%3R\nuser:%3U\nsys:%3S' #指定time命令的输出格式 5 | (time echo "scale=$num; 4*a(1)" | bc -l -q | grep "real") >&tmp #获取CPU计算圆周率到小数点后5000位所用的时间,并将结果写入到tmp文件 6 | real=`cat tmp | awk -F ':' 'NR==1{print $2}'` #获取CPU实际运算的时间 7 | #echo $real 8 | cpu_cal_speed=$(awk 'BEGIN{printf"%.3f\n",'$num' / '$real'}') 9 | echo "CPU的运算速度:"$cpu_cal_speed"Flops(浮点运算/秒)" 10 | 11 | rm -rf tmp 12 | -------------------------------------------------------------------------------- /源代码/脚本/cpu_show/cpu_show2.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | ################# 3 | ## CPU软件信息 ## 4 | ################# 5 | 6 | #(需动态刷新) 7 | 8 | ##计算cpu利用率 9 | #计算公式: 10 | #total_0USER[0]+NICE[0]+SYSTEM[0]+IDLE[0]+IOWAIT[0]+IRQ[0]+SOFTIRQ[0] 11 | #total_1=USER[1]+NICE[1]+SYSTEM[1]+IDLE[1]+IOWAIT[1]+IRQ[1]+SOFTIRQ[1] 12 | #cpu usage=(IDLE[0]-IDLE[1]) / (total_0-total_1) * 100 13 | CPULOG_1=$(cat /proc/stat | grep 'cpu ' | awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8}') 14 | SYS_IDLE_1=$(echo $CPULOG_1 | awk '{print $4}') 15 | Total_1=$(echo $CPULOG_1 | awk '{print $1+$2+$3+$4+$5+$6+$7}') 16 | 17 | sleep 1 18 | 19 | CPULOG_2=$(cat /proc/stat | grep 'cpu ' | awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8}') 20 | SYS_IDLE_2=$(echo $CPULOG_2 | awk '{print $4}') 21 | Total_2=$(echo $CPULOG_2 | awk '{print $1+$2+$3+$4+$5+$6+$7}') 22 | 23 | SYS_IDLE=`expr $SYS_IDLE_2 - $SYS_IDLE_1` 24 | 25 | Total=`expr $Total_2 - $Total_1` 26 | SYS_USAGE=`expr $SYS_IDLE/$Total*100 |bc -l` 27 | 28 | SYS_Rate=`expr 100-$SYS_USAGE |bc -l` 29 | 30 | #Disp_SYS_Rate=`expr "scale=2; $SYS_Rate/1" |bc` 31 | Disp_SYS_Rate=$(awk 'BEGIN{printf"%.2f\n",'$SYS_Rate' / 1}') 32 | echo -e "CPU占用:\t\t\t\t $Disp_SYS_Rate%" 33 | echo "" 34 | ##计算可运行队列的线程数 35 | cpu_count=$(grep 'physical id' /proc/cpuinfo | sort -u | wc -l) #cpu个数 36 | loadavg_1min=$( cat /proc/loadavg | awk '{print $1}') #cpu一分钟平均负载 37 | task_per_cpu=$(awk 'BEGIN{printf"%.2f\n",'$loadavg_1min' / '$cpu_count'}') 38 | #每个cpu的当前任务数 39 | echo -e "可运行队列的线程数:\t\t\t" $task_per_cpu 40 | echo "" 41 | ##用户占用率 42 | user_rate=`top -b -n 1 | grep Cpu | awk '{print $2}'` 43 | echo -e "用户占用率:\t\t\t "$user_rate% 44 | echo "" 45 | ##系统占用率 46 | sys_rate=`top -b -n 1 | grep Cpu | awk '{print $4}'` 47 | echo -e "系统占用率:\t\t\t "$sys_rate% 48 | echo "" 49 | ##io等待占用CPU时间的百分比 50 | iowait_rate=`top -b -n 1 | grep Cpu | awk '{print $10}'` #(-b -n 1 表示只需要1次的输出结果) 51 | echo -e "IO等待占用率:\t\t\t "$iowait_rate% 52 | echo "" 53 | #从磁盘交换到内存的交换页 54 | si=`top -b -n 1 | grep Cpu | awk '{print $14}'` 55 | echo -e "从磁盘交换到内存的页占用率:\t\t "$si% 56 | echo "" 57 | #从内存交换到磁盘的交换页 58 | so=`top -b -n 1 | grep Cpu | awk '{print $16}'` 59 | echo -e "从内存交换到磁盘的页占用率:\t\t "$so% 60 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/dd_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #dd命令测试磁盘读写速度 3 | echo $1 |sudo -S echo -n 2> /dev/null 4 | if [ $? == 0 ];then 5 | #测磁盘写速度 6 | echo "磁盘写速度测试结果:">info 7 | sudo dd if=/dev/zero of=test.bin bs=4096 count=1M conv=fdatasync 2>> info 8 | #测磁盘读速度 9 | echo "磁盘读速度测试结果:">>info 10 | sudo dd if=test.bin of=/dev/zero bs=4096 count=1M iflag=direct 2>> info 11 | rm -rf test.bin 12 | cat info 13 | rm -rf info 14 | else 15 | echo "密码输入错误!" 16 | fi 17 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/dd_test.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #dd命令测试磁盘读写速度 3 | echo $1 |sudo -S echo "" 2> /dev/null 4 | if [ $? == 0 ];then 5 | #测磁盘写速度 6 | echo "磁盘写速度测试结果如下:" 7 | sudo dd if=/dev/zero of=test.bin bs=4096 count=1M conv=fdatasync 8 | #测磁盘读速度 9 | echo "磁盘读速度测试结果如下:" 10 | sudo dd if=test.bin of=/dev/zero bs=4096 count=1M iflag=direct 11 | rm -rf test.bin 12 | else 13 | echo "密码输入错误!" 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #判断软件安装 4 | hddtemp -v > /dev/null 5 | if [ $? -ne 0 ];then 6 | #echo "hddtemp 未安装" 7 | #安装hddtemp 8 | #验证密码是否正确 9 | echo $1 | sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | sudo -S apt-get -y install hddtemp > /dev/null 12 | if [ $? == 0 ]; then 13 | echo "hddtemp安装完成!" 14 | else 15 | echo "hddtemp安装失败!" 16 | fi 17 | else 18 | echo "密码输入错误!" 19 | fi 20 | else 21 | echo "hddtemp 已安装" 22 | fi 23 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_judge.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: is_install.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月11日 星期日 15时51分57秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #判断软件安装 9 | hddtemp -v > /dev/null 10 | if [ $? == 0 ];then 11 | echo "Y" 12 | else 13 | echo "N" 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_judge.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: is_install.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月11日 星期日 15时51分57秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #判断软件安装 9 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "hddtemp" |wc -l` 10 | if [ $a == 0 ];then 11 | echo "hddtemp 未安装" 12 | else 13 | echo "hddtemp 已安装" 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | hddtemp -v > /dev/null 4 | if [ $? == 0 ];then 5 | #echo "hddtemp 已安装" 6 | #卸载hddtemp 7 | echo $1 | sudo -S echo -n 2> /dev/null 8 | if [ $? == 0 ];then 9 | sudo -S dpkg -r hddtemp > /dev/null 10 | if [ $? == 0 ]; then 11 | echo "hddtemp卸载成功!" 12 | else 13 | echo "hddtemp卸载失败!" 14 | fi 15 | else 16 | echo "密码输入错误!" 17 | fi 18 | else 19 | echo "hddtemp 未安装" 20 | 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_remove.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | hddtemp -v > /dev/null 4 | if [ $? == 0 ];then 5 | echo "hddtemp 已安装" 6 | #卸载hddtemp 7 | echo $1 | sudo -S echo -n 2> /dev/null 8 | if [ $? == 0 ];then 9 | sudo -S dpkg -r hddtemp > /dev/null 10 | if [ $? == 0 ]; then 11 | echo "hddtemp卸载成功!" 12 | else 13 | echo "hddtemp卸载失败!" 14 | fi 15 | else 16 | echo "密码输入错误!" 17 | fi 18 | else 19 | echo "hddtemp 未安装" 20 | 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_tool.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: disk_speed.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月06日 星期二 20时06分08秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #hdparm工具磁盘读写速度 9 | echo $1 |sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | #判断软件安装 12 | hddtemp -v > /dev/null 13 | if [ $? -ne 0 ];then 14 | echo "温度测试工具hddtemp安装失败(可能软件源有问题),无法检测" 15 | else 16 | sudo hddtemp /dev/sda >hddtemp_test 17 | c=`cat hddtemp_test | awk '{print int($3)}'` 18 | if [ $c -lt 59 ];then 19 | echo "磁盘当前温度为:`cat hddtemp_test | awk -F: '{print $3}'` (硬盘工作温度正常!)" >hddtempinfo 20 | fi 21 | if [ $c -ge 70 ];then 22 | echo "磁盘当前温度为:`cat hddtemp_test | awk -F: '{print $3}'` (硬盘工作温度超过极限!)">hddtempinfo 23 | fi 24 | cat hddtempinfo 25 | rm hddtempinfo 26 | rm hddtemp_test 27 | fi 28 | 29 | else 30 | echo "密码输入错误!" 31 | fi 32 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/hddtemp_tool.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: disk_speed.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月06日 星期二 20时06分08秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #hdparm工具磁盘读写速度 9 | echo $1 |sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | #判断软件安装 12 | # hddtemp -v > /dev/null 13 | if [ $? -ne 0 ];then 14 | echo "未安装相关专业工具,无法测评" 15 | else 16 | sudo hddtemp /dev/sda >hddtemp_test 17 | c=`cat hddtemp_test | awk '{print int($3)}'` 18 | if [ $c -lt 59 ];then 19 | echo "当前磁盘温度为:`cat hddtemp_test | awk '{print $3}'` (硬盘工作温度正常!)" >hddtempinfo 20 | fi 21 | if [ $c -ge 70 ];then 22 | echo "当前磁盘温度为:`cat hddtemp_test | awk '{print $3}'` (硬盘工作温度超过极限!)">hddtempinfo 23 | fi 24 | fi 25 | cat hddtempinfo 26 | rm hddtempinfo 27 | rm hddtemp_test 28 | else 29 | echo "密码输入错误!" 30 | fi 31 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/install_hddtemp.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #判断软件安装 4 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "hddtemp" |wc -l` 5 | if [ $a == 0 ];then 6 | echo "hddtemp 未安装" 7 | #安装hddtemp 8 | #验证密码是否正确 9 | echo $1 | sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | sudo -S apt-get -y install hddtemp > /dev/null 12 | if [ $? == 0 ]; then 13 | echo "hddtemp安装完成!" 14 | else 15 | echo "hddtemp安装失败!" 16 | fi 17 | else 18 | echo "密码输入错误!" 19 | fi 20 | else 21 | echo "hddtemp 已安装" 22 | fi 23 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/install_sysstat.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "sysstat" |wc -l` 4 | if [ $a == 0 ];then 5 | echo "sysstat 未安装" 6 | #安装sysstat 7 | #验证密码是否正确 8 | echo $1 | sudo -S echo -n 2> /dev/null 9 | if [ $? == 0 ];then 10 | sudo -S apt-get -y install sysstat > /dev/null 11 | if [ $? == 0 ]; then 12 | echo "sysstat安装完成!" 13 | else 14 | echo "sysstat安装失败!" 15 | fi 16 | else 17 | echo "密码输入错误!" 18 | fi 19 | else 20 | echo "sysstat 已安装" 21 | fi 22 | 23 | 24 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/iostat_tool.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: disktool.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 15时09分50秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #echo $1 |sudo -S echo -n 2> /dev/null 9 | #if [ $? == 0 ];then 10 | #sudo -S apt-get -y install sysstat > /dev/null 11 | iostat > /dev/null 12 | if [ $? -ne 0 ];then 13 | echo "IO测试工具安装失败sysstat(可能软件源有问题),无法测试IO性能" 14 | else 15 | #echo "sysstat已安装" 16 | 17 | #r/s 18 | echo -e "每秒读I/O设备次数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $4}'`" 19 | #w/r 20 | echo -e "每秒写I/O设备次数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $5}'`" 21 | echo "" 22 | #rkB/s 23 | echo -e "每秒读K字节数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $6}'`" 24 | #wkB/s 25 | echo -e "每秒写K字节数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $7}'`" 26 | echo "" 27 | #avgqu-sz 28 | echo -e "平均I/O队列长度:\t\t\t`iostat -x -k |grep "sda"|awk '{print $9}'`" 29 | echo "" 30 | #avgrq-sz 31 | echo -e "平均每次设备I/O操作的数据大小(扇区):\t`iostat -x -k |grep "sda"|awk '{print $8}'`" 32 | echo "" 33 | #await 34 | echo -e "平均每次设备I/O操作的等待时间(毫秒):\t`iostat -x -k |grep "sda"|awk '{print $10}'`" 35 | #svctm 36 | echo -e "平均每次设备I/O操作的服务时间(毫秒):\t`iostat -x -k |grep "sda"|awk '{print $13}'`" 37 | echo "" 38 | #util 39 | a=`iostat -x -k|grep "sda"|awk '{print int($2)}'` 40 | if [ $a -ge 70 -a $a -lt 95 ];then 41 | echo -e "一秒中有百分之多少的时间用于 I/O 操作:\t`iostat -x -k |grep "sda"|awk '{print $2}'`(I/O压力比较大)" 42 | elif [ $a -ge 95 -a $a -lt 100 ];then 43 | echo -e "一秒中有百分之多少的时间用于 I/O 操作:\t`iostat -x -k |grep "sda"|awk '{print $2}'`(I/O请求太多,磁盘可能存在瓶颈)" 44 | fi 45 | echo -e "一秒中有百分之多少的时间用于 I/O 操作:\t`iostat -x -k |grep "sda"|awk '{print $2}'`" 46 | echo "" 47 | #mpstat测系统启动以后所有硬盘IO平均等待时间 48 | ioindex=`mpstat |tail -1|awk '{print int($6)}'` 49 | if [ $ioindex -lt 20 ];then 50 | echo -e "系统启动后硬盘IO平均等待时间(%):\t`mpstat |tail -1|awk '{print $6}'`(磁盘IO状态指标良好)" 51 | elif [ $ioindex -ge 20 ];then 52 | echo -e "系统启动后硬盘IO平均等待时间(%):\t`mpstat |tail -1|awk '{print $6}'`(磁盘IO状态指标不是很良好)" 53 | 54 | fi 55 | fi 56 | #else 57 | # echo "密码输入错误!" 58 | #fi 59 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/iostat_tool.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: disktool.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 15时09分50秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #echo $1 |sudo -S echo -n 2> /dev/null 9 | #if [ $? == 0 ];then 10 | #sudo -S apt-get -y install sysstat > /dev/null 11 | iostat > /dev/null 12 | if [ $? -ne 0 ];then 13 | echo "未安装相关专业工具,无法测评" 14 | else 15 | #echo "sysstat已安装" 16 | 17 | #r/s 18 | echo -e "每秒读I/O设备次数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $4}'`" 19 | #w/r 20 | echo -e "每秒写I/O设备次数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $5}'`" 21 | echo "" 22 | #rkB/s 23 | echo -e "每秒读K字节数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $6}'`" 24 | #wkB/s 25 | echo -e "每秒写K字节数:\t\t\t`iostat -x -k |grep "sda"|awk '{print $7}'`" 26 | echo "" 27 | #avgqu-sz 28 | echo -e "平均I/O队列长度:\t\t\t`iostat -x -k |grep "sda"|awk '{print $9}'`" 29 | echo "" 30 | #avgrq-sz 31 | echo -e "平均每次设备I/O操作的数据大小(扇区):\t`iostat -x -k |grep "sda"|awk '{print $8}'`" 32 | echo "" 33 | #await 34 | echo -e "平均每次设备I/O操作的等待时间(毫秒):\t`iostat -x -k |grep "sda"|awk '{print $10}'`" 35 | #svctm 36 | echo -e "平均每次设备I/O操作的服务时间(毫秒):\t`iostat -x -k |grep "sda"|awk '{print $13}'`" 37 | echo "" 38 | #util 39 | a=`iostat -x -k|grep "sda"|awk '{print int($2)}'` 40 | if [ $a -ge 70 -a $a -lt 95 ];then 41 | echo -e "一秒中有百分之多少的时间用于 I/O 操作:\t`iostat -x -k |grep "sda"|awk '{print $2}'`(I/O压力比较大)" 42 | elif [ $a -ge 95 -a $a -lt 100 ];then 43 | echo -e "一秒中有百分之多少的时间用于 I/O 操作:\t`iostat -x -k |grep "sda"|awk '{print $2}'`(I/O请求太多,磁盘可能存在瓶颈)" 44 | fi 45 | echo -e "一秒中有百分之多少的时间用于 I/O 操作:\t`iostat -x -k |grep "sda"|awk '{print $2}'`" 46 | 47 | #mpstat测系统启动以后所有硬盘IO平均等待时间 48 | ioindex=`mpstat |tail -1|awk '{print int($6)}'` 49 | if [ $ioindex -lt 20 ];then 50 | echo -e "系统启动后硬盘IO平均等待时间(%):\t`mpstat |tail -1|awk '{print $6}'`(磁盘IO状态指标良好)" 51 | elif [ $ioindex -ge 20 ];then 52 | echo -e "系统启动后硬盘IO平均等待时间(%):\t`mpstat |tail -1|awk '{print $6}'`(磁盘IO状态指标不是很良好)" 53 | 54 | fi 55 | fi 56 | #else 57 | # echo "密码输入错误!" 58 | #fi 59 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/remove_hddtemp.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "sysstat" |wc -l` 4 | if [ $a == 0 ];then 5 | echo "hddtemp 未安装" 6 | else 7 | #echo "hddtemp 已安装" 8 | #卸载hddtemp 9 | echo $1 | sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | sudo -S dpkg -P hddtemp 2> /dev/null 12 | if [ $? == 0 ]; then 13 | echo "hddtemp卸载成功!" 14 | else 15 | echo "hddtemp卸载失败!" 16 | fi 17 | else 18 | echo "密码输入错误!" 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/remove_sysstat.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "sysstat" |wc -l` 4 | if [ $a == 0 ];then 5 | echo "sysstat 未安装" 6 | else 7 | #echo "sysstat 已安装" 8 | #卸载sysstat 9 | echo $1 | sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | sudo -S dpkg -P sysstat 2> /dev/null 12 | if [ $? == 0 ]; then 13 | echo "sysstat卸载成功!" 14 | else 15 | echo "sysstat卸载失败!" 16 | fi 17 | else 18 | echo "密码输入错误!" 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/sysstat_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | iostat > /dev/null 4 | if [ $? == 0 ];then 5 | echo "sysstat 已安装" 6 | else 7 | #echo "sysstat 未安装" 8 | #安装sysstat 9 | #验证密码是否正确 10 | echo $1 | sudo -S echo -n 2> /dev/null 11 | if [ $? == 0 ];then 12 | sudo -S apt-get -y install sysstat > /dev/null 13 | if [ $? == 0 ]; then 14 | echo "sysstat安装完成!" 15 | else 16 | echo "sysstat安装失败!" 17 | fi 18 | else 19 | echo "密码输入错误!" 20 | fi 21 | fi 22 | 23 | 24 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/sysstat_judge.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: is_install.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月11日 星期日 15时51分57秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #判断软件安装 9 | iostat > /dev/null 10 | if [ $? == 0 ];then 11 | echo "Y" 12 | else 13 | echo "N" 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/sysstat_judge.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: is_install.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月11日 星期日 15时51分57秒 6 | ######################################################################### 7 | #!/bin/bash 8 | #判断软件安装 9 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "sysstat" |wc -l` 10 | if [ $a == 0 ];then 11 | echo "sysstat 未安装" 12 | else 13 | echo "sysstat 已安装" 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/disk/disktool/sysstat_remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #判断软件安装 3 | iostat > /dev/null 4 | if [ $? -ne 0 ];then 5 | echo "sysstat 未安装" 6 | else 7 | #echo "sysstat 已安装" 8 | #卸载sysstat 9 | echo $1 | sudo -S echo -n 2> /dev/null 10 | if [ $? == 0 ];then 11 | sudo apt-get -y remove sysstat > /dev/null 12 | if [ $? == 0 ]; then 13 | echo "sysstat卸载成功!" 14 | else 15 | echo "sysstat卸载失败!" 16 | fi 17 | else 18 | echo "密码输入错误!" 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/flush_percent/cpu-mem.sh: -------------------------------------------------------------------------------- 1 | #cpu 2 | echo "占用cpu最高的前三名进程" 3 | echo "PID号 CPU% 进程名" 4 | ps aux|grep -v PID|sort -rn -k +3|head -n 3|awk '{print $2" "$3" "$11}' 5 | echo 6 | echo "占用内存最高的前三名进程" 7 | echo "PID号 内存% 进程名" 8 | ps aux|grep -v PID|sort -rn -k +4|head -n 3|awk '{print $2" "$4" "$11}' 9 | -------------------------------------------------------------------------------- /源代码/脚本/flush_percent/cpu-mem.sh~: -------------------------------------------------------------------------------- 1 | #cpu 2 | echo "占用cpu最高的前三名进程" 3 | echo "PID号 CPU% 进程名" 4 | ps aux|grep -v PID|sort -rn -k +3|head -n 3|awk '{print $2" "$3" "$11}' 5 | echo "占用内存最高的前三名进程" 6 | echo "PID号 内存% 进程名" 7 | ps aux|grep -v PID|sort -rn -k +4|head -n 3|awk '{print $2" "$4" "$11}' 8 | -------------------------------------------------------------------------------- /源代码/脚本/flush_percent/cpu_rate.sh: -------------------------------------------------------------------------------- 1 | ##计算cpu利用率(需动态刷新) 2 | #计算公式: 3 | #total_0USER[0]+NICE[0]+SYSTEM[0]+IDLE[0]+IOWAIT[0]+IRQ[0]+SOFTIRQ[0] 4 | #total_1=USER[1]+NICE[1]+SYSTEM[1]+IDLE[1]+IOWAIT[1]+IRQ[1]+SOFTIRQ[1] 5 | #cpu usage=(IDLE[0]-IDLE[1]) / (total_0-total_1) * 100 6 | CPULOG_1=$(cat /proc/stat | grep 'cpu ' | awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8}') 7 | SYS_IDLE_1=$(echo $CPULOG_1 | awk '{print $4}') 8 | Total_1=$(echo $CPULOG_1 | awk '{print $1+$2+$3+$4+$5+$6+$7}') 9 | 10 | sleep 2 11 | 12 | CPULOG_2=$(cat /proc/stat | grep 'cpu ' | awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8}') 13 | SYS_IDLE_2=$(echo $CPULOG_2 | awk '{print $4}') 14 | Total_2=$(echo $CPULOG_2 | awk '{print $1+$2+$3+$4+$5+$6+$7}') 15 | 16 | SYS_IDLE=`expr $SYS_IDLE_2 - $SYS_IDLE_1` 17 | 18 | Total=`expr $Total_2 - $Total_1` 19 | SYS_USAGE=`expr $SYS_IDLE/$Total*100 |bc -l` 20 | 21 | SYS_Rate=`expr 100-$SYS_USAGE |bc -l` 22 | 23 | Disp_SYS_Rate=`awk 'BEGIN{printf"%.2f\n",'$SYS_Rate' / 1}'` 24 | echo $Disp_SYS_Rate 25 | -------------------------------------------------------------------------------- /源代码/脚本/flush_percent/mem_rate.sh: -------------------------------------------------------------------------------- 1 | ##计算内存占用率 2 | MemTotal=$(cat /proc/meminfo | awk '/^MemTotal/{print $2}') #内存总量 3 | MemFree=$(cat /proc/meminfo | awk '/^MemFree/{print $2}') #空闲内存 4 | MemUsed=$(expr $MemTotal - $MemFree) #已用内存 5 | Mem_Rate=$(awk 'BEGIN{printf"%.2f\n",'$MemUsed' / '$MemTotal' *100}') #保留小数点后2位 6 | echo $Mem_Rate 7 | -------------------------------------------------------------------------------- /源代码/脚本/home_info/ethnetspeedhome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #计算每秒有线网网速 4 | enum=`cat /proc/net/dev |grep "eth" |wc -l` 5 | if [ $enum -gt 0 ];then 6 | for((j=0;j<$enum;j++)) 7 | do 8 | n=`ethtool eth$j | grep "Link detected: yes" |wc -l` > /dev/null #判断有线网是否连接 9 | if [ $n -eq 1 ] 10 | then 11 | eth=eth$j 12 | 13 | #提取下载速度 14 | #求出一秒前后流量的差值,作为这一秒的下载网速, 从/proc/net/dev文件中. 15 | eRXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') 16 | sleep 1 17 | eRXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') 18 | 19 | eRX=$((${eRXnext}-${eRXpre})) 20 | 21 | #流量单位转换 22 | if [[ $eRX -lt 1024 ]];then 23 | eRX="${eRX}B/s" 24 | elif [[ $eRX -gt 1048576 ]];then 25 | eRX=$(echo $eRX | awk '{print $1/1048576 "MB/s"}') 26 | else 27 | eRX=$(echo $eRX | awk '{print $1/1024 "KB/s"}') 28 | fi 29 | #输出下载速度 30 | #echo -e "当前下载速度为 $eRX" 31 | 32 | #提取上传速度 33 | #求出一秒前后流量的差值,作为这一秒的上传网速, 从/proc/net/dev文件中 34 | eTXpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') 35 | sleep 1 36 | eTXnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') 37 | TX=$((${eTXnext}-${eTXpre})) 38 | 39 | #流量单位转换 40 | if [[ $eTX -lt 1024 ]];then 41 | eTX="${eTX}B/s" 42 | elif [[ $eTX -gt 1048576 ]];then 43 | eTX=$(echo $eTX | awk '{print $1/1048576 "MB/s"}') 44 | else 45 | eTX=$(echo $eTX | awk '{print $1/1024 "KB/s"}') 46 | fi 47 | #输出下载速度 48 | echo -e "有线网下载速度 $eRX 上传速度 $eTX" 49 | else 50 | echo "有线网未连接" 51 | fi 52 | done 53 | else 54 | echo "本机没有有线网卡" 55 | fi 56 | 57 | 58 | -------------------------------------------------------------------------------- /源代码/脚本/home_info/homeinfo_btime.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | 3 | #echo "当前登入的用户:`whoami` " 4 | 5 | #此函数计算系统开机所用时间单位是秒数 6 | function run_time (){ 7 | #计算出dmesg中系统启动记录的时间相对文件开头的时间 8 | a=`cat /var/log/dmesg | grep "setting system" | awk '{print $2}'` 9 | run=${a%?} 10 | run=${run:0:1} 11 | #获取dmesg中系统启动时记录的时间 12 | start_hour=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($1)}'`*3600] 13 | start_min=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($2)}'`*60] 14 | start_sec=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($3)}'`] 15 | #做减法获取真正系统启动的时间 16 | start_time=$[$start_hour+$start_min+$start_sec-$run] 17 | #获取图形登入界面启动的时间,这里有两个要去掉父进程为1的进程,取最近时间的进程 18 | end_time=0 19 | for pid in $(pgrep lightdm); 20 | do 21 | t2=`ps -p ${pid} -o lstart=` 22 | end_hour=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($1)}'`*3600] 23 | end_min=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($2)}'`*60] 24 | end_sec=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($3)}'`] 25 | t1=$[$end_hour+$end_min+$end_sec] 26 | if [ $t1 -gt $end_time ] 27 | then 28 | end_time=$t1 29 | fi 30 | done 31 | #获取系统启动的时长 32 | cur_runtime=$[$end_time-$start_time] 33 | #为了判断cmos有问题,还是格林尼治时间的处理,要把结果减去28800 34 | if [ $cur_runtime -ge 28800 ] 35 | then 36 | cur_runtime=$[$cur_runtime - 28800] 37 | fi 38 | #返回系统启动时长 39 | echo $cur_runtime 40 | } 41 | 42 | #此函数将开机所用的的秒数格式化转换成时分秒 43 | function date_time() 44 | { 45 | min=0 46 | hour=0 47 | #一般情况下针对个人PC开机时长是不会超过一个小时的 48 | min=$[$[ $1 / 60 ] %60] 49 | second=$[$1 % 60] 50 | if [ $1 -gt 60 ] 51 | then 52 | echo "本次开机用时$min分$second秒" 53 | else 54 | echo "本次开机用时$second秒" 55 | fi 56 | } 57 | timelength=$(run_time) 58 | date_time $timelength 59 | 60 | echo "本次开机时刻:`date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S"`" 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /源代码/脚本/home_info/homeinfousr.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | echo -e " 当前登入用户" 3 | echo -e " `whoami`" 4 | -------------------------------------------------------------------------------- /源代码/脚本/home_info/wlannetspeedhome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################################################################ 4 | #计算每秒无线网网速 5 | #判断有多少个无线网卡,有的电脑可能有wlan0、wlan1 6 | wnum=`cat /proc/net/dev |grep "wlan" |wc -l` 7 | #判断本机有没有无线网卡 8 | if [ $wnum -gt 0 ];then 9 | #循环求每个无线网卡的网速 10 | for((i=0;i<$wnum;i++)) 11 | do 12 | m=`ethtool wlan$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 13 | if [ $m -eq 1 ] 14 | then 15 | wla=wlan$i 16 | 17 | 18 | #提取下载速度 19 | #求出一秒前后流量的差值,作为这一秒的下载网速, 从/proc/net/dev文件中. 20 | RXpre=$(cat /proc/net/dev | grep $wla | tr : " " | awk '{print $2}') 21 | sleep 1 22 | RXnext=$(cat /proc/net/dev | grep $wla | tr : " " | awk '{print $2}') 23 | 24 | RX=$((${RXnext}-${RXpre})) 25 | 26 | #流量单位转换 27 | if [[ $RX -lt 1024 ]];then 28 | RX="${RX}B/s" 29 | elif [[ $RX -gt 1048576 ]];then 30 | RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}') 31 | else 32 | RX=$(echo $RX | awk '{print $1/1024 "KB/s"}') 33 | fi 34 | #输出下载速度 35 | #echo -e "当前下载速度为 $RX" 36 | 37 | #提取上传速度 38 | #求出一秒前后流量的差值,作为这一秒的上传网速, 从/proc/net/dev文件中 39 | TXpre=$(cat /proc/net/dev | grep $wla | tr : " " | awk '{print $10}') 40 | sleep 1 41 | TXnext=$(cat /proc/net/dev | grep $wla | tr : " " | awk '{print $10}') 42 | TX=$((${TXnext}-${TXpre})) 43 | #流量单位转换 44 | if [[ $TX -lt 1024 ]];then 45 | TX="${TX}B/s" 46 | elif [[ $TX -gt 1048576 ]];then 47 | TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}') 48 | else 49 | TX=$(echo $TX | awk '{print $1/1024 "KB/s"}') 50 | fi 51 | #输出下载速度 52 | echo -e "无线网下载速度 $RX 上传速度 $TX " 53 | 54 | else 55 | echo "无线网未连接" 56 | fi 57 | done 58 | else 59 | echo "本机没有有线网卡" 60 | fi 61 | 62 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/1/netinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #有线网卡信息 3 | ecnum=`lspci |grep "Ethernet controller:"|grep -v "Wireless"|wc -l` 4 | if [ $ecnum -ne 0 ];then 5 | echo "有线网卡" 6 | echo -e "个数:\t $ecnum " 7 | echo -e "生产商:\t `lspci | grep -i eth | grep -v "Wireless" | awk '{print $4,$5}'`" 8 | echo -e "型号:\t `lspci | grep -i eth | grep -v "Wireless" | cut -f3 -d ":" | sed 's/([^>]*)//g'`" 9 | 10 | count_wireless=`lspci | grep -i Wireless | wc -l` 11 | 12 | #判断是否在虚拟情况下 13 | v_judge=`ethtool eth0 |wc -l` 14 | if [ $v_judge -ge 19 ];then 15 | echo -e "支持的端口: `ethtool eth0 |grep "Supported ports:" |awk '{print $4}'`" 16 | echo -e "工作带宽: `ethtool eth0 |grep "Speed:" |awk '{print $2}'`" 17 | 18 | estatus=`ethtool eth0 |grep "Link detected: yes" |wc -l` 19 | if [ $estatus -eq 1 ];then 20 | echo -e "当前状态:\t 连接" 21 | else 22 | echo -e "当前状态:\t 未连接" 23 | fi 24 | 25 | echo "" 26 | 27 | fi 28 | fi 29 | ######################################################################## 30 | #无线网卡信息 31 | ncnum=`lspci |grep "Wireless Network Adapter" |wc -l` 32 | echo "无线网卡" 33 | echo -e "个数:\t $ncnum " 34 | 35 | if [ $count_wireless -ne 0 ] 36 | then 37 | echo -e "生产商:\t `lspci | grep "Wireless" | awk '{print $4,$5}'`" #(可优化) 38 | echo -e "型号:\t `lspci | grep "Wireless" | cut -f3 -d ":" | sed 's/([^>]*)//g'`" 39 | wstatus=`ethtool wlan0 |grep "Link detected: yes" |wc -l` 40 | if [ $wstatus -eq 1 ];then 41 | echo -e "当前状态:\t 连接" 42 | else 43 | echo -e "当前状态:\t 未连接" 44 | fi 45 | else 46 | echo -e "无线网卡:\t 无" 47 | fi 48 | 49 | echo "" 50 | #提取硬件MAC地址 51 | echo -e "网卡MAC地址:`ifconfig |grep "eth0" |awk '{print $5}'`" 52 | 53 | #内核路由表(U路由被启用,H目标是一个主机,G使用网关) 54 | #route -n 55 | #echo "注:标志Flags U表示路由被启用、H表示目标是一个主机、G表示使用网关" 56 | echo "" 57 | #查看ipv6是否开启 58 | ip6=`cat /proc/sys/net/ipv6/conf/all/disable_ipv6` 59 | if [ $ip6 == 0 ];then 60 | echo "IPv6是开启状态(目前网络主要使用IPv4协议,开启IPv6可能影响网络性能)" 61 | fi 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/1/netinfo.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #有线网卡信息 3 | ecnum=`lspci |grep "Ethernet controller:"|grep -v "Wireless"|wc -l` 4 | if [ $ecnum -ne 0 ];then 5 | echo "有线网卡" 6 | echo -e "个数:\t $ecnum " 7 | echo -e "生产商:\t `lspci | grep -i eth | grep -v "Wireless" | awk '{print $4,$5}'`" 8 | echo -e "型号:\t `lspci | grep -i eth | grep -v "Wireless" | cut -f3 -d ":" | sed 's/([^>]*)//g'`" 9 | 10 | count_wireless=`lspci | grep -i Wireless | wc -l` 11 | 12 | #判断是否在虚拟情况下 13 | v_judge=`ethtool eth0 |wc -l` 14 | if [ $v_judge -ge 19 ];then 15 | echo -e "支持的端口: `ethtool eth0 |grep "Supported ports:" |awk '{print $4}'`" 16 | echo -e "工作带宽: `ethtool eth0 |grep "Speed:" |awk '{print $2}'`" 17 | 18 | estatus=`ethtool eth0 |grep "Link detected: yes" |wc -l` 19 | if [ $estatus -eq 1 ];then 20 | echo -e "当前状态:\t 连接" 21 | else 22 | echo -e "当前状态:\t 未连接" 23 | fi 24 | 25 | echo "" 26 | 27 | fi 28 | fi 29 | ######################################################################## 30 | #无线网卡信息 31 | ncnum=`lspci |grep "Wireless Network Adapter" |wc -l` 32 | echo "无线网卡" 33 | echo -e "个数:\t $ncnum " 34 | 35 | if [ $count_wireless -ne 0 ] 36 | then 37 | echo -e "生产商:\t `lspci | grep "Wireless" | awk '{print $4,$5}'`" #(可优化) 38 | echo -e "型号:\t `lspci | grep "Wireless" | cut -f3 -d ":" | sed 's/([^>]*)//g'`" 39 | wstatus=`ethtool wlan0 |grep "Link detected: yes" |wc -l` 40 | if [ $wstatus -eq 1 ];then 41 | echo -e "当前状态:\t 连接" 42 | else 43 | echo -e "当前状态:\t 未连接" 44 | fi 45 | else 46 | echo -e "无线网卡:\t 无" 47 | fi 48 | 49 | echo "" 50 | #提取硬件MAC地址 51 | echo -e "网卡MAC地址:`ifconfig |grep "eth0" |awk '{print $5}'`" 52 | 53 | #内核路由表(U路由被启用,H目标是一个主机,G使用网关) 54 | #route -n 55 | #echo "注:标志Flags U表示路由被启用、H表示目标是一个主机、G表示使用网关" 56 | echo "" 57 | #查看ipv6是否开启 58 | ip6=`cat /proc/sys/net/ipv6/conf/all/disable_ipv6` 59 | if [ $ip6 == 0 ];then 60 | echo "IPv6是开启状态(目前网络主要使用IPv4协议,开启IPv6可能影响网络性能)" 61 | fi 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/ethavgflow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #测一定时间内有线网总流量和平均流量 3 | 4 | #测试时间超过1小时提醒用户 5 | n=3600 6 | wnum=`cat /proc/net/dev |grep "eth" |wc -l` 7 | #判断本机有没有有线网卡 8 | if [ $wnum -gt 0 ];then 9 | if [ $1 -gt 3600 ];then 10 | echo "测试时间段已超过1小时,您将要等待很长时间!" 11 | fi 12 | if [ $1 -gt 0 ]; then 13 | for((i=0;i<$wnum;i++)) 14 | do 15 | m=`ethtool eth$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 16 | if [ $m -eq 1 ] 17 | then 18 | eth=eth$i 19 | sec=$1 20 | echo "$eth "$sec"秒内的流量情况正在计算中..." 21 | infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 22 | outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 23 | sumfirst=$(($infirst+$outfirst)) 24 | sleep $sec"s" 25 | inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 26 | outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 27 | sumend=$(($inend+$outend)) 28 | sum=$(($sumend-$sumfirst)) 29 | #echo "$eth 网卡接口:" 30 | #echo $sec" 秒内总流量为:"$sum"bytes" 31 | aver=$(($sum/$sec)) 32 | echo "总流量:"$sum"bytes,平均流量:"$aver"bytes/s" 33 | else 34 | echo "有线网未连接,无法测试!" 35 | fi 36 | done 37 | else 38 | echo "测试时间输入不规范!" 39 | fi 40 | else 41 | echo "本机没有有线网卡" 42 | fi 43 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/ethavgflow.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #测一定时间内有线网总流量和平均流量 3 | wnum=`cat /proc/net/dev |grep "eth" |wc -l` 4 | #判断本机有没有有线网卡 5 | if [ $wnum -gt 0 ];then 6 | for((i=0;i<$wnum;i++)) 7 | do 8 | m=`ethtool eth$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 9 | if [ $m -eq 1 ] 10 | then 11 | eth=eth$i 12 | #echo -n "请输入需要查询的网卡的接口:" 13 | #read eth 14 | #echo "你要查询的网卡接口为"$eth 15 | #echo -n "输入需要等到的时间(秒):" 16 | #read sec 17 | sec=$1 18 | echo "您计算的是"$sec"秒内的平均流量,请等待." 19 | infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 20 | outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 21 | sumfirst=$(($infirst+$outfirst)) 22 | sleep $sec"s" 23 | inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 24 | outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 25 | sumend=$(($inend+$outend)) 26 | sum=$(($sumend-$sumfirst)) 27 | echo "$eth 网卡接口:" 28 | echo $sec" 秒内总流量为:"$sum"bytes" 29 | aver=$(($sum/$sec)) 30 | echo "$sec 内的平均流量为:"$aver"bytes/s" 31 | else 32 | echo "有线网未连接,无法测试!" 33 | fi 34 | done 35 | else 36 | echo "本机没有有线网卡" 37 | fi 38 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/netavg.sh~: -------------------------------------------------------------------------------- 1 | gvar1=2 2 | 3 | #每秒有线网平均负载 4 | enum=`cat /proc/net/dev |grep "eth" |wc -l` 5 | for((j=0;j<$enum;j++)) 6 | do 7 | #packets 接收的报文总数 8 | erpackets1=`cat /proc/net/dev |grep "eth$j"|awk '{print $3}'` 9 | 10 | #packets 发送的报文总数 11 | etpackets1=`cat /proc/net/dev |grep "eth$j"|awk '{print $11}'` 12 | 13 | 14 | etotalpackets1=$[$erpackets1+$etpackets1] 15 | 16 | sleep 1 17 | #packets 接收的报文总数 18 | erpackets2=`cat /proc/net/dev |grep "eth$j"|awk '{print $3}'` 19 | 20 | #packets 发送的报文总数 21 | etpackets2=`cat /proc/net/dev |grep "eth$j"|awk '{print $11}'` 22 | 23 | 24 | etotalpackets2=$[$erpackets2+$etpackets2] 25 | esub=$[$etotalpackets2-$etotalpackets1] 26 | enetavg=`awk 'BEGIN{printf"%.2f\n",'$esub' / '$gvar1'}'` 27 | echo "eth$j每秒平均网络负载为:$enetavg" 28 | done 29 | 30 | #每秒无线网平均负载 31 | wnum=`cat /proc/net/dev |grep "wlan" |wc -l` 32 | for((i=0;i<$wnum;i++)) 33 | do 34 | #packets 接收的报文总数 35 | wrpackets1=`cat /proc/net/dev |grep "wlan$i"|awk '{print $3}'` 36 | 37 | #packets 发送的报文总数 38 | wtpackets1=`cat /proc/net/dev |grep "wlan$i"|awk '{print $11}'` 39 | 40 | wtotalpackets1=$[$wrpackets1+$wtpackets1] 41 | sleep 1 42 | #packets 接收的报文总数 43 | wrpackets2=`cat /proc/net/dev |grep "wlan$i"|awk '{print $3}'` 44 | 45 | #packets 发送的报文总数 46 | wtpackets2=`cat /proc/net/dev |grep "wlan$i"|awk '{print $11}'` 47 | 48 | wtotalpackets2=$[$wrpackets2+$wtpackets2] 49 | wsub=$[$wtotalpackets2-$wtotalpackets1] 50 | wnetavg=`awk 'BEGIN{printf"%.2f\n",'$wsub' / '$gvar1'}'` 51 | echo "wlan$i每秒平均网络负载为:$wnetavg" 52 | done 53 | 54 | 55 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/tcp_rrate.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: tcp_rrate.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月12日 星期一 15时53分54秒 6 | ######################################################################### 7 | #!/bin/bash 8 | gvar=240 9 | 10 | po=`cat /proc/net/snmp |grep "Tcp"|grep -A1 "PassiveOpens" |awk NR==2'{print int($7)}'` 11 | 12 | idata=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($2)}'` 13 | 14 | odata=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($5)}'` 15 | 16 | sleep 240 17 | 18 | ponew=`cat /proc/net/snmp |grep "Tcp"|grep -A1 "PassiveOpens" |awk NR==2'{print int($7)}'` 19 | idatanew=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($2)}'` 20 | odatanew=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($5)}'` 21 | 22 | #平均每秒新增TCP连接数 23 | posub=$[$ponew-$po] 24 | pos=`awk 'BEGIN{printf"%.2f\n",'$posub' / '$gvar'}'` 25 | echo "平均每秒新增的TCP连接数$posub" 26 | 27 | #平均每秒的UDP接收数据报 28 | idatasub=$[$idatanew-$idata] 29 | idatas=`awk 'BEGIN{printf"%.2f\n",'$idatasub' / '$gvar'}'` 30 | echo "平均每秒接收的UDP数据报:$idatas" 31 | 32 | #平均每秒的UDP发送数据报 33 | odatasub=$[$odatanew-$odata] 34 | odatas=`awk 'BEGIN{printf"%.2f\n",'$odatasub' / '$gvar'}'` 35 | echo "平均每秒发送的UDP数据报:$odatas" 36 | 37 | 38 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/tcp_udp.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: tcp_rrate.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月12日 星期一 15时53分54秒 6 | ######################################################################### 7 | #!/bin/bash 8 | gvar=60 9 | 10 | po=`cat /proc/net/snmp |grep "Tcp"|grep -A1 "PassiveOpens" |awk NR==2'{print int($7)}'` 11 | 12 | idata=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($2)}'` 13 | 14 | odata=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($5)}'` 15 | 16 | sleep $gvar 17 | 18 | ponew=`cat /proc/net/snmp |grep "Tcp"|grep -A1 "PassiveOpens" |awk NR==2'{print int($7)}'` 19 | idatanew=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($2)}'` 20 | odatanew=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($5)}'` 21 | 22 | #平均每秒新增TCP连接数 23 | posub=$[$ponew-$po] 24 | pos=`awk 'BEGIN{printf"%.2f\n",'$posub' / '$gvar'}'` 25 | echo "平均每秒新增的TCP连接数$posub" 26 | 27 | #平均每秒的UDP接收数据报 28 | idatasub=$[$idatanew-$idata] 29 | idatas=`awk 'BEGIN{printf"%.2f\n",'$idatasub' / '$gvar'}'` 30 | echo "平均每秒接收的UDP数据报:$idatas" 31 | 32 | #平均每秒的UDP发送数据报 33 | odatasub=$[$odatanew-$odata] 34 | odatas=`awk 'BEGIN{printf"%.2f\n",'$odatasub' / '$gvar'}'` 35 | echo "平均每秒发送的UDP数据报:$odatas" 36 | 37 | 38 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/tcp_udp.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: tcp_rrate.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月12日 星期一 15时53分54秒 6 | ######################################################################### 7 | #!/bin/bash 8 | gvar=2 9 | 10 | po=`cat /proc/net/snmp |grep "Tcp"|grep -A1 "PassiveOpens" |awk NR==2'{print int($7)}'` 11 | 12 | idata=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($2)}'` 13 | 14 | odata=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($5)}'` 15 | 16 | sleep $gvar 17 | 18 | ponew=`cat /proc/net/snmp |grep "Tcp"|grep -A1 "PassiveOpens" |awk NR==2'{print int($7)}'` 19 | idatanew=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($2)}'` 20 | odatanew=`cat /proc/net/snmp |grep -A1 "Udp: InDatagrams" |awk NR==2'{print int($5)}'` 21 | 22 | #平均每秒新增TCP连接数 23 | posub=$[$ponew-$po] 24 | pos=`awk 'BEGIN{printf"%.2f\n",'$posub' / '$gvar'}'` 25 | echo "平均每秒新增的TCP连接数$posub" 26 | 27 | #平均每秒的UDP接收数据报 28 | idatasub=$[$idatanew-$idata] 29 | idatas=`awk 'BEGIN{printf"%.2f\n",'$idatasub' / '$gvar'}'` 30 | echo "平均每秒接收的UDP数据报:$idatas" 31 | 32 | #平均每秒的UDP发送数据报 33 | odatasub=$[$odatanew-$odata] 34 | odatas=`awk 'BEGIN{printf"%.2f\n",'$odatasub' / '$gvar'}'` 35 | echo "平均每秒发送的UDP数据报:$odatas" 36 | 37 | 38 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/test_netlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 无网返回0,有线网连接返回1,无线网连接返回2,有线网和无线网都连接返回3(有的电脑有线和无线都可以连接) 3 | eth_link=0 4 | eth_unlink=0 5 | wlan_link=0 6 | wlan_unlink=0 7 | 8 | #判断有多少个有线网卡,有的电脑可能有eth0、eth1 9 | enum=`cat /proc/net/dev |grep "eth" |wc -l` 10 | if [ $enum -gt 0 ];then 11 | for((j=0;j<$enum;j++)) 12 | do 13 | n=`ethtool eth$j | grep "Link detected: yes" |wc -l` > /dev/null #判断有线网是否连接 14 | if [ $n -eq 1 ] 15 | then 16 | eth_link=1 17 | #echo "有线网已连接" 18 | else 19 | eth_unlink=1 20 | #echo "有线网未连接" 21 | fi 22 | done 23 | else 24 | echo "本机没有有线网卡" 25 | fi 26 | 27 | ############################################################################# 28 | #判断有多少个无线网卡,有的电脑可能有wlan0、wlan1 29 | wnum=`cat /proc/net/dev |grep "wlan" |wc -l` 30 | #判断本机有没有无线网卡 31 | if [ $wnum -gt 0 ];then 32 | #循环求每个无线网卡的网速 33 | for((i=0;i<$wnum;i++)) 34 | do 35 | m=`ethtool wlan$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 36 | if [ $m -eq 1 ] 37 | then 38 | wlan_link=1 39 | #echo "无线网已连接" 40 | else 41 | wlan_unlink=1 42 | #echo "无线网未连接" 43 | fi 44 | done 45 | else 46 | echo "本机没有有线网卡" 47 | fi 48 | 49 | #无网返回0,有线网连接返回1,无线网连接返回2,有线网和无线网都连接返回3(有的电脑有线和无线都可以连接) 50 | if [ $eth_unlink == 1 -a $wlan_unlink == 1 ];then 51 | echo 0 52 | elif [ $eth_link == 1 -a $wlan_unlink == 1 ];then 53 | echo 1 54 | elif [ $eth_unlink == 1 -a $wlan_link == 1 ];then 55 | echo 2 56 | elif [ $eth_link == 1 -a $wlan_link == 1 ];then 57 | echo 3 58 | fi 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/wlanavgflow.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #测一定时间内无线网总流量和平均流量 3 | #测试时间超过1小时提醒用户 4 | n=3600 5 | wnum=`cat /proc/net/dev |grep "wlan" |wc -l` 6 | #判断本机有没有无线网卡 7 | if [ $wnum -gt 0 ];then 8 | if [ $1 -gt 3600 ];then 9 | echo "测试时间段已超过1小时,您将要等待很长时间!" 10 | fi 11 | if [ $1 -gt 0 ]; then 12 | for((i=0;i<$wnum;i++)) 13 | do 14 | m=`ethtool wlan$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 15 | if [ $m -eq 1 ] 16 | then 17 | eth=wlan$i 18 | sec=$1 19 | echo "$eth "$sec"秒内的流量情况正在计算中..." 20 | infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 21 | outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 22 | sumfirst=$(($infirst+$outfirst)) 23 | sleep $sec"s" 24 | inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 25 | outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 26 | sumend=$(($inend+$outend)) 27 | sum=$(($sumend-$sumfirst)) 28 | #echo "$eth 网卡接口:" 29 | #echo $sec" 秒内总流量为:"$sum"bytes" 30 | aver=$(($sum/$sec)) 31 | echo "总流量:"$sum"bytes,平均流量:"$aver"bytes/s" 32 | else 33 | echo "无线网未连接,无法测试!" 34 | fi 35 | done 36 | else 37 | echo "测试时间输入不规范!" 38 | fi 39 | else 40 | echo "本机没有无线网卡" 41 | fi 42 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/wlanavgflow.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #测一定时间内无线网总流量和平均流量 3 | wnum=`cat /proc/net/dev |grep "wlan" |wc -l` 4 | #判断本机有没有无线网卡 5 | if [ $wnum -gt 0 ];then 6 | for((i=0;i<$wnum;i++)) 7 | do 8 | m=`ethtool wlan$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 9 | if [ $m -eq 1 ] 10 | then 11 | eth=wlan$i 12 | #echo -n "请输入需要查询的网卡的接口:" 13 | #read eth 14 | #echo "你要查询的网卡接口为"$eth 15 | #echo -n "输入需要等到的时间(秒):" 16 | #read sec 17 | sec=$1 18 | echo "您计算的是"$sec"秒内的平均流量,请等待." 19 | infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 20 | outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 21 | sumfirst=$(($infirst+$outfirst)) 22 | sleep $sec"s" 23 | inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 24 | outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 25 | sumend=$(($inend+$outend)) 26 | sum=$(($sumend-$sumfirst)) 27 | echo "$eth 网卡接口:" 28 | echo $sec" 秒内总流量为:"$sum"bytes" 29 | aver=$(($sum/$sec)) 30 | echo "$sec 内的平均流量为:"$aver"bytes/s" 31 | else 32 | echo "无线网未连接,无法测试!" 33 | fi 34 | done 35 | else 36 | echo "本机没有无线网卡" 37 | fi 38 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/2/wlanethavgflow.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #测一定时间内无线网总流量和平均流量 3 | wnum=`cat /proc/net/dev |grep "wlan" |wc -l` 4 | #判断本机有没有无线网卡 5 | if [ $wnum -gt 0 ];then 6 | for((i=0;i<$wnum;i++)) 7 | do 8 | m=`ethtool wlan$i |grep "Link detected: yes" |wc -l` > /dev/null #判断无线网是否连接 9 | if [ $m -eq 1 ] 10 | then 11 | eth=wlan$i 12 | #echo -n "请输入需要查询的网卡的接口:" 13 | #read eth 14 | #echo "你要查询的网卡接口为"$eth 15 | #echo -n "输入需要等到的时间(秒):" 16 | #read sec 17 | sec=$1 18 | echo "您计算的是"$sec"秒内的平均流量,请等待." 19 | infirst=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 20 | outfirst=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 21 | sumfirst=$(($infirst+$outfirst)) 22 | sleep $sec"s" 23 | inend=$(awk '/'$eth'/{print $1 }' /proc/net/dev |sed 's/'$eth'://') 24 | outend=$(awk '/'$eth'/{print $10 }' /proc/net/dev) 25 | sumend=$(($inend+$outend)) 26 | sum=$(($sumend-$sumfirst)) 27 | echo "$eth 网卡接口:" 28 | echo $sec" 秒内总流量为:"$sum"bytes" 29 | aver=$(($sum/$sec)) 30 | echo "$sec 内的平均流量为:"$aver"bytes/s" 31 | else 32 | echo "无线网未连接,无法测试!" 33 | fi 34 | done 35 | else 36 | echo "本机没有有线网卡" 37 | fi 38 | -------------------------------------------------------------------------------- /源代码/脚本/netinfo/3/firewall.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: firewall.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月21日 星期三 21时25分34秒 6 | ######################################################################### 7 | #!/bin/bash 8 | iptabnum=0 9 | #查看防火墙状态 10 | echo $1 | sudo -S echo -n 2> /dev/null 11 | if [ $? == 0 ];then 12 | #适应中文的系统 13 | ufwnum=`sudo ufw status |grep "active" |wc -l` 14 | if [ $ufwnum == 0 ];then 15 | echo "ufw防火墙`sudo ufw status`" 16 | else 17 | #适应英文的系统 18 | ufwstatus=`sudo ufw status |awk '{print $2}'` 19 | if [ $ufwstatus = "active" ];then 20 | echo "ufw防火墙状态:激活" 21 | elif [ $ufwstatus = "inactive" ];then 22 | echo "ufw防火墙状态:不活动" 23 | fi 24 | fi 25 | 26 | echo " " 27 | inputnum=`sudo iptables -L |grep "Chain INPUT" |wc -l` 28 | if [ $inputnum -ne 0 ];then 29 | ((iptabnum++)) 30 | 31 | fi 32 | forwardnum=`sudo iptables -L |grep "Chain FORWARD" |wc -l` 33 | if [ $forwardnum -ne 0 ];then 34 | ((iptabnum++)) 35 | 36 | fi 37 | outputnum=`sudo iptables -L |grep "Chain OUTPUT" |wc -l` 38 | if [ $outputnum -ne 0 ];then 39 | ((iptabnum++)) 40 | 41 | fi 42 | if [ $iptabnum -ge 3 ];then 43 | echo "iptables防火墙默认防护已开启" 44 | else 45 | echo "iptables默认防护规则不完整" 46 | fi 47 | #echo "采用tcp协议,处于监听状态进程的绑定端口及IP信息如下:" 48 | #sudo netstat -lntp 49 | #else 50 | #echo "采用tcp协议,处于监听状态进程的绑定端口及IP信息如下:" 51 | #netstat -lntp 52 | fi 53 | -------------------------------------------------------------------------------- /源代码/脚本/otherinfo/hardwareinfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #硬件信息 3 | 4 | ##显卡信息 5 | #集成显卡 6 | echo -e "集成显卡型号:" #sed删除括号里的内容(可优化) 7 | echo -e "`lspci | grep -i 'VGA' | sed '2d' | cut -f3 -d ":" | sed 's/([^>]*)//g'`" 8 | 9 | echo -e "集成显卡生产商:" #(可优化) 10 | echo -e "`lspci | grep -i 'VGA'| sed '2d'| awk '{ print $5,$6 }'`" 11 | 12 | #lspci | grep -i 'VGA' | sed '2d' |awk '{for(i=5;i<=11;i++)printf $i""FS;print""}' 13 | echo "" 14 | count_dis=`lspci | grep -i 'VGA' | wc -l` 15 | 16 | if [ $count_dis -eq 2 ] 17 | then 18 | #独立显卡 19 | echo -e "独立显卡型号:" 20 | echo -e "`lspci | grep -i 'VGA' | sed '1d' | cut -f3 -d ":" | sed 's/([^>]*)//g'`" #(可优化) 21 | 22 | echo -e "独立显卡生产商:" 23 | echo -e "`lspci | grep -i 'VGA'| sed '1d'| awk '{ print $5,$6 }'`" #(可优化) 24 | 25 | else 26 | echo -e "独立显卡信息:" 27 | echo -e "无" 28 | fi 29 | echo "" 30 | ##声卡 31 | count_sound=`lspci | grep Audio | wc -l` 32 | 33 | if [ $count_sound -eq 1 ] 34 | then 35 | echo -e "声卡型号:" 36 | echo -e "`lspci |grep Audio | cut -f3 -d ":" | sed 's/([^>]*)//g'`" 37 | 38 | echo -e "声卡生产商:" 39 | echo -e "`lspci | grep Audio | awk '{ print $4,$5 }'`" 40 | 41 | echo "" 42 | else #有的电脑有超过2个声卡 43 | for((i=1;i<=$count_sound;i++));do 44 | 45 | echo -e "声卡$i型号:"; 46 | echo -e "`lspci |grep Audio | awk 'NR=='$i'' | cut -f3 -d ":" | sed 's/([^>]*)//g'`"; 47 | 48 | echo -e "声卡$i生产商:"; 49 | echo -e "`lspci | grep Audio | awk 'NR=='$i' { print $4,$5 }'`"; 50 | 51 | 52 | echo "" 53 | done 54 | fi 55 | 56 | 57 | -------------------------------------------------------------------------------- /源代码/脚本/otherinfo/hardwareinfomore.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: hardwareinfomore.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月21日 星期三 21时28分33秒 6 | ######################################################################### 7 | #!/bin/bash 8 | echo $1 | sudo -S echo -n 2> /dev/null 9 | if [ $? == 0 ] 10 | then 11 | ##主板信息 12 | sudo dmidecode > hardware_tmp 13 | echo "------------------------------主板信息------------------------------" 14 | echo -e "主板厂商:\t\t\t`cat hardware_tmp | grep -A 10 "Base Board Information" |grep "Manufacturer" | awk -F ':' '{print $2}'`" 15 | echo "" 16 | echo -e "产品名称:\t\t\t`cat hardware_tmp | grep -A 10 "Base Board Information" |grep "Product Name" | awk -F ':' '{print $2}'`" 17 | echo "" 18 | echo -e "版本:\t\t\t`cat hardware_tmp | grep -A 10 "Base Board Information" | grep 'Version' | awk -F ':' '{print $2}'`" 19 | echo "" 20 | echo -e "序列号:\t\t\t`cat hardware_tmp | grep -A 10 "Base Board Information" | grep 'Serial' | awk -F ':' '{print $2}'`" 21 | echo "" 22 | echo "" 23 | ##BIOS信息 24 | echo "------------------------------BIOS信息------------------------------" 25 | echo -e "BIOS厂商:\t\t\t`cat hardware_tmp | grep -A 28 "BIOS Information" | grep 'Vendor' | awk -F ':' '{print $2}'`" 26 | echo "" 27 | echo -e "BIOS版本:\t\t\t`cat hardware_tmp | grep -A 28 "BIOS Information" | grep 'Version' | awk -F ':' '{print $2}'`" 28 | echo "" 29 | echo -e "发行日期:\t\t\t`cat hardware_tmp | grep -A 28 "BIOS Information" | grep 'Release' | awk -F ':' '{print $2}'`" 30 | 31 | rm -rf hardware_tmp 32 | 33 | fi 34 | -------------------------------------------------------------------------------- /源代码/脚本/otherinfo/startup.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: startup.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月21日 星期三 21时12分51秒 6 | ######################################################################### 7 | #!/bin/bash 8 | 9 | #显示开机自启动项(S开头) 10 | base=56 11 | #(点击更多信息按钮时可查看到)root权限显示的信息 12 | #验证输入的用户名密码是否正确,并把错误信息重定向到垃圾桶里 13 | echo $1 | sudo -S echo -n 2> /dev/null 14 | if [ $? == 0 ];then 15 | #得到rc0.d~rc6.d、rcS.d这几个目录的路径 16 | filelist=`echo $1 | sudo -S find /etc -name "rc*.d"` 17 | for file in $filelist 18 | do 19 | #把rc0.d~rc6.d、rcS.d这几个目录下的所有文件名定向到result0中 20 | find $file -name "S*" >> result0 21 | done 22 | #去除result中的重复行,并重定向到result1中 23 | sort -u result0 > result1 24 | startup=`cat result1|wc -l` 25 | echo -e "系统开机自启动项总数:$startup" #统计启动项个数 26 | echo "" 27 | echo "Ubuntu新系统的开机自启动项数一般是$base" 28 | echo "" 29 | subs=$[$startup-$base] 30 | sutil=`awk 'BEGIN{printf"%.2f\n",'$subs' / '$base'*100}'` 31 | echo "系统新增开机自启动项数:$subs" 32 | echo "" 33 | echo "比刚装的新系统增加了:$sutil%" 34 | echo "" 35 | #删除result0、result1 36 | rm -rf result0 result1 37 | #筛选可建议关闭的启动项 38 | echo "建议可关闭的启动项如下(用户程序一般是2运行级别):" 39 | #find /etc/rc2.d -name "S*" >> startinfo 40 | #startup=`cat startinfo|wc -l` 41 | 42 | #softnum=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}'|wc -l` 43 | #dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}'> softinfo 44 | #for((i=1;i<=$softnum;i++)) 45 | #do 46 | #softname=`cat softinfo|awk NR==$i'{print $1}'` 47 | #cat startinfo |grep -v "saned"|grep -v "grub-common" |grep -v "speech-dispatcher"|grep -v "rsync"|grep $softname 48 | #done 49 | #rm -rf startinfo softinfo 50 | #筛选rc2.d的开机自启动项 51 | find /etc/rc2.d -name "S*" >> startinfo 52 | #过滤掉不能关闭的开机自启动项(有些开机自启动项关闭可能会有问题) 53 | cat startinfo |grep -v "saned"|grep -v "grub-common" |grep -v "speech-dispatcher"|grep -v "rsync"|grep -v "ondemand"|grep -v "rc.local"|grep -v "kerneloops" 54 | rm -rf startinfo 55 | fi 56 | -------------------------------------------------------------------------------- /源代码/脚本/otherinfo/startup.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: startup.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月21日 星期三 21时12分51秒 6 | ######################################################################### 7 | #!/bin/bash 8 | 9 | #显示开机自启动项(S开头) 10 | base=56 11 | #(点击更多信息按钮时可查看到)root权限显示的信息 12 | #验证输入的用户名密码是否正确,并把错误信息重定向到垃圾桶里 13 | echo $1 | sudo -S echo -n 2> /dev/null 14 | if [ $? == 0 ];then 15 | #得到rc0.d~rc6.d、rcS.d这几个目录的路径 16 | filelist=`echo $1 | sudo -S find /etc -name "rc*.d"` 17 | for file in $filelist 18 | do 19 | #把rc0.d~rc6.d、rcS.d这几个目录下的所有文件名定向到result0中 20 | find $file -name "S*" >> result0 21 | done 22 | #去除result中的重复行,并重定向到result1中 23 | sort -u result0 > result1 24 | startup=`cat result1|wc -l` 25 | echo -e "系统开机自启动项总数:$startup" #统计启动项个数 26 | echo "" 27 | echo "Ubuntu新系统的开机自启动项数一般是$base" 28 | subs=$[$startup-$base] 29 | sutil=`awk 'BEGIN{printf"%.2f\n",'$subs' / '$base'*100}'` 30 | echo "系统新增开机自启动项数:$subs" 31 | echo "比刚装的新系统增加了:$sutil%" 32 | echo "" 33 | #删除result0、result1 34 | rm result0 result1 35 | #筛选可建议关闭的启动项 36 | #echo "建议可关闭的启动项如下(用户程序一般运行在2级别):" 37 | #find /etc/rc2.d -name "S*" >> startinfo 38 | #startup=`cat startinfo|wc -l` 39 | 40 | #softnum=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}'|wc -l` 41 | #dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}'> softinfo 42 | #for((i=1;i<=$softnum;i++)) 43 | #do 44 | #softname=`cat softinfo|awk NR==$i'{print $1}'` 45 | #cat startinfo |grep -v "saned"|grep -v "grub-common" |grep -v "speech-dispatcher"|grep -v "rsync"|grep $softname 46 | #done 47 | #rm -rf startinfo softinfo 48 | fi 49 | -------------------------------------------------------------------------------- /源代码/脚本/otherinfo/systeminfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #系统信息 3 | 4 | echo -e "当前操作系统位数:\t\t`getconf LONG_BIT `位" 5 | echo -e "操作系统内核:\t\t`cat /proc/version | awk '{OFS=" ";print $1, $2, $3}'`" 6 | echo -e "查看操作系统版本:\t\t`head -n 1 /etc/issue | awk '{print $1,$2}'`" 7 | 8 | usernum=`cut -d: -f1 /etc/passwd |wc -l` 9 | echo -e "系统用户总数:\t\t$usernum" 10 | 11 | #登陆用户数 12 | login_user=`who | wc -l` 13 | echo -e "登陆的用户数:\t\t$login_user" 14 | 15 | groupnum=`cut -d: -f1 /etc/group |wc -l` 16 | echo -e "系统组总数:\t\t$groupnum" 17 | 18 | modnum=`lsmod |wc -l` 19 | echo -e "已加载的内核模块总数:\t$modnum" 20 | 21 | #软件总信息 22 | softnum=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |wc -l ` 23 | echo -e "本机已安装软件总数:\t\t$softnum" 24 | echo -e #空行 25 | #apt-cache stats 26 | 27 | #获取加密算法的个数和名字 28 | num=`cat /proc/crypto |grep "name" | sort | uniq | awk '{print $3}' | wc -l` 29 | namesum=`cat /proc/crypto |grep "name" | sort | uniq | awk '{print $3}'` 30 | echo "当前系统有"$num"种加密算法,分别为:" 31 | i=0 32 | for name in $namesum; 33 | do 34 | ((i++)); 35 | if [ $[$i % 6] -eq 0 ] 36 | then 37 | 38 | echo -n $name" 、"; 39 | echo -e; 40 | else 41 | if [ $i -eq $num ] 42 | then 43 | echo $name" 。 "; 44 | else 45 | echo -n $name" 、"; 46 | fi 47 | fi 48 | done 49 | -------------------------------------------------------------------------------- /源代码/脚本/otherinfo/systemrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #非root权限显示的信息 3 | #打印出当前系统已经运行的时间 4 | cat /proc/uptime| awk -F. '{ 5 | run_days=$1 / 86400; 6 | run_hour=($1 % 86400)/3600; 7 | run_minute=($1 % 3600)/60; 8 | run_second=$1 % 60;printf("系统已运行:\t\t\t%d天%d时%d分%d秒\n",run_days,run_hour,run_minute,run_second)}' 9 | echo "" 10 | #进程总数 11 | process=`ps aux | wc -l` 12 | echo -e "进程总数:\t\t\t\t$process" 13 | 14 | #僵尸进程数 15 | zombie_process=`ps -eal | awk '{ if ($2 == "Z") {print $4}}' | wc -l` 16 | echo -e "僵尸进程数:\t\t\t$zombie_process" 17 | 18 | #获取帧缓冲的个数 19 | buf=`cat /proc/fb | awk '{print $1}' | head -1` 20 | echo -e "帧缓冲个数为:\t\t\t"$buf"个" 21 | 22 | #打开文件数 23 | open_files=`lsof | wc -l` 24 | echo -e "打开文件总数:\t\t\t$open_files" 25 | 26 | #获取系统启动以来发生的中断总的次数 27 | irq=`cat /proc/stat | grep "intr" | awk '{print $2}'` 28 | echo -e "系统启动以来发生中断的次数:\t\t"$irq"次" 29 | #获取系统启动以来cpu上下文交换的次数 30 | ch=`cat /proc/stat | grep "ctxt" | awk '{print $2}'` 31 | echo -e "系统启动以来cpu上下文交换次数:\t\t$ch" 32 | 33 | echo "" 34 | #获取当前队列的任务个数 35 | que=`cat /proc/stat | grep "procs_running" | awk '{print $2}'` 36 | echo -e "当前队列任务的个数:\t\t\t"$que"个" 37 | #获取被阻塞任务的个数 38 | block=`cat /proc/stat | grep "procs_blocked" | awk '{print $2}'` 39 | echo -e "当前被阻塞任务的个数:\t\t$block" 40 | #获取系统启动以来所创建的任务的个数 41 | task=`cat /proc/stat | grep "processes" | awk '{print $2}'` 42 | echo -e "系统启动以来创建任务数:\t\t"$task"个" 43 | 44 | echo "" 45 | #获取虚拟文件系统的个数 46 | vfs=`cat /proc/filesystems | grep nodev | wc -l` 47 | echo -e "虚拟文件系统的个数为:\t\t"$vfs"个" 48 | 49 | #获取可供使用的文件系统类型个数 50 | fs=`cat /proc/filesystems | wc -l` 51 | echo -e "系统可供使用的文件系统类型数:\t\t"$fs"" 52 | echo "" 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /源代码/脚本/security/1/1.sh: -------------------------------------------------------------------------------- 1 | #最近三次登陆时间 2 | echo "最近三次登陆时间如下:" 3 | echo "用户名" " ""登入时间" 4 | last -n 3 | awk '{print $1" "$4" "$5" "$6" "$7" "$8$9}' |head -3 5 | 6 | #检查passwd文件中有哪些特权用户 7 | echo "passwd文件中的特权用户有:" 8 | awk -F: '$3==0 {print $1}' /etc/passwd 9 | 10 | -------------------------------------------------------------------------------- /源代码/脚本/security/1/2.sh: -------------------------------------------------------------------------------- 1 | #每个进程都会有一个PID,而每一个PID都会在/proc目录下有一个相应的目录,一般后门程序,在ps等进程查看工具里找不到,因为这些常用工具甚至系统库在系统被入侵之后基本上已经被动过手脚(网上流传着大量的rootkit,假如是内核级的木马,那么该方法就无效了)。因为修改系统内核相对复杂(假如内核被修改过,或者是内核级的木马,就更难发现了),所以在/proc下,基本上还都可以找到木马的痕迹 2 | woodenflag=0 3 | str_pids="`ps -A | awk '{print $1}'`" 4 | for i in /proc/[[:digit:]]*; do 5 | if echo "$str_pids" | grep -qs `basename "$i"`; then 6 | : 7 | else 8 | ((woodenflag++)) 9 | echo "Rootkit's PID: $(basename "$i")" 10 | fi 11 | done 12 | if [ $woodenflag == 0 ];then 13 | echo "ps下的进程号与pro文件相符合" 14 | echo "未发现有用户态的木马后门程序" 15 | else 16 | echo "共发现 $woodenflag 个后门程序" 17 | fi 18 | -------------------------------------------------------------------------------- /源代码/脚本/security/1/2.sh~: -------------------------------------------------------------------------------- 1 | #每个进程都会有一个PID,而每一个PID都会在/proc目录下有一个相应的目录,一般后门程序,在ps等进程查看工具里找不到,因为这些常用工具甚至系统库在系统被入侵之后基本上已经被动过手脚(网上流传着大量的rootkit,假如是内核级的木马,那么该方法就无效了)。因为修改系统内核相对复杂(假如内核被修改过,或者是内核级的木马,就更难发现了),所以在/proc下,基本上还都可以找到木马的痕迹 2 | woodenflag=0 3 | str_pids="`ps -A | awk '{print $1}'`" 4 | for i in /proc/[[:digit:]]*; do 5 | if echo "$str_pids" | grep -qs `basename "$i"`; then 6 | : 7 | else 8 | ((woodenflag++)) 9 | echo "Rootkit's PID: $(basename "$i")" 10 | fi 11 | done 12 | if [ $woodenflag == 0 ];then 13 | echo "ps下的进程号与pro文件相符合" 14 | echo "未发现有用户态的木马后门程序" 15 | else 16 | echo "共发现 $woodenflag 个后门程序" 17 | fi 18 | -------------------------------------------------------------------------------- /源代码/脚本/security/2/1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | shopt -s -o nounset 3 | echo "要检查的文件如下:" 4 | Temp=$(mktemp /tmp/check.XXX) 5 | for i in /etc /tmp /etc/passwd /etc/shadow /etc/group /etc/security /etc/services /etc/rc*.d 6 | do 7 | ls -ld $i>>$Temp 8 | echo "$i" 9 | done 10 | -------------------------------------------------------------------------------- /源代码/脚本/security/2/2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | shopt -s -o nounset 3 | echo "要检查的文件如下:" 4 | Temp=$(mktemp /tmp/check.XXX) 5 | for i in /etc /tmp /etc/passwd /etc/shadow /etc/group /etc/security /etc/services /etc/rc*.d 6 | do 7 | ls -ld $i>>$Temp 8 | done 9 | #check_operation(){ 10 | # local f 11 | # for f in $(cat $Temp); 12 | # do 13 | # ls -ld $f|awk '{print $1}' 14 | # done 15 | #} 16 | #check_operation 17 | echo "检查/etc的权限,默认权限为drwxr-xr-x" 18 | chmod=$(ls -ld /etc|awk '{print $1}') 19 | if [ $chmod = "drwxr-xr-x" ];then 20 | echo -e "/etc/awk \tcompare ok" 21 | else 22 | echo "/etc/awk compare failed,now is $chmod!" 23 | fi 24 | 25 | echo "检查/etc/passwd和/etc/group的权限,默认权限为-rw-w--w--" 26 | dirs="/etc/passwd /etc/group /etc/services" 27 | for i in $dirs 28 | do 29 | chmod1=$(ls -ld $i|awk '{print $1}') 30 | if [ $chmod1 = "-rw-r--r--" ];then 31 | echo -e "$i \tcompare ok" 32 | else 33 | echo "$i compare failed,now is $chmod" 34 | fi 35 | done 36 | 37 | echo "检查/etc/rc0~/etc/rcs的权限,默认权限为drwxr-xr-x" 38 | dirs="/etc/rc0.d /etc/rc1.d /etc/rc2.d /etc/rc3.d /etc/rc4.d /etc/rc5.d /etc/rc6.d /etc/rcS.d" 39 | for i in $dirs 40 | do 41 | chmod1=$(ls -ld $i|awk '{print $1}') 42 | if [ $chmod1 = "drwxr-xr-x" ];then 43 | echo -e "$i \tcompare ok" 44 | else 45 | echo "$i compare failed,now is $chmod" 46 | fi 47 | done 48 | -------------------------------------------------------------------------------- /源代码/脚本/security/3/part1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/bin /sbin " 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | search_file 48 | create_md5 49 | rm_file 50 | cat $File|tail -n 5 51 | fi 52 | -------------------------------------------------------------------------------- /源代码/脚本/security/3/part1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/bin /sbin " 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD=$(pwd) 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | search_file 48 | create_md5 49 | rm_file 50 | cat $File|tail -n 5 51 | fi 52 | -------------------------------------------------------------------------------- /源代码/脚本/security/3/part2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #!/bin/bash 3 | #******************************# 4 | #Author:xuelimin 5 | #Function:md5校验 6 | #******************************# 7 | echo $1 |sudo -S echo -n 2> /dev/null 8 | if [ $? == 0 ];then 9 | shopt -s -o nounset 10 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 11 | #查找的目录 12 | Dirs="/usr/bin/ /usr/sbin" 13 | #新建文件 14 | Temp=$(mktemp /tmp/check.XXXX) 15 | #存储的文件 16 | PWD="/usr/share/systemtest/application/systemtest" 17 | File="$PWD/usr.bin.$Time.file" 18 | #使用工具 19 | Check_tool="/usr/bin/md5sum" 20 | Find="/usr/bin/find" 21 | #使用函数 22 | #查找目录下的普通文件 23 | search_file(){ 24 | #局部变量 25 | local f 26 | for f in $Dirs 27 | do 28 | $Find $f -type f >>$Temp 29 | done 30 | } 31 | cat $Temp |tail -n 5 32 | #生成md5值 33 | create_md5(){ 34 | local f 35 | if [ -f $Temp ];then 36 | for f in $(cat $Temp); 37 | do 38 | $Check_tool $f >> $File 39 | done 40 | else 41 | echo "failed" 42 | fi 43 | } 44 | rm_file(){ 45 | if [ -f $Temp ];then 46 | rm -rf $Temp 47 | fi 48 | } 49 | search_file 50 | create_md5 51 | rm_file 52 | cat $File|tail -n 5 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/3/part2.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #!/bin/bash 3 | #******************************# 4 | #Author:xuelimin 5 | #Function:md5校验 6 | #******************************# 7 | echo $1 |sudo -S echo -n 2> /dev/null 8 | if [ $? == 0 ];then 9 | shopt -s -o nounset 10 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 11 | #查找的目录 12 | Dirs="/usr/bin/ /usr/sbin" 13 | #新建文件 14 | Temp=$(mktemp /tmp/check.XXXX) 15 | #存储的文件 16 | PWD=$(pwd) 17 | File="$PWD/usr.bin.$Time.file" 18 | #使用工具 19 | Check_tool="/usr/bin/md5sum" 20 | Find="/usr/bin/find" 21 | #使用函数 22 | #查找目录下的普通文件 23 | search_file(){ 24 | #局部变量 25 | local f 26 | for f in $Dirs 27 | do 28 | $Find $f -type f >>$Temp 29 | done 30 | } 31 | cat $Temp |tail -n 5 32 | #生成md5值 33 | create_md5(){ 34 | local f 35 | if [ -f $Temp ];then 36 | for f in $(cat $Temp); 37 | do 38 | $Check_tool $f >> $File 39 | done 40 | else 41 | echo "failed" 42 | fi 43 | } 44 | rm_file(){ 45 | if [ -f $Temp ];then 46 | rm -rf $Temp 47 | fi 48 | } 49 | search_file 50 | create_md5 51 | rm_file 52 | cat $File|tail -n 5 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/3/part3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #!/bin/bash 3 | #******************************# 4 | #Author:xuelimin 5 | #Function:md5校验 6 | #******************************# 7 | echo $1 |sudo -S echo -n 2> /dev/null 8 | if [ $? == 0 ];then 9 | shopt -s -o nounset 10 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 11 | #查找的目录 12 | Dirs=" /usr/local/sbin /usr/local/bin" 13 | #新建文件 14 | Temp=$(mktemp /tmp/check.XXXX) 15 | #存储的文件 16 | PWD="/usr/share/systemtest/application/systemtest" 17 | File="$PWD/usr.local.$Time.file" 18 | #使用工具 19 | Check_tool="/usr/bin/md5sum" 20 | Find="/usr/bin/find" 21 | #使用函数 22 | #查找目录下的普通文件 23 | search_file(){ 24 | #局部变量 25 | local f 26 | for f in $Dirs 27 | do 28 | $Find $f -type f >>$Temp 29 | done 30 | } 31 | #生成md5值 32 | create_md5(){ 33 | local f 34 | if [ -f $Temp ];then 35 | for f in $(cat $Temp); 36 | do 37 | $Check_tool $f >> $File 38 | done 39 | else 40 | echo "failed" 41 | fi 42 | } 43 | rm_file(){ 44 | if [ -f $Temp ];then 45 | rm -rf $Temp 46 | fi 47 | } 48 | search_file 49 | create_md5 50 | rm_file 51 | cat $File|tail -n 5 52 | fi 53 | -------------------------------------------------------------------------------- /源代码/脚本/security/3/part3.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #!/bin/bash 3 | #******************************# 4 | #Author:xuelimin 5 | #Function:md5校验 6 | #******************************# 7 | echo $1 |sudo -S echo -n 2> /dev/null 8 | if [ $? == 0 ];then 9 | shopt -s -o nounset 10 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 11 | #查找的目录 12 | Dirs=" /usr/local/sbin /usr/local/bin" 13 | #新建文件 14 | Temp=$(mktemp /tmp/check.XXXX) 15 | #存储的文件 16 | PWD=$(pwd) 17 | File="$PWD/usr.local.$Time.file" 18 | #使用工具 19 | Check_tool="/usr/bin/md5sum" 20 | Find="/usr/bin/find" 21 | #使用函数 22 | #查找目录下的普通文件 23 | search_file(){ 24 | #局部变量 25 | local f 26 | for f in $Dirs 27 | do 28 | $Find $f -type f >>$Temp 29 | done 30 | } 31 | #生成md5值 32 | create_md5(){ 33 | local f 34 | if [ -f $Temp ];then 35 | for f in $(cat $Temp); 36 | do 37 | $Check_tool $f >> $File 38 | done 39 | else 40 | echo "failed" 41 | fi 42 | } 43 | rm_file(){ 44 | if [ -f $Temp ];then 45 | rm -rf $Temp 46 | fi 47 | } 48 | search_file 49 | create_md5 50 | rm_file 51 | cat $File|tail -n 5 52 | fi 53 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/part1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/bin /sbin " 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | if [ $? == 0 ];then 38 | echo -e "$f\t已备份结束" 39 | fi 40 | done 41 | else 42 | echo "failed" 43 | fi 44 | } 45 | rm_file(){ 46 | if [ -f $Temp ];then 47 | rm -rf $Temp 48 | fi 49 | } 50 | search_file 51 | create_md5 52 | rm_file 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/part1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/bin /sbin " 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD=$(pwd) 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | if [ $? == 0 ];then 38 | echo -e "$f\t已备份结束" 39 | fi 40 | done 41 | else 42 | echo "failed" 43 | fi 44 | } 45 | rm_file(){ 46 | if [ -f $Temp ];then 47 | rm -rf $Temp 48 | fi 49 | } 50 | search_file 51 | create_md5 52 | rm_file 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:删除md5产生的文件 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | cd /usr/share/systemtest/application/systemtest/ 9 | `ls -l` 10 | dir=$(ls -l |grep "bin.*") 11 | echo $dir 12 | if [ -f $dir ];then 13 | rm -rf $dir 14 | if [ $? == 0 ];then 15 | echo "$dir 删除成功!" 16 | fi 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/remove.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:删除md5产生的文件 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | cd /usr/share/systemtest/application/systemtest/ 9 | ls -l 10 | dir=$(ls -l |grep "bin.*") 11 | echo $dir 12 | if [ -f $dir ];then 13 | rm -rf $dir 14 | if [ $? == 0 ];then 15 | echo "$dir 删除成功!" 16 | fi 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | 9 | PWD="/usr/share/systemtest/application/systemtest" 10 | dir=$(ls -l $PWD|grep bin.* |awk '{print $NF}') 11 | #echo $dir 12 | cd $PWD 13 | #查找文件是否篡改 14 | md5sum -c $dir 15 | #查找篡改出的文件 16 | md5sum -c $dir | grep "确定" 17 | fi 18 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/test.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | 9 | PWD=$(pwd) 10 | dir=$(ls -l $PWD|grep bin.* |awk '{print $NF}') 11 | #echo $dir 12 | cd $PWD 13 | #查找文件是否篡改 14 | md5sum -c $dir 15 | #查找篡改出的文件 16 | md5sum -c $dir | grep "确定" 17 | fi 18 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/test1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/bin /sbin " 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | 48 | 49 | search_file 50 | create_md5 51 | rm_file 52 | 53 | 54 | #查找文件是否篡改 55 | md5sum -c $File 56 | #查找篡改出的文件 57 | md5sum -c $File | grep "确定" 58 | fi 59 | -------------------------------------------------------------------------------- /源代码/脚本/security/4/test1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/bin /sbin " 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | 48 | 49 | search_file 50 | create_md5 51 | rm_file 52 | 53 | 54 | #查找文件是否篡改 55 | md5sum -c $File 56 | #查找篡改出的文件 57 | md5sum -c $File | grep "确定" 58 | fi 59 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/part1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/usr/bin/ /usr/sbin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/usr.bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | if [ $? == 0 ];then 38 | echo -e "$f\t已备份结束" 39 | fi 40 | done 41 | else 42 | echo "failed" 43 | fi 44 | } 45 | rm_file(){ 46 | if [ -f $Temp ];then 47 | rm -rf $Temp 48 | fi 49 | } 50 | search_file 51 | create_md5 52 | rm_file 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/part1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/usr/bin/ /usr/sbin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD=$(pwd) 16 | File=" $PWD/usr.bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | if [ $? == 0 ];then 38 | echo -e "$f\t已备份结束" 39 | fi 40 | done 41 | else 42 | echo "failed" 43 | fi 44 | } 45 | rm_file(){ 46 | if [ -f $Temp ];then 47 | rm -rf $Temp 48 | fi 49 | } 50 | search_file 51 | create_md5 52 | rm_file 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:删除md5产生的文件 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep usr.bin.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | if [ -f $dir ];then 13 | rm -rf $dir 14 | if [ $? == 0 ];then 15 | echo "$dir 删除成功!" 16 | fi 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/remove.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:删除md5产生的文件 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep bin.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | if [ -f $dir ];then 13 | rm -rf $dir 14 | if [ $? == 0 ];then 15 | echo "$dir 删除成功!" 16 | fi 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep usr.bin.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | #查找文件是否篡改 13 | md5sum -c $dir 14 | #查找篡改出的文件 15 | md5sum -c $dir | grep "确定" 16 | fi 17 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/test.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep bin.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | #查找文件是否篡改 13 | md5sum -c $dir 14 | #查找篡改出的文件 15 | md5sum -c $dir | grep "确定" 16 | fi 17 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/test1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/usr/bin/ /usr/sbin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | 48 | 49 | search_file 50 | create_md5 51 | rm_file 52 | 53 | #查找文件是否篡改 54 | md5sum -c $File 55 | #查找篡改出的文件 56 | md5sum -c $File | grep "确定" 57 | fi 58 | -------------------------------------------------------------------------------- /源代码/脚本/security/5/test1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs="/usr/bin/ /usr/sbin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD=$(pwd) 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | 48 | 49 | search_file 50 | create_md5 51 | rm_file 52 | 53 | #查找文件是否篡改 54 | md5sum -c $File 55 | #查找篡改出的文件 56 | md5sum -c $File | grep "确定" 57 | fi 58 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/part1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs=" /usr/local/sbin /usr/local/bin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/usr.local.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | if [ $? == 0 ];then 38 | echo -e "$f\t已备份结束" 39 | fi 40 | done 41 | else 42 | echo "failed" 43 | fi 44 | } 45 | rm_file(){ 46 | if [ -f $Temp ];then 47 | rm -rf $Temp 48 | fi 49 | } 50 | search_file 51 | create_md5 52 | rm_file 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/part1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs=" /usr/local/sbin /usr/local/bin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD=$(pwd) 16 | File=" $PWD/usr.local.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | if [ $? == 0 ];then 38 | echo -e "$f\t已备份结束" 39 | fi 40 | done 41 | else 42 | echo "failed" 43 | fi 44 | } 45 | rm_file(){ 46 | if [ -f $Temp ];then 47 | rm -rf $Temp 48 | fi 49 | } 50 | search_file 51 | create_md5 52 | rm_file 53 | fi 54 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/remove.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:删除md5产生的文件 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep usr.local.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | if [ -f $dir ];then 13 | rm -rf $dir 14 | if [ $? == 0 ];then 15 | echo "$dir 删除成功!" 16 | fi 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/remove.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:删除md5产生的文件 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep usr.bin.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | if [ -f $dir ];then 13 | rm -rf $dir 14 | if [ $? == 0 ];then 15 | echo "$dir 删除成功!" 16 | fi 17 | fi 18 | fi 19 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep usr.local.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | #查找文件是否篡改 13 | md5sum -c $dir 14 | #查找篡改出的文件 15 | md5sum -c $dir | grep "确定" 16 | fi 17 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/test.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | PWD=$(pwd) 9 | dir=$(ls -l $PWD|grep usr.bin.* |awk '{print $NF}') 10 | #echo $dir 11 | cd $PWD 12 | #查找文件是否篡改 13 | md5sum -c $dir 14 | #查找篡改出的文件 15 | md5sum -c $dir | grep "确定" 16 | fi 17 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/test1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs=" /usr/local/sbin /usr/local/bin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD="/usr/share/systemtest/application/systemtest" 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | 48 | 49 | search_file 50 | create_md5 51 | rm_file 52 | 53 | 54 | #查找文件是否篡改 55 | md5sum -c $File 56 | #查找篡改出的文件 57 | md5sum -c $File | grep "确定" 58 | fi 59 | -------------------------------------------------------------------------------- /源代码/脚本/security/6/test1.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #******************************# 3 | #Author:xuelimin 4 | #Function:md5校验文件内容是否相同 5 | #******************************# 6 | echo $1 |sudo -S echo -n 2> /dev/null 7 | if [ $? == 0 ];then 8 | shopt -s -o nounset 9 | Time=$(date +'%Y-%m-%d_%H:%M:%S') 10 | #查找的目录 11 | Dirs=" /usr/local/sbin /usr/local/bin" 12 | #新建文件 13 | Temp=$(mktemp /tmp/check.XXXX) 14 | #存储的文件 15 | PWD=$(pwd) 16 | File=" $PWD/bin.$Time.file" 17 | #使用工具 18 | Check_tool="/usr/bin/md5sum" 19 | Find="/usr/bin/find" 20 | #使用函数 21 | #查找目录下的普通文件 22 | search_file(){ 23 | #局部变量 24 | local f 25 | for f in $Dirs 26 | do 27 | sudo $Find $f -type f >> $Temp 28 | done 29 | } 30 | #生成md5值 31 | create_md5(){ 32 | local f 33 | if [ -f $Temp ];then 34 | for f in $(cat $Temp); 35 | do 36 | $Check_tool $f >> $File 37 | done 38 | else 39 | echo "failed" 40 | fi 41 | } 42 | rm_file(){ 43 | if [ -f $Temp ];then 44 | rm -rf $Temp 45 | fi 46 | } 47 | 48 | 49 | search_file 50 | create_md5 51 | rm_file 52 | 53 | 54 | #查找文件是否篡改 55 | md5sum -c $File 56 | #查找篡改出的文件 57 | md5sum -c $File | grep "确定" 58 | fi 59 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/arp_secure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #返回0表示ip都没有静态绑定,被arp攻击的风险最大;返回1表示ip都静态绑定了,可以预防arp攻击;返回小数表示已绑定ip数占总ip数的比例 3 | max=100 4 | min=0 5 | 6 | #查看是否存在arp攻击 7 | a=`arp |grep :|wc -l` 8 | if [ $a == 0 ];then 9 | echo $max 10 | else 11 | #统计已经静态绑定的ip-mac数目 12 | ap1=`arp -a |grep "PERM" |wc -l` 13 | if [ $ap1 == 0 ];then 14 | echo $max #"当前没有IP与网关MAC静态绑定(有被ARP攻击的风险)" 15 | elif [ $ap1 -gt 0 ];then 16 | #统计未静态绑定的ip数目 17 | uap1=`arp -a|grep -v "PERM" |wc -l` 18 | if [ $uap1 == 0 ];then 19 | echo $min #"当前所有IP和网关MAC都已经静态绑定(被ARP攻击的风险较小)" 20 | else 21 | 22 | ipnum=$[$ap1+$uap1] 23 | #计算静态绑定ip数占总ip数的比例 24 | secureutil0=$(awk 'BEGIN{printf"%.2f\n",'$uap1' / '$ipnum'}') 25 | secureutil=$(awk 'BEGIN{printf"%.0f\n",'$secureutil0' * '$max' }') 26 | echo $secureutil 27 | fi 28 | fi 29 | fi 30 | 31 | 32 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/checkdisk.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: lj.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月06日 星期二 19时40分04秒 6 | ######################################################################### 7 | #!/bin/bash 8 | errnum=0 9 | util=100 10 | #检查普通分区(不包括根分区)是否正常可用 11 | device_name=(`df -lh |grep "^/dev/sd"|awk '{print $1}'`) 12 | mount_dir=(`df -lh |grep "^/dev/sd"|awk '{print $6}'`) 13 | num=${#device_name[@]} 14 | 15 | for ((i=1;i<=$num-1;i++)) 16 | do 17 | touch ${mount_dir[$i]}/file1 18 | if [ $? -ne 0 ];then 19 | ((errnum++)) 20 | fi 21 | rm -rf ${mount_dir[$i]}/file1 22 | done 23 | #计算不能正常使用的普通盘占检查普通盘总数的百分比 24 | errutil0=`awk 'BEGIN{printf"%.2f\n",'$errnum' / '$num' }'` 25 | errutil1=`awk 'BEGIN{printf"%.0f\n",'$errutil0' * '$util' }'` 26 | echo $errutil1 27 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/cpu_hyper.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持超线程(测评使用) 3 | cpu_cores=$(cat /proc/cpuinfo | grep "cpu cores" | awk -F ':' 'NR==1 {print $2}') 4 | siblings=$( cat /proc/cpuinfo | grep "siblings" | awk -F ':' 'NR==1 {print $2}') 5 | val=`expr $siblings / $cpu_cores` 6 | 7 | if [ $siblings -eq $cpu_cores ] 8 | then 9 | echo 0 #不支持超线程 10 | fi 11 | 12 | if [ $val -eq 2 ] 13 | then 14 | echo 1 #支持超线程 15 | fi 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/cpu_iowait.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #io等待占用CPU时间的百分比(测评使用) 3 | iowait_rate=`top -b -n 1 | grep Cpu | awk '{print $10}'` #(-b -n 1 表示只需要1次的输出结果) 4 | echo $iowait_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/cpu_run_threads.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算可运行队列的线程数(测评使用) 3 | cpu_count=$(grep 'physical id' /proc/cpuinfo | sort -u | wc -l) #cpu个数 4 | loadavg_1min=$( cat /proc/loadavg | awk '{print $1}') #cpu一分钟平均负载 5 | task_per_cpu=$(awk 'BEGIN{printf"%.2f\n",'$loadavg_1min' / '$cpu_count'}') 6 | #每个cpu的当前任务数 7 | echo $task_per_cpu 8 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/cpu_sys_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU系统占用率(测评使用) 3 | sys_rate=`top -b -n 1 | grep Cpu | awk '{print $4}'` 4 | echo $sys_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/cpu_user_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU用户占用率(测评使用) 3 | cpu_user_rate=`top -b -n 1 | grep Cpu | awk '{print $2}'` 4 | echo $cpu_user_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/cpu_virtual.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持虚拟化(测评使用) 3 | cpu_virtual=`egrep -o '(vmx | svm)' /proc/cpuinfo | awk 'NR==1'` 4 | 5 | if [ $cpu_virtual = "vmx" -o $cpu_virtual = "svm" ] #判断CPU是否支持虚拟化 6 | then 7 | { 8 | if [ $cpu_virtual = "vmx" ] #Intel提供的虚拟化 9 | then 10 | echo 2 11 | fi 12 | if [ $cpu_virtual = "svm" ] #AMD提供的虚拟化 13 | then 14 | echo 1 15 | fi 16 | } 17 | else 18 | echo 0 #不支持虚拟化 19 | fi 20 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/earntime.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #获取启动时长 3 | function run_time (){ 4 | 5 | a=`cat /var/log/dmesg | grep "setting system" | awk '{print $2}'` 6 | run=${a%?} 7 | run=${run:0:1} 8 | start_hour=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($1)}'`*3600] 9 | start_min=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($2)}'`*60] 10 | start_sec=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($3)}'`] 11 | start_time=$[$start_hour+$start_min+$start_sec-$run] 12 | 13 | end_time=0 14 | for pid in $(pgrep lightdm); 15 | do 16 | t2=`ps -p ${pid} -o lstart=` 17 | end_hour=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($1)}'`*3600] 18 | end_min=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($2)}'`*60] 19 | end_sec=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($3)}'`] 20 | t1=$[$end_hour+$end_min+$end_sec] 21 | if [ $t1 -gt $end_time ] 22 | then 23 | end_time=$t1 24 | fi 25 | done 26 | cur_runtime=$[$end_time-$start_time] 27 | return $cur_runtime 28 | } 29 | 30 | run_time 31 | timelength=$? 32 | echo $timelength 33 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/firefox_cookies.sh: -------------------------------------------------------------------------------- 1 | flag=0 2 | #检查firefox有没有安装 3 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "firefox" |wc -l` 4 | if [ $a -gt 0 ];then 5 | #检测有没有firefox跟踪cookies 6 | path=`find ~/.mozilla/firefox -type d -name "*.default"` 7 | cd $path 8 | fc0=`ls -l |grep "cookies.sqlite" |wc -l` 9 | if [ $fc0 -eq 1 ];then 10 | fc1=`ls -l cookies.sqlite |awk '{print $5}'` 11 | if [ $fc1 -gt 0 ];then 12 | ((flag++)) 13 | echo $flag 14 | else 15 | echo $flag 16 | fi 17 | else 18 | echo $flag 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/google_cookies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | flag=0 3 | #判断有没有安装google-chrome 4 | b=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "google-chrome" |wc -l` 5 | if [ $b -gt 0 ];then 6 | #echo "google-chrome已安装" 7 | #判断有没有google-chrome配置文件 8 | g=` ls -l ~/.config |grep "google-chrome" |wc -l ` 9 | if [ $g -gt 0 ];then 10 | #进入google-chrome跟踪cookies所在目录 11 | cd ~/.config/google-chrome/Default/ 12 | #检测有没有google-chrome跟踪cookies 13 | if [ -f "Cookies" ];then 14 | #获取谷歌跟踪Cookies的大小 15 | gc0=`ls -l Cookies |awk '{print $5}'` 16 | #如果cookies大小为0,则不存在 17 | if [ $gc0 -gt 0 ];then 18 | ((flag++)) 19 | echo $flag #"检测到存在google-chrome跟踪cookies,个人隐私有泄露危险" 20 | else 21 | echo $flag #"检测到不存在google-chrome跟踪cookies" 22 | fi 23 | else 24 | echo $flag #"检测到不存在google-chrome跟踪cookies" 25 | fi 26 | 27 | else 28 | echo $flag #"未检测到有google-chrome跟踪cookies" 29 | fi 30 | fi 31 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/google_history.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #检测有没有google-chrome跟踪URL历史记录 3 | 4 | flag=0 5 | #判断有没有安装google-chrome 6 | b=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "google-chrome" |wc -l` 7 | if [ $b -gt 0 ];then 8 | #echo "google-chrome已安装" 9 | #判断有没有google-chrome配置文件 10 | g=` ls -l ~/.config |grep "google-chrome" |wc -l ` 11 | 12 | if [ $g -gt 0 ];then 13 | #进入google-chrome跟踪cookies所在目录 14 | cd ~/.config/google-chrome/Default/ 15 | #检测有没有google-chrome跟踪cookies 16 | if [ -f "History" ];then 17 | #获取谷歌跟踪Cookies的大小 18 | gc0=`ls -l History |awk '{print $5}'` 19 | #如果cookies大小为0,则不存在 20 | if [ $gc0 -gt 0 ];then 21 | ((flag++)) 22 | echo $flag #"检测到存在google-chrome历史跟踪记录,个人隐私有泄露危险" 23 | else 24 | echo $flag #"检测到不存在google-chrome历史跟踪记录" 25 | fi 26 | else 27 | echo $flag #"检测到不存在google-chrome历史跟踪记录" 28 | fi 29 | 30 | else 31 | echo $flag #"未检测到有google-chrome历史跟踪记录" 32 | fi 33 | fi 34 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/init_arp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #查看是否开机自动绑定IP和MAC地址 3 | ap=`cat /etc/init.d/rc.local |grep "arp -f /etc/ip-mac" |wc -l` 4 | if [ $ap == 0 ];then 5 | echo 0 #"开机自启动ARP欺骗防护未开启!" 6 | else 7 | echo 1 #"开机自启动ARP欺骗防护已开启!" 8 | fi 9 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/io_await.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #计算平均IO响应时间await,一般地系统IO响应时间应该低于5ms,如果大于10ms就比较大了,await、svctm越低越好,说明io响应延迟很低,iops能力很高 3 | 4 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 5 | rio=`cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($4)}'` 6 | 7 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 8 | wio=`cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($8)}'` 9 | 10 | #第4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数。 11 | ruse=`cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($7)}'` 12 | 13 | #第8个域:写操作花费的毫秒数 --- 写花费的毫秒数,这是所有写操作所花费的毫秒数 14 | wuse=`cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($11)}'` 15 | 16 | #await:平均每次设备I/O操作的等待时间 (毫秒)(IO Response Time),包括在请求队列中的时间和响应消耗时间,即 (ruse+wuse)/(rio+wio) 17 | rwuse=$[$ruse+$wuse] 18 | rwio=$[$rio+$wio] 19 | await=`awk 'BEGIN{printf"%.2f\n",'$rwuse' / '$rwio'}'` 20 | echo "$await" 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/io_reqnum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #正在进行的I/O数,I/O队列中请求数(running),一个磁盘队列值为2-3最佳,默认队列为128个长度 3 | #第9个域:正在处理的输入/输出请求数--I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小 4 | running=`cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($12)}'` 5 | echo "$running" 6 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/io_svctm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ##svctm:平均每次设备I/O操作的服务时间 (毫秒),svctm不超过5 3 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 4 | rio=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($4)}') 5 | 6 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 7 | wio=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($8)}') 8 | 9 | #第10个域:输入/输出操作花费的毫秒数--花在I/O操作上的毫秒数,这个域会增长只要field 9不为0,系统真正花费在I/O上的时间,除去重复等待时间(use)(从系统启动时的累积值) 10 | use=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($13)}') 11 | 12 | rwio=$[$rio+$wio] 13 | #svctm:平均每次设备I/O操作的服务时间 (毫秒),即 use/(rio+wio) 14 | svctm=$(awk 'BEGIN{printf"%.2f\n",'$use' / '$rwio'}') 15 | echo $svctm #平均每次设备I/O操作的服务时间svctm 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/io_util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #一秒中有百分之多少的时间用于I/O操作%util,小于等于70%,如果 %util 接近 100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘可能存在瓶颈。 3 | 4 | #/proc/uptime第一列输出的是,系统启动到现在的时间(以秒为单位) 5 | ut=`cat /proc/uptime |awk '{print $1}'` 6 | 7 | #第10个域:输入/输出操作花费的毫秒数--花在I/O操作上的毫秒数,这个域会增长只要field 9不为0。 8 | use=`cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($13)}'` 9 | 10 | #%util: 一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的,即 delta(use)/s/1000 (因为use的单位为毫秒) 11 | util=`awk 'BEGIN{printf"%.2f\n",'$use' / '$ut' / 1000 * 100}'` 12 | echo "$util" 13 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/junk_files.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: junk_files.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 16时24分32秒 6 | ######################################################################### 7 | #!/bin/bash 8 | flag=0 9 | #查看回收站垃圾大小 10 | a1=`du -ks $HOME/.local/share/Trash/files/ | awk '{print int($1)}'` 11 | 12 | #查看无用软件包垃圾大小,/var/cache/apt/archives是安装软件时下载包的临时存放目录 13 | a2=`du -ks /var/cache/apt/archives | awk '{print int($1)}'` 14 | 15 | #查看是缩略图缓存垃圾大小 16 | a3=`du -ks ~/.cache/thumbnails/ |awk '{print int($1)}'` 17 | 18 | 19 | sum=$[$a1+$a2+$a3] 20 | if [ $sum -ge 0 -a $sum -lt 1048576 ];then 21 | echo $flag 22 | elif [ $sum -ge 1048576 ];then 23 | ((flag++)) 24 | echo $flag #"您的磁盘垃圾已超过1G,最好及时清理!" 25 | fi 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/mem_user.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算应用程序可用内存百分比(测评使用) 3 | #计算公式:应用程序可用内存=MemFree + Buffers + Cached 4 | MemFree=$(cat /proc/meminfo | awk '/^MemFree/{print $2}') #系统空闲内存 5 | Buffers=$(cat /proc/meminfo | awk '/^Buffers/{print $2}') #缓冲区内存 6 | Cached=$(cat /proc/meminfo | awk '/^Cached/{print $2}') #高速缓存 7 | MemUser=$[$MemFree + $Buffers +$Cached] 8 | 9 | MemTotal=$(cat /proc/meminfo | awk '/^MemTotal/{print $2}') #内存总量 10 | mem_user_rate=$(awk 'BEGIN{printf"%.2f\n",'$MemUser' / '$MemTotal' * 100}') 11 | echo $mem_user_rate #百分比 12 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/recent_used.sh: -------------------------------------------------------------------------------- 1 | #检测有没有最近使用文档跟踪记录 2 | flag=0 3 | sec0=`ls -l ~/.local/share/ |grep "recently-used.xbel" |wc -l ` 4 | if [ $sec0 -eq 1 ];then 5 | sec1=`ls -l ~/.local/share/recently-used.xbel |awk '{print $5}'` 6 | if [ $sec1 -eq 0 ];then 7 | echo $flag 8 | else 9 | ((flag++)) 10 | echo $flag 11 | fi 12 | else 13 | echo $flag 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/arp_secure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #返回0表示ip都没有静态绑定,被arp攻击的风险最大;返回1表示ip都静态绑定了,可以预防arp攻击;返回小数表示已绑定ip数占总ip数的比例 3 | totalmark=5 4 | #统计已经静态绑定的ip-mac数目 5 | ap1=`arp -a |grep "PERM" |wc -l` 6 | if [ $ap1 == 0 ];then 7 | echo $totalmark #"当前没有IP与网关MAC静态绑定(有被ARP攻击的风险)" 8 | elif [ $ap1 -gt 0 ];then 9 | #统计未静态绑定的ip数目 10 | uap1=`arp -a|grep -v "PERM" |wc -l` 11 | if [ $uap1 == 0 ];then 12 | echo 1 #"当前所有IP和网关MAC都已经静态绑定(被ARP攻击的风险较小)" 13 | else 14 | 15 | ipnum=$[$ap1+$uap1] 16 | #计算静态绑定ip数占总ip数的比例 17 | secureutil=$(awk 'BEGIN{printf"%.2f\n",'$uap1' / '$ipnum'}') 18 | mark=$(awk 'BEGIN{printf"%.0f\n",'$secureutil' * '$totalmark' }') 19 | echo $mark 20 | fi 21 | fi 22 | 23 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/arp_secure.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #返回0表示ip都没有静态绑定,被arp攻击的风险最大;返回1表示ip都静态绑定了,可以预防arp攻击;返回小数表示已绑定ip数占总ip数的比例 3 | totalmark=5 4 | #统计已经静态绑定的ip-mac数目 5 | ap1=`arp -a |grep "PERM" |wc -l` 6 | if [ $ap1 == 0 ];then 7 | echo $totalmark #"当前没有IP与网关MAC静态绑定(有被ARP攻击的风险)" 8 | elif [ $ap1 -gt 0 ];then 9 | #统计未静态绑定的ip数目 10 | uap1=`arp -a|grep -v "PERM" |wc -l` 11 | if [ $uap1 == 0 ];then 12 | echo 1 #"当前所有IP和网关MAC都已经静态绑定(被ARP攻击的风险较小)" 13 | else 14 | 15 | ipnum=$[$ap1+$uap1] 16 | #计算静态绑定ip数占总ip数的比例 17 | secureutil=$(awk 'BEGIN{printf"%.2f\n",'$uap1' / '$ipnum'}') 18 | echo $secureutil 19 | mark=$(awk 'BEGIN{printf"%.0f\n",'$secureutil' * '$totalmark' }') 20 | echo $mark 21 | fi 22 | fi 23 | 24 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/await.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #计算平均IO响应时间await 3 | 4 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 5 | rio=`cat /proc/diskstats |grep "0 sda" |awk '{print int($4)}'` 6 | echo "读请求总数(rio)(从系统启动时的累积值):$rio" 7 | 8 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 9 | wio=`cat /proc/diskstats |grep "0 sda" |awk '{print int($8)}'` 10 | echo "写请求总数(wio)(从系统启动时的累积值):$wio" 11 | 12 | #第4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数。 13 | ruse=`cat /proc/diskstats |grep "0 sda" |awk '{print int($7)}'` 14 | echo "读数据花费的时间(ruse)(从系统启动时的累积值):$ruse ms" 15 | 16 | #第8个域:写操作花费的毫秒数 --- 写花费的毫秒数,这是所有写操作所花费的毫秒数 17 | wuse=`cat /proc/diskstats |grep "0 sda" |awk '{print int($11)}'` 18 | echo "写数据花费的时间(wuse)(从系统启动时的累积值):$wuse ms" 19 | #await:平均每次设备I/O操作的等待时间 (毫秒)(IO Response Time),包括在请求队列中的时间和响应消耗时间,即 (ruse+wuse)/(rio+wio) 20 | rwuse=$[$ruse+$wuse] 21 | rwio=$[$rio+$wio] 22 | await=`awk 'BEGIN{printf"%.2f\n",'$rwuse' / '$rwio'}'` 23 | echo "$await" 24 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/checkdisk.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: lj.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月06日 星期二 19时40分04秒 6 | ######################################################################### 7 | #!/bin/bash 8 | errnum=0 9 | util=100 10 | #检查普通分区(不包括根分区)是否正常可用 11 | device_name=(`df -lh |grep "^/dev/sd"|awk '{print $1}'`) 12 | mount_dir=(`df -lh |grep "^/dev/sd"|awk '{print $6}'`) 13 | num=${#device_name[@]} 14 | 15 | for ((i=1;i<=$num-1;i++)) 16 | do 17 | touch ${mount_dir[$i]}/file1 18 | if [ $? -ne 0 ];then 19 | ((errnum++)) 20 | fi 21 | rm -rf ${mount_dir[$i]}/file1 22 | done 23 | #计算不能正常使用的普通盘占检查普通盘总数的百分比 24 | errutil0=`awk 'BEGIN{printf"%.2f\n",'$errnum' / '$num' }'` 25 | errutil1=`awk 'BEGIN{printf"%.0f\n",'$errutil0' * '$util' }'` 26 | echo $errutil1 27 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/checkdisk.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: lj.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月06日 星期二 19时40分04秒 6 | ######################################################################### 7 | #!/bin/bash 8 | errnum=0 9 | util=100 10 | #检查普通分区(不包括根分区)是否正常可用 11 | device_name=(`df -lh |grep "^/dev/sd"|awk '{print $1}'`) 12 | mount_dir=(`df -lh |grep "^/dev/sd"|awk '{print $6}'`) 13 | num=${#device_name[@]} 14 | 15 | for ((i=1;i<=$num-1;i++)) 16 | do 17 | touch ${mount_dir[$i]}/file1 18 | if [ $? -ne 0 ];then 19 | ((errnum++)) 20 | fi 21 | rm -rf ${mount_dir[$i]}/file1 22 | done 23 | #计算不能正常使用的普通盘占检查普通盘总数的百分比 24 | errutil0=`awk 'BEGIN{printf"%.2f\n",'$errnum' / '$num' }'` 25 | errutil1=`awk 'BEGIN{printf"%.0f\n",'$errutil0' * '$util' }'` 26 | echo $errutil1 27 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/checkroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #检查根分区是否正常可用 3 | flag=0 4 | #验证输入的用户名密码是否正确,并把错误信息重定向到垃圾桶里 5 | echo $1 | sudo -S echo -n 2> /dev/null 6 | if [ $? == 0 ];then 7 | device_name=(`df -lh |grep "^/dev/sd"|awk '{print $1}'`) 8 | mount_dir=(`df -lh |grep "^/dev/sd"|awk '{print $6}'`) 9 | num=${#device_name[@]} 10 | 11 | sudo touch ${mount_dir[0]}/file1 12 | if [ $? -eq 0 ] 13 | then 14 | ((flag++)) 15 | echo $flag #根分区可用,能正常创建文本文件 16 | else 17 | echo $flag #根分区不能正常创建文本文件 18 | fi 19 | sudo rm -rf ${mount_dir[0]}/file1 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/checkroot.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #检查根分区是否正常可用 3 | flag=0 4 | #验证输入的用户名密码是否正确,并把错误信息重定向到垃圾桶里 5 | echo $1 | sudo -S echo -n 2> /dev/null 6 | if [ $? == 0 ];then 7 | device_name=(`df -lh |grep "^/dev/sd"|awk '{print $1}'`) 8 | mount_dir=(`df -lh |grep "^/dev/sd"|awk '{print $6}'`) 9 | num=${#device_name[@]} 10 | 11 | sudo touch ${mount_dir[0]}/file1 12 | if [ $? -eq 0 ] 13 | then 14 | ((flag++)) 15 | echo $flag #根分区可用,能正常创建文本文件 16 | else 17 | echo -e "\e[31m${device_name[0]} is error\e[0m" 18 | fi 19 | sudo rm -rf ${mount_dir[0]}/file1 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_hyper.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持超线程(测评使用) 3 | cpu_cores=$(cat /proc/cpuinfo | grep "cpu cores" | awk -F ':' 'NR==1 {print $2}') 4 | siblings=$( cat /proc/cpuinfo | grep "siblings" | awk -F ':' 'NR==1 {print $2}') 5 | val=`expr $siblings / $cpu_cores` 6 | 7 | if [ $siblings -eq $cpu_cores ] 8 | then 9 | echo 0 #不支持超线程 10 | fi 11 | 12 | if [ $val -eq 2 ] 13 | then 14 | echo 1 #支持超线程 15 | fi 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_hyper.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持超线程 3 | cpu_cores=$(cat /proc/cpuinfo | grep "cpu cores" | awk -F ':' 'NR==1 {print $2}') 4 | siblings=$( cat /proc/cpuinfo | grep "siblings" | awk -F ':' 'NR==1 {print $2}') 5 | val=`expr $siblings / $cpu_cores` 6 | 7 | if [ $siblings -eq $cpu_cores ] 8 | then 9 | echo 0 #不支持超线程 10 | fi 11 | 12 | if [ $val -eq 2 ] 13 | then 14 | echo 1 #支持超线程 15 | fi 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_iowait.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #io等待占用CPU时间的百分比(测评使用) 3 | iowait_rate=`top -b -n 1 | grep Cpu | awk '{print $10}'` #(-b -n 1 表示只需要1次的输出结果) 4 | echo $iowait_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_iowait.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #io等待占用CPU时间的百分比(测评使用) 3 | iowait_rate=`top -b -n 1 | grep Cpu | awk '{print $10}'` #(-b -n 1 表示只需要1次的输出结果) 4 | echo $iowait_rate 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_run_threads.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算可运行队列的线程数(测评使用) 3 | cpu_count=$(grep 'physical id' /proc/cpuinfo | sort -u | wc -l) #cpu个数 4 | loadavg_1min=$( cat /proc/loadavg | awk '{print $1}') #cpu一分钟平均负载 5 | task_per_cpu=$(awk 'BEGIN{printf"%.2f\n",'$loadavg_1min' / '$cpu_count'}') 6 | #每个cpu的当前任务数 7 | echo $task_per_cpu 8 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_run_threads.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算可运行队列的线程数(测评使用) 3 | cpu_count=$(grep 'physical id' /proc/cpuinfo | sort -u | wc -l) #cpu个数 4 | loadavg_1min=$( cat /proc/loadavg | awk '{print $1}') #cpu一分钟平均负载 5 | task_per_cpu=$(awk 'BEGIN{printf"%.2f\n",'$loadavg_1min' / '$cpu_count'}') 6 | #每个cpu的当前任务数 7 | echo "可运行队列的线程数:" $task_per_cpu >> cpu_total_info.txt 8 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_sys_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU系统占用率(测评使用) 3 | sys_rate=`top -b -n 1 | grep Cpu | awk '{print $4}'` 4 | echo $sys_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_sys_rate.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU系统占用率(测评使用) 3 | sys_rate=`top -b -n 1 | grep Cpu | awk '{print $4}'` 4 | echo $sys_rate 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_user_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU用户占用率(测评使用) 3 | cpu_user_rate=`top -b -n 1 | grep Cpu | awk '{print $2}'` 4 | echo $cpu_user_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_user_rate.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU用户占用率(测评使用) 3 | user_rate=`top -b -n 1 | grep Cpu | awk '{print $2}'` 4 | echo $user_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_virtual.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持虚拟化(测评使用) 3 | cpu_virtual=`egrep -o '(vmx | svm)' /proc/cpuinfo | awk 'NR==1'` 4 | 5 | if [ $cpu_virtual = "vmx" -o $cpu_virtual = "svm" ] #判断CPU是否支持虚拟化 6 | then 7 | { 8 | if [ $cpu_virtual = "vmx" ] #Intel提供的虚拟化 9 | then 10 | echo 2 11 | fi 12 | if [ $cpu_virtual = "svm" ] #AMD提供的虚拟化 13 | then 14 | echo 1 15 | fi 16 | } 17 | else 18 | echo 0 #不支持虚拟化 19 | fi 20 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_evaluation/cpu_virtual.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持虚拟化(测评使用) 3 | cpu_virtual=`egrep -o '(vmx | svm)' /proc/cpuinfo | awk 'NR==1'` 4 | 5 | if [ $cpu_virtual = "vmx" -o $cpu_virtual = "svm" ] #判断CPU是否支持虚拟化 6 | then 7 | { 8 | if [ $cpu_virtual = "vmx" ] #Intel提供的虚拟化 9 | then 10 | echo 2 11 | fi 12 | if [ $cpu_virtual = "svm" ] #AMD提供的虚拟化 13 | then 14 | echo 1 15 | fi 16 | } 17 | else 18 | echo 0 19 | fi 20 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_hyper.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持超线程(测评使用) 3 | cpu_cores=$(cat /proc/cpuinfo | grep "cpu cores" | awk -F ':' 'NR==1 {print $2}') 4 | siblings=$( cat /proc/cpuinfo | grep "siblings" | awk -F ':' 'NR==1 {print $2}') 5 | val=`expr $siblings / $cpu_cores` 6 | 7 | if [ $siblings -eq $cpu_cores ] 8 | then 9 | echo 0 #不支持超线程 10 | fi 11 | 12 | if [ $val -eq 2 ] 13 | then 14 | echo 1 #支持超线程 15 | fi 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_iowait.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #io等待占用CPU时间的百分比(测评使用) 3 | iowait_rate=`top -b -n 1 | grep Cpu | awk '{print $10}'` #(-b -n 1 表示只需要1次的输出结果) 4 | echo $iowait_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_run_threads.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算可运行队列的线程数(测评使用) 3 | cpu_count=$(grep 'physical id' /proc/cpuinfo | sort -u | wc -l) #cpu个数 4 | loadavg_1min=$( cat /proc/loadavg | awk '{print $1}') #cpu一分钟平均负载 5 | task_per_cpu=$(awk 'BEGIN{printf"%.2f\n",'$loadavg_1min' / '$cpu_count'}') 6 | #每个cpu的当前任务数 7 | echo $task_per_cpu 8 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_sys_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU系统占用率(测评使用) 3 | sys_rate=`top -b -n 1 | grep Cpu | awk '{print $4}'` 4 | echo $sys_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_user_rate.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #CPU用户占用率(测评使用) 3 | cpu_user_rate=`top -b -n 1 | grep Cpu | awk '{print $2}'` 4 | echo $cpu_user_rate #百分比 5 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/cpu_virtual.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #是否支持虚拟化(测评使用) 3 | cpu_virtual=`egrep -o '(vmx | svm)' /proc/cpuinfo | awk 'NR==1'` 4 | 5 | if [ $cpu_virtual = "vmx" -o $cpu_virtual = "svm" ] #判断CPU是否支持虚拟化 6 | then 7 | { 8 | if [ $cpu_virtual = "vmx" ] #Intel提供的虚拟化 9 | then 10 | echo 2 11 | fi 12 | if [ $cpu_virtual = "svm" ] #AMD提供的虚拟化 13 | then 14 | echo 1 15 | fi 16 | } 17 | else 18 | echo 0 #不支持虚拟化 19 | fi 20 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/earntime.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #获取启动时长 3 | function run_time (){ 4 | 5 | a=`cat /var/log/dmesg | grep "setting system" | awk '{print $2}'` 6 | run=${a%?} 7 | run=${run:0:1} 8 | start_hour=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($1)}'`*3600] 9 | start_min=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($2)}'`*60] 10 | start_sec=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($3)}'`] 11 | start_time=$[$start_hour+$start_min+$start_sec-$run] 12 | 13 | end_time=0 14 | for pid in $(pgrep lightdm); 15 | do 16 | t2=`ps -p ${pid} -o lstart=` 17 | end_hour=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($1)}'`*3600] 18 | end_min=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($2)}'`*60] 19 | end_sec=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($3)}'`] 20 | t1=$[$end_hour+$end_min+$end_sec] 21 | if [ $t1 -gt $end_time ] 22 | then 23 | end_time=$t1 24 | fi 25 | done 26 | cur_runtime=$[$end_time-$start_time] 27 | return $cur_runtime 28 | } 29 | 30 | run_time 31 | timelength=$? 32 | echo $timelength 33 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/firefox_cookies.sh: -------------------------------------------------------------------------------- 1 | flag=0 2 | #检查firefox有没有安装 3 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "firefox" |wc -l` 4 | if [ $a -gt 0 ];then 5 | #检测有没有firefox跟踪cookies 6 | path=`find ~/.mozilla/firefox -type d -name "*.default"` 7 | cd $path 8 | fc0=`ls -l |grep "cookies.sqlite" |wc -l` 9 | if [ $fc0 -eq 1 ];then 10 | fc1=`ls -l cookies.sqlite |awk '{print $5}'` 11 | if [ $fc1 -gt 0 ];then 12 | ((flag++)) 13 | echo $flag 14 | else 15 | echo $flag 16 | fi 17 | else 18 | echo $flag 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/firefox_cookies.sh~: -------------------------------------------------------------------------------- 1 | flag=0 2 | #检查firefox有没有安装 3 | a=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "firefox" |wc -l` 4 | if [ $a -gt 0 ];then 5 | #检测有没有firefox跟踪cookies 6 | path=`find ~/.mozilla/firefox -type d -name "*.default"` 7 | cd $path 8 | fc0=`ls -l |grep "cookies.sqlite" |wc -l` 9 | if [ $fc0 -eq 1 ];then 10 | fc1=`ls -l cookies.sqlite |awk '{print $5}'` 11 | if [ $fc1 -gt 0 ];then 12 | ((flag++)) 13 | echo $flag 14 | else 15 | echo $flag 16 | fi 17 | else 18 | echo "检测到不存在firefox跟踪cookies" 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/google_cookies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | flag=0 3 | #判断有没有安装google-chrome 4 | b=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "google-chrome" |wc -l` 5 | if [ $b -gt 0 ];then 6 | #echo "google-chrome已安装" 7 | #判断有没有google-chrome配置文件 8 | g=` ls -l ~/.config |grep "google-chrome" |wc -l ` 9 | if [ $g -gt 0 ];then 10 | #进入google-chrome跟踪cookies所在目录 11 | cd ~/.config/google-chrome/Default/ 12 | #检测有没有google-chrome跟踪cookies 13 | if [ -f "Cookies" ];then 14 | #获取谷歌跟踪Cookies的大小 15 | gc0=`ls -l Cookies |awk '{print $5}'` 16 | #如果cookies大小为0,则不存在 17 | if [ $gc0 -gt 0 ];then 18 | ((flag++)) 19 | echo $flag #"检测到存在google-chrome跟踪cookies,个人隐私有泄露危险" 20 | else 21 | echo $flag #"检测到不存在google-chrome跟踪cookies" 22 | fi 23 | else 24 | echo $flag #"检测到不存在google-chrome跟踪cookies" 25 | fi 26 | 27 | else 28 | echo $flag #"未检测到有google-chrome跟踪cookies" 29 | fi 30 | fi 31 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/google_cookies.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | flag=0 3 | #判断有没有安装google-chrome 4 | b=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "google-chrome" |wc -l` 5 | if [ $b -gt 0 ];then 6 | #echo "google-chrome已安装" 7 | #判断有没有google-chrome配置文件 8 | g=` ls -l ~/.config |grep "google-chrome" |wc -l ` 9 | if [ $g -gt 0 ];then 10 | #进入google-chrome跟踪cookies所在目录 11 | cd ~/.config/google-chrome/Default/ 12 | #检测有没有google-chrome跟踪cookies 13 | if [ -f "Cookies" ];then 14 | #获取谷歌跟踪Cookies的大小 15 | gc0=`ls -l Cookies |awk '{print $5}'` 16 | #如果cookies大小为0,则不存在 17 | if [ $gc0 -gt 0 ];then 18 | ((flag++)) 19 | echo $flag #"检测到存在google-chrome跟踪cookies,个人隐私有泄露危险" 20 | else 21 | echo $flag #"检测到不存在google-chrome跟踪cookies" 22 | fi 23 | else 24 | echo $flag #"检测到不存在google-chrome跟踪cookies" 25 | fi 26 | 27 | else 28 | echo "未检测到有google-chrome跟踪cookies" 29 | fi 30 | fi 31 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/google_history.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #检测有没有google-chrome跟踪URL历史记录 3 | 4 | flag=0 5 | #判断有没有安装google-chrome 6 | b=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "google-chrome" |wc -l` 7 | if [ $b -gt 0 ];then 8 | #echo "google-chrome已安装" 9 | #判断有没有google-chrome配置文件 10 | g=` ls -l ~/.config |grep "google-chrome" |wc -l ` 11 | 12 | if [ $g -gt 0 ];then 13 | #进入google-chrome跟踪cookies所在目录 14 | cd ~/.config/google-chrome/Default/ 15 | #检测有没有google-chrome跟踪cookies 16 | if [ -f "History" ];then 17 | #获取谷歌跟踪Cookies的大小 18 | gc0=`ls -l History |awk '{print $5}'` 19 | #如果cookies大小为0,则不存在 20 | if [ $gc0 -gt 0 ];then 21 | ((flag++)) 22 | echo $flag #"检测到存在google-chrome历史跟踪记录,个人隐私有泄露危险" 23 | else 24 | echo $flag #"检测到不存在google-chrome历史跟踪记录" 25 | fi 26 | else 27 | echo $flag #"检测到不存在google-chrome历史跟踪记录" 28 | fi 29 | 30 | else 31 | echo $flag #"未检测到有google-chrome历史跟踪记录" 32 | fi 33 | fi 34 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/google_history.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #检测有没有google-chrome跟踪URL历史记录 3 | 4 | flag=0 5 | #判断有没有安装google-chrome 6 | b=`dpkg -l | awk '{if(NR!=1&&NR!=2&&NR!=3&&NR!=4&&NR!=5) {print $2}}' |grep "google-chrome" |wc -l` 7 | if [ $b -gt 0 ];then 8 | #echo "google-chrome已安装" 9 | #判断有没有google-chrome配置文件 10 | g=` ls -l ~/.config |grep "google-chrome" |wc -l ` 11 | 12 | if [ $g -gt 0 ];then 13 | #进入google-chrome跟踪cookies所在目录 14 | cd ~/.config/google-chrome/Default/ 15 | #检测有没有google-chrome跟踪cookies 16 | if [ -f "History" ];then 17 | #获取谷歌跟踪Cookies的大小 18 | gc0=`ls -l History |awk '{print $5}'` 19 | #如果cookies大小为0,则不存在 20 | if [ $gc0 -gt 0 ];then 21 | ((flag++)) 22 | echo $flag"检测到存在google-chrome历史跟踪记录,个人隐私有泄露危险" 23 | else 24 | echo $flag"检测到不存在google-chrome历史跟踪记录" 25 | fi 26 | else 27 | echo $flag"检测到不存在google-chrome历史跟踪记录" 28 | fi 29 | 30 | else 31 | echo $flag"未检测到有google-chrome历史跟踪记录" 32 | fi 33 | fi 34 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/init_arp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #查看是否开机自动绑定IP和MAC地址 3 | ap=`cat /etc/init.d/rc.local |grep "arp -f /etc/ip-mac" |wc -l` 4 | if [ $ap == 0 ];then 5 | echo 0 #"开机自启动ARP欺骗防护未开启!" 6 | else 7 | echo 1 #"开机自启动ARP欺骗防护已开启!" 8 | fi 9 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/init_arp.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #查看是否开机自动绑定IP和MAC地址 3 | ap=`cat /etc/init.d/rc.local |grep "arp -f /etc/ip-mac" |wc -l` 4 | if [ $ap == 0 ];then 5 | echo "开机自启动ARP欺骗防护未开启!" 6 | else 7 | echo "开机自启动ARP欺骗防护已开启!" 8 | fi 9 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_await.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #计算平均IO响应时间await,一般地系统IO响应时间应该低于5ms,如果大于10ms就比较大了,await、svctm越低越好,说明io响应延迟很低,iops能力很高 3 | 4 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 5 | rio=`cat /proc/diskstats |grep "0 sda" |awk '{print int($4)}'` 6 | 7 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 8 | wio=`cat /proc/diskstats |grep "0 sda" |awk '{print int($8)}'` 9 | 10 | #第4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数。 11 | ruse=`cat /proc/diskstats |grep "0 sda" |awk '{print int($7)}'` 12 | 13 | #第8个域:写操作花费的毫秒数 --- 写花费的毫秒数,这是所有写操作所花费的毫秒数 14 | wuse=`cat /proc/diskstats |grep "0 sda" |awk '{print int($11)}'` 15 | 16 | #await:平均每次设备I/O操作的等待时间 (毫秒)(IO Response Time),包括在请求队列中的时间和响应消耗时间,即 (ruse+wuse)/(rio+wio) 17 | rwuse=$[$ruse+$wuse] 18 | rwio=$[$rio+$wio] 19 | await=`awk 'BEGIN{printf"%.2f\n",'$rwuse' / '$rwio'}'` 20 | echo "$await" 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_await.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #计算平均IO响应时间await,一般地系统IO响应时间应该低于5ms,如果大于10ms就比较大了。 3 | 4 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 5 | rio=`cat /proc/diskstats |grep "0 sda" |awk '{print int($4)}'` 6 | 7 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 8 | wio=`cat /proc/diskstats |grep "0 sda" |awk '{print int($8)}'` 9 | 10 | #第4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数。 11 | ruse=`cat /proc/diskstats |grep "0 sda" |awk '{print int($7)}'` 12 | 13 | #第8个域:写操作花费的毫秒数 --- 写花费的毫秒数,这是所有写操作所花费的毫秒数 14 | wuse=`cat /proc/diskstats |grep "0 sda" |awk '{print int($11)}'` 15 | 16 | #await:平均每次设备I/O操作的等待时间 (毫秒)(IO Response Time),包括在请求队列中的时间和响应消耗时间,即 (ruse+wuse)/(rio+wio) 17 | rwuse=$[$ruse+$wuse] 18 | rwio=$[$rio+$wio] 19 | await=`awk 'BEGIN{printf"%.2f\n",'$rwuse' / '$rwio'}'` 20 | echo "$await" 21 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_reqnum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #正在进行的I/O数,I/O队列中请求数(running),一个磁盘队列值为2-3最佳,默认队列为128个长度 3 | #第9个域:正在处理的输入/输出请求数--I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小 4 | running=`cat /proc/diskstats |grep "0 sda" |awk '{print int($12)}'` 5 | echo "$running" 6 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_reqnum.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #正在进行的I/O数,I/O队列中请求数(running),一个磁盘队列值为2-3最佳 3 | #第9个域:正在处理的输入/输出请求数--I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小 4 | running=`cat /proc/diskstats |grep "0 sda" |awk '{print int($12)}'` 5 | echo "$running" 6 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_svctm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ##svctm:平均每次设备I/O操作的服务时间 (毫秒),svctm不超过5 3 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 4 | rio=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($4)}') 5 | 6 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 7 | wio=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($8)}') 8 | 9 | #第10个域:输入/输出操作花费的毫秒数--花在I/O操作上的毫秒数,这个域会增长只要field 9不为0,系统真正花费在I/O上的时间,除去重复等待时间(use)(从系统启动时的累积值) 10 | use=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($13)}') 11 | 12 | rwio=$[$rio+$wio] 13 | #svctm:平均每次设备I/O操作的服务时间 (毫秒),即 use/(rio+wio) 14 | svctm=$(awk 'BEGIN{printf"%.2f\n",'$use' / '$rwio'}') 15 | echo $svctm #平均每次设备I/O操作的服务时间svctm 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_svctm.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ##svctm:平均每次设备I/O操作的服务时间 (毫秒),svctm不超过5 3 | #第1个域:读完成次数 ----- 读磁盘的次数,成功完成读的总次数 4 | rio=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($4)}'` 5 | 6 | #第5个域:写完成次数 ----写完成的次数,成功写完成的总次数。 7 | wio=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($8)}'` 8 | 9 | #第10个域:输入/输出操作花费的毫秒数--花在I/O操作上的毫秒数,这个域会增长只要field 9不为0,系统真正花费在I/O上的时间,除去重复等待时间(use)(从系统启动时的累积值) 10 | use=$(cat /proc/diskstats |grep " 0 sda " |awk NR==1'{print int($13)}') 11 | 12 | rwio=$[$rio+$wio] 13 | #svctm:平均每次设备I/O操作的服务时间 (毫秒),即 use/(rio+wio) 14 | svctm=$(awk 'BEGIN{printf"%.2f\n",'$use' / '$rwio'}') 15 | echo $svctm #平均每次设备I/O操作的服务时间svctm 16 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #一秒中有百分之多少的时间用于I/O操作%util,小于等于70%,如果 %util 接近 100%,说明产生的I/O请求太多,I/O系统已经满负荷,该磁盘可能存在瓶颈。 3 | 4 | #/proc/uptime第一列输出的是,系统启动到现在的时间(以秒为单位) 5 | ut=`cat /proc/uptime |awk '{print $1}'` 6 | 7 | #第10个域:输入/输出操作花费的毫秒数--花在I/O操作上的毫秒数,这个域会增长只要field 9不为0。 8 | use=`cat /proc/diskstats |grep "0 sda" |awk '{print int($13)}'` 9 | 10 | #%util: 一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的,即 delta(use)/s/1000 (因为use的单位为毫秒) 11 | util=`awk 'BEGIN{printf"%.2f\n",'$use' / '$ut' / 1000 * 100}'` 12 | echo "$util" 13 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/io_util.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #一秒中有百分之多少的时间用于I/O操作%util 3 | 4 | #/proc/uptime第一列输出的是,系统启动到现在的时间(以秒为单位) 5 | ut=`cat /proc/uptime |awk '{print $1}'` 6 | 7 | #第10个域:输入/输出操作花费的毫秒数--花在I/O操作上的毫秒数,这个域会增长只要field 9不为0。 8 | use=`cat /proc/diskstats |grep "0 sda" |awk '{print int($13)}'` 9 | 10 | #%util: 一秒中有百分之多少的时间用于 I/O 操作,或者说一秒中有多少时间 I/O 队列是非空的,即 delta(use)/s/1000 (因为use的单位为毫秒) 11 | util=`awk 'BEGIN{printf"%.2f\n",'$use' / '$ut' / 1000 * 100}'` 12 | echo "$util" 13 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/iptables_judge.sh: -------------------------------------------------------------------------------- 1 | #查看iptables三个基本防护规则是否存在 2 | flag=0 3 | echo $1 | sudo -S echo -n 2> /dev/null 4 | if [ $? == 0 ];then 5 | ipnum=`sudo iptables -L |grep "prot opt source" |wc -l` 6 | if [ $ipnum == 3 ];then 7 | ((flag++)) 8 | echo $flag #iptables防火墙基本防护已开启 9 | else 10 | echo $flag 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/junk_files.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: junk_files.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 16时24分32秒 6 | ######################################################################### 7 | #!/bin/bash 8 | flag=0 9 | #查看回收站垃圾大小 10 | a1=`du -ks $HOME/.local/share/Trash/files/ | awk '{print int($1)}'` 11 | 12 | #查看无用软件包垃圾大小,/var/cache/apt/archives是安装软件时下载包的临时存放目录 13 | a2=`du -ks /var/cache/apt/archives | awk '{print int($1)}'` 14 | 15 | #查看是缩略图缓存垃圾大小 16 | a3=`du -ks ~/.cache/thumbnails/ |awk '{print int($1)}'` 17 | 18 | 19 | sum=$[$a1+$a2+$a3] 20 | if [ $sum -ge 0 -a $sum -lt 1048576 ];then 21 | echo $flag 22 | elif [ $sum -ge 1048576 ];then 23 | ((flag++)) 24 | echo $flag #"您的磁盘垃圾已超过1G,最好及时清理!" 25 | fi 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/junk_files.sh~: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: junk_files.sh 3 | # Author: liujing 4 | # mail: 2510034575@qq.com 5 | # Created Time: 2015年01月07日 星期三 16时24分32秒 6 | ######################################################################### 7 | #!/bin/bash 8 | flag=0 9 | #查看回收站垃圾大小 10 | a1=`du -ks $HOME/.local/share/Trash/files/ | awk '{print int($1)}'` 11 | 12 | #查看无用软件包垃圾大小,/var/cache/apt/archives是安装软件时下载包的临时存放目录 13 | a2=`du -ks /var/cache/apt/archives | awk '{print int($1)}'` 14 | 15 | #查看是缩略图缓存垃圾大小 16 | a3=`du -ks ~/.cache/thumbnails/ |awk '{print int($1)}'` 17 | 18 | 19 | sum=$[$a1+$a2+$a3] 20 | if [ $sum -ge 0 -a $sum -lt 1048576 ];then 21 | echo $flag 22 | elif [ $sum -ge 1048576 ];then 23 | ((flag++)) 24 | echo $flag #"您的磁盘垃圾已超过1G,最好及时清理!" 25 | fi 26 | 27 | 28 | #查看是否有旧内核 29 | a6=`ls /boot |grep "vmlinuz" |wc -l` 30 | if [ $a6 -gt 1 ];then 31 | echo "该系统有旧版本内核,可删除释放一些磁盘空间!" 32 | fi 33 | 34 | 35 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/mem_evaluation/mem_user.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算应用程序可用内存百分比(测评使用) 3 | #计算公式:应用程序可用内存=MemFree + Buffers + Cached 4 | MemFree=$(cat /proc/meminfo | awk '/^MemFree/{print $2}') #系统空闲内存 5 | Buffers=$(cat /proc/meminfo | awk '/^Buffers/{print $2}') #缓冲区内存 6 | Cached=$(cat /proc/meminfo | awk '/^Cached/{print $2}') #高速缓存 7 | MemUser=$[$MemFree + $Buffers +$Cached] 8 | 9 | MemTotal=$(cat /proc/meminfo | awk '/^MemTotal/{print $2}') #内存总量 10 | mem_user_rate=$(awk 'BEGIN{printf"%.2f\n",'$MemUser' / '$MemTotal' * 100}') 11 | echo $mem_user_rate #百分比 12 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/mem_evaluation/mem_user.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算应用程序可用内存百分比 3 | #计算公式:应用程序可用内存=MemFree + Buffers + Cached 4 | MemFree=$(cat /proc/meminfo | awk '/^MemFree/{print $2}') #系统空闲内存 5 | Buffers=$(cat /proc/meminfo | awk '/^Buffers/{print $2}') #缓冲区内存 6 | Cached=$(cat /proc/meminfo | awk '/^Cached/{print $2}') #高速缓存 7 | MemUser=$[$MemFree + $Buffers +$Cached] 8 | 9 | MemTotal=$(cat /proc/meminfo | awk '/^MemTotal/{print $2}') #内存总量 10 | mem_user_rate=$(awk 'BEGIN{printf"%.2f\n",'$MemUser' / '$MemTotal' * 100}') 11 | echo $mem_user_rate #百分比 12 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/mem_user.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | #计算应用程序可用内存百分比(测评使用) 3 | #计算公式:应用程序可用内存=MemFree + Buffers + Cached 4 | MemFree=$(cat /proc/meminfo | awk '/^MemFree/{print $2}') #系统空闲内存 5 | Buffers=$(cat /proc/meminfo | awk '/^Buffers/{print $2}') #缓冲区内存 6 | Cached=$(cat /proc/meminfo | awk '/^Cached/{print $2}') #高速缓存 7 | MemUser=$[$MemFree + $Buffers +$Cached] 8 | 9 | MemTotal=$(cat /proc/meminfo | awk '/^MemTotal/{print $2}') #内存总量 10 | mem_user_rate=$(awk 'BEGIN{printf"%.2f\n",'$MemUser' / '$MemTotal' * 100}') 11 | echo $mem_user_rate #百分比 12 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/recent_used.sh: -------------------------------------------------------------------------------- 1 | #检测有没有最近使用文档跟踪记录 2 | flag=0 3 | sec0=`ls -l ~/.local/share/ |grep "recently-used.xbel" |wc -l ` 4 | if [ $sec0 -eq 1 ];then 5 | sec1=`ls -l ~/.local/share/recently-used.xbel |awk '{print $5}'` 6 | if [ $sec1 -eq 0 ];then 7 | echo $flag 8 | else 9 | ((flag++)) 10 | echo $flag 11 | fi 12 | else 13 | echo $flag 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/recent_used.sh~: -------------------------------------------------------------------------------- 1 | #检测有没有最近使用文档跟踪记录 2 | flag=0 3 | sec0=`ls -l ~/.local/share/ |grep "recently-used.xbel" |wc -l ` 4 | if [ $sec0 -eq 1 ];then 5 | sec1=`ls -l ~/.local/share/recently-used.xbel |awk '{print $5}'` 6 | if [ $sec1 -eq 0 ];then 7 | echo $flag 8 | else 9 | ((flag++)) 10 | echo "检测到存在最近使用文档跟踪记录,个人隐私有泄露危险" 11 | fi 12 | else 13 | echo $flag 14 | fi 15 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/startup_items.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #显示开机自启动项(S开头) 3 | if [ -n "$1" ];then 4 | #验证输入的用户名密码是否正确,并把错误信息重定向到垃圾桶里 5 | echo $1 | sudo -S echo -n 2> /dev/null 6 | if [ $? == 0 ];then 7 | #得到rc0.d~rc6.d、rcS.d这几个目录的路径 8 | filelist=`echo $1 | sudo -S find /etc -name "rc*.d"` 9 | for file in $filelist 10 | do 11 | #把rc0.d~rc6.d、rcS.d这几个目录下的所有文件名定向到./shell/result0中 12 | find $file -name "S*" >> result0 13 | done 14 | #去除./shell/result中的重复行,并重定向到./shell/result1中 15 | sort -u result0 > result1 16 | startup=`cat result1|wc -l` 17 | echo $startup #统计启动项个数 18 | #删除./shell/result0、result1 19 | rm result0 20 | rm result1 21 | fi 22 | fi 23 | 24 | 25 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/startup_items.sh~: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #显示开机自启动项(S开头) 3 | if [ -n "$1" ];then 4 | #验证输入的用户名密码是否正确,并把错误信息重定向到垃圾桶里 5 | echo $1 | sudo -S echo -n 2> /dev/null 6 | if [ $? == 0 ];then 7 | #得到rc0.d~rc6.d、rcS.d这几个目录的路径 8 | filelist=`echo $1 | sudo -S find /etc -name "rc*.d"` 9 | for file in $filelist 10 | do 11 | #把rc0.d~rc6.d、rcS.d这几个目录下的所有文件名定向到./shell/result0中 12 | find $file -name "S*" >> result0 13 | done 14 | #去除./shell/result中的重复行,并重定向到./shell/result1中 15 | sort -u result0 > result1 16 | startup=`cat result1|wc -l` 17 | echo $startup #"启动项个数 18 | #删除./shell/result0、result1 19 | rm result0 20 | rm result1 21 | fi 22 | fi 23 | 24 | 25 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/开机时间/earntime.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #获取启动时长 3 | function run_time (){ 4 | 5 | a=`cat /var/log/dmesg | grep "setting system" | awk '{print $2}'` 6 | run=${a%?} 7 | run=${run:0:1} 8 | start_hour=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($1)}'`*3600] 9 | start_min=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($2)}'`*60] 10 | start_sec=$[`cat /var/log/dmesg | grep "setting system" | awk '{print $10}' | awk -F: '{print int($3)}'`] 11 | start_time=$[$start_hour+$start_min+$start_sec-$run] 12 | 13 | end_time=0 14 | for pid in $(pgrep lightdm); 15 | do 16 | t2=`ps -p ${pid} -o lstart=` 17 | end_hour=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($1)}'`*3600] 18 | end_min=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($2)}'`*60] 19 | end_sec=$[`echo $t2 | awk '{print $4}' | awk -F: '{print int($3)}'`] 20 | t1=$[$end_hour+$end_min+$end_sec] 21 | if [ $t1 -gt $end_time ] 22 | then 23 | end_time=$t1 24 | fi 25 | done 26 | cur_runtime=$[$end_time-$start_time] 27 | return $cur_runtime 28 | } 29 | 30 | run_time 31 | timelength=$? 32 | echo $timelength 33 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/测评标准: -------------------------------------------------------------------------------- 1 | 我们通常经验值是: 2 | 3 | svctm不超过0.5; 4 | 5 | await不超过5; 6 | 7 | 主要看当前设备 8 | 9 | 核心要点: 10 | 11 | 1、tps(iops)越高,但%util越低,说明io能力容量越大 12 | 13 | 2、await、svctm越低越好,说明io响应延迟很低,iops能力很高 14 | 15 | 调整buffer,提高性能 16 | 17 | 无非就是调整队列数,以及增加预读数,下面我们来手动做一下 18 | 19 | ·增加队列长度 20 | 21 | 格式: 22 | 23 | /sys/block/vda(特定某设备)/queue/nr_requests 24 | 25 | 由于我这里跑的是kvm虚机,所以设备号默认都以vdx开头 26 | 27 | 默认队列为128个长度 28 | 29 | [root@node3 ~]# cat /sys/block/vda/queue/nr_requests 30 | 31 | 128 32 | 33 | 这个值是可以调大一点的 34 | 35 | 2.增加预读数 36 | 37 | /sys/block/vda(特定某设备)/queue/read_ahead_kb 38 | 39 | 表示事先预读数据的kb数,默认也是128 40 | 41 | [root@node3 ~]# cat /sys/block/vda/queue/read_ahead_kb 42 | 43 | 128 44 | 45 | 这个值也是可以调大的,具体多少自行而定 46 | -------------------------------------------------------------------------------- /源代码/脚本/sys_test/体检/一键测评/测评标准~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KitKat-liujing/LeSystemDetection/1c261686f5d69e7d9ddb259b1b27a1504e28d2c3/源代码/脚本/sys_test/体检/一键测评/测评标准~ -------------------------------------------------------------------------------- /源代码/脚本/sys_test_result/test.sh~: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | echo -e "请输入参数:" 3 | read str param 4 | echo -e "str="$str 5 | echo -e "param="$param 6 | -------------------------------------------------------------------------------- /源代码/脚本/testpwd/testpwd.sh: -------------------------------------------------------------------------------- 1 | 2 | ######################################################################### 3 | # File Name: hardwareinfo.sh 4 | # Author: liujing 5 | # mail: 2510034575@qq.com 6 | # Created Time: 2015年01月07日 星期三 19时23分25秒 7 | ######################################################################### 8 | #!/bin/bash 9 | echo $1 |sudo -S echo "" 2> /dev/null 10 | if [ $? == 0 ] 11 | then 12 | echo "Y" 13 | else 14 | echo "N" 15 | fi 16 | 17 | 18 | --------------------------------------------------------------------------------