root / plugins / other / wordpress @ 46804929
Historique | Voir | Annoter | Télécharger (2,06 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# wordpress-munin plugin |
| 3 |
# |
| 4 |
# Author Andre Darafarin |
| 5 |
# Version 0.1 05 Oct 2010 |
| 6 |
# |
| 7 |
# |
| 8 |
: <<=cut |
| 9 |
=head1 NAME |
| 10 |
|
| 11 |
Wordpress-Munin plugin |
| 12 |
|
| 13 |
A simple Munin plugin to monitor some data from a running wordpress instance |
| 14 |
|
| 15 |
=head1 CONFIGURATION |
| 16 |
|
| 17 |
The plugin need access to the database of the wordpress instance. |
| 18 |
|
| 19 |
|
| 20 |
=head2 Config file |
| 21 |
|
| 22 |
Add file plugin-conf.d/wordpress and fill like this |
| 23 |
|
| 24 |
|
| 25 |
=over 4 |
| 26 |
|
| 27 |
=item * [wordpress] |
| 28 |
# Name of section. Must be wordpress. |
| 29 |
|
| 30 |
=item * env.DB_NAME your_db_name |
| 31 |
# Replace your_db_name |
| 32 |
|
| 33 |
=item * env.DB_USER your_db_username |
| 34 |
# Replace you_db_username |
| 35 |
|
| 36 |
=item * env.DB_PASSWORD your_db_pass |
| 37 |
# Replace your_db_pass |
| 38 |
|
| 39 |
=item * env.DB_HOST host_of_your_db |
| 40 |
# Replace with host of database server. Will be localhost for many users. |
| 41 |
|
| 42 |
=back |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
=head1 VERSION |
| 47 |
|
| 48 |
0.1, Oct 05 2010 |
| 49 |
|
| 50 |
=head1 AUTHOR |
| 51 |
|
| 52 |
Andre Darafarin, happypork.com |
| 53 |
=cut |
| 54 |
|
| 55 |
case $1 in |
| 56 |
config) |
| 57 |
cat <<'EOM' |
| 58 |
graph_title Wordpress average |
| 59 |
graph_order posts comments pingbacks users |
| 60 |
graph_vlabel Wordpress |
| 61 |
graph_info Some Statistics of Wordpress |
| 62 |
posts.label Posts |
| 63 |
posts.draw LINE3 |
| 64 |
comments.label Comments |
| 65 |
pingbacks.label Pingbacks |
| 66 |
users.label Users |
| 67 |
EOM |
| 68 |
exit 0;; |
| 69 |
esac |
| 70 |
|
| 71 |
# DBNAME=${logfile:-/var/log/syslog}
|
| 72 |
|
| 73 |
POSTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --execute="SELECT COUNT(*) FROM wp_posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"` |
| 74 |
SHORTPOSTS="${POSTS:9}"
|
| 75 |
|
| 76 |
COMMENTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --execute="SELECT COUNT(*) FROM wp_comments WHERE comment_approved = '1' AND comment_type = '';"` |
| 77 |
SHORTCOMMENTS="${COMMENTS:9}"
|
| 78 |
|
| 79 |
PINGBACKS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --execute="SELECT COUNT(*) FROM wp_comments WHERE comment_approved = '1' AND comment_type = 'pingback';"` |
| 80 |
SHORTPINGBACKS="${PINGBACKS:9}"
|
| 81 |
|
| 82 |
USERS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --execute="SELECT COUNT(*) FROM wp_users ;"` |
| 83 |
SHORTUSERS="${USERS:9}"
|
| 84 |
|
| 85 |
|
| 86 |
#AUSGABE BEREICH |
| 87 |
echo -n "posts.value $SHORTPOSTS |
| 88 |
" |
| 89 |
|
| 90 |
echo -n "comments.value $SHORTCOMMENTS |
| 91 |
" |
| 92 |
|
| 93 |
echo -n "pingbacks.value $SHORTPINGBACKS |
| 94 |
" |
| 95 |
|
| 96 |
echo -n "users.value $SHORTUSERS |
| 97 |
" |
| 98 |
|
| 99 |
|
| 100 |
|
