k8s_centos
[eliot.git] / scripts / generatePromeyml.sh
1 #!/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 promyml=~/prometheus.yml
12 workernodeip=""
13 blank=""
14 count=1
15 firstline=1
16 while read line
17 do
18   if [ $count -gt $firstline ]; then
19      workernodeip+="','"
20   fi
21   nodeinfo="${line}"
22   nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
23   echo $nodeip
24   workernodeip+=$nodeip
25   workernodeip+=":8081"
26   echo $workernodeip
27   count=2
28   echo $count
29 done < nodelist > /dev/null 2>&1
30
31 echo "workernodeip="
32 echo $workernodeip
33
34 cat <<EOF > "${promyml}"
35 ---
36 global:
37   scrape_interval: 15s
38
39 scrape_configs:
40   - job_name: 'prometheus'
41     scrape_interval: 5s
42     static_configs:
43       - targets: ['localhost:9090']
44
45   - job_name: cadvisor
46     scrape_interval: 5s
47     static_configs:
48       - targets: ['$workernodeip']
49 EOF