linux下統(tǒng)計(jì)appche站點(diǎn)IP訪問(wèn)量的shell腳本
經(jīng)常需要根據(jù)IP地址統(tǒng)計(jì)apache站點(diǎn)訪問(wèn)量,最基本的腳本.
根據(jù)IP訪問(wèn)量降序排列:
#!/bin/bash
#Script_name: access_count
acc_log=/usr/local/apache2/logs/access_log
/bin/awk '{print $1}' $acc_log | sort | uniq -c | sort -nr
執(zhí)行效果:
[root@zabbix ~]# sh access_count
94989 192.168.100.34
38863 192.168.200.92
23658 192.168.1.71
16720 192.168.100.80
13688 192.168.200.34
1618 192.168.100.104
1251 192.168.1.202
1195 192.168.100.30
1058 192.168.1.203
934 192.168.1.208
792 127.0.0.1
773 192.168.5.126
189 192.168.1.68
打印訪問(wèn)量前三的IP地址:
#!/bin/bash
#Script_name:access_count
acc_log=/usr/local/apache2/logs/access_log
/bin/awk '{print $1}' $acc_log | sort | uniq -c | sort -nr | head -n 3
執(zhí)行效果:
[root@zabbix ~]# sh access_count
94989 192.168.100.34
38863 192.168.200.92
23658 192.168.1.71
apache站點(diǎn)訪問(wèn)錯(cuò)誤統(tǒng)計(jì):
#!/bin/bash
#Script_name:error_count
err_log=/usr/local/apache2/logs/error_log
cat $err_log | grep -e "^\[" | awk '{print $6}' | sort | uniq -c |sort -nr
執(zhí)行效果:
[root@zabbix ~]# sh error_count
701 [core:notice]
30 [mpm_event:notice]
12 [core:warn]
1 [:error]
- Linux命令行和shell腳本編程寶典 Richard Blum
- linux c程序中獲取shell腳本輸出的實(shí)現(xiàn)方法
- Linux shell腳本編程if語(yǔ)句的使用方法(條件判斷)
- linux shell腳本學(xué)習(xí)xargs命令使用詳解
- Linux Shell腳本編程的注意事項(xiàng)
- Linux中執(zhí)行shell腳本的4種方法總結(jié)
- 阿里云云服務(wù)器Linux系統(tǒng)更新yum源Shell腳本
- 一個(gè)監(jiān)控LINUX目錄和文件變化的Shell腳本分享
- Linux下實(shí)現(xiàn)SSH免密碼登錄和實(shí)現(xiàn)秘鑰的管理、分發(fā)、部署SHELL腳本分享
- 讓Linux下的cron以秒為單位執(zhí)行shell腳本的3種方法
- Linux Shell腳本編程初體驗(yàn)
- Linux Shell 腳本編程入門教程
相關(guān)文章
Linux上兩種網(wǎng)絡(luò)連接實(shí)現(xiàn)方式
這篇文章主要介紹了Linux上兩種網(wǎng)絡(luò)連接實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09apache You don''t have permission to access /test.php on thi
這篇文章主要介紹了apache You don't have permission to access /test.php on this server解決方法,需要的朋友可以參考下2015-04-04Linux環(huán)境下Apache開(kāi)啟https服務(wù)的方法詳解
這篇文章主要介紹了Linux環(huán)境下Apache開(kāi)啟https服務(wù)的方法,結(jié)合實(shí)例形式分析了阿里云環(huán)境下獲取SSL證書及Apache服務(wù)器安裝、開(kāi)啟SSL的相關(guān)操作技巧,需要的朋友可以參考下2019-07-07centos最小化安裝系統(tǒng)后的基本調(diào)優(yōu)及安全設(shè)置
這篇文章主要介紹了centos最小化安裝系統(tǒng)后的一些基本調(diào)優(yōu)及安全設(shè)置,需要的朋友可以參考下2013-04-04如何通過(guò)其他主機(jī)查看Apahce服務(wù)器的運(yùn)行狀態(tài)
這篇文章主要介紹了如何通過(guò)其他主機(jī)查看Apahce服務(wù)器的運(yùn)行狀態(tài),需要的朋友可以參考下2016-04-04