Commit 0c0ada0a authored by E-Science Admin's avatar E-Science Admin
Browse files

Date added, headers changed to MIME

parents fb3dc1a5 7e3a6a3b
The wp-check script checks statistics for a wordpress instance for the time frame of 1 day and logs those into file with a timestamp.
Checks statistics for wordpress instances for the last 24 hours and logs those into a log file with a timestamp.
* new users
* new posts
* new pages
## Requirenments
For Centos:
```
yum install MySQL-python
```
Create the user and grant select privileges on the DB:
```
create user 'wp-check-user'@'your_server' identified by 'password';
grant select on wordpress_db.* to `wp-check-user`@`your_server`;
```
Let the check run every day at 5am
```
crontab -e
```
Insert
```
# check wordpress instances for news
0 5 * * * /usr/bin/python /opt/check-wp/check-wp.py
````
LOG_DIR = ''
LOG_FILE = ''
EMAIL_CONF = {
'FROM': '',
'TO': [''],
'SUBJECT': '[Wordpress daily]',
'SMTP_SERVER': '',
'PORT': '',
}
WORDPRESS_DATABASES = {
'default': {
'NAME': '',
'URL': '',
'USER': '',
'PASSWORD': '',
'HOST': '',
......@@ -9,20 +20,21 @@ WORDPRESS_DATABASES = {
'DATABASE': '',
}
}
WORDPRESS_STATS = {
'users': {
'count': "SELECT COUNT(*) FROM `wp_users` WHERE `user_registered` >= NOW() - INTERVAL 1 DAY",
'header': 'ID | user_login | display_name | user_registered',
'query': "SELECT `ID`, `user_login`, `display_name`, `user_registered` FROM `wp_users` WHERE `user_registered` >= NOW() - INTERVAL 1 DAY",
'header': 'user_registered, display_name',
'query': "SELECT `user_registered`, `display_name` FROM `wp_users` WHERE `user_registered` >= NOW() - INTERVAL 1 DAY",
},
'posts': {
'count': "SELECT COUNT(*) FROM `wp_posts` WHERE `post_type` LIKE \'post\' AND `post_modified` >= NOW() - INTERVAL 1 DAY",
'header': 'ID | post_author | post_modified | post_title',
'query': "SELECT `ID`, `post_author`, `post_modified`, `post_title` FROM `wp_posts` WHERE `post_type` LIKE \'post\' AND `post_modified` >= NOW() - INTERVAL 1 DAY",
'header': 'post_modified, post_title',
'query': "SELECT `post_modified`, `post_title` FROM `wp_posts` WHERE `post_type` LIKE \'post\' AND `post_modified` >= NOW() - INTERVAL 1 DAY",
},
'pages': {
'count': "SELECT COUNT(*) FROM `wp_posts` WHERE `post_type` LIKE \'page\' AND `post_modified` >= NOW() - INTERVAL 1 DAY",
'header': 'ID | post_author | post_modified | post_title',
'query': 'SELECT `ID`, `post_author`, `post_modified`, `post_title` FROM `wp_posts` WHERE `post_type` LIKE \'page\' AND `post_modified` >= NOW() - INTERVAL 1 DAY',
'header': 'post_modified, post_title',
'query': 'SELECT `post_modified`, `post_title` FROM `wp_posts` WHERE `post_type` LIKE \'page\' AND `post_modified` >= NOW() - INTERVAL 1 DAY',
},
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment