[root@falcon21 ~]# yum -y install net-snmp net-snmp-utils mrtg



[root@falcon21 ~]# vi /etc/snmp/snmpd.conf
42 #com2sec notConfigUser default public
43 com2sec local localhost private
44 com2sec mynetwork 192.168.2.0/24 public

49 #group notConfigGroup v1 notConfigUser
50 #group notConfigGroup v2c notConfigUser
51 group MyROGroup v1 local
52 group MyROGroup v2c local
53 group MyROGroup v1 mynetwork
54 group MyROGroup v2c mynetwork

70 view all included .1 80

80 disk / 10000

90 ## sec.name source community
91 com2sec local localhost falcon21
92 com2sec mynetwork 192.168.2.0/24 falcon21

110 access MyROGroup "" v2c noauth exact all none none
111 access MyRWGroup "" v2c noauth exact all all all


[root@falcon21 ~]# systemctl restart snmpd
[root@falcon21 ~]# systemctl enable snmpd
[root@falcon21 ~]# systemctl status snmpd
 snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled)
Active: active (running) since 月 2018-12-03 12:37:12 JST; 8min ago
Main PID: 19586 (snmpd)
Tasks: 1
CGroup: /system.slice/snmpd.service
└─19586 /usr/sbin/snmpd -LS0-6d -f

12月 03 12:37:11 falcon21.space systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
12月 03 12:37:12 falcon21.space snmpd[19586]: NET-SNMP version 5.7.2
12月 03 12:37:12 falcon21.space systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..


動作確認 
[root@falcon21 ~]# snmpwalk -v2c -c falcon21 localhost system
SNMPv2-MIB::sysDescr.0 = STRING: Linux falcon21.space 3.10.0-862.3.2.el7.x86_64.debug #1 SMP Mon May 21 23:56:17 UTC 2018 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (5751) 0:00:57.51
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: falcon21.space
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (11) 0:00:00.11
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering.
SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (10) 0:00:00.10
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (11) 0:00:00.11
SNMPv2-MIB::sysORUpTime.10 = Timeticks: (11) 0:00:00.11


MRTG の設定
[root@falcon21 ~]# cfgmaker --snmp-options=:::::2 --ifref=descr --ifdesc=descr falcon21@192.168.2.101> /etc/mrtg/mrtg.cfg
--base: Get Device Info on falcon21@192.168.2.101:::::2
--base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.8072.3.2.10
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd: falcon21@192.168.2.101:::::2 -> 1 -> ifIndex = 1
--snpd: falcon21@192.168.2.101:::::2 -> 2 -> ifIndex = 2
--snpd: falcon21@192.168.2.101:::::2 -> 3 -> ifIndex = 3
--snpd: falcon21@192.168.2.101:::::2 -> 4 -> ifIndex = 4
--base: Walking ifType
--snpd: falcon21@192.168.2.101:::::2 -> 1 -> ifType = 24
--snpd: falcon21@192.168.2.101:::::2 -> 2 -> ifType = 6
--snpd: falcon21@192.168.2.101:::::2 -> 3 -> ifType = 6
--snpd: falcon21@192.168.2.101:::::2 -> 4 -> ifType = 6
--base: Walking ifAdminStatus
--snpd: falcon21@192.168.2.101:::::2 -> 1 -> ifAdminStatus = 1
--snpd: falcon21@192.168.2.101:::::2 -> 2 -> ifAdminStatus = 1
--snpd: falcon21@192.168.2.101:::::2 -> 3 -> ifAdminStatus = 1
--snpd: falcon21@192.168.2.101:::::2 -> 4 -> ifAdminStatus = 2
--base: Walking ifOperStatus
--snpd: falcon21@192.168.2.101:::::2 -> 1 -> ifOperStatus = 1
--snpd: falcon21@192.168.2.101:::::2 -> 2 -> ifOperStatus = 1
--snpd: falcon21@192.168.2.101:::::2 -> 3 -> ifOperStatus = 2
--snpd: falcon21@192.168.2.101:::::2 -> 4 -> ifOperStatus = 2
--base: Walking ifMtu
--snpd: falcon21@192.168.2.101:::::2 -> 1 -> ifMtu = 65536
--snpd: falcon21@192.168.2.101:::::2 -> 2 -> ifMtu = 1500
--snpd: falcon21@192.168.2.101:::::2 -> 3 -> ifMtu = 1500
--snpd: falcon21@192.168.2.101:::::2 -> 4 -> ifMtu = 1500
--base: Walking ifSpeed
--snpd: @ifSpeed = 1:10000000 2:100000000 3:0 4:10000000

--base: Walking ifHighSpeed
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHighSpeed.1 -> 10 Mb/s
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHCInOctets.1 -> 1707326
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHighSpeed.2 -> 100 Mb/s
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHCInOctets.2 -> 281350785
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHighSpeed.3 -> unknown Mb/s
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHCInOctets.3 -> unknown
--base: check for HighspeedCounters failed ... Dropping back to V1
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHighSpeed.4 -> 10 Mb/s
--base: snmpget falcon21@192.168.2.101:::::2:v4only for ifHCInOctets.4 -> unknown
--base: check for HighspeedCounters failed ... Dropping back to V1



[root@falcon21 ~]# vi /etc/mrtg/mrtg.cfg
WorkDir: /var/www/mrtg

16 Options[_]: growright, bits

73 Target[192.168.2.101_enp0s25]: \enp0s25:falcon21@192.168.2.101:::::2
74 SetEnv[192.168.2.101_enp0s25]: MRTG_INT_IP="192.168.2.101" MRTG_INT_DESCR="enp0s25"
75 MaxBytes[192.168.2.101_enp0s25]: 12500000
76 Title[192.168.2.101_enp0s25]: enp0s25 -- falcon21.space
77 PageTop[192.168.2.101_enp0s25]: <h1>enp0s25 -- falcon21.space</h1>

###110 行目以降を削除して追加###

### CPU Usage ###
Target[cpu]: .1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.52.0:private@localhost
MaxBytes[cpu]: 100
#Unscaled[cpu]: dwmy # \u7e26\u8ef8\u3092100%\u306b\u3057\u306a\u3044\u3067\u5b9f\u7e3e\u5024\u306b\u5408\u308f\u305b\u308b(100%\u306b\u3059\u308b\u3068\u30b0\u30e9\u30d5\u304c\u307f\u3048\u306a\u3044\u305f\u3081)
Options[cpu]: growright, noinfo, nopercent
YLegend[cpu]: CPU usage(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: \u30e6\u30fc\u30b6 
LegendO[cpu]: \u30b7\u30b9\u30c6\u30e0
Legend1[cpu]: CPU\u4f7f\u7528\u7387(\u30e6\u30fc\u30b6)(%)
Legend2[cpu]: CPU\u4f7f\u7528\u7387(\u30b7\u30b9\u30c6\u30e0)(%)
Title[cpu]: \uff23\uff30\uff35\u4f7f\u7528\u7387
PageTop[cpu]: <H1>\uff23\uff30\uff35\u4f7f\u7528\u7387</H1>

### Memory Free ####
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:private@localhost
MaxBytes1[mem]: 8107236
MaxBytes2[mem]: 15212540
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Mem Free(Bytes)
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: \u7a7a\u304d\u7269\u7406\u30e1\u30e2\u30ea[MBytes]
Legend2[mem]: \u7a7a\u304d\u30b9\u30ef\u30c3\u30d7\u30e1\u30e2\u30ea[MBytes]
Title[mem]: \u7a7a\u304d\u30e1\u30e2\u30ea\u91cf
PageTop[mem]: <H1>\u7a7a\u304d\u30e1\u30e2\u30ea\u91cf</H1>

### Disk Used ####
Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:private@localhost
MaxBytes[disk]: 100
Unscaled[disk]: dwmy
Options[disk]: gauge, absolute, growright, nopercent, noinfo
YLegend[disk]: Disk Used(%)
ShortLegend[disk]: (%)
LegendI[disk]: / Disk used
LegendO[disk]: / Disk Used
Legend1[disk]: / Disk used
Legend2[disk]: / Disk used
Title[disk]: \u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u7387
PageTop[disk]: <H1>\u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u7387</H1>

### httpd \u306e\u30d7\u30ed\u30bb\u30b9\u6570 ###
Target[httpd]: .1.3.6.1.4.1.2021.2.1.5.1&.1.3.6.1.4.1.2021.2.1.4.1:private@localhost
MaxBytes[httpd]: 50
Unscaled[httpd]: dwmy
Options[httpd]: gauge, growright, nopercent
YLegend[httpd]: Count
ShortLegend[httpd]: proc(s).
Title[httpd]: Httpd Processes
LegendI[httpd]: Processes
LegendO[httpd]:
Legend1[httpd]: Httpd Processes
Legend2[httpd]:
PageTop[httpd]: <h1>Httpd Processes</h1>

### CPU\u3068\u30de\u30b6\u30fc\u30dc\u30fc\u30c9\u306e\u6e29\u5ea6 ###
Target[cputemp]: `/usr/bin/sensors | grep Temp | awk '{print $3}' | sed -e 's/+//' -e 's/[^0-9+\.].*//'`
MaxBytes[cputemp]: 100
Title[cputemp]: CPU\u3068\u30de\u30b6\u30fc\u30dc\u30fc\u30c9\u306e\u6e29\u5ea6
PageTop[cputemp]: <h1>CPU\u3068\u30de\u30b6\u30fc\u30dc\u30fc\u30c9\u306e\u6e29\u5ea6</h1>
Options[cputemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[cputemp]: ymw
#unscaled[cputemp]: dwmy
YLegend[cputemp]: Temperature
ShortLegend[cputemp]: C
LegendI[cputemp]: M/B
LegendO[cputemp]: CPU
Legend1[cputemp]: M/B 
Legend2[cputemp]: CPU

### OS\u30cf\u30fc\u30c9\u30c7\u30a3\u30b9\u30af\u306e\u6e29\u5ea6 ###
Target[hddtemp]: `hddtemp -n /dev/sda; hddtemp -n /dev/sda; uptime | awk '{$1=""; $2=""; print}'`
MaxBytes[hddtemp]: 100
Title[hddtemp]: OS\u30cf\u30fc\u30c9\u30c7\u30a3\u30b9\u30af\u306e\u6e29\u5ea6
PageTop[hddtemp]: <h1>OS\u30cf\u30fc\u30c9\u30c7\u30a3\u30b9\u30af\u306e\u6e29\u5ea6</h1>
Options[hddtemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[hddtemp]: ymw
YLegend[hddtemp]: Temperature
ShortLegend[hddtemp]: \u2103
LegendI[hddtemp]: \u6e29\u5ea6:
LegendO[hddtemp]: \u6e29\u5ea6:
Legend1[hddtemp]: OS\u30cf\u30fc\u30c9\u30c7\u30a3\u30b9\u30af\u306e\u6e29\u5ea6
Legend2[hddtemp]:

### GPU \u6e29\u5ea6\u3000\uff08fglrx \u30c9\u30e9\u30a4\u30d0\u304c\u5fc5\u8981\uff09###
#Target[gpu0.temp]: `gputemp.sh 0`
#MaxBytes[gpu0.temp]: 99
#Title[gpu0.temp]: gpu0 Temperature
#PageTop[gpu0.temp]: <H1> gpu0 temperature</H1>
#ShortLegend[gpu0.temp]: C
#YLegend[gpu0.temp]: Celsius
#Options[gpu0.temp]: growright,nopercent, nobanner, noinfo, gauge
#Unscaled[gpu0.temp]: ymd



---------------------
mrtg を3回手動実行
[root@falcon21 ~]# for (( i=1 ; i <= 3 ; i++ )); do env LANG=C mrtg /etc/mrtg/mrtg.cfg; done


mrtg.cfgecu-jp で、文字化けに、なる。コピーをリネーム保存して、UTF-8 に文字コード変換
[root@falcon21 ~]# cp -f /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg.org

[root@falcon21 ~]# nkf -w --overwrite /etc/mrtg/mrtg.cfg



インデックスファイル作成

[root@falcon21 ~]# indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html


cron 設定
[root@falcon21 ~]# vi /etc/cron.d/mrtg
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
 

conf設定
[root@falcon21 ~]# vi /etc/httpd/conf.d/mrtg.conf

[root@falcon21 ~]# systemctl restart httpd
 

 
投票数:5 平均点:10.00

 
Back to Top