apt-get update
apt-get install -y mysql-server
mysql -u root
CREATE DATABASE grafana CHARACTER SET UTF8 COLLATE UTF8_BIN;
CREATE USER 'grafana'@'%' IDENTIFIED BY 'grafana123';
GRANT ALL PRIVILEGES ON grafana.* TO 'grafana'@'%';
quit;
Grafana APT 저장소 구성
mkdir grafana
cd grafana
wget https://packages.grafana.com/gpg.key
apt-key add gpg.key
add-apt-repository 'deb [arch=amd64,i386] https://packages.grafana.com/oss/deb stable main'
apt-get update
Grafana 설치
apt-get install -y grafana
/etc/grafana/grafana.ini
[database]
type = mysql
host = 127.0.0.1:3306
name = grafana
user = grafana
password = grafana123
url = mysql://grafana:grafana123@[PUBLIC IP]:3306/grafana
service grafana-server start
systemctl start grafana-server
systemctl enable --now grafana-server
systemctl status grafana-server
http://[PUBLIC_IP]:3000 접속
초기 id/pw - admin/admin
influxDB 설치
mkdir influxDB
cd influxDB
wget https://dl.influxdata.com/influxdb/releases/influxdb_1.7.8_amd64.deb
dpkg -i influxdb_1.7.8_amd64.deb
systemctl enable --now influxdb
systemctl status influxdb
influxDB# influx
Connected to http://localhost:8086 version 1.7.8
InfluxDB shell version: 1.7.8
> exit
SNMP 설치
# grafana 있는 서버
apt-get install -y snmp snmp-mibs-downloader
# 모니터링할 서버
apt-get install -y snmpd
/etc/snmp/snmp.conf
# As the snmp packages come without MIB files due to license reasons, loading
# of MIBs is disabled by default. If you added the MIBs you can reenable
# loading them by commenting out the following line.
# mibs :
/etc/snmp/snmpd.conf ( 모니터링할 서버 )
rocommunity GokuBlack default -V systemonly
sysLocation Universe10 - IT Room
sysContact kangbock kangbock0827@naver.com
service snmpd start
service snmpd status
snmpwalk -v2c -c GokuBlack 127.0.0.1
Telegraf 설치
mkdir telegraf
cd telegraf
wget https://dl.influxdata.com/telegraf/releases/telegraf_1.12.1-1_amd64.deb
dpkg -i telegraf_1.12.1-1_amd64.deb
systemctl enable --now telegraf
systemctl status telegraf
/etc/telegraf/telegraf.conf
[[inputs.snmp]]
agents = [ "127.0.0.1:161" ]
# agents = [ "x.x.x.x:161", "10.0.0.4:161" ]
# ## Timeout for each SNMP query.
timeout = "5s"
# ## Number of retries to attempt within timeout.
# retries = 3
# ## SNMP version, values can be 1, 2, or 3
version = 2
#
# ## SNMP community string.
community = "GokuBlack"
[[inputs.snmp.field]]
name = "hostname"
oid = "RFC1213-MIB::sysName.0"
[[inputs.snmp.table]]
name = "snmp"
inherit_tags = [ "hostname" ]
oid = "IF-MIB::ifXTable"
[[inputs.snmp.table.field]]
name = "snmp"
oid = "IF-MIB::ifName"
is_tag = true
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
# urls = ["unix:///var/run/influxdb.sock"]
# urls = ["udp://127.0.0.1:8089"]
urls = ["http://127.0.0.1:8086"]
## The target database for metrics; will be created as needed.
## For UDP url endpoint database needs to be configured on server side.
database = "telegraf"
## HTTP Basic Auth
username = "admin"
password = "<PASSWORD>"
service telegraf restart
telegraf --test --config /etc/telegraf/telegraf.conf
snmpwalk -v2c -c GokuBlack [Public_ip]
eth0 인터페이스 입력 모니터링
SELECT non_negative_derivative(mean("ifHCInOctets"), 1s) *8 AS "In" FROM "snmp" WHERE $timeFilter GROUP BY time($__interval), "agent_host"::tag fill(null)
eth0 인터페이스 출력 모니터링
SELECT non_negative_derivative(mean("ifHCOutOctets"), 1s) *8 AS "Out" FROM "snmp" WHERE $timeFilter GROUP BY time($__interval), "agent_host"::tag fill(null)
# influx
Connected to http://localhost:8086 version 1.7.8
InfluxDB shell version: 1.7.8
> use telegraf
Using database telegraf
> show measurements
name: measurements
name
----
cpu
disk
diskio
interface
kernel
mem
processes
snmp
swap
system
> select * from snmp
'DevOps' 카테고리의 다른 글
Slack Notification (1) | 2023.10.31 |
---|---|
Harbor (cert-manager) (0) | 2023.10.13 |
Jenkins + Argo CD (kaniko, harbor, cert-manager) (0) | 2023.08.11 |
Dapr with AKS (0) | 2023.06.09 |
Kaniko (0) | 2023.05.23 |