0

Through my MRTG I am trying to monitor my CPU Load and Disk usage. I am generating 2 graphs, the 2 respective log files are xband-disk.log file, containing hard disk statistics and xband.cpusum.log file, containing cpu usage.

The problem is with xband-disk.log file. Every 5 minutes, MRTG renames the "xband-disk.log" file to an "xband-disk.old" file, and then creates a NEW xband-disk.log file, instead of inserting new statistic in the old one.

Say, for example, I started MRTG at 12 PM. So at 12 PM, MRTG will generated a new log file for CPU and Harddisk, and each will contain only a single non-zero entry at the top of file.

At this point of time, there is no ".old" file. Now, after 5 mins, that is at 12:05 PM, when MRTG will again log new statistics, it will "insert" the new statistic at the top of the the CPU file, BUT NOT in the Harddisk log file. It will rename the xband-disk.log file to xband-disk.old, and will create a new xband-disk.log file with no non-zero statistic at all (just like the one it crated at 12 PM), and will insert the 12:05 statistic in it. Again at 12:10 PM, MRTG will rename the xband-disk.log file to xband-disk.old, overwriting the old xband-disk.log file, and will again create a new xband-disk.log file.

This is happening only for the xband-disk.log file. The xband.cpusum.log file is perfect, MRTG is not recreating it every 5 mins, its inserting the new statistic like it should. Though it does creates an old file for cpusum also, but creation of an old file for some targets is necessary for the working of MRTG, so nothing abnormal about it.


Here is my MRTG.cfg file

########## ################

RunAsDaemon: Yes
Interval: 5
WriteExpires: Yes
WorkDir:/var/www/html
Options[]:bits,growright
WithPeak[
]:wmy
Forks:4
kilo[]: 1024
YLegend[
]:Kilo Bits/Sec.
Logdir: /etc/mrtg/log
LoadMIBS:/usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt

########## ################

Target[xband.cpusum]:ssCpuRawUser.0&ssCpuRawUser.0:xgen-m@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:xgen-m@localhost + ssCpuRawNice.0&ssCpuRawNice.0:xgen-m@localhost RouterUptime[xband.cpusum]: xgen-m@localhost MaxBytes[xband.cpusum]: 100
Title[xband.cpusum]: CPU LOAD
PageTop[xband.cpusum]: Active CPU Load %
Unscaled[xband.cpusum]: ymwd
ShortLegend[xband.cpusum]: % YLegend[xband.cpusum]: CPU Utilization
Legend1[xband.cpusum]: Active CPU in % (Load)
Legend2[xband.cpusum]: Legend3[xband.cpusum]: Legend4[xband.cpusum]: LegendI[xband.cpusum]: Active LegendO[xband.cpusum]: Options[xband.cpusum]: growright,nopercent

##########################

Target[xband-disk]: hrStorageSize.31&hrStorageUsed.31:xgen-m@localhost
Title[xband-disk]: Disk Partition Usage
PageTop[xband-disk]: Disk Partition Usage
MaxBytes[xband-disk]: 100
ShortLegend[xband-disk]: %
YLegend[xband-disk]: Utilization
LegendI[xband-disk]: Size
LegendO[xband-disk]: Used
Options[xband-disk]: gauge,growright,nopercent
Unscaled[xband-disk]: ymwd`


Here is the output of snmpwalk command is below.
As can be seen, hrStorageSize.31 is for the size of my / partition.
And hrStorageUsed.31 is for the used space of / partition.

[root@mrtg ~]# snmpwalk -v1 -c xgen-m localhost hrStorage
HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 294448 KBytes
HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1
HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3
HOST-RESOURCES-MIB::hrStorageIndex.6 = INTEGER: 6
HOST-RESOURCES-MIB::hrStorageIndex.7 = INTEGER: 7
HOST-RESOURCES-MIB::hrStorageIndex.10 = INTEGER: 10
HOST-RESOURCES-MIB::hrStorageIndex.31 = INTEGER: 31
HOST-RESOURCES-MIB::hrStorageIndex.35 = INTEGER: 35
HOST-RESOURCES-MIB::hrStorageType.1 = OID: HOST-RESOURCES-TYPES::hrStorageRam
HOST-RESOURCES-MIB::hrStorageType.3 = OID: HOST-RESOURCES-TYPES::hrStorageVirtualMemory
HOST-RESOURCES-MIB::hrStorageType.6 = OID: HOST-RESOURCES-TYPES::hrStorageOther
HOST-RESOURCES-MIB::hrStorageType.7 = OID: HOST-RESOURCES-TYPES::hrStorageOther
HOST-RESOURCES-MIB::hrStorageType.10 = OID: HOST-RESOURCES-TYPES::hrStorageVirtualMemory
HOST-RESOURCES-MIB::hrStorageType.31 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.35 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Memory buffers
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: Cached memory
HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: Swap space
HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /
HOST-RESOURCES-MIB::hrStorageDescr.35 = STRING: /boot
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.7 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.10 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.31 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.35 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 294448
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 1900072
HOST-RESOURCES-MIB::hrStorageSize.6 = INTEGER: 294448
HOST-RESOURCES-MIB::hrStorageSize.7 = INTEGER: 64372
HOST-RESOURCES-MIB::hrStorageSize.10 = INTEGER: 1605624
HOST-RESOURCES-MIB::hrStorageSize.31 = INTEGER: 1610887
HOST-RESOURCES-MIB::hrStorageSize.35 = INTEGER: 101086
HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 191792
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 191792
HOST-RESOURCES-MIB::hrStorageUsed.6 = INTEGER: 9936
HOST-RESOURCES-MIB::hrStorageUsed.7 = INTEGER: 64372
HOST-RESOURCES-MIB::hrStorageUsed.10 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.31 = INTEGER: 745341
HOST-RESOURCES-MIB::hrStorageUsed.35 = INTEGER: 19832
HOST-RESOURCES-MIB::hrStorageAllocationFailures.31 = Counter32: 0
HOST-RESOURCES-MIB::hrStorageAllocationFailures.35 = Counter32: 0


Here is the top entries of my xband-disk.log file and xband.cpusum.log. As you can see, the xband.cpusum.log file has all the past entries, but xband-disk.log file doesn't

[root@mrtg html]# head -n 10 *.log
==> xband.cpusum.log <==
1334747536 94463 94463
1334747536 93 93 93 93
1334747234 91 91 91 91
1334747100 92 92 94 94
1334746800 58 58 94 94
1334746500 6 6 10 10
1334746200 1 1 1 1
1334745900 0 0 1 1
1334745600 0 0 0 0
1334745300 0 0 1 1

==> xband-disk.log <==
1334747536 1610887 745194
1334747536 0 0 0 0
1334747234 0 0 0 0
1334747100 0 0 0 0
1334746800 0 0 0 0
1334746500 0 0 0 0
1334746200 0 0 0 0
1334745900 0 0 0 0
1334745600 0 0 0 0
1334745300 0 0 0 0
[root@mrtg html]#
[root@mrtg html]#
[root@mrtg html]#


Here are the top entries of the .old files. As seen, xband.cpusum.old file has all entries too, but again xband-disk.old file has only single entry, since it being overwritten again and again.

[root@mrtg html]# head -n 10 *.old
==> xband.cpusum.old <==
1334747234 66261 66261
1334747234 91 91 91 91
1334746925 94 94 94 94
1334746800 58 58 94 94
1334746500 6 6 10 10
1334746200 1 1 1 1
1334745900 0 0 1 1
1334745600 0 0 0 0
1334745300 0 0 1 1
1334745000 1 1 1 1

==> xband-disk.old <==
1334747234 1610887 745193
1334747234 0 0 0 0
1334746925 0 0 0 0
1334746800 0 0 0 0
1334746500 0 0 0 0
1334746200 0 0 0 0
1334745900 0 0 0 0
1334745600 0 0 0 0
1334745300 0 0 0 0
1334745000 0 0 0 0
[root@mrtg html]#

Can any one please tell me what is the small mistake I am making.
Thanks in Advance

Gautam Somani
  • 296
  • 3
  • 14

1 Answers1

0

A bit late but the MaxBytes is too small. MRTG will ignore values over 100 bytes in your configuration.

Philippe Green
  • 171
  • 1
  • 1