-
Notifications
You must be signed in to change notification settings - Fork 0
/
wordpress_checks.py.bak
44 lines (40 loc) · 1.53 KB
/
wordpress_checks.py.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import os
import re
from datetime import date, timedelta
# Define the day of interest in the Apache common log format.
try:
# daysAgo = int(sys.argv[1])
daysAgo = 1
except:
daysAgo = 1
theDay = date.today() - timedelta(daysAgo)
apacheDay = theDay.strftime('[%d/%b/%Y:')
path = "/home/username/Desktop/domlogs"
logs_path = os.listdir(path)
stats_output = open(os.getcwd() + '/stats.txt', "w")
for log in logs_path:
file = os.path.join(path, log)
text = open(file, "r")
wp_login_hit_count = 0
wp_cron_hit_count = 0
wp_xmlrpc_hit_count = 0
wp_admin_ajax_hit_count = 0
for line in text:
if re.match("(.*)(wp-login.php)(.*)", line):
wp_login_hit_count = wp_login_hit_count + 1
if re.match("(.*)(wp-cron.php)(.*)", line):
wp_cron_hit_count = wp_cron_hit_count + 1
if re.match("(.*)(xmlrpc.php)(.*)", line):
wp_xmlrpc_hit_count = wp_xmlrpc_hit_count + 1
if re.match("(.*)(admin-ajax.php)(.*)", line):
wp_admin_ajax_hit_count = wp_admin_ajax_hit_count + 1
# print >> stats_output, log + "|" + line,
print(log + "|" + line, end="", file=stats_output)
print(log)
print("Wordpress Logins => " + str(wp_login_hit_count))
print("Wordpress wp-cron => " + str(wp_cron_hit_count))
print("Wordpress xmlrpc => " + str(wp_xmlrpc_hit_count))
print("Wordpress admin-ajax => " + str(wp_admin_ajax_hit_count))
print("===============================================================")
text.close()