Глюк с графиком нагрузки ЦП
Секция mrtg.conf
Target[cpua]: `/etc/mrtg/cpuinfo.pl`
MaxBytes[cpua]: 100
Options[cpua]: gauge,nopercent
Unscaled[cpua]: dwym
YLegend[cpua]: % of CPU used (average 10 sec)
ShortLegend[cpua]: %
LegendO[cpua]: CPU System:
LegendI[cpua]: CPU User:
Title[cpua]: host
PageTop[cpua]: <H1>CPU usage for host
</H1>
<TABLE>
<TR><TD>System:</TD><TD>host</TD></TR>
</TABLE>
cpuinfo.pl
#!/usr/bin/perl
$getcpu = `/usr/bin/sar -u 1 3 | grep "Среднее"`;
$getuptime = `date +%s`;
# Parse though getcpu and get data
$getcpu =~ /^Среднее:\s+all\s+(\d+),\d+\s+\d+,\d+\s+(\d+),\d+\s+\d+,\d+/;
$getcpuusr = $1;
$getcpusys = $2;
# Print getcpu data for mrtg
print $getcpuusr."\n";
print $getcpusys."\n";
# Print getuptime data for mrtg
print $getuptime;
# Print machine name for mrtg
print "host\n";
exit(0);
8
7
1370352717
host
говорю ему
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
- ругается:
2013-06-04 17:33:11: WARNING: Problem with External get '/etc/mrtg/cpuinfo.pl':
Expected a Number for 'in' but got ''
2013-06-04 17:33:11: WARNING: Problem with External get '/etc/mrtg/cpuinfo.pl':
Expected a Number for 'out' but got ''
2013-06-04 17:33:14: ERROR: Target[cpua][_IN_] ' $target->[1]{$mode} ' did not eval into defined data
2013-06-04 17:33:14: ERROR: Target[cpua][_OUT_] ' $target->[1]{$mode} ' did not eval into defined data
заменяю в cpuinfo.pl
$getcpuusr = "2";
$getcpusys = "3";
на выходе cpuinfo.pl соответственно
2
3
1370352717
host
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