-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnode_exporter.sh
29 lines (29 loc) · 940 Bytes
/
node_exporter.sh
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
#!/bin/bash
version=1.5.0
os=`uname`
if [ $os == "Linux" ]
then
wget https://github.com/prometheus/node_exporter/releases/download/v$version/node_exporter-$version.linux-amd64.tar.gz
tar xvfz node_exporter-$version.linux-amd64.tar.gz
cd node_exporter-$version*amd64
./node_exporter &
fi
cd /tmp
promfile=`hostname`.properties
ip=`ifconfig | grep "inet " |grep -v 127.0.0.1 |awk '{print $2}'`
hostname=`hostname`
comp_id=`oci-metadata |grep "Compartment OCID" |awk '{print $3}'`
/bin/cat <<EOM > $promfile
url=http://$ip:9100/metrics
namespace=dev_prometheus
nodeName=$hostname
metricDimensions=nodeName
allowMetrics=*
compartmentId=$comp_id
EOM
sleep 60
if [ -d "/var/lib/oracle-cloud-agent/plugins/oci-managementagent/polaris/agent_inst/discovery/PrometheusEmitter/" ]
then
cd /var/lib/oracle-cloud-agent/plugins/oci-managementagent/polaris/agent_inst/discovery/PrometheusEmitter
cp /tmp/`hostname`.properties .
fi