The original Plugin was written by Chris Bair, after some tunings it worked fine for me.
I made some useful modifications to this Plugin:
– Visualization of the number of Drafts
– Set table prefix (I hate hardcodet things)
And now how to use it, first you need to create a configuration file for the plugin(replace the needed credentials)
1 | vim /etc/munin/plugin-conf.d/wordpress_stats |
1 2 3 4 5 6 | [wordpress*] env.DB_HOST localhost env.DB_NAME database01 env.DB_USER user01 env.DB_PASSWORD XYZ!123 env.DB_PREFIX wp_ |
And the plugin:
1 | vim /etc/munin/plugins/wordpress_stats |
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 | #!/bin/sh if [ "$1" = "config" ]; then echo 'graph_title Wordpress average' echo 'graph_category Wordpress' echo 'graph_order posts comments pingbacks users' echo 'graph_vlabel Wordpress' echo 'graph_info Some Statistics of Wordpress' echo 'posts.label Posts' echo 'posts.draw LINE3' echo 'drafts.label Drafts' echo 'comments.label Comments' echo 'pingbacks.label Pingbacks' echo 'users.label Users' exit 0 fi POSTS=0 DRAFTS=0 COMMENTS=0 PINGBACKS=0 USERS=0 POSTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}posts WHERE post_status = 'publish' AND post_password = '' AND post_type = 'post';"` DRAFTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}posts WHERE post_status = 'draft' AND post_password = '' AND post_type = 'post';"` COMMENTS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}comments WHERE comment_approved = '1' AND comment_type = '';"` PINGBACKS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}comments WHERE comment_approved = '1' AND comment_type = 'pingback';"` USERS=`mysql -h$DB_HOST -p$DB_PASSWORD -u$DB_USER -D $DB_NAME --column-names=0 -s --execute="SELECT COUNT(*) FROM ${DB_PREFIX}users ;"` # Output echo "posts.value $POSTS" echo "drafts.value $DRAFTS" echo "comments.value $COMMENTS" echo "pingbacks.value $PINGBACKS" echo "users.value $USERS" |
[…] WordPress Plugin http://zeldor.biz/2011/06/wordpress-munin-plugin/ […]