123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/usr/bin/env bash
- output_html(){
-
- if [ ! -e '/etc/redhat-release' ]; then
- INDEX_HTML=/var/www/html/index.html
- mkdir -p /var/www/html/
- else
- INDEX_HTML=/usr/share/nginx/html/index.html
- fi
- echo '<!DOCTYPE html><meta charset=utf-8><pre>' > ${INDEX_HTML}
- top -b | head -5 >> ${INDEX_HTML}
- vnstat -u
- vnstat -m >> ${INDEX_HTML}
- vnstat -d >> ${INDEX_HTML}
- vnstat -h >> ${INDEX_HTML}
- echo ' ' >> ${INDEX_HTML}
- echo ' netlog.sh Source code: https://git.io/fxxlb' >> ${INDEX_HTML}
- }
- vnstat_install(){
-
- if [ ! -e '/etc/redhat-release' ]; then
-
- apt -y install vnstat nginx
- else
-
- yum -y install vnstat nginx
- systemctl enable nginx
- systemctl restart nginx
- fi
-
- ni=$(ls /sys/class/net | awk {print} | grep -e eth. -e ens. -e venet.)
- if [ $ni != "eth0" ]; then
- sed -i "s/eth0/${ni}/g" /etc/vnstat.conf
- fi
- systemctl restart vnstat
-
- crontab -l >> crontab.txt
- echo "* */3 * * * wget -qO- git.io/fxxlb | bash" >> crontab.txt
- crontab crontab.txt
- sleep 2
- if [ ! -e '/etc/redhat-release' ]; then
- systemctl restart cron
- else
- systemctl restart crond
- fi
- rm -f crontab.txt
- }
- if [ ! -f '/usr/bin/vnstat' ]; then
- vnstat_install
- fi
- output_html
|