事象の水平線

個人的ブックマーク代わりなメモ書きブログ。 地球は丸いよ。↓このへん。

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

PageTop
以前CentOS6.0にMRTGを入れてHDDの温度を記録したのだけれど、その後CPU使用率なども知りたくなり結局SNMPも入れてそのときの手順と、configファイルを元に今回も構築しようとしたらうまくいかないので、一からやり直しました。

前回同様、中身を理解するというより動きゃいいってノリですが・・・・

参考にしたのは
『水銀室』さんの『MRTGをインストールする』  (手順はほぼこのまま)
MRTGの公式』 (英語)
『server-memo.net』さんの『MRTGでディスク監視(linux)
『drk7jp』さんの『サーバ監視項目でよく使う SNMP の MIB オブジェクト ID まとめ★★必見
MRTG グラフ生成オプション一覧


まず、MRTGとSNMPの前に、webサーバーのアパッチ(httpd)を入れます。
データ(グラフ)をwebページで見るようになるためです。
[root@localhost ~]# yum -y install httpd ←まずアパッチ入れます
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-15.el6.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-15.el6.centos.1 for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-15.el6.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.2.15-15.el6.centos.1 base 813 k
Installing for dependencies:
apr x86_64 1.3.9-5.el6_2 updates 123 k
apr-util x86_64 1.3.9-3.el6_0.1 base 87 k
apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
httpd-tools x86_64 2.2.15-15.el6.centos.1 base 70 k
mailcap noarch 2.1.31-2.el6 base 27 k

Transaction Summary
================================================================================
Install 6 Package(s)

Total download size: 1.1 M
Installed size: 3.6 M
Downloading Packages:
(1/6): apr-1.3.9-5.el6_2.x86_64.rpm | 123 kB 00:00
(2/6): apr-util-1.3.9-3.el6_0.1.x86_64.rpm | 87 kB 00:00
(3/6): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm | 15 kB 00:00
(4/6): httpd-2.2.15-15.el6.centos.1.x86_64.rpm | 813 kB 00:01
(5/6): httpd-tools-2.2.15-15.el6.centos.1.x86_64.rpm | 70 kB 00:00
(6/6): mailcap-2.1.31-2.el6.noarch.rpm | 27 kB 00:00
--------------------------------------------------------------------------------
Total 572 kB/s | 1.1 MB 00:01
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-3.el6.centos.9.x86_64 (@base/$releasever)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : apr-1.3.9-5.el6_2.x86_64 1/6
Installing : apr-util-1.3.9-3.el6_0.1.x86_64 2/6
Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/6
Installing : httpd-tools-2.2.15-15.el6.centos.1.x86_64 4/6
Installing : mailcap-2.1.31-2.el6.noarch 5/6
Installing : httpd-2.2.15-15.el6.centos.1.x86_64 6/6
Verifying : httpd-2.2.15-15.el6.centos.1.x86_64 1/6
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 2/6
Verifying : apr-1.3.9-5.el6_2.x86_64 3/6
Verifying : httpd-tools-2.2.15-15.el6.centos.1.x86_64 4/6
Verifying : mailcap-2.1.31-2.el6.noarch 5/6
Verifying : apr-util-1.3.9-3.el6_0.1.x86_64 6/6

Installed:
httpd.x86_64 0:2.2.15-15.el6.centos.1

Dependency Installed:
apr.x86_64 0:1.3.9-5.el6_2
apr-util.x86_64 0:1.3.9-3.el6_0.1
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
httpd-tools.x86_64 0:2.2.15-15.el6.centos.1
mailcap.noarch 0:2.1.31-2.el6

Complete!
[root@localhost ~]# chkconfig --list httpd ←自動起動の確認
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# chkconfig httpd on   ←自動起動on
[root@localhost ~]# chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# /etc/rc.d/init.d/httpd start ←開始
Starting httpd: [ OK ]
[root@localhost ~]# yum -y install php ←php入れます
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-14.el6_3 will be installed
--> Processing Dependency: php-common = 5.3.3-14.el6_3 for package: php-5.3.3-14.el6_3.x86_64
--> Processing Dependency: php-cli = 5.3.3-14.el6_3 for package: php-5.3.3-14.el6_3.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.3.3-14.el6_3 will be installed
---> Package php-common.x86_64 0:5.3.3-14.el6_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php x86_64 5.3.3-14.el6_3 updates 1.1 M
Installing for dependencies:
php-cli x86_64 5.3.3-14.el6_3 updates 2.2 M
php-common x86_64 5.3.3-14.el6_3 updates 523 k

Transaction Summary
================================================================================
Install 3 Package(s)

Total download size: 3.8 M
Installed size: 13 M
Downloading Packages:
(1/3): php-5.3.3-14.el6_3.x86_64.rpm | 1.1 MB 00:01
(2/3): php-cli-5.3.3-14.el6_3.x86_64.rpm | 2.2 MB 00:02
(3/3): php-common-5.3.3-14.el6_3.x86_64.rpm | 523 kB 00:00
--------------------------------------------------------------------------------
Total 751 kB/s | 3.8 MB 00:05
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-common-5.3.3-14.el6_3.x86_64 1/3
Installing : php-cli-5.3.3-14.el6_3.x86_64 2/3
Installing : php-5.3.3-14.el6_3.x86_64 3/3
Verifying : php-common-5.3.3-14.el6_3.x86_64 1/3
Verifying : php-cli-5.3.3-14.el6_3.x86_64 2/3
Verifying : php-5.3.3-14.el6_3.x86_64 3/3

Installed:
php.x86_64 0:5.3.3-14.el6_3

Dependency Installed:
php-cli.x86_64 0:5.3.3-14.el6_3 php-common.x86_64 0:5.3.3-14.el6_3

Complete!
[root@localhost ~]# /etc/rc.d/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost ~]# reboot

apache と php の設定は割愛

次に、SNMP入れます。
[root@NAS ~]# yum -y install net-snmp net-snmp-utils ←snmp関連入れます
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package net-snmp.x86_64 1:5.5-41.el6_3.1 will be installed
--> Processing Dependency: net-snmp-libs = 1:5.5-41.el6_3.1 for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
--> Processing Dependency: libsensors.so.4()(64bit) for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
--> Processing Dependency: libnetsnmptrapd.so.20()(64bit) for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
--> Processing Dependency: libnetsnmpmibs.so.20()(64bit) for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
--> Processing Dependency: libnetsnmphelpers.so.20()(64bit) for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
--> Processing Dependency: libnetsnmpagent.so.20()(64bit) for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
--> Processing Dependency: libnetsnmp.so.20()(64bit) for package: 1:net-snmp-5.5-41.el6_3.1.x86_64
---> Package net-snmp-utils.x86_64 1:5.5-41.el6_3.1 will be installed
--> Running transaction check
---> Package lm_sensors-libs.x86_64 0:3.1.1-10.el6 will be installed
---> Package net-snmp-libs.x86_64 1:5.5-41.el6_3.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
net-snmp x86_64 1:5.5-41.el6_3.1 updates 302 k
net-snmp-utils x86_64 1:5.5-41.el6_3.1 updates 170 k
Installing for dependencies:
lm_sensors-libs x86_64 3.1.1-10.el6 base 37 k
net-snmp-libs x86_64 1:5.5-41.el6_3.1 updates 1.5 M

Transaction Summary
================================================================================
Install 4 Package(s)

Total download size: 2.0 M
Installed size: 6.6 M
Downloading Packages:
(1/4): lm_sensors-libs-3.1.1-10.el6.x86_64.rpm | 37 kB 00:00
(2/4): net-snmp-5.5-41.el6_3.1.x86_64.rpm | 302 kB 00:00
(3/4): net-snmp-libs-5.5-41.el6_3.1.x86_64.rpm | 1.5 MB 00:01
(4/4): net-snmp-utils-5.5-41.el6_3.1.x86_64.rpm | 170 kB 00:00
--------------------------------------------------------------------------------
Total 684 kB/s | 2.0 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lm_sensors-libs-3.1.1-10.el6.x86_64 1/4
Installing : 1:net-snmp-libs-5.5-41.el6_3.1.x86_64 2/4
Installing : 1:net-snmp-utils-5.5-41.el6_3.1.x86_64 3/4
Installing : 1:net-snmp-5.5-41.el6_3.1.x86_64 4/4
Verifying : 1:net-snmp-libs-5.5-41.el6_3.1.x86_64 1/4
Verifying : 1:net-snmp-utils-5.5-41.el6_3.1.x86_64 2/4
Verifying : 1:net-snmp-5.5-41.el6_3.1.x86_64 3/4
Verifying : lm_sensors-libs-3.1.1-10.el6.x86_64 4/4

Installed:
net-snmp.x86_64 1:5.5-41.el6_3.1 net-snmp-utils.x86_64 1:5.5-41.el6_3.1

Dependency Installed:
lm_sensors-libs.x86_64 0:3.1.1-10.el6 net-snmp-libs.x86_64 1:5.5-41.el6_3.1

Complete!
[root@NAS ~]# vi /etc/snmp/snmpd.conf ←snmpの設定
###############################################################################
#
# snmpd.conf:
# An example configuration file for configuring the ucd-snmp snmpd agent.
#
###############################################################################
#
# This file is intended to only be as a starting point. Many more
# configuration directives exist than are mentioned in this file. For
# full details, see the snmpd.conf(5) manual page.
#
# All lines beginning with a '#' are comments and are intended for you
# to read. All other lines are configuration commands for the agent.

###############################################################################
# Access Control
###############################################################################

# As shipped, the snmpd demon will only respond to queries on the
# system mib group until this file is replaced or modified for
# security purposes. Examples are shown below about how to increase the
# level of access.

# By far, the most common question I get about the agent is "why won't
# it work?", when really it should be "how do I configure the agent to
# allow me to access it?"
#
# By default, the agent responds to the "public" community for read
# only access, if run out of the box without any configuration file in
# place. The following examples show you other ways of configuring
# the agent so that you can change the community names, and give
# yourself write access to the mib tree as well.
#
# For more information, read the FAQ as well as the snmpd.conf(5)
# manual page.

####
# First, map the community name "public" into a "security name"

# sec.name source community
#com2sec notConfigUser default public
com2sec local localhost public
com2sec mynetwork 192.168.0.0/24 public
   ←192.168.0.0/24から見れるようにします

####
# Second, map the security name into a group name:

# groupName securityModel securityName
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser
group MyROGroup v1 local
group MyROGroup v2c local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork


####
# Third, create a view for us to let the group have rights to:

# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
#view systemview included .1.3.6.1.2.1.1
#view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80

####
# Finally, grant the group read-only access to the systemview view.

# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact systemview none none

# -----------------------------------------------------------------------------

# Here is a commented out example configuration that allows less
# restrictive access.

# YOU SHOULD CHANGE THE "COMMUNITY" TOKEN BELOW TO A NEW KEYWORD ONLY
# KNOWN AT YOUR SITE. YOU *MUST* CHANGE THE NETWORK TOKEN BELOW TO
# SOMETHING REFLECTING YOUR LOCAL NETWORK ADDRESS SPACE.

## sec.name source community
#com2sec local localhost COMMUNITY
#com2sec mynetwork NETWORK/24 COMMUNITY

## group.name sec.model sec.name
#group MyRWGroup any local
#group MyROGroup any mynetwork
#
#group MyRWGroup any otherv3user
#...

## incl/excl subtree mask
#view all included .1 80

## -or just the mib2 tree-

#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc


## context sec.model sec.level prefix read write notif
#access MyROGroup "" any noauth 0 all none none
#access MyRWGroup "" any noauth 0 all all all
access MyROGroup "" any noauth exact all none none


###############################################################################
# Sample configuration to make net-snmpd RFC 1213.
# Unfortunately v1 and v2c don't allow any user based authentification, so
# opening up the default config is not an option from a security point.
#
# WARNING: If you uncomment the following lines you allow write access to your
# snmpd daemon from any source! To avoid this use different names for your
# community or split out the write access to a different community and
# restrict it to your local network.
# Also remember to comment the syslocation and syscontact parameters later as
# otherwise they are still read only (see FAQ for net-snmp).
#

# First, map the community name "public" into a "security name"
# sec.name source community
#com2sec notConfigUser default public

# Second, map the security name into a group name:
# groupName securityModel securityName
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser

# Third, create a view for us to let the group have rights to:
# Open up the whole tree for ro, make the RFC 1213 required ones rw.
# name incl/excl subtree mask(optional)
#view roview included .1
#view rwview included system.sysContact
#view rwview included system.sysName
#view rwview included system.sysLocation
#view rwview included interfaces.ifTable.ifEntry.ifAdminStatus
#view rwview included at.atTable.atEntry.atPhysAddress
#view rwview included at.atTable.atEntry.atNetAddress
#view rwview included ip.ipForwarding
#view rwview included ip.ipDefaultTTL
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteDest
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteIfIndex
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteMetric1
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteMetric2
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteMetric3
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteMetric4
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteType
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteAge
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteMask
#view rwview included ip.ipRouteTable.ipRouteEntry.ipRouteMetric5
#view rwview included ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaIfIndex
#view rwview included ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress
#view rwview included ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaNetAddress
#view rwview included ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaType
#view rwview included tcp.tcpConnTable.tcpConnEntry.tcpConnState
#view rwview included egp.egpNeighTable.egpNeighEntry.egpNeighEventTrigger
#view rwview included snmp.snmpEnableAuthenTraps

# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
#access notConfigGroup "" any noauth exact roview rwview none



###############################################################################
# System contact information
#

# It is also possible to set the sysContact and sysLocation system
# variables through the snmpd.conf file:

syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)

# Example output of snmpwalk:
# % snmpwalk -v 1 localhost -c public system
# system.sysDescr.0 = "SunOS name sun4c"
# system.sysObjectID.0 = OID: enterprises.ucdavis.ucdSnmpAgent.sunos4
# system.sysUpTime.0 = Timeticks: (595637548) 68 days, 22:32:55
# system.sysContact.0 = "Me "
# system.sysName.0 = "name"
# system.sysLocation.0 = "Right here, right now."
# system.sysServices.0 = 72


###############################################################################
# Logging
#

# We do not want annoying "Connection from UDP: " messages in syslog.
# If the following option is commented out, snmpd will print each incoming
# connection, which can be useful for debugging.

dontLogTCPWrappersConnects yes

# -----------------------------------------------------------------------------


###############################################################################
# Process checks.
#
# The following are examples of how to use the agent to check for
# processes running on the host. The syntax looks something like:
#
# proc NAME [MAX=0] [MIN=0]
#
# NAME: the name of the process to check for. It must match
# exactly (ie, http will not find httpd processes).
# MAX: the maximum number allowed to be running. Defaults to 0.
# MIN: the minimum number to be running. Defaults to 0.

#
# Examples (commented out by default):
#

# Make sure mountd is running
#proc mountd

# Make sure there are no more than 4 ntalkds running, but 0 is ok too.
#proc ntalkd 4

# Make sure at least one sendmail, but less than or equal to 10 are running.
#proc sendmail 10 1

# A snmpwalk of the process mib tree would look something like this:
#
# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.2
# enterprises.ucdavis.procTable.prEntry.prIndex.1 = 1
# enterprises.ucdavis.procTable.prEntry.prIndex.2 = 2
# enterprises.ucdavis.procTable.prEntry.prIndex.3 = 3
# enterprises.ucdavis.procTable.prEntry.prNames.1 = "mountd"
# enterprises.ucdavis.procTable.prEntry.prNames.2 = "ntalkd"
# enterprises.ucdavis.procTable.prEntry.prNames.3 = "sendmail"
# enterprises.ucdavis.procTable.prEntry.prMin.1 = 0
# enterprises.ucdavis.procTable.prEntry.prMin.2 = 0
# enterprises.ucdavis.procTable.prEntry.prMin.3 = 1
# enterprises.ucdavis.procTable.prEntry.prMax.1 = 0
# enterprises.ucdavis.procTable.prEntry.prMax.2 = 4
# enterprises.ucdavis.procTable.prEntry.prMax.3 = 10
# enterprises.ucdavis.procTable.prEntry.prCount.1 = 0
# enterprises.ucdavis.procTable.prEntry.prCount.2 = 0
# enterprises.ucdavis.procTable.prEntry.prCount.3 = 1
# enterprises.ucdavis.procTable.prEntry.prErrorFlag.1 = 1
# enterprises.ucdavis.procTable.prEntry.prErrorFlag.2 = 0
# enterprises.ucdavis.procTable.prEntry.prErrorFlag.3 = 0
# enterprises.ucdavis.procTable.prEntry.prErrMessage.1 = "No mountd process running."
# enterprises.ucdavis.procTable.prEntry.prErrMessage.2 = ""
# enterprises.ucdavis.procTable.prEntry.prErrMessage.3 = ""
# enterprises.ucdavis.procTable.prEntry.prErrFix.1 = 0
# enterprises.ucdavis.procTable.prEntry.prErrFix.2 = 0
# enterprises.ucdavis.procTable.prEntry.prErrFix.3 = 0
#
# Note that the errorFlag for mountd is set to 1 because one is not
# running (in this case an rpc.mountd is, but thats not good enough),
# and the ErrMessage tells you what's wrong. The configuration
# imposed in the snmpd.conf file is also shown.
#
# Special Case: When the min and max numbers are both 0, it assumes
# you want a max of infinity and a min of 1.
#


# -----------------------------------------------------------------------------


###############################################################################
# Executables/scripts
#

#
# You can also have programs run by the agent that return a single
# line of output and an exit code. Here are two examples.
#
# exec NAME PROGRAM [ARGS ...]
#
# NAME: A generic name. The name must be unique for each exec statement.
# PROGRAM: The program to run. Include the path!
# ARGS: optional arguments to be passed to the program

# a simple hello world

#exec echotest /bin/echo hello world

# Run a shell script containing:
#
# #!/bin/sh
# echo hello world
# echo hi there
# exit 35
#
# Note: this has been specifically commented out to prevent
# accidental security holes due to someone else on your system writing
# a /tmp/shtest before you do. Uncomment to use it.
#
#exec shelltest /bin/sh /tmp/shtest

# Then,
# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.8
# enterprises.ucdavis.extTable.extEntry.extIndex.1 = 1
# enterprises.ucdavis.extTable.extEntry.extIndex.2 = 2
# enterprises.ucdavis.extTable.extEntry.extNames.1 = "echotest"
# enterprises.ucdavis.extTable.extEntry.extNames.2 = "shelltest"
# enterprises.ucdavis.extTable.extEntry.extCommand.1 = "/bin/echo hello world"
# enterprises.ucdavis.extTable.extEntry.extCommand.2 = "/bin/sh /tmp/shtest"
# enterprises.ucdavis.extTable.extEntry.extResult.1 = 0
# enterprises.ucdavis.extTable.extEntry.extResult.2 = 35
# enterprises.ucdavis.extTable.extEntry.extOutput.1 = "hello world."
# enterprises.ucdavis.extTable.extEntry.extOutput.2 = "hello world."
# enterprises.ucdavis.extTable.extEntry.extErrFix.1 = 0
# enterprises.ucdavis.extTable.extEntry.extErrFix.2 = 0

# Note that the second line of the /tmp/shtest shell script is cut
# off. Also note that the exit status of 35 was returned.

# -----------------------------------------------------------------------------


###############################################################################
# disk checks
#

# The agent can check the amount of available disk space, and make
# sure it is above a set limit.

# disk PATH [MIN=100000]
#
# PATH: mount path to the disk in question.
# MIN: Disks with space below this value will have the Mib's errorFlag set.
# Default value = 100000.

# Check the / partition and make sure it contains at least 10 megs.

#disk / 10000
disk / 10000   ←HDDの使用量を知るには必要 『/』ディレクトリ用
disk /media/sdb
     ←OSとは別のHDD

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.9
# enterprises.ucdavis.diskTable.dskEntry.diskIndex.1 = 0
# enterprises.ucdavis.diskTable.dskEntry.diskPath.1 = "/" Hex: 2F
# enterprises.ucdavis.diskTable.dskEntry.diskDevice.1 = "/dev/dsk/c201d6s0"
# enterprises.ucdavis.diskTable.dskEntry.diskMinimum.1 = 10000
# enterprises.ucdavis.diskTable.dskEntry.diskTotal.1 = 837130
# enterprises.ucdavis.diskTable.dskEntry.diskAvail.1 = 316325
# enterprises.ucdavis.diskTable.dskEntry.diskUsed.1 = 437092
# enterprises.ucdavis.diskTable.dskEntry.diskPercent.1 = 58
# enterprises.ucdavis.diskTable.dskEntry.diskErrorFlag.1 = 0
# enterprises.ucdavis.diskTable.dskEntry.diskErrorMsg.1 = ""

# -----------------------------------------------------------------------------


###############################################################################
# load average checks
#

# load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0]
#
# 1MAX: If the 1 minute load average is above this limit at query
# time, the errorFlag will be set.
# 5MAX: Similar, but for 5 min average.
# 15MAX: Similar, but for 15 min average.

# Check for loads:
#load 12 14 14

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.10
# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.1 = 1
# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.2 = 2
# enterprises.ucdavis.loadTable.laEntry.loadaveIndex.3 = 3
# enterprises.ucdavis.loadTable.laEntry.loadaveNames.1 = "Load-1"
# enterprises.ucdavis.loadTable.laEntry.loadaveNames.2 = "Load-5"
# enterprises.ucdavis.loadTable.laEntry.loadaveNames.3 = "Load-15"
# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.1 = "0.49" Hex: 30 2E 34 39
# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.2 = "0.31" Hex: 30 2E 33 31
# enterprises.ucdavis.loadTable.laEntry.loadaveLoad.3 = "0.26" Hex: 30 2E 32 36
# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.1 = "12.00"
# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.2 = "14.00"
# enterprises.ucdavis.loadTable.laEntry.loadaveConfig.3 = "14.00"
# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.1 = 0
# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.2 = 0
# enterprises.ucdavis.loadTable.laEntry.loadaveErrorFlag.3 = 0
# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.1 = ""
# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.2 = ""
# enterprises.ucdavis.loadTable.laEntry.loadaveErrMessage.3 = ""

# -----------------------------------------------------------------------------


###############################################################################
# Extensible sections.
#

# This alleviates the multiple line output problem found in the
# previous executable mib by placing each mib in its own mib table:

# Run a shell script containing:
#
# #!/bin/sh
# echo hello world
# echo hi there
# exit 35
#
# Note: this has been specifically commented out to prevent
# accidental security holes due to someone else on your system writing
# a /tmp/shtest before you do. Uncomment to use it.
#
# exec .1.3.6.1.4.1.2021.50 shelltest /bin/sh /tmp/shtest

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.50
# enterprises.ucdavis.50.1.1 = 1
# enterprises.ucdavis.50.2.1 = "shelltest"
# enterprises.ucdavis.50.3.1 = "/bin/sh /tmp/shtest"
# enterprises.ucdavis.50.100.1 = 35
# enterprises.ucdavis.50.101.1 = "hello world."
# enterprises.ucdavis.50.101.2 = "hi there."
# enterprises.ucdavis.50.102.1 = 0

# Now the Output has grown to two lines, and we can see the 'hi
# there.' output as the second line from our shell script.
#
# Note that you must alter the mib.txt file to be correct if you want
# the .50.* outputs above to change to reasonable text descriptions.

# Other ideas:
#
# exec .1.3.6.1.4.1.2021.51 ps /bin/ps
# exec .1.3.6.1.4.1.2021.52 top /usr/local/bin/top
# exec .1.3.6.1.4.1.2021.53 mailq /usr/bin/mailq

# -----------------------------------------------------------------------------


###############################################################################
# Pass through control.
#

# Usage:
# pass MIBOID EXEC-COMMAND
#
# This will pass total control of the mib underneath the MIBOID
# portion of the mib to the EXEC-COMMAND.
#
# Note: You'll have to change the path of the passtest script to your
# source directory or install it in the given location.
#
# Example: (see the script for details)
# (commented out here since it requires that you place the
# script in the right location. (its not installed by default))

# pass .1.3.6.1.4.1.2021.255 /bin/sh /usr/local/local/passtest

# % snmpwalk -v 1 localhost -c public .1.3.6.1.4.1.2021.255
# enterprises.ucdavis.255.1 = "life the universe and everything"
# enterprises.ucdavis.255.2.1 = 42
# enterprises.ucdavis.255.2.2 = OID: 42.42.42
# enterprises.ucdavis.255.3 = Timeticks: (363136200) 42 days, 0:42:42
# enterprises.ucdavis.255.4 = IpAddress: 127.0.0.1
# enterprises.ucdavis.255.5 = 42
# enterprises.ucdavis.255.6 = Gauge: 42
#
# % snmpget -v 1 localhost public .1.3.6.1.4.1.2021.255.5
# enterprises.ucdavis.255.5 = 42
#
# % snmpset -v 1 localhost public .1.3.6.1.4.1.2021.255.1 s "New string"
# enterprises.ucdavis.255.1 = "New string"
#

# For specific usage information, see the man/snmpd.conf.5 manual page
# as well as the local/passtest script used in the above example.

###############################################################################
# Further Information
#
# See the snmpd.conf manual page, and the output of "snmpd -H".
[root@NAS ~]#
[root@NAS ~]# service snmpd start
Starting snmpd: [ OK ]
[root@NAS ~]# chkconfig --list | grep snmpd
snmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@NAS ~]# chkconfig snmpd on
[root@NAS ~]# chkconfig --list | grep snmpd
snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@NAS ~]# snmpwalk -v 2c -c public 192.168.0.101
SNMPv2-MIB::sysDescr.0 = STRING: Linux NAS.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (23036) 0:03:50.36
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

~~ずらずら出ます


FireWallの設定をします。
www(http)  80  tcp  にチェック
other ports で  161-162  udp  を追加

MRTGを入れます。
[root@NAS ~]# yum -y install mrtg  ←mrtg入れます
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mrtg.x86_64 0:2.16.2-5.el6 will be installed
--> Processing Dependency: mrtg-libs = 2.16.2-5.el6 for package: mrtg-2.16.2-5.el6.x86_64
--> Processing Dependency: perl-Socket6 for package: mrtg-2.16.2-5.el6.x86_64
--> Processing Dependency: perl-IO-Socket-INET6 for package: mrtg-2.16.2-5.el6.x86_64
--> Processing Dependency: perl(locales_mrtg) for package: mrtg-2.16.2-5.el6.x86_64
--> Processing Dependency: perl(MRTG_lib) for package: mrtg-2.16.2-5.el6.x86_64
--> Processing Dependency: gd for package: mrtg-2.16.2-5.el6.x86_64
--> Processing Dependency: libgd.so.2()(64bit) for package: mrtg-2.16.2-5.el6.x86_64
--> Running transaction check
---> Package gd.x86_64 0:2.0.35-10.el6 will be installed
--> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-10.el6.x86_64
---> Package mrtg-libs.x86_64 0:2.16.2-5.el6 will be installed
--> Processing Dependency: perl(SNMP_Session) for package: mrtg-libs-2.16.2-5.el6.x86_64
--> Processing Dependency: perl(BER) for package: mrtg-libs-2.16.2-5.el6.x86_64
---> Package perl-IO-Socket-INET6.noarch 0:2.56-4.el6 will be installed
---> Package perl-Socket6.x86_64 0:0.23-3.el6 will be installed
--> Running transaction check
---> Package libXpm.x86_64 0:3.5.8-2.el6 will be installed
---> Package perl-SNMP_Session.noarch 0:1.12-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mrtg x86_64 2.16.2-5.el6 base 694 k
Installing for dependencies:
gd x86_64 2.0.35-10.el6 base 142 k
libXpm x86_64 3.5.8-2.el6 base 59 k
mrtg-libs x86_64 2.16.2-5.el6 base 95 k
perl-IO-Socket-INET6 noarch 2.56-4.el6 base 17 k
perl-SNMP_Session noarch 1.12-4.el6 base 67 k
perl-Socket6 x86_64 0.23-3.el6 base 23 k

Transaction Summary
================================================================================
Install 7 Package(s)

Total download size: 1.1 M
Installed size: 3.3 M
Downloading Packages:
(1/7): gd-2.0.35-10.el6.x86_64.rpm | 142 kB 00:00
(2/7): libXpm-3.5.8-2.el6.x86_64.rpm | 59 kB 00:00
(3/7): mrtg-2.16.2-5.el6.x86_64.rpm | 694 kB 00:01
(4/7): mrtg-libs-2.16.2-5.el6.x86_64.rpm | 95 kB 00:00
(5/7): perl-IO-Socket-INET6-2.56-4.el6.noarch.rpm | 17 kB 00:00
(6/7): perl-SNMP_Session-1.12-4.el6.noarch.rpm | 67 kB 00:00
(7/7): perl-Socket6-0.23-3.el6.x86_64.rpm | 23 kB 00:00
--------------------------------------------------------------------------------
Total 277 kB/s | 1.1 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Socket6-0.23-3.el6.x86_64 1/7
Installing : perl-IO-Socket-INET6-2.56-4.el6.noarch 2/7
Installing : libXpm-3.5.8-2.el6.x86_64 3/7
Installing : gd-2.0.35-10.el6.x86_64 4/7
Installing : perl-SNMP_Session-1.12-4.el6.noarch 5/7
Installing : mrtg-libs-2.16.2-5.el6.x86_64 6/7
Installing : mrtg-2.16.2-5.el6.x86_64 7/7
Verifying : mrtg-libs-2.16.2-5.el6.x86_64 1/7
Verifying : perl-SNMP_Session-1.12-4.el6.noarch 2/7
Verifying : perl-Socket6-0.23-3.el6.x86_64 3/7
Verifying : perl-IO-Socket-INET6-2.56-4.el6.noarch 4/7
Verifying : gd-2.0.35-10.el6.x86_64 5/7
Verifying : libXpm-3.5.8-2.el6.x86_64 6/7
Verifying : mrtg-2.16.2-5.el6.x86_64 7/7

Installed:
mrtg.x86_64 0:2.16.2-5.el6

Dependency Installed:
gd.x86_64 0:2.0.35-10.el6
libXpm.x86_64 0:3.5.8-2.el6
mrtg-libs.x86_64 0:2.16.2-5.el6
perl-IO-Socket-INET6.noarch 0:2.56-4.el6
perl-SNMP_Session.noarch 0:1.12-4.el6
perl-Socket6.x86_64 0:0.23-3.el6

Complete!



cfgmaker ってのでconfigを勝手に作ってくれるらしいです。
でも、ネットワーク転送量だけみたいです。
家の中で使うのでネットワーク転送量なんてどうでもいいけど、まぁみてみるか。
というわけで。

[root@NAS ~]# cfgmaker --ifref=descr --ifdesc=descr public@192.168.0.101 > /etc/mrtg/mrtg.cfg
[root@NAS ~]# cat /etc/mrtg/mrtg.cfg ←どんなのができたか見てみます
# Created by 
# /usr/bin/cfgmaker --ifref=descr --ifdesc=descr public@192.168.0.101


### Global Config Options

# for UNIX
# WorkDir: /home/http/mrtg
WorkDir: /var/www/mrtg

# or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

# to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits
Options[_]: growright, bits

EnableIPv6: no

######################################################################
# System: NAS.localdomain
# Description: Linux NAS.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64
# Contact: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
# Location: Unknown (edit /etc/snmp/snmpd.conf)
######################################################################


### Interface 1 >> Descr: 'lo' | Name: 'lo' | Ip: '127.0.0.1' | Eth: '' ###
### The following interface is commented out because:
### * it is a Software Loopback interface
#
# Target[192.168.0.101_lo]: \lo:public@192.168.0.101:
# SetEnv[192.168.0.101_lo]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo"
# MaxBytes[192.168.0.101_lo]: 1250000
# Title[192.168.0.101_lo]: lo -- NAS.localdomain
# PageTop[192.168.0.101_lo]: <h1>lo -- NAS.localdomain</h1>
# <div id="sysdetails">
# <table>
# <tr>
# <td>System:</td>
# <td>NAS.localdomain in Unknown (edit /etc/snmp/snmpd.conf)</td>
# </tr>
# <tr>
# <td>Maintainer:</td>
# <td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td>
# </tr>
# <tr>
# <td>Description:</td>
# <td>lo </td>
# </tr>
# <tr>
# <td>ifType:</td>
# <td>softwareLoopback (24)</td>
# </tr>
# <tr>
# <td>ifName:</td>
# <td>lo</td>
# </tr>
# <tr>
# <td>Max Speed:</td>
# <td>1250.0 kBytes/s</td>
# </tr>
# <tr>
# <td>Ip:</td>
# <td>127.0.0.1 (localhost.localdomain)</td>
# </tr>
# </table>
# </div>


### Interface 2 >> Descr: 'eth0' | Name: 'eth0' | Ip: '192.168.0.101' | Eth: '00-22-4d-83-ff-44' ###

Target[192.168.0.101_eth0]: \eth0:public@192.168.0.101:
SetEnv[192.168.0.101_eth0]: MRTG_INT_IP="192.168.0.101" MRTG_INT_DESCR="eth0"
MaxBytes[192.168.0.101_eth0]: 12500000
Title[192.168.0.101_eth0]: eth0 -- NAS.localdomain
PageTop[192.168.0.101_eth0]: <h1>eth0 -- NAS.localdomain</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>NAS.localdomain in Unknown (edit /etc/snmp/snmpd.conf)</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td>
</tr>
<tr>
<td>Description:</td>
<td>eth0 </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>eth0</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>12.5 MBytes/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>192.168.0.101 ()</td>
</tr>
</table>
</div>
[root@NAS ~]#
htmlタグの前には、半角スペースないとだめみたいです。

最初の二回目は過去のデータがなく平均が出せないだかなんだかでエラーが出るらしいです。
三回テスト出力をやります。
[root@NAS ~]# env LANG=ja_JP.EUC_JP /usr/bin/mrtg /etc/mrtg/mrtg.cfg
[root@NAS ~]# env LANG=ja_JP.EUC_JP /usr/bin/mrtg /etc/mrtg/mrtg.cfg
[root@NAS ~]# env LANG=ja_JP.EUC_JP /usr/bin/mrtg /etc/mrtg/mrtg.cfg


アパッチ(httpd)の設定でMRTGのディレクトリを公開します。
[root@NAS ~]# cat /etc/httpd/conf.d/mrtg.conf
#
# This configuration file maps the mrtg output (generated daily)
# into the URL space. By default these results are only accessible
# from the local host.
#
Alias /mrtg /var/www/mrtg

<Location /mrtg>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.0
Allow from ::1
# Allow from .example.com
</Location>
[root@NAS ~]# service httpd reload   ←アパッチ再起動
Reloading httpd:

さて、さて、HDD温度をとります。
snmpでも出来なくないみたいですけど、前と同じやり方でやります。


[root@NAS ~]# smartctl -A /dev/sda  ←S.M.A.R.T.で/dev/sdaのデータを試しに取ります
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-279.el6.x86_64] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 062 Pre-fail Always - 0
2 Throughput_Performance 0x0005 100 100 040 Pre-fail Offline - 0
3 Spin_Up_Time 0x0007 178 178 033 Pre-fail Always - 2
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 153
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 100 100 040 Pre-fail Offline - 0
9 Power_On_Hours 0x0012 100 100 000 Old_age Always - 88
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 148
191 G-Sense_Error_Rate 0x000a 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 131082
193 Load_Cycle_Count 0x0012 099 099 000 Old_age Always - 16699
194 Temperature_Celsius 0x0002 200 200 000 Old_age Always - 30 (Min/Max 13/42)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
223 Load_Retry_Count 0x000a 100 100 000 Old_age Always - 0
[root@NAS ~]# smartctl -A /dev/sdb | grep Temp  ←/dev/sdbも試します
194 Temperature_Celsius 0x0022 122 108 000 Old_age Always - 30

前回同様、HDDの温度を取るスクリプトを書きます。
前回との違いは/dev/sdbがリムーバブルのガチャポンなので、外している時にエラーメールがrootに来ないように、『0』を返すようにします。

[root@NAS ~]# vi /usr/local/bin/hddtemp.sh
#!/bin/sh
/usr/sbin/smartctl -A /dev/sda | grep Temperature | awk '{print $10}' > /usr/local/bin/hddtemp

sdbtemp=`/usr/sbin/smartctl -A /dev/sdb | grep Temperature | awk '{print $10}'`

if [ "$sdbtemp" = "" ]
then
echo "0" >> /usr/local/bin/hddtemp
else
echo $sdbtemp >> /usr/local/bin/hddtemp
fi


[root@NAS ~]# chmod 755 /usr/local/bin/hddtemp.sh  ←パーミッション
[root@NAS ~]# /usr/local/bin/hddtemp.sh  ←一度実行
[root@NAS ~]# chmod 755 /usr/local/bin/hddtemp  ←出力されたファイルのパーミッション

お次は、CPU温度を取ります。

[root@NAS ~]# yum -y install lm_sensors   ←lm_sensorsを入れます
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lm_sensors.x86_64 0:3.1.1-10.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
lm_sensors x86_64 3.1.1-10.el6 base 122 k

Transaction Summary
================================================================================
Install 1 Package(s)

Total download size: 122 k
Installed size: 348 k
Downloading Packages:
lm_sensors-3.1.1-10.el6.x86_64.rpm | 122 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lm_sensors-3.1.1-10.el6.x86_64 1/1
Verifying : lm_sensors-3.1.1-10.el6.x86_64 1/1

Installed:
lm_sensors.x86_64 0:3.1.1-10.el6

Complete!
[root@NAS ~]# sensors   ←温度を取ってみます。
No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.  だそうです。
[root@NAS ~]# sensors-detect
# sensors-detect revision 1.1
# Board: Intel Corporation DN2800MT

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): y
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 11h thermal sensors... No
Intel Core family thermal sensor... No
Intel AMB FB-DIMM thermal sensor... No
VIA C7 thermal and voltage sensors... No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): y
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... Yes
Found `Winbond W83627DHG-P Super IO Sensors' Success!
(address 0x290, driver `w83627ehf')
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'... No
Trying family `SMSC'... No
Trying family `VIA/Winbond/Nuvoton/Fintek'... No
Trying family `ITE'... No

Some systems (mainly servers) implement IPMI, a set of common interfaces
through which system health data may be retrieved, amongst other things.
We first try to get the information from SMBIOS. If we don't find it
there, we have to read from arbitrary I/O ports to probe for such
interfaces. This is normally safe. Do you want to scan for IPMI
interfaces? (YES/no): y
Probing for `IPMI BMC KCS' at 0xca0... No
Probing for `IPMI BMC SMIC' at 0xca8... No

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (yes/NO): y
Probing for `National Semiconductor LM78' at 0x290... No
Probing for `National Semiconductor LM79' at 0x290... No
Probing for `Winbond W83781D' at 0x290... No
Probing for `Winbond W83782D' at 0x290... No

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no): y
Using driver `i2c-i801' for device 0000:00:1f.3: Intel 82801G ICH7
Module i2c-dev loaded successfully.

Next adapter: SMBus I801 adapter at 3000 (i2c-0)
Do you want to scan it? (yes/NO/selectively): y
Client found at address 0x0b
Probing for `Smart Battery'... Success!
(confidence 5, driver `sbs')
Client found at address 0x51
Probing for `Analog Devices ADM1033'... No
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... No

Now follows a summary of the probes I have just done.
Just press ENTER to continue:   Enter

Driver `w83627ehf':
* ISA bus, address 0x290
Chip `Winbond W83627DHG-P Super IO Sensors' (confidence: 9)

Driver `sbs':
* Bus `SMBus I801 adapter at 3000'
Busdriver `i2c_i801', I2C address 0x0b
Chip `Smart Battery' (confidence: 5)

Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no): y
Starting lm_sensors: loading module sbs w83627ehf [ OK ]
Unloading i2c-dev... OK

[root@NAS ~]# vi /usr/local/bin/cputemp.sh  ←CPUの温度を取るスクリプト
#!/bin/sh
sensors | grep temp3 | awk '{print $2}{print $2}' | tr -d +°C
  ←DN2800MTはtemp3みたいだなぁ~?
[root@NAS ~]# chmod 755 /usr/local/bin/cputemp.sh  ←パーミッション

[root@NAS ~]# crontab -e   ←クロン登録
4-59/5 * * * * /usr/local/bin/hddtemp.sh

[root@NAS ~]# indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html  ←index.htmlつくります。

http://IPアドレス/mrtg/ にアクセスすれば見れるようになります。

snmpwalkの使い方やMIBに関しては、参照先をみてください。(ぉぃ

おしまい。

自分用mrtg.cfgメモ

[root@NAS ~]# cat /etc/mrtg/mrtg.cfg
# Created by
# /usr/bin/cfgmaker --ifref=descr --ifdesc=descr public@192.168.0.101


### Global Config Options

# for UNIX
# WorkDir: /home/http/mrtg
WorkDir: /var/www/mrtg

# or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

# to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits
Options[_]: growright, bits

EnableIPv6: no

######################################################################
# System: NAS.localdomain
# Description: Linux NAS.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64
# Contact: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
# Location: Unknown (edit /etc/snmp/snmpd.conf)
######################################################################


##### HDD Temperature #####
Target[hddtemp]: `cat /usr/local/bin/hddtemp`
ThreshMaxI[hddtemp]: 51
ThreshMaxO[hddtemp]: 51
MaxBytes[hddtemp]: 65
Unscaled[hddtemp]: dwmy
Options[hddtemp]: gauge,growright,noinfo,nopercent
ShortLegend[hddtemp]: °C
YLegend[hddtemp]: HDD Temp (C)
LegendI[hddtemp]: sda
LegendO[hddtemp]: sdb
Legend1[hddtemp]: sda
Legend2[hddtemp]: sdb
Title[hddtemp]: HDD Temperature
PageTop[hddtemp]: <H1>HDD Temp</H1>


##### CPU Temperature #####
Target[cputemp]: `/usr/local/bin/cputemp.sh`
ThreshMaxI[cputemp]: 65
ThreshMaxO[cputemp]: 65
MaxBytes[cputemp]: 70
Unscaled[cputemp]: dwmy
Options[cputemp]: gauge,growright,noinfo,nopercent
ShortLegend[cputemp]: °C
YLegend[cputemp]: CPU Temp (C)
LegendI[cputemp]: CPU
LegendO[cputemp]:
Legend1[cputemp]: CPU
Legend2[cputemp]:
Title[cputemp]: CPU Temperature
PageTop[cputemp]: <H1>CPU Temp</H1>


##### CPU Usage #####
Target[cpuusage]: .1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.52.0:public@localhost + .1.3.6.1.4.1.2021.11.52.0&.1.3.6.1.4.1.2021.4.1.0:public@localhost
MaxBytes[cpuusage]: 100
Unscaled[cpuusage]: dwmy
Options[cpuusage]: growright,noinfo,nopercent
ShortLegend[cpuusage]: %
YLegend[cpuusage]: CPU Usage (%)
LegendI[cpuusage]: All
LegendO[cpuusage]: System
Legend1[cpuusage]: CPU Usage(All)(%)
Legend2[cpuusage]: CPU Usage(System)(%)
Title[cpuusage]: Rate of CPU use
PageTop[cpuusage]: <H1>CPU Usage</H1>


##### Memory Usage #####
Target[memusage]: .1.3.6.1.4.1.2021.4.5.0&.1.3.6.1.4.1.2021.4.3.0:public@localhost - .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@localhost - .1.3.6.1.4.1.2021.4.14.0&.1.3.6.1.4.1.2021.4.1.0:public@localhost - .1.3.6.1.4.1.2021.4.15.0&.1.3.6.1.4.1.2021.4.1.0:public@localhost
MaxBytes1[memusage]: 1905016
MaxBytes2[memusage]: 2895888
Unscaled[memusage]: dwmy
Options[memusage]: gauge,absolute,growright,noinfo
ShortLegend[memusage]: Bytes
YLegend[memusage]: Mem Use (Bytes)
kilo[memusage]: 1024
kMG[memusage]: k,M,G,T,P
LegendI[memusage]: Real
LegendO[memusage]: Swap
Legend1[memusage]: Memory[MBytes]
Legend2[memusage]: Swap[MBytes]
Title[memusage]: Memory Usage
PageTop[memusage]: <H1>Memory Usage</H1>


##### /dev/sda Usage #####
Target[hddusage_sda]: .1.3.6.1.4.1.2021.9.1.8.1&.1.3.6.1.4.1.2021.9.1.7.1:public@localhost
MaxBytes1[hddusage_sda]: 477615072
MaxBytes2[hddusage_sda]: 477615072
Unscaled[hddusage_sda]: dwmy
Options[hddusage_sda]: gauge,absolute,growright,noinfo,nopercent
ShortLegend[hddusage_sda]: Bytes
YLegend[hddusage_sda]: disk Use (Bytes)
kilo[hddusage_sda]: 1024
kMG[hddusage_sda]: k,M,G,T,P
LegendI[hddusage_sda]: /sda Usage[Bytes]
LegendO[hddusage_sda]: /sda Available[Bytes]
Legend1[hddusage_sda]: /sda Usage[Bytes]
Legend2[hddusage_sda]: /sda Available[Bytes]
Title[hddusage_sda]: Disk Usage
PageTop[hddusage_sda]: <H1>/dev/sda Usage</H1>


##### /dev/sdb Usage #####
#Target[hddusage_sdb]: .1.3.6.1.4.1.2021.9.1.8.2&.1.3.6.1.4.1.2021.9.1.7.2:public@localhost
Target[hddusage_sdb]: `df /dev/sdb1 | grep /dev/sdb | awk '{print$3}{print$4}'`  #
MaxBytes1[hddusage_sdb]: 2884284060
MaxBytes2[hddusage_sdb]: 2884284060
Unscaled[hddusage_sdb]: dwmy
Options[hddusage_sdb]: gauge,absolute,growright,noinfo,nopercent
ShortLegend[hddusage_sdb]: Bytes
YLegend[hddusage_sdb]: disk Use (Bytes)
kilo[hddusage_sdb]: 1024
kMG[hddusage_sdb]: k,M,G,T,P
LegendI[hddusage_sdb]: /sdb Usage[Bytes]
LegendO[hddusage_sdb]: /sdb Available[Bytes]
Legend1[hddusage_sdb]: /sdb Usage[Bytes]
Legend2[hddusage_sdb]: /sdb Available[Bytes]
Title[hddusage_sdb]: Disk Usage
PageTop[hddusage_sdb]: <H1>/dev/sdb Usage</H1>


### Interface 1 >> Descr: 'lo' | Name: 'lo' | Ip: '127.0.0.1' | Eth: '' ###
### The following interface is commented out because:
### * it is a Software Loopback interface
#
# Target[192.168.0.101_lo]: \lo:public@192.168.0.101:
# SetEnv[192.168.0.101_lo]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo"
# MaxBytes[192.168.0.101_lo]: 1250000
# Title[192.168.0.101_lo]: lo -- NAS.localdomain
# PageTop[192.168.0.101_lo]: <h1>lo -- NAS.localdomain</h1>
# <div id="sysdetails">
# <table>
# <tr>
# <td>System:</td>
# <td>NAS.localdomain in Unknown (edit /etc/snmp/snmpd.conf)</td>
# </tr>
# <tr>
# <td>Maintainer:</td>
# <td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td>
# </tr>
# <tr>
# <td>Description:</td>
# <td>lo </td>
# </tr>
# <tr>
# <td>ifType:</td>
# <td>softwareLoopback (24)</td>
# </tr>
# <tr>
# <td>ifName:</td>
# <td>lo</td>
# </tr>
# <tr>
# <td>Max Speed:</td>
# <td>1250.0 kBytes/s</td>
# </tr>
# <tr>
# <td>Ip:</td>
# <td>127.0.0.1 (localhost.localdomain)</td>
# </tr>
# </table>
# </div>


### Interface 2 >> Descr: 'eth0' | Name: 'eth0' | Ip: '192.168.0.101' | Eth: '00-22-4d-83-ff-44' ###

Target[192.168.0.101_eth0]: \eth0:public@192.168.0.101:
SetEnv[192.168.0.101_eth0]: MRTG_INT_IP="192.168.0.101" MRTG_INT_DESCR="eth0"
MaxBytes[192.168.0.101_eth0]: 12500000
Title[192.168.0.101_eth0]: eth0 -- NAS.localdomain
PageTop[192.168.0.101_eth0]: <h1>eth0 -- NAS.localdomain</h1>
<div id="sysdetails">
<table>
<tr>
<td>System:</td>
<td>NAS.localdomain in Unknown (edit /etc/snmp/snmpd.conf)</td>
</tr>
<tr>
<td>Maintainer:</td>
<td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td>
</tr>
<tr>
<td>Description:</td>
<td>eth0 </td>
</tr>
<tr>
<td>ifType:</td>
<td>ethernetCsmacd (6)</td>
</tr>
<tr>
<td>ifName:</td>
<td>eth0</td>
</tr>
<tr>
<td>Max Speed:</td>
<td>12.5 MBytes/s</td>
</tr>
<tr>
<td>Ip:</td>
<td>192.168.0.101 ()</td>
</tr>
</table>
</div>
[root@NAS ~]#

<<追記1>>
問題には至らないタイプミスを修正
<<追記2>>
なんとSNMPのintの最大値が31bit(2147483647)らしく3TB HDDのバイト数が扱えない。
ので、dfを使って取得するように変更



参照
MRTGをインストールする
MRTGの公式』 (英語)
MRTGでディスク監視(linux)
サーバ監視項目でよく使う SNMP の MIB オブジェクト ID まとめ
MRTG グラフ生成オプション一覧

試してうまくいかなかったもの
MRTG « harumaki.net』 日本語化 UTF-8化

その他参照
ネットワークトラフィック監視ツール導入(NET-SNMP+MRTG)
MRTGによるサーバ監視(Linux編)
cactiインストールへの道 (1)net-snmpインストール
MRTG メモリ
freeコマンドの見方
MRTGでメモリ使用量取得
スポンサーサイト

PageTop

コメント

 ※
 ※
管理者にだけ表示を許可する
  ※ 必須項目です

上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。