e-Sensibility
New member
Here's a simple set of scripts that enable you to pull network usage stats on XenServer Guests (domU) in a secure manner by polling their VIFs on the XenServer Host (Dom0). These scripts work across reboots, and can easily be used to feed data into graphing utilities like Cacti.
Installation:
========================================================
On the Dom0 (host) (the following must be done as root):
Unpack the tar.gz archive linked above and cd to the newly created directory:
Now move the bwpoll directory located herein to where it expects to live:
Next we'll make sure the permissions are correct -- this is very important to ensure that the user we'll create later can't execute arbitrary commands as root.
Now that everything is in the right place and permissions are properly set, we'll add a command to /etc/rc.d/rc.local to make sure everything starts on boot:
And we'll also add a user who will poll:
And configure a password for that user:
Now everything is set up on the Dom0 side. To start the scripts without rebooting, simply execute spawn.pl manually (as root):
===============================================
Client install (on a domU or another host):
===============================================
Dependencies: You must install Net : : SSH : : Perl (broken up because of smileys) from CPAN (or via yum if you have the RPMForge repo enabled)
On a guest or separate machine, unarchive the tar.gz file linked at the beginning of this post:
Now move the bwpoll directory located herein to where it expects to live:
Next, edit /etc/bwpoll/bwpoll.pl adding in the appropriate values for username, password and hostname:
That's it! By default if you execute /etc/bwpoll/bwpoll.pl you'll see the current network read/write statistics for each guest (domU) living on the host (dom0) that you've configured!
These scripts are extremely easy to extend via perl modules or custom subroutines within bwpoll.pl. If you feel like it, please share how you implement the scripts in your environment and contribute back any modifications you make to this thread.
Hope this helps somebody!
Installation:
========================================================
On the Dom0 (host) (the following must be done as root):
Unpack the tar.gz archive linked above and cd to the newly created directory:
Code:
tar -xzvf bwpoll.tar.gz
Code:
cd bwpoll/server/
Code:
mv bwpoll /etc/bwpoll
Code:
cd /etc/bwpoll
Code:
chmod 500 *
Code:
chmod 555 poll.pl ; chmod 555 Connection.pm
Now that everything is in the right place and permissions are properly set, we'll add a command to /etc/rc.d/rc.local to make sure everything starts on boot:
Code:
echo "perl /etc/bwpoll/spawn.pl" >> /etc/rc.d/rc.local
Code:
useradd -d /dev/null/ bw
Code:
passwd bw
Now everything is set up on the Dom0 side. To start the scripts without rebooting, simply execute spawn.pl manually (as root):
Code:
perl /etc/bwpoll/spawn.pl
===============================================
Client install (on a domU or another host):
===============================================
Dependencies: You must install Net : : SSH : : Perl (broken up because of smileys) from CPAN (or via yum if you have the RPMForge repo enabled)
On a guest or separate machine, unarchive the tar.gz file linked at the beginning of this post:
Code:
tar -xzvf bwpoll.tar.gz
Code:
cd bwpoll/client/
Code:
mv bwpoll /etc/bwpoll
Code:
cd /etc/bwpoll
Code:
vi /etc/bwpoll/bwpoll.pl
That's it! By default if you execute /etc/bwpoll/bwpoll.pl you'll see the current network read/write statistics for each guest (domU) living on the host (dom0) that you've configured!
Code:
perl /etc/bwpoll/bwpoll.pl
These scripts are extremely easy to extend via perl modules or custom subroutines within bwpoll.pl. If you feel like it, please share how you implement the scripts in your environment and contribute back any modifications you make to this thread.
Hope this helps somebody!