본문 바로가기

Prometheus

exporter 설치

사전 세팅 python 설치

설치

zypper install prometheus-hanadb_exporter

or

zypper in git

git clone  <https://github.com/PPJINHONG/SAP_prometheus>

모니터링 유저 생성

sudo su -ndbadm

hdbsql -n 10.100.100.75 -i 00 -u SYSTEM -p dev0Bsgone -d SYSTEMDB

아래 쿼리 문 적용
CREATE USER HANADB_EXPORTER_USER PASSWORD MyExporterPassword NO FORCE_FIRST_PASSWORD_CHANGE;
CREATE ROLE HANADB_EXPORTER_ROLE;
GRANT MONITORING TO HANADB_EXPORTER_ROLE;
GRANT HANADB_EXPORTER_ROLE TO HANADB_EXPORTER_USER;

<aside>

아래 1,2번 중 1번인 zypper 방법으로 권장

실패 시 2번으로 세팅

</aside>

1. zypper 방법

zypper 설치후 세팅확인

해당 경로에 아래 파일 확인

/usr/share/doc/packages/prometheus-hanadb_exporter

-rw-r--r-- 1 root root  2693 Nov  2  2020 METRICS.md
-rw-r--r-- 1 root root  9529 Nov  2  2020 README.md
-rw-r--r-- 1 root root   297 Oct 18 17:30 config.json
-rw-r--r-- 1 root root  1171 Nov 18  2020 logging_config.ini
-rw-r--r-- 1 root root 37621 Nov 18  2020 metrics.json

/usr/bin

-rwxr-xr-x 1 root root         148 Nov 18  2020 hanadb_exporter
---------------------------------------------------------------------------
cat hanadb_exporter 아래 출력 값 

#!/usr/bin/python3
"""
hanadb_exporter command line execution file
"""

from hanadb_exporter import main

if __name__ == "__main__":
    main.run()

위에 main함수가 아래 경로로 실행

/usr/lib/python3.6/site-packages/hanadb_exporter

-rw-r--r-- 1 root root  158 Nov  2  2020 **init**.py
drwxr-xr-x 1 root root  308 Oct 18 16:56 **pycache**
-rw-r--r-- 1 root root 5355 Nov  2  2020 db_manager.py
-rw-r--r-- 1 root root 4624 Nov  2  2020 [main.py](<http://main.py/>)
-rw-r--r-- 1 root root 7273 Nov  2  2020 prometheus_exporter.py
-rw-r--r-- 1 root root 2811 Nov  2  2020 prometheus_metrics.py
-rw-r--r-- 1 root root 1807 Nov  2  2020 [utils.py](<http://utils.py/>)

/usr/etc/hanadb_exporter/

lrwxrwxrwx 1 root root 62 Oct 18 17:23 config.json.example -> /usr/share/doc/packages/prometheus-hanadb_exporter/config.json
lrwxrwxrwx 1 root root 69 Oct 18 16:56 logging_config.ini -> /usr/share/doc/packages/prometheus-hanadb_exporter/logging_config.ini
lrwxrwxrwx 1 root root 63 Oct 18 16:56 metrics.json -> /usr/share/doc/packages/prometheus-hanadb_exporter/metrics.json

/etc/hanadb_exporter/config.json 생성해서 실행시 설정파일 적용

{
  "listen_address": "0.0.0.0",
  "exposition_port": 9668,
  "multi_tenant": true,
  "timeout": 30,
  "hana": {
    "host": "10.100.100.6",
    "port": 30013,
    "user": "SYSTEM",
    "password": "dev0Bsgone",
    "ssl": false,
    "ssl_validate_cert": false
  },
  "logging": {
    "config_file": "/usr/etc/hanadb_exporter/logging_config.ini",
    "log_file": "/hana/data/hanadb_exporter.log"
  }
}



pip 필수 패키지 설치

vi /root/requirments.txt

prometheus-client>=0.6.0
git+https://github.com/SUSE/shaptools.git#egg=shaptools>=0.3.2
pyhdb>=0.3.4
certifi>=2018.1.18
boto3
requests

pip 설치

chmod 777 requirments.txt
chmod +x requirments.txt

pip install -r requirements.txt

#hdbcli 설치 아래 버전 다름
pip install /usr/sap/hdbclient/hdbcli-2.7.26.tar.gz

pip list

DEVHANA:/usr/share/doc/packages/prometheus-hanadb_exporter # pip list
Package            Version
------------------ ---------
apparmor           2.13.4
appdirs            1.4.3
asn1crypto         0.24.0
Brlapi             0.7.0
certifi            2018.1.18
cffi               1.13.2
chardet            3.0.4
chrome-gnome-shell 0.0.0
cmdln              2.0.0
createrepo_c       0.15.4
cryptography       2.8
cupshelpers        1.0
decorator          4.2.1
hanadb-exporter    0.7.1
hdbcli             2.7.26
idna               2.6
isc                2.0
LibAppArmor        2.13.4
louis              3.11.0
packaging          20.3
pip                21.3.1
ply                3.10
prometheus-client  0.7.1
py                 1.8.1
pyasn1             0.4.2
pycairo            1.15.1
pycparser          2.17
pycups             1.9.74
pycurl             7.43.0.2
PyGObject          3.34.0
pyOpenSSL          17.5.0
pyparsing          2.2.0
pysmbc             1.0.15.6
PySocks            1.6.8
requests           2.20.1
rpm                4.14.1
setuptools         40.5.0
shaptools          0.3.12
six                1.14.0
slip               0.6.5
slip.dbus          0.6.5
urllib3            1.24



systemd 설정

vi /etc/systemd/system/hanadb_exporter.service
[Unit]
Description=HANA DB Exporter for Prometheus
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/hanadb_exporter -c /etc/hanadb_exporter/config.json -m /usr/etc/hanadb_exporter/metrics.json
WorkingDirectory=/usr/lib/python3.6/site-packages/hanadb_exporter
Restart=on-failure
User=root

[Install]
WantedBy=multi-user.target

/etc/hanadb_exporter/config.json 안에 log file 용량 큼으로 경로 확인 후 설정




2. git 방법

git clone

git clone  <https://github.com/PPJINHONG/SAP_prometheus>

pip 패키지 설치

cd hanadb_exporter 

pip install .

pip install -r requirements.txt

#hdbcli 설치 아래 버전 다름
pip install /usr/sap/hdbclient/hdbcli-2.7.26.tar.gz

SAP_prometheus 구성 확인

SAP_prometheus # ll
total 124
-rw-r--r-- 1 root root   164 Oct 23 10:49 .coveragerc
drwxr-xr-x 1 root root   138 Oct 23 10:49 .git
-rw-r--r-- 1 root root   142 Oct 23 10:49 .gitignore
-rw-r--r-- 1 root root 13772 Oct 23 10:49 .pylintrc
-rw-r--r-- 1 root root  3811 Oct 23 10:49 CONTRIBUTING.md
-rw-r--r-- 1 root root 10761 Oct 23 10:49 LICENSE
-rw-r--r-- 1 root root   172 Oct 23 10:49 MANIFEST.in
-rw-r--r-- 1 root root  2709 Oct 23 10:49 Makefile
-rw-r--r-- 1 root root 11364 Oct 23 10:49 README.md
drwxr-xr-x 1 root root    88 Oct 23 10:49 bin
-rw-r--r-- 1 root root   363 Oct 23 10:49 config.json.example
drwxr-xr-x 1 root root    48 Oct 23 10:49 daemon
drwxr-xr-x 1 root root    72 Oct 23 10:49 dashboards
drwxr-xr-x 1 root root    20 Oct 23 10:49 docs
drwxr-xr-x 1 root root   200 Oct 23 10:49 hanadb_exporter
-rw-r--r-- 1 root root  1171 Oct 23 10:49 logging_config.ini
-rw-r--r-- 1 root root 37621 Oct 23 10:49 metrics.json
drwxr-xr-x 1 root root     6 Oct 23 10:49 packaging
-rw-r--r-- 1 root root    68 Oct 23 10:49 pytest.ini
-rw-r--r-- 1 root root   134 Oct 23 10:49 requirements.txt
-rw-r--r-- 1 root root  2311 Oct 23 10:49 setup.py
drwxr-xr-x 1 root root   260 Oct 23 10:49 tests
-rw-r--r-- 1 root root   419 Oct 23 10:49 tox.ini

config 파일 설정

	mv config.json.example config.json
	vi config.json
	
	{
  "listen_address": "0.0.0.0",
  "exposition_port": 9668,
  "multi_tenant": true,
  "timeout": 30,
  "hana": {
    "host": "10.100.100.6",
    "port": 30013,
    "user": "SYSTEM",
    "password": "dev0Bsgone",
    "ssl": false,
    "ssl_validate_cert": false
  },
  "logging": {
    "config_file": "./logging_config.ini",
    "log_file": "/hana/data/hanadb_exporter.log"
  }
}

실행

pwd /root/SAP_prometheus

python3 hanadb_exporter/main.py -c config.json -m metrics.json

정상 실행되면 systemd 설정해야되는데 자꾸 안됨.. 구글링해서 해결 ㄱ

3. 실행 결과

curl 10.100.100.75:9668 
or 
크롬에서 주소 입력

아래 정상 결과

'Prometheus' 카테고리의 다른 글

hanadb_exporter 로그 cron설정  (0) 2024.10.28
prometheus 설치  (0) 2024.10.28