RUN apt-get update -y
 RUN apt-get install -y sudo
-
-ADD ./build-collectd.sh /build-collectd.sh
 
 SSH to openstack controller node:
     source openrc
     ceilometer sample-list --meter interface.if_packets
-
-9) known issues
-
-a) connection aborted
-  root@node-11:~# ceilometer sample-list --meter interface.if_packets
-('Connection aborted.', BadStatusLine("''",))
-
-  workaround:
-  root@node-11:~# sudo service ceilometer-api restart
-
-b) Service Unavailable
-  root@node-11:~# ceilometer sample-list --meter interface.if_packets
-Service Unavailable (HTTP 503)
-
-  workaround:
-  root@node-11:~# sudo service ceilometer-api restart
 
 #!/bin/bash
 
-BUILD_HOME="$(pwd)"
+BUILD_HOME=/tmp/collectd-build
 
 set -eux
+
+sudo rm -rf $BUILD_HOME
+sudo mkdir -p $BUILD_HOME
+sudo chmod 777 $BUILD_HOME
+
 sudo apt-get -y install build-essential dh-autoreconf fakeroot  devscripts dpkg-dev git wget
 
 sudo apt-get -y install \
     python-dev
 
 
+
+cd ${BUILD_HOME}
+git clone https://github.com/01org/intel-cmt-cat.git
+cd intel-cmt-cat/
+git checkout c194e3a14d5efc1bd05a8ef7a49cfaf689f66937
+make
+sudo make install PREFIX=/fuel-plugin/build/qpos
+
 cd ${BUILD_HOME}
 rm -rf collectd
-git clone https://github.com/collectd/collectd; cd collectd; git checkout 797ed5e5bee9ee89361f12e447ffc6ceb6ef79d2
+git clone https://github.com/collectd/collectd; cd collectd; git checkout 786a6be461cf58ef2b8c57974cad2a79ba2ee82c
 git clone https://github.com/collectd/pkg-debian; cd pkg-debian; git checkout 549d3caba74210ad762fe8c556801d9c11ab9876
-mv debian ..
+patch -p1 < /fuel-plugin/enable_pqos.diff
+cp -r debian ..
 
 cd ${BUILD_HOME}/collectd
 ./build.sh
 debian/rules build || true
 debian/rules build
 fakeroot debian/rules binary
-cp ${BUILD_HOME}/*.deb /build
+cp ${BUILD_HOME}/*.deb /fuel-plugin/build
 
 sudo apt-get install -y ruby-dev rubygems-integration python-pip rpm createrepo dpkg-dev git docker.io
 sudo gem install fpm
 sudo pip install fuel-plugin-builder
-cp -r /fuel-plugin /home/vagrant
-cd /home/vagrant/fuel-plugin;
-rm -rf vagrant/.vagrant
 fpb --debug --build .
-cp *.rpm /vagrant
 
 CEILOMETER_URL_TYPE=${CEILOMETER_URL_TYPE:-internalURL}
 CEILOMETER_TIMEOUT=${CEILOMETER_TIMEOUT:-1000}
 
-apt-get install -y collectd python-dev libpython2.7
-
 rm -rf $INSTALL_HOME; mkdir -p $INSTALL_HOME
 cd $INSTALL_HOME
 curl http://$HOST:8080/plugins/fuel-plugin-collectd-ceilometer-1.0/repositories/ubuntu/collectd-ceilometer.tgz | tar xzvf -
 
+cat << EOF > /etc/ld.so.conf.d/pqos.conf
+$INSTALL_HOME/lib
+EOF
+ldconfig
+modprobe msr
+
+apt-get install -y --allow-unauthenticated collectd python-dev libpython2.7
+
 cat << EOF > /etc/collectd/collectd.conf.d/collectd-ceilometer-plugin.conf
 <LoadPlugin python>
   Globals true
 </LoadPlugin>
 
 <Plugin python>
-    ModulePath "$INSTALL_HOME"
+    ModulePath "$INSTALL_HOME/collectd-ceilometer-plugin"
     LogTraces true
     Interactive false
     Import "collectd_ceilometer.plugin"
 
--- /dev/null
+diff --git a/debian/changelog b/debian/changelog
+index 88d2293..fa6bce1 100644
+--- a/debian/changelog
++++ b/debian/changelog
+@@ -1,3 +1,10 @@
++collectd (5.7.0-1) UNRELEASED; urgency=medium
++
++  * debian/rules:
++    - enable ppos
++
++ -- Ruijing Guo <ruijing.guo@intel.com>  Thu, 22 Dec 2016 13:24:11 -0500
++
+ collectd (5.5.0-4) UNRELEASED; urgency=medium
+ 
+   * debian/collectd-core.overrides:
+diff --git a/debian/rules b/debian/rules
+index ba7cfc0..d876e12 100755
+--- a/debian/rules
++++ b/debian/rules
+@@ -168,6 +168,7 @@ config.status: configure
+       
+       PKG_CONFIG_PATH="$(CURDIR)/debian/pkgconfig:$$PKG_CONFIG_PATH" \
+       ./configure $(confflags) CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
++              --enable-syslog --enable-logfile --with-libpqos=/opt/pqos/--enable-debug \
+               || ( status=$$?; cat config.log; exit $$status )
+ 
+ build: build-arch build-indep
 
 function build_pkg {
   case $1 in
     ubuntu)
-      cd ${DIR}
-      rm -rf ${DIR}/repositories/ubuntu; mkdir -p ${DIR}/repositories/ubuntu
-      rm -rf collectd-ceilometer-plugin
+      sudo rm -rf ${DIR}/build; mkdir -p ${DIR}/build
+
+      cd ${DIR}/build
       git clone https://github.com/openstack/collectd-ceilometer-plugin
       cd  collectd-ceilometer-plugin
       git checkout 73372f2eb86c81f12bc10b392f75050a401107db
-      tar cfvz ${DIR}/repositories/ubuntu/collectd-ceilometer.tgz . --exclude=collectd-ceilometer.tgz
-      cd ..; rm -rf collectd-ceilometer-plugin
 
       # build collectd
       cd ${DIR}
-      sudo docker  build -t collectd_build .
-      sudo docker run -v${DIR}/repositories/ubuntu:/build -t collectd_build /build-collectd.sh
+      sudo docker build -t collectd_build .
+      sudo docker run -v ${DIR}:/fuel-plugin -t collectd_build /fuel-plugin/build-collectd.sh
+
+      rm -rf ${DIR}/repositories/ubuntu; mkdir -p ${DIR}/repositories/ubuntu
+      cd ${DIR}/build
+      mv *.deb ${DIR}/repositories/ubuntu
+      tar cfvz ${DIR}/repositories/ubuntu/collectd-ceilometer.tgz .
+      cd ..; sudo rm -rf ${DIR}/build
       ;;
     *) echo "Not supported system"; exit 1;;
   esac
 
 
   config.vm.define "fuel" do | h |
     h.vm.host_name = "fuel"
-    h.vm.provision :shell, :inline => "/vagrant/build_fuel_plugin.sh", privileged: false
+    h.vm.provision :shell, :inline => "cd /fuel-plugin; ./build_fuel_plugin.sh", privileged: false
     h.vm.synced_folder "..", "/fuel-plugin"
     h.vm.provider :virtualbox do |v|
       v.customize ["modifyvm", :id, "--memory", 4096]