Budiwijaya kirjoitti:
Hello,

On Tue, Jul 24, 2012 at 8:43 PM, Anssi Johansson <timekee...@miuku.net <mailto:timekee...@miuku.net>> wrote:

    Hi, it's been 2.5 years since I set up a NTP server in Turkey to
    reduce the effects of Turk Telekom's routers querying the pool NTP
    servers. I think this method has worked quite nicely, with the
    server serving some 1400-1500 packets/sec on average[1] for the last
    year. I was hoping that at some point Turk Telekom would reconfigure
    their routers to not query the pool, but alas, that has not happened.


Anyone know how to make these graphs ? Where do I have to grab that numbers (ntp packets).
    [1] http://kameli.miuku.net/stats/__ntppackets.html
    <http://kameli.miuku.net/stats/ntppackets.html>

This was the fourth request for my stats scripts, so apparently there's a need for this kind of information. This time I'm sending this information to the list, in case there are more people who want to have graphs like this.

I'm using MRTG for drawing the graphs. I suppose there are lots of guides about installing MRTG on the web, so I'm not describing that step.

In any case, here's a snippet from my mrtg.cfg:

---
Title[ntppackets]: kameli.miuku.net NTP packets
Target[ntppackets]: `/home/anssi/mrtg/ntppackets.pl`
PageTop[ntppackets]: <h1>Received and sent NTP packets for kameli.miuku.net</h1>
MaxBytes[ntppackets]: 60000
Options[ntppackets]: growright, nopercent
YLegend[ntppackets]: #/s
ShortLegend[ntppackets]: &nbsp;
Legend1[ntppackets]: Received packets/s &nbsp;
Legend2[ntppackets]: Sent packets/s &nbsp;
Legend3[ntppackets]: Maximal 5 minute received packets/s &nbsp;
Legend4[ntppackets]: Maximal 5 minute sent packets/s &nbsp;
LegendI[ntppackets]: &nbsp;received packets/s &nbsp;
LegendO[ntppackets]: &nbsp;sent packets/s &nbsp;
WithPeak[ntppackets]: wmy
---

And ntppackets.pl looks like this:

---
#!/usr/bin/perl
use strict;

#### Options ####
my $uptimeprog = '/usr/bin/uptime'; # Set to program to give system uptime my $hostnameprog = '/bin/hostname'; # Set to program to give system hostname

##### Nothing below here should have to be changed #####

# Clear path and get uptime
delete $ENV{PATH};
delete $ENV{BASH_ENV};
my $uptime = `$uptimeprog`;
chomp($uptime);
$uptime=substr($uptime,12);
my $hostname = `$hostnameprog`;
chomp($hostname);

my $received = 0;
my $sent = 0;
my $status = `/usr/sbin/ntpdc -c iostats`;
if($status =~ m!received packets:\s*(-?\d+)!) {
    $received=$1 + 2147483648;
}
if($status =~ m!packets sent:\s*(-?\d+)!) {
    $sent=$1 + 2147483648;
}

print "$received\n$sent\n$uptime\n$hostname\n";
---

The "+ 2147483648" part is there to make the number always positive. My version of ntpdc wraps around at 2^31 to -2^31, which confuses MRTG. The "+ 2147483648" part makes the scale to be 0 from 2^32.

Hope this helps.

_______________________________________________
pool mailing list
pool@lists.ntp.org
http://lists.ntp.org/listinfo/pool

Reply via email to