Merge "This Patch is used to add grafana config to opnfv dashboard for kvmfornfv_cycl...
[yardstick.git] / yardstick / network_services / nfvi / collectd.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2016-2017 Intel Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 INSTALL_NSB_BIN="/opt/nsb_bin"
18 cd $INSTALL_NSB_BIN
19
20 if [ "$(whoami)" != "root" ]; then
21         echo "Must be root to run $0"
22         exit 1;
23 fi
24
25 echo "Install required libraries to run collectd..."
26 pkg=(git flex bison build-essential pkg-config automake  autotools-dev libltdl-dev librabbitmq-dev rabbitmq-server)
27 for i in "${pkg[@]}"; do
28 dpkg-query -W --showformat='${Status}\n' "${i}"|grep "install ok installed"
29     if [  "$?" -eq "1" ]; then
30         apt-get -y install "${i}";
31     fi
32 done
33 echo "Done"
34
35 ldconfig -p | grep libpqos >/dev/null
36 if [ $? -eq 0 ]
37 then
38     echo "Intel RDT library already installed. Done"
39 else
40     pushd .
41
42     echo "Get intel_rdt repo and install..."
43     rm -rf intel-cmt-cat >/dev/null
44     git clone https://github.com/01org/intel-cmt-cat.git
45     pushd intel-cmt-cat
46     git checkout tags/v1.5 -b v1.5
47     make install PREFIX=/usr
48     popd
49
50     popd
51     echo "Done."
52 fi
53
54 which /opt/nsb_bin/collectd/collectd >/dev/null
55 if [ $? -eq 0 ]
56 then
57     echo "Collectd already installed. Done"
58 else
59     pushd .
60     echo "Get collectd from repository and install..."
61     rm -rf collectd >/dev/null
62     git clone https://github.com/collectd/collectd.git
63     pushd collectd
64     git stash
65     git checkout -b collectd 43a4db3b3209f497a0ba408aebf8aee385c6262d
66     ./build.sh
67     ./configure --with-libpqos=/usr/
68     make install > /dev/null
69     popd
70     echo "Done."
71     popd
72 fi
73
74 modprobe msr
75 cp $INSTALL_NSB_BIN/collectd.conf /opt/collectd/etc/
76
77 echo "Check if admin user already created"
78 rabbitmqctl list_users | grep '^admin$' > /dev/null
79 if [ $? -eq 0 ];
80 then
81     echo "'admin' user already created..."
82 else
83     echo "Creating 'admin' user for collectd data export..."
84     rabbitmqctl delete_user guest
85     rabbitmqctl add_user admin admin
86     rabbitmqctl authenticate_user admin admin
87     rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
88     echo "Done"
89 fi