MRTGのDisk使用率のグラフがおかしくなってしまいました。

こんばんは。

MRTGのDisk使用率のグラフが0%になってしまいました。

これは、VPSだけがおかしいのではなく、手元のパソコンのLinux MintのMRTGも、同じ先週の金曜日から0%になってしまっています。

MRTGのディスク使用率に関するプログラムが、どうにかなっちゃったのかもしれません。

これは、私の直感では、放っておくしか無いと思います。

運が良ければ、バグフィックスされて直るかもしれませんね。

VPSのディスク使用率が、どうしても見たい人は、MUNINのDisk使用率のグラフをどうぞ。

それでは、ごきげんよう。

今年、3月末頃から、メモリの使用量が増えて、鯖落ちの原因になると判断し、設定を大幅見直ししました。

下図は、MRTGの今年のメモリのグラフです。mem-year

お蔭様で、ホームページ、ツイッターの公開する情報量が増えてしまっていたので、

その公開の情報量を減らしていくと、このVPSサーバーの容量のまま、

使い続けることができると思いまして、

サーバーの設定などを、大幅縮小しました。

今現在のMRTGのメモリ状況は、下記URLからどうぞ!

http://thanks.linuxparadise.net/mrtg/mem.html

2016年5月9日 午後7時0分現在、メモリの状況は、安定しております。

今後も、サーバーに負担をかけず、運営してまいりたいと思います。

今後とも、KOUJIの運営するサーバーを、どうぞ宜しくお願いします。

 

Linux Mint 13 MayaでのMRTGの動かし方。

MRTG Index Page2MRTGというのは、右図のようなグラフ表示をさせる、プログラムです。右図で解ります通り、

光ファイバーのトラフィック、CPU使用率、空きメモリ量、SSD(HDD)の使用量、CPU温度、SSD(HDD)温度などが調べられて、それをcronで5分置きにグラフが更新される仕組みです。

何が重要かと言いますと、このグラフを見ることによって、サーバーがアタックを受けているとか、サーバーがダウンしているかな? とか、サーバーダウンしそうかな? などと憶測を交えて、推測することが出来ることが大切なのです。

これと、同じような物に、MUNINがありますが、MUNINの方が大変楽にグラフを沢山作ります。

MRTGは設定がややこしいなぁと言う方も大勢でしょう。

パパッとやってしまいますよ。

[crayon]
# apt-get install snmp snmpd mrtg hddtemp lm-sensors nkf
# vi /etc/snmp/snmpd.conf

##### 下記を最下部に付け足します。

# sec.name source community
#com2sec paranoid default public
#com2sec readonly default public
#com2sec readwrite default private
#group MyROSystem v1 paranoid
#group MyROSystem v2c paranoid
#group MyROSystem usm paranoid
#group MyROGroup v1 readonly
#group MyROGroup v2c readonly
#group MyROGroup usm readonly
#group MyRWGroup v1 readwrite
#group MyRWGroup v2c readwrite
#group MyRWGroup usm readwrite

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

# incl/excl subtree mask
view all included .1 80
view system included .1.3.6.1.2.1.1
#view system included .iso.org.dod.internet.mgmt.mib-2.system
#access MyROSystem “” any noauth exact system none none
#access MyROGroup “” any noauth exact all none none
#access MyRWGroup “” any noauth exact all all none

# —————————————————————————–

#- com2sec paranoid default public
#+ #com2sec paranoid default public
#com2sec readonly default public
#com2sec readwrite default private
com2sec local localhost private
com2sec mynetwork 192.168.0.0/24 public (←trusthostの数値は適宜変更してください)
group MyROSystem v1 paranoid
group MyROSystem v2c paranoid
group MyROSystem usm paranoid
group MyROGroup v1 readonly
group MyROGroup v2c readonly
group MyROGroup usm readonly
group MyRWGroup v1 readwrite
group MyRWGroup v2c readwrite
group MyRWGroup usm readwrite
group MyRWGroup any local
group MyROGroup any mynetwork

access MyROSystem “” any noauth exact system none none
#- access MyROGroup “” any noauth exact all none none
#+ #access MyROGroup “” any noauth exact all none none
#- access MyRWGroup “” any noauth exact all all none
#+ #access MyRWGroup “” any noauth exact all all none
access MyROGroup “” any noauth 0 all none none
access MyRWGroup “” any noauth 0 all all all

disk /home 10000
disk / 10000
[/crayon]
[crayon]

# /etc/init.d/snmpd restart
# cfgmaker private@localhost > /etc/mrtg.cfg

[/crayon]
[crayon]
# vi /etc/mrtg.cfg

# Created by
# /usr/bin/cfgmaker –ifref=descr –ifdesc=descr public@192.168.0.111

### Global Config Options

# for UNIX
WorkDir: /home/USERDIR/public_html/html/mrtg   #ここは適宜変えてください。

# or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

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

EnableIPv6: no
Language:eucjp

### Interface 2 Descr: ‘eth0’ | Name: ‘eth0’ | Ip: ‘192.168.0.111’ | Eth: ’00-03-0d-d3-bf-46′ ###

Target[eth0]: \eth0:public@192.168.0.111: #ちゃんと、自宅サーバーのIPアドレスになっているか、確認します。
SetEnv[eth0]: MRTG_INT_IP=”192.168.0.111″ MRTG_INT_DESCR=”eth0″
MaxBytes[eth0]: 125000000
Title[eth0]: eth0トラフィック #この辺のタイトル文字も、変えた方が、見やすくなります。
PageTop[eth0]:

eth0トラフィック

### 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 # 縦軸を100%にしないで実績値に合わせる(100%にするとグラフがみえないため)
Options[cpu]: growright, noinfo, nopercent
YLegend[cpu]: CPU usage(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: ユーザ
LegendO[cpu]: システム
Legend1[cpu]: CPU使用率(ユーザ)(%)
Legend2[cpu]: CPU使用率(システム)(%)
Title[cpu]: CPU使用率
PageTop[cpu]:

CPU使用率

# free(コマンド’free’を打ち込み、下記のused/Memと、used/Swapの部分を、”Memory Free”項目の、”MaxBytes1[mem]:”、”MaxBytes2[mem]:”にコピペする。)
# total used free shared buffers cached
# Mem: 4049052 3714600 334452 0 565632 1791352
# -/+ buffers/cache: 1357616 2691436
# Swap: 4124668 356 4124312

### 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]: 4049052
MaxBytes2[mem]: 4124668
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]: 空き物理メモリ[MBytes]
Legend2[mem]: 空きスワップメモリ[MBytes]
Title[mem]: 空きメモリ量
PageTop[mem]:

空きメモリ量

### 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]: ディスク使用率
PageTop[disk]:

ディスク使用率

### CPU Temp ###
Target[cputemp]: `/root/sensors.sh` # /root/sensors.sh は後述します。
MaxBytes[cputemp]: 100
Title[cputemp]: CPU温度
PageTop[cputemp]:

CPU温度

Options[cputemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[cputemp]: ymw
#unscaled[cputemp]: dwmy
YLegend[cputemp]: Temperature
ShortLegend[cputemp]: C
LegendI[cputemp]: CPU0
LegendO[cputemp]: CPU1
Legend1[cputemp]: CPU0温度
Legend2[cputemp]: CPU1温度

### HDD Temp ###
Target[hddtemp]: `/root/hddtemp.sh` #/root/hddtemp.sh は後述します。
MaxBytes[hddtemp]: 80
Title[hddtemp]: ハードディスクの温度
PageTop[hddtemp]:

ハードディスクの温度

Options[hddtemp]: growright,absolute,gauge,nopercent,noinfo
WithPeak[hddtemp]: ymw
YLegend[hddtemp]: Temperature
ShortLegend[hddtemp]: C
LegendI[hddtemp]: Temp:
LegendO[hddtemp]:
Legend1[hddtemp]: HDD Temperature in Degrees Celcius
Legend2[hddtemp]:
[/crayon]
[crayon]
# cp /etc/mrtg.cfg /etc/mrtg.cfg.org
# nkf -e /etc/mrtg.cfg.org > /etc/mrtg.cfg
[/crayon]
[crayon]
# vi /root/sensors.sh

#!/bin/sh
sensors | grep Core | awk ‘{print $3}’ | sed -e ‘s/+//’ -e ‘s/[^0-9+\.].*//’

# vi /root/hddtemp.sh

#!/bin/sh
/usr/sbin/hddtemp -n /dev/sda1
/usr/sbin/hddtemp -n /dev/sda2
[/crayon]
[crayon]
# sensors-detect

(下記のYES/NOは、みんな’ENTERキー’でおk)

# sensors-detect revision 5861 (2010-09-21 17:21:05 +0200)
# System: Mouse Computer I50Ix1 (laptop)

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):
Module cpuid loaded successfully.
Silicon Integrated Systems SIS5595… No
VIA VT82C686 Integrated Sensors… No
VIA VT8231 Integrated Sensors… No
AMD K8 thermal sensors… No
AMD Family 10h thermal sensors… No
AMD Family 11h thermal sensors… No
Intel digital thermal sensor… Success!
(driver `coretemp’)
Intel AMB FB-DIMM thermal sensor… No
VIA C7 thermal sensor… No
VIA Nano thermal sensor… 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):
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor’… No
Trying family `SMSC’… No
Trying family `VIA/Winbond/Nuvoton/Fintek’… No
Trying family `ITE’… No
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor’… Yes
Found unknown chip with ID 0x8502

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):
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):
Using driver `i2c-i801′ for device 0000:00:1f.3: Intel ICH9
Module i2c-i801 loaded successfully.
Module i2c-dev loaded successfully.

Next adapter: i915 gmbus disabled (i2c-0)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus ssc (i2c-1)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOB (i2c-2)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus vga (i2c-3)
Do you want to scan it? (YES/no/selectively):
Next adapter: i915 GPIOA (i2c-4)
Do you want to scan it? (YES/no/selectively):
Next adapter: i915 gmbus panel (i2c-5)
Do you want to scan it? (YES/no/selectively):
Client found at address 0x50
Probing for `Analog Devices ADM1033’… No
Probing for `Analog Devices ADM1034’… No
Probing for `SPD EEPROM’… No
Probing for `EDID EEPROM’… Yes
(confidence 8, not a hardware monitoring chip)

Next adapter: i915 GPIOC (i2c-6)
Do you want to scan it? (YES/no/selectively):
Client found at address 0x50
Probing for `Analog Devices ADM1033’… No
Probing for `Analog Devices ADM1034’… No
Probing for `SPD EEPROM’… No
Probing for `EDID EEPROM’… Yes
(confidence 8, not a hardware monitoring chip)

Next adapter: i915 gmbus dpc (i2c-7)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOD (i2c-8)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus dpb (i2c-9)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOE (i2c-10)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus reserved (i2c-11)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 gmbus dpd (i2c-12)
Do you want to scan it? (YES/no/selectively):

Next adapter: i915 GPIOF (i2c-13)
Do you want to scan it? (YES/no/selectively):

Next adapter: DPDDC-B (i2c-14)
Do you want to scan it? (YES/no/selectively):

Next adapter: DPDDC-C (i2c-15)
Do you want to scan it? (YES/no/selectively):

Next adapter: DPDDC-D (i2c-16)
Do you want to scan it? (YES/no/selectively):

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

Driver `coretemp’:
* Chip `Intel digital thermal sensor’ (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#—-cut here—-(ココが重要ポイントです。この部分を切り取り、”/etc/modules”に書き込みます。)
# Chip drivers
coretemp
#—-cut here—-
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO)

Unloading i2c-dev… OK
Unloading i2c-i801… OK
Unloading cpuid… OK
[/crayon]
[crayon]
# vi /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.

lp

#—-cut here—-
# Chip drivers
coretemp
#—-cut here—-
[/crayon]
[crayon]
# modprobe coretemp
# reboot (PC再起動)
[/crayon]
[crayon]
# indexmaker –columns=1 /etc/mrtg.cfg > /home/USERDIR/public_html/html/mrtg/index.html #適宜変更します。
# vi /home/USERDIR/public_html/html/mrtg/index.html #適宜変更します。

(indexmakerで出力した物の、7行目辺りのこの部分を””で括ると、文字化けしないで表示される)
[/crayon]
[crayon]
# vi /etc/cron.d/mrtg
# 下記のように書き換えます。
*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg.cfg 2>&1
[/crayon]

これで、五分置きに、MRTGのグラフが変わっていたら、成功です。お疲れ様でした。