root / plugins / wordpress / wordpress-mu-or-network @ 17f78427
Historique | Voir | Annoter | Télécharger (2,57 ko)
| 1 |
#!/bin/bash |
|---|---|
| 2 |
# wordpress-mu-munin plugin |
| 3 |
# |
| 4 |
# Author Andre Darafarin |
| 5 |
# Improvements by Chris Bair |
| 6 |
# Modified for Wordpress MU (or Network) by raT rat@espiv.net @ 22-04-2011 |
| 7 |
# Version 0.2 15 Feb 2011 |
| 8 |
# |
| 9 |
# |
| 10 |
# |
| 11 |
: <<=cut |
| 12 |
=head1 NAME |
| 13 |
|
| 14 |
Wordpress-Munin plugin |
| 15 |
|
| 16 |
A simple Munin plugin to monitor some data from a running wordpress instance |
| 17 |
|
| 18 |
=head1 CONFIGURATION |
| 19 |
|
| 20 |
The plugin need access to the database of the wordpress instance. |
| 21 |
|
| 22 |
|
| 23 |
=head2 Config file |
| 24 |
|
| 25 |
Add file plugin-conf.d/wordpress and fill like this |
| 26 |
|
| 27 |
|
| 28 |
=over 4 |
| 29 |
|
| 30 |
=item * [wordpress] |
| 31 |
# Name of section. Must be wordpress. |
| 32 |
|
| 33 |
=item * env.DB_NAME your_db_name |
| 34 |
# Replace your_db_name |
| 35 |
|
| 36 |
=item * env.DB_USER your_db_username |
| 37 |
# Replace you_db_username |
| 38 |
|
| 39 |
=item * env.DB_PASSWORD your_db_pass |
| 40 |
# Replace your_db_pass |
| 41 |
|
| 42 |
=item * env.DB_HOST host_of_your_db |
| 43 |
# Replace with host of database server. Will be localhost for many users. |
| 44 |
|
| 45 |
=back |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
=head1 VERSION |
| 50 |
|
| 51 |
0.2 15 Feb 2011 |
| 52 |
|
| 53 |
=head1 AUTHOR |
| 54 |
|
| 55 |
Andre Darafarin, happypork.com |
| 56 |
=cut |
| 57 |
|
| 58 |
|
| 59 |
if [ "$1" = "config" ]; then |
| 60 |
echo 'graph_title Wordpress average' |
| 61 |
echo 'graph_order posts comments pingbacks users' |
| 62 |
echo 'graph_category cms' |
| 63 |
echo 'graph_vlabel Wordpress' |
| 64 |
echo 'graph_info Some Statistics of Wordpress' |
| 65 |
echo 'posts.label Posts' |
| 66 |
echo 'posts.draw LINE3' |
| 67 |
echo 'comments.label Comments' |
| 68 |
echo 'pingbacks.label Pingbacks' |
| 69 |
echo 'users.label Users' |
| 70 |
exit 0 |
| 71 |
fi |
| 72 |
|
| 73 |
USERS=0 |
| 74 |
POSTS=0 |
| 75 |
COMMENTS=0 |
| 76 |
PINGBACKS=0 |
| 77 |
POSTS_=0 |
| 78 |
COMMENTS_=0 |
| 79 |
PINGBACKS_=0 |
| 80 |
|
| 81 |
|
| 82 |
# DBNAME=${logfile:-/var/log/syslog}
|
| 83 |
|
| 84 |
BLOGS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="select blog_id from wp_blogs |
| 85 |
"` |
| 86 |
for i in $BLOGS |
| 87 |
do |
| 88 |
|
| 89 |
|
| 90 |
POSTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_${i}_posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"`
|
| 91 |
let POSTS_=POSTS_+POSTS |
| 92 |
|
| 93 |
COMMENTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_${i}_comments WHERE comment_approved = '1' AND comment_type = '';"`
|
| 94 |
let COMMENTS_=COMMENTS_+COMMENTS |
| 95 |
|
| 96 |
PINGBACKS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_${i}_comments WHERE comment_approved = '1' AND comment_type = 'pingback';"`
|
| 97 |
let PINGBACKS_=PINGBACKS_+PINGBACKS |
| 98 |
|
| 99 |
done |
| 100 |
USERS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM wp_users ;"` |
| 101 |
|
| 102 |
|
| 103 |
#AUSGABE BEREICH |
| 104 |
echo "posts.value $POSTS_" |
| 105 |
echo "comments.value $COMMENTS_" |
| 106 |
echo "pingbacks.value $PINGBACKS_" |
| 107 |
echo "users.value $USERS" |
