Giter Site home page Giter Site logo

manuelkasper / as-stats Goto Github PK

View Code? Open in Web Editor NEW
195.0 34.0 67.0 5.19 MB

A simple tool to generate per-AS traffic graphs from NetFlow/sFlow records

License: BSD 2-Clause "Simplified" License

Perl 47.92% Shell 11.08% Python 1.08% PHP 37.40% CSS 2.53%

as-stats's Introduction

AS-Stats v1.6 (2014-09-12)

A simple tool to generate per-AS traffic graphs from NetFlow/sFlow records
by Manuel Kasper [email protected] for Monzoon Networks AG

Update 2017-02-15

I currently don't have time to maintain AS-Stats. There have been some (merged) contributions since the last release, so you may want to download the latest repository version instead of the v1.6 release. Also, Nicolas Debrigode has released a more modern Web UI for AS-Stats: https://github.com/nidebr/as-stats-gui

How it works

A Perl script (asstatd.pl) collects NetFlow v8/v9 AS aggregation records or sFlow v5 samples from one or more routers. It caches them for about a minute (to prevent excessive writes to RRD files), identifies the link that each record refers to (by means of the SNMP in/out interface index), maps it to a corresponding "known link" and RRD data source, and then runs RRDtool. To avoid losing new records while the RRD files are updated, the update task is run in a separate process.

For each AS, a separate RRD file is created as needed. It contains two data sources for each link - one for inbound and one for outbound traffic. In generated per-AS traffic graphs, inbound traffic is shown as positive, while outbound traffic is shown as negative values.

Another Perl script, rrd-extractstats.pl, is meant to run about once per hour. It sums up per-AS and link traffic during the last 24 hours, sorts the ASes by total traffic (descending) and writes the results to a text file. This is then used to display the "top N AS" and other stats by the provided PHP scripts.

Prerequisites

  • Perl 5.10 or newer
  • RRDtool 1.3 or newer (with Perl "RRDs" library)
  • File::Find::Rule module (CPAN)
  • if using sFlow: the Net::sFlow module (CPAN)
  • web server with PHP 5
  • php-sqlite3
  • libdbd-sqlite3-perl
  • one or more routers than can generate NetFlow v8/v9 AS aggregation records or sFlow samples
  • ip2as.pm, for additional lookup (https://github.com/JackSlateur/perl-ip2as)

Considerations

Thoughts on a location for RRD files: RRD files are small in size, but there are a lot of them. You will see a performance gain on a filesystem like XFS over EXT3/4. Consider what filesystem you put the RRD files on if performance is a factor for your needs.

Installation

  • Copy the perl scripts asstatd.pl and rrd-extractstats.pl to the machine that will collect NetFlow/sFlow records

  • Create a "known links" file with the following information about each link that you want to appear in your AS stats:

    • IP address of router (= source IP of NetFlow datagrams)
    • SNMP interface index of interface (use "show snmp mib ifmib ifindex" to find out)
    • a short "tag" (12 chars max., a-z A-Z 0-9 _ only) that will be used internally (e.g. for RRD DS names)
    • a human-readable description (will appear in the generated graphs)
    • a color code for the graphs (HTML style, 6 hex digits)
    • the sampling rate (or 1 if you're not using sampling on the router)

    See the example file provided (knownlinks) for the format.
    Important: you must use tabs, not spaces, to separate fields!

  • Create a directory to hold per-AS RRD files. For each AS, about 128 KB of storage are required, and there could be (in theory) up to 64511 ASes. AS-Stats automatically creates 256 subdirectories in this directory for more efficient storage of RRD files (one directory per lower byte of AS number, in hex).

  • Start asstatd.pl in the background (or, better yet, write a startup script for your operating system to automatically start asstatd.pl on boot):

    nohup asstatd.pl -r /path/to/rrd/dir -k /path/to/knownlinks &

    By default, asstatd.pl will listen on port 9000 (UDP) for NetFlow datagrams, and on port 6343 (UDP) for sFlow datagrams. Use the -p/-P options if you want to change that (use 0 as the port number to disable either protocol). For sFlow, you also need to specify your own AS number with the -a option for accurate classification of inbound and outbound traffic. It's a good idea to make sure only UDP datagrams from your trusted routers will reach the machine running asstatd.pl (firewall etc.).

  • NetFlow only: Have your router(s) send NetFlow v8 or v9 AS aggregation records to your machine. This is typically done with commands like the following (Cisco IOS):

      ip flow-cache timeout active 5
    
      int Gi0/x.y
        ip flow ingress
    
      ip flow-export source <source interface>
      ip flow-export version 5 origin-as
      ip flow-aggregation cache as
       cache timeout active 5
       cache entries 16384
       export destination <IP address of server running AS stats> 9000
       enabled
    

    Adjust the number of cache entries if necessary (i.e. if you get messages like "Netflow as aggregation cache is almost full" in the logs).

    Note that the version has to be specified as 5, even though the AS aggregation records will actually be v8. Also, setting the global flow cache timeout to 5 minutes is necessary to get "smooth" traffic graphs (default is 30 minutes), as a flow is only counted when it expires from the cache. Decreasing the flow-cache timeout may result in a slight increase in CPU usage (and NetFlow AS aggregation takes its fair share of CPU as well, of course).

    Routers with MLS (Multi-Layer Switching, e.g. Cisco 7600 series) require additional commands like the following in order to enable NetFlow processing/aggregation for packets processed in hardware:

      mls aging fast time 4 threshold 2
      mls aging long 128
      mls aging normal 64
      mls flow ip interface-full
    

    For IOS XR, the configuration looks as follows:

      flow exporter-map FEM
       version v9
       !
       transport udp 9000
       source <source interface>
       destination <IP address of server running AS stats> vrf default
    
      flow monitor-map IPV4-FMM
       record ipv4
       exporter FEM
       cache entries 16384
       cache timeout active 300
      !
      flow monitor-map IPV6-FMM
       record ipv6
       exporter FEM
       cache entries 16384
       cache timeout active 300
      !
    
      sampler-map SM
       random 1 out-of 10000
    
      router bgp 100
        address-family ipv4 unicast
         bgp attribute-download
        address-family ipv6 unicast
         bgp attribute-download
    

    For JunOS, the configuration looks as follows:

      forwarding-options {
      	sampling {
      		input {
      			rate 2048;
      			max-packets-per-second 4096;
      		}
      		family inet {
      			output {
      				flow-active-timeout 60;
      				flow-server x.x.x.x {
      					port 9000;
      					autonomous-system-type origin;
      					aggregation {
      						autonomous-system;
      					}
      					version 8;
      				}
      			}
      		}
      	}
      }
    

    JunOS IPFIX configuration:

      chassis {
      	tfeb {
      		slot 0 {
      			sampling-instance as-stats;
      		}
      	}
      }
      interfaces {
      	ge-1/0/0 {
      		unit 0 {
      			family inet {
      				sampling {
      					input;
      					output;
      				}
      			}
      		}
      	}
      }
      forwarding-options {
      	sampling {
      		instance {
      			as-stats {
      				input {
      					rate 2048;
      				}
      				family inet {
      					output {
      						flow-server 192.0.2.10 {
      							port 9000;
      							autonomous-system-type origin;
      							no-local-dump;
      							source-address 192.0.2.1;
      							version-ipfix {
      								template {
      									ipv4;
      								}
      							}
      						}
      						inline-jflow {
      							source-address 192.0.2.1;
      						}
      					}
      				}
      			}
      		}
      	}
      }
      services {
      	flow-monitoring {
      		version-ipfix {
      			template ipv4 {
      				flow-active-timeout 60;
      				flow-inactive-timeout 60;
      				template-refresh-rate {
      					packets 1000;
      					seconds 10;
      				}
      				option-refresh-rate {
      					packets 1000;
      					seconds 10;
      				}
      				ipv4-template;
      			}
      		}
      	}
      }
    

    Huawei NE Netstream (netflow) config:

      slot 3 
       ip netstream sampler to slot self
       ip netstream export host 192.168.200.1 8999
      !
      ip netstream as-mode 32
      ip netstream timeout active 1
      ip netstream timeout inactive 15
      ip netstream export version 9 origin-as
      ip netstream export index-switch 32
      ip netstream export template timeout-rate 2
      ip netstream sampler random-packets 2048 inbound
      ip netstream sampler random-packets 2048 outbound
      ip netstream export source 192.168.200.48
      ip netstream export template option sampler
      ip netstream export template option application-label
      
      ip netstream aggregation as
      export version 9
      template timeout-rate 2
      ip netstream export source 192.168.200.48
      ip netstream export host 192.168.200.1 8999
    

    If you configured a physical interface, use its IfIndex, if you configured a L3 Vlanif, use this ones IfIndex. It should a double decimal value like 72 or 68, etc. Note the interface should contain following config:

      interface vlanif 120
       ip netstream inbound
       ip netstream outbound
      !
    
  • sFlow only: Have your router(s) send sFlow samples to your machine. Your routers may need a software upgrade to make them include AS path information for both inbound and outbound packets (this is a good thing to check if your graphs only show traffic on one direction).

  • Wait 1-2 minutes. You should then see new RRD files popping up in the directory that you defined/created earlier on. If not, make sure that asstatd.pl is running, not spewing out any error messages, and that the NetFlow/sFlow datagrams are actually reaching your machine (tcpdump...).

  • Add a cronjob to run the following command every hour:

    rrd-extractstats.pl /path/to/rrd/dir /path/to/knownlinks /path/to/asstats_day.txt

    That script will go through all RRD files and collect per-link summary stats for each AS in the last 24 hours, sort them by total traffic (descending), and write them to a text file. The "top N AS" page uses this to determine which ASes to show.

    If you want an additional interval for the top N AS (e.g. top N AS in the last 30 days), add another cronjob with the desired interval in hours as the last argument (and another output file of course). Example:

    rrd-extractstats.pl /path/to/rrd/dir /path/to/knownlinks /path/to/asstats_month.txt 720

    Add the interval to the top_intervals array in config.inc (see the example) so that it will appear in the web interface.

    Repeat for further intervals if necessary.

    It is not recommended to run more than one rrd-extractstats.pl cronjobs at the same time for disk I/O reasons – add some variation in the start minute setting so that the jobs can run separately. For longer intervals than one day, the cronjob frequency can be adjusted as well (e.g. for monthly output, it is sufficient to run the cronjob once a day).

  • Copy the contents of the "www" directory to somewhere within your web server's document root and change file paths in config.inc as necessary.

  • Make the directory "asset" within www writable by the web server (this is used to cache AS-SETs and avoid having to query whois for every request).

  • Wait a few hours for data to accumulate. :)

  • Access the provided PHP scripts via your web server and marvel at the (hopefully) beautiful graphs.

Adding a new link

Adding a new link involves adding two new data sources to all RRD files. This is a bit of a PITA since RRDtool itself doesn't provide a command to do that. A simple (but slow) Perl script that is meant to be used with RRDtool's XML dump/restore feature is provided (add_ds_proc.pl, add_ds.sh). Note that asstatd.pl should be stopped while modifying RRD files, to avoid breaking them with concurrent modifications.

Before you follow the instructions below:

  • Make sure you stop asstatd.pl.
  • Take a backup of your whole RRD folder. That is the only way to roll back from this process.
  • This will only add one data source at a time. If you are adding multiple new links, you will need to follow the instructions below once for each new link you add.

Instructions for adding a new link:

  1. Edit your known links file and add your new link (see above for syntax)
    Example:

    10.1.17.10      33      router-newlink  Friendlyname     1F78B4  1
    
  2. Edit the script tools/add_ds_proc.pl

    Change this line:
    my $newlinkname = 'newlink';

    To have the same ID in your knownlinks file:
    my $newlinkname = 'router-newlink';

  3. Edit the script tools/add_ds.sh

    Make sure the path to add_ds_proc.pl is correct.

  4. cd into the rrd folder:
    cd rrd

  5. Run the script
    /path/to/add_ds.sh

    This will take a while (around 20 minutes), so go get a cup of coffee.

  6. Start the collector back up again, and watch for new graphs!

You can also read the RRD files with the command rrdtool info file.rrd, which will show you the data sourced in each one.

Changing the RRAs

By default, the created RRDs keep data as follows:

* 48 hours at 5 minute resolution
* 1 week at 1 hour resolution
* 1 month at 4 hour resolution
* 1 year at 1 day resolution

If you want to change that, modify the getrrdfile() function in asstatd.pl and delete any old RRD files.

Support

A mailing list is available at https://groups.google.com/d/forum/as-stats-users. Please do not send requests for help/support directly to the author.

Donations

  • Immobilien Scout GmbH sponsored the work to add support for multiple configurable stats intervals

To do

  • rrd-extractstats.pl uses a lot of memory and could probably use some optimization.
  • Consider adding a command line parameter to add_ds_proc.pl and add_ds.sh for ease of adding new links.

as-stats's People

Contributors

alarig avatar buchtajz avatar d307473 avatar green525 avatar gregoo avatar jackslateur avatar josqu4red avatar kegeruneku avatar manuelkasper avatar marcbanyard avatar nshopik avatar pirmins avatar pv2b avatar rlanyi avatar shanemcc avatar twiddern avatar will-h avatar xmorpheus avatar zlobar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

as-stats's Issues

SQLite table not getting created

Just attempted upgrading an existing install to the latest from this repository. When running rrd-extractstats.pl, I get a whole lot of this:

DBD::SQLite::db do failed: no such table: stats at /usr/local/www/as-stats/current/bin/rrd-extractstats.pl line 78.

Is there anything I should be doing to initially create this database or table?

Error when run rrd-extractstats.pl

Can't use bareword ("as_list") as a HASH ref while "strict refs" in use at ./rrd-extractstats.pl line 57.

My perl version:

This is perl 5, version 30, subversion 2 (v5.30.2) built for amd64-freebsd-thread-multi

Do not create files in the rrd directory

Hi,

I installed and configured AS-STATS. I have it running. The rrd files are not created in the rrd folder. I configured a flow collector both nfprobe and pmacct. I checked with tcpdump and it is receiving the flows correctly.

Any help to solve this problem?

Thanks.

Flexible netflow ipv6 AS aggregation support

I was playing around to get IPv6 stats with classic Cisco IOS (15.0 and later). From my understanding only way to get it AS-aggregation is this configuration:

flow exporter FLEX-EXAMPLE
    destination 192.0.2.1
    transport udp 9000
flow monitor as-stats
    record netflow ipv6 as
    exporter FLEX-EXAMPLE
    cache timeout active 300
    cache entries 16384
interface GigabitEthernet0/1
    ipv6 flow monitor as-stats input
    ipv6 flow monitor as-stats output

Unfortunately it doesn't work, seems data is ignored, my assumption there no support for this template in AS-Stats? And only way to get IPv6 data is export all packets or just sampled data, right?

Better colors for per link graphs

So I was playing with colors with much help of colorbrewer2.org and looks like this array of colors looks much better and distinctive from each other

$ascolors = array("A6CEE3", "1F78B4", "B2DF8A", "33A02C", "FB9A99", "E31A1C", "FDBF6F", "FF7F00", "CAB2D6", "6A3D9A");

Give a try, if you like I could attach patch for it, seems trivial change

ipfix : Use of uninitialized value in addition (+) at /usr/local/AS-Stats/bin/asstatd.pl line 446.

Hello,
Running asstats.pl like this :
/usr/bin/perl /usr/local/AS-Stats/bin/asstatd.pl -a $ASN -r /usr/local/AS-Stats/rrd -k /usr/local/AS-Stats/conf/knownlinks -p 6344

always triggers warnings :
Use of uninitialized value in addition (+) at /usr/local/AS-Stats/bin/asstatd.pl line 446.
Use of uninitialized value in addition (+) at /usr/local/AS-Stats/bin/asstatd.pl line 446.
Use of uninitialized value in addition (+) at /usr/local/AS-Stats/bin/asstatd.pl line 446.
Use of uninitialized value in addition (+) at /usr/local/AS-Stats/bin/asstatd.pl line 446.

I tried to debug it but I was not able to find the cause.
Can you help me with that please ?
I can provide a pcap of IPFIX trafic coming into port 6344 (which looks correct)

Regards,
Cédric

pmacct / as-stats

Hello,

First I want to apologize because I don't know yet if my problem comes from aw-stats or pmacct.
I'm trying to use as-stats with pmacct as netflow sender.
I have a bird bgp router with a pmacct process on it, which sends netflow data to as-stats server on port 9995.
pmacct has a bgp session established with bird, and send as-aware netflow packets to as-stats (verified by wireshark).

wireshark tells me that Flow id is 1024 : FlowSet 1 [id=1024](6 flows)
pmacct (192.168.156.23) sends flows to aw-stats (192.168.156.109), so in as-stats knownlinks file, I have :
192.168.156.23 1024 provider provider A6CEE3 1
I run as-stats like this :
bin/asstatd.pl -r /tmp -k conf/knownlinks -p 9995 -P 0
and I get :
DEBUG Sampling Rate for 192.168.156.23_1024 is IN: 1 | OUT: 1

No rrd files are created in /tmp.
is there a way to debug as-stats ?

Graphs: smooth network bursting (enhansment)

the following patch helped a lot in smoothing the graphs on network bursts:

- "--slope-mode --alt-autoscale -u 0 -l 0 --imgformat=PNG --base=1000 --height=$height --width=$width " .
+ "--logarithmic --slope-mode --alt-autoscale -u 0 --imgformat=PNG --base=1000 --height=$height --width=$width " .

it may be nice to have this as an option in the config file.

Incorrect Graphs !!

Hi,

I've setup the AS-Stats on dell switch with sflow. However the graphs are showing bandwidth in Kbps while the bandwidth supposed to be in Mbit/s. More than that IN/bytes showing 0. Please have a look :-

http://prntscr.com/hokjth

Thanks.

Add VLAN ID to knownlinks

It would be quite nice to be able to define the VLAN ID inside the knownlinks file. For example we've got a router using sflow which has two seperate VLAN interfaces running through the same physical interface.

For sflow it would be:

$sFlowSample->{SwitchSrcVlan}
$sFlowSample->{SwitchDestVlan}

netflow mode 32bit: Invalid type 'Q' in unpack at asstatd.pl line 321.

Greetings,

this issue exists on netflow mode only. sflow mode does not exhibit this behavior.

the pmacct config:

daemonize: false
promisc: true
plugin_buffer_size: 10240
plugin_pipe_size: 10240000
pcap_filter: net 10.0.0.0/8
interface: eth0
plugins: nfprobe[in],nfprobe[out]
nfprobe_receiver: 10.2.19.18:9000
nfprobe_source_ip: 10.2.19.3
nfprobe_version: 9
nfprobe_direction[in]: in
nfprobe_direction[out]: out
nfprobe_ifindex[in]: 731
nfprobe_ifindex[out]: 732
nfacctd_as_new: bgp
nfprobe_peer_as: true
bgp_peer_src_as_type: bgp
bgp_src_as_path_type: bgp
bgp_src_std_comm_type: bgp
bgp_src_ext_comm_type: bgp
bgp_daemon_pipe_size: 1310710
bgp_daemon: true
bgp_daemon_ip: 10.2.146.10
bgp_daemon_id: 10.2.146.10
bgp_daemon_port: 17917
bgp_agent_map: /etc/pmacct/agent_to_peer.map
bgp_follow_nexthop: 10.2.19.0/24, 10.2.146.0/24, 10.0.0.0/8
aggregate[in]: src_host, dst_host, src_port, dst_port, src_as, dst_as, as_path, peer_src_as, peer_dst_as, proto
aggregate[out]: src_host, dst_host, src_port, dst_port, src_as, dst_as, as_path, peer_src_as, peer_dst_as, proto
aggregate_filter[in]: ether src !(50:e5:49:33:5c:xx)
aggregate_filter[out]: ether src 50:e5:49:33:5c:xx

pmacct/nfprobe, quagga & as-stats all run on same physical fresh gentoo/rolling 32bit system.

attaching a wireshark capture:

wireshark_enp4s0_pcapng.zip

Unable to install rrdtool-dev

Hi
tried to install all necessary packages as per instruction in Wiki but unable to install rrdtool-dev . Let me know from where I can get this package.
root@asstats# apt-get install rrdtool-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package rrdtool-dev

no sFlowSample->{'HeaderBin'} in sflow packets

Hello,
in asstatsd.pl, line
my (undef, $ethertype, $ipdata) = unpack('a12H4a*', $sFlowSample->{'HeaderBin'});
throws warnings, because my sflow samples does not have a "HeaderBin" part.
I'm using pmacct as sflow sender.

example of sflow packet shown via Data::Dumper :

$VAR1 = {
          'GatewayAsRouter' => 0,
          'GatewayDestAsPaths' => [
                                    {
                                      'asPathSegmentType' => 1,
                                      'lengthAsList' => 1,
                                      'AsPath' => []
                                    }
                                  ],
          'flowRecordsCount' => 4,
          'GatewayCommunities' => [],
          'outputInterface' => 1,
          'drops' => 0,
          'sourceIdIndex' => 1,
          'SwitchSrcPriority' => 0,
          'GatewayAsSourcePeer' => 0,
          'sampleTypeEnterprise' => 0,
          'EtherDestMac' => '000000330001',
          'SwitchDestVlan' => 51,
          'samplePool' => 14283505,
          'samplingRate' => 100,
          'inputInterface' => 1073741823,
          'HEADERDATA' => 'HEADERDATA',
          'GatewayLengthCommunitiesList' => 0,
          'GatewayIpVersionNextHopRouter' => 1,
          'sampleLength' => 216,
          'SwitchSrcVlan' => 0,
          'HeaderFrameLength' => 58,
          'HeaderProtocol' => 4,
          'sampleSequenceNumber' => 142453,
          'sampleTypeFormat' => 1,
          'HeaderStrippedLength' => 1423979124,
          'EtherPackettype' => 76,
          'SWITCHDATA' => 'SWITCHDATA',
          'SwitchDestPriority' => 0,
          'GatewayAsSource' => 0,
          'GatewayDestAsPathsCount' => 1,
          'ETHERNETFRAMEDATA' => 'ETHERNETFRAMEDATA',
          'GATEWAYDATA' => 'GATEWAYDATA',
          'sourceIdType' => 0,
          'EtherSrcMac' => '000000020000',
          'HeaderSizeByte' => 3217254405,
          'GatewayIpAddressNextHopRouter' => '0.0.0.0',
          'localPref' => 0,
          'EtherMacPacketlength' => 0
        };

how can I fix this ?
Regards

Multicore and Freebsd

I have heavy load on network and i can see that perl script netflow-asstatd.pl uses only 1 CPU core in system for processing data, this cause problem cause there is not enough Mhz for this process. Is there any options to tune this?

Blanks in my graphs

Hello,
I have an issue, randomly, I have blanks in my graphs.

I first tough it was cpu related so we done a cpu upgrade, but the problem is still here.

I don't know what can be the source of this issue...

Have you an idea ?

I asked first the question on the mailing list without success.

Here are attached samples. The issue is only viewable on daily views.

Thank you.

gengraph php1
gengraph php2
gengraph php3
gengraph php4

After adding new link I get issues when running rrd-extratstats.pl

I have added a new link to knownlinks
I have had issues with adding a new link, so I ended up deleting all rrd files (emptying whole folder).
and wanted to regenerate them again.

but after running
/as-stats/AS-Stats/bin/rrd-extractstats.pl /as-stats/rrd /as-stats/AS-Stats/conf/knownlinks /as-stats/stats/asstats_day.txt_

I get the following error now:
DBD::SQLite::db do failed: table stats has 38 columns but 42 values were supplied at /as-stats/AS-Stats/bin/rrd-extractstats.pl line 160.

I do not see any resolution for this anywhere. Can you please let me know how to resolve this?

Thank you,

No License specified

This looks like a really nice tool, and I'd like to try it out. Can you specify what the license is, and include a license file in the project?

"inet_pton" is not exported by the Socket module

i'm trying to run as-stats, but have some errors below

"inet_pton" is not exported by the Socket module

"inet_ntop" is not exported by the Socket module
Can't continue after import errors at /data/as-stats/bin/asstatd.pl line 10
BEGIN failed--compilation aborted at /data/as-stats/bin/asstatd.pl line 10

i'm not sure whats wrong, since my last installed on old machine on december 2017 was fine.
today i'm installing on new machine have problem above

Sudden php errors !!

Hi,

We had setup as-stats 2 days back and everything was working perfectly until today. I just restarted as-stats after which i am no more able access web interface and web logs are showing following errors :

http://prntscr.com/hp0yhx

Issue with select time period

There is an issue with selecting a time period from the menu bar, it doesnt work!

There are missing echo statements in the build a graph line (top.php)

I have corrected it, but thought i would share

            <?php if ($showv6): ?>
            <a href="history.php?v=4&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=4&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV4"); ?>&amp;start=<?php echo $start ; ?>&amp;end=<?php echo $end ; ?>" width="597" height="207" border="0" /></a>
            <a href="history.php?v=6&amp;as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;v=6&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . " - IPV6"); ?>&amp;start=<?php echo $start ; ?>&amp;end=<?php echo $end ; ?>" width="597" height="207" border="0" /></a>
            <?php else: ?>
            <a href="history.php?as=<?php echo $as; ?>" target="_blank"><img alt="AS graph" src="gengraph.php?as=<?php echo $as; ?>&amp;width=500&amp;height=150&amp;nolegend=1&amp;dname=<?php echo rawurlencode("AS" . $as . " - " . $asinfo['descr'] . ""); ?>&amp;start=<?php $start ; ?>&amp;end=<?php $end ; ?>" width="581" height="189" border="0" /></a>
            <?php endif; ?>

I have a problem to use with AS-Stats

netflow bin # ./netflow-asstatd.pl -p 9001 -r /var/cache/as-stat/data/rrd/ -k /var/cache/as-stat/data/knownlinks

pwd
/var/cache/as-stat/data/rrd
netflow rrd # ls -al
total 8
drw-rw-rw- 2 root root 4096 Jun 28 10:09 .
drwxr-xr-x 3 root root 4096 Jun 28 10:05 ..

Agree with juniper stream ipfix.
I run the script but the directory is empty, the port I used the default.
Can you tell what the problem can somehow run or debug?
Thanks.

rrd-extractstats.pl needs sort on %knownlinks & requires statsfile to be deleted if knownlinks file has changed

  1. With the addition of skipifnotmodified, the stats table is no longer being re-created during every run. However, function read_knownlinks() loads all the links into a hash %knownlinks which has inconsistent sort order when it's filled into @links.

Quick fix for is to update line 41:

my @links = values %knownlinks;

to

my @links = sort values %knownlinks;

This will keep the list of links consistent across runs.

  1. Per above, since stats table is no longer recreated during every run, if there's a new link added (or removed) the statsfile needs to be deleted so that rrd-extractstats.pl will recreate. Ideally schema should be checked to identify if there's any new links added (or removed).

IPv6 stats

Hi,
i'm using pmacct to send sflow to as-stats collector. Works fine for IPv4.
Trying to understand why my IPv6 trafic is not handled by as-stats, I ran sflowtool, and sflowtool show "IP6_label" for IPv6 packets.

How can I tell pmacct that these samples are IPv6 ?
(pmacct is sending etype, but I can't see it in sflowtool dumps)

Regards,
Cédric

Link usage better space usage

So I was thinking maybe we could use space better in Link Usage page. Get rid of left side name and use rrdtool title to name graphs like "IPv4 - Peering1".

This has two benefits, we can fit two graphs ipv4 + ipv6 vertically on smaller monitors(1280) and if there just IPv4 used we could make it little bit longer.
I'm already running with these changes, can make pull request if it sounds good.

This won't touch Top N AS page, only link usage page.

peerusage blank

Hey we having problem with peerusage, its showing blank page, how to fix it?

AS-Stats not working with sFlow data from Brocade/Extreme NetIron routers

Hello,

it seems as-stats is not working with sFlow data from Brocade/Extreme NetIron devices. No RRD-files are being created within the data-directory. Running asstatd.pl in debug mode produces the following output:

# /opt/as-stats/bin/asstatd.pl -P 2080 -p 0 -r /opt/as-stats/data/rrd -k /opt/as-stats/conf/knownlinks -a 47251
DEBUG Sampling Rate for 192.168.236.1_1 is IN: 1024 | OUT: 1024
DEBUG Sampling Rate for 192.168.236.1_2 is IN: 1024 | OUT: 1024
DEBUG Sampling Rate for 192.168.236.2_1 is IN: 1024 | OUT: 1024
DEBUG Sampling Rate for 192.168.236.2_2 is IN: 1024 | OUT: 1024
3333 => 0 (56 octets, version 4, snmpin 1, snmpout 6)
0 => 31898 (60 octets, version 4, snmpin 6, snmpout 1)
0 => 16509 (380 octets, version 4, snmpin 6, snmpout 1)
14061 => 0 (44 octets, version 4, snmpin 1, snmpout 6)
0 => 397197 (76 octets, version 4, snmpin 6, snmpout 1)
41018 => 0 (44 octets, version 4, snmpin 1, snmpout 6)
0 => 1273 (76 octets, version 4, snmpin 6, snmpout 1)
0 => 14618 (183 octets, version 4, snmpin 6, snmpout 1)
212906 => 0 (56 octets, version 4, snmpin 1, snmpout 6)
0 => 54113 (577 octets, version 4, snmpin 6, snmpout 1)
53667 => 0 (56 octets, version 4, snmpin 1, snmpout 65)
Invalid interface index 3/2147483649
37963 => 39110 (64 octets, version 4, snmpin 1, snmpout 3)
37963 => 0 (64 octets, version 4, snmpin 1, snmpout 3)

Our sFlow-config on both routers:

sflow enable
sflow source ve 4000 8888
sflow destination 192.168.236.100 2080 
sflow polling-interval 30
sflow sample 1024

and on all interfaces we have set:

sflow forwarding

And the knownlinks-file (separated with tabs):

# Router IP	ifindex		tag		description	color	samplingrate
192.168.236.1	1		uplink1		Transit1	239614	1024
192.168.236.1	2		uplink2		Peering1	4167B5	1024
192.168.236.2	1		uplink3		Transit2	721358	1024
192.168.236.2	2		uplink4		Peering2	EA891B	1024

By using tcpdump we can confirm that sFlow-data is being received on the collector host. Other sFlow monitoring tools are also working as expected - only as-stats does not work. Maybe any hints?

Thanks in advance

sketchy graphs - how to avoid?

Hi, how does one avoid sketchy graphs like this? I have a sampling rate of 100, which I think is pretty low, and have set flows to purge after 5 minutes and update every minute, to align with the RRD values.

screenshot on 2013-05-01 at 10 53 31

set forwarding-options sampling input rate 100
set forwarding-options sampling family inet output flow-inactive-timeout 300
set forwarding-options sampling family inet output flow-active-timeout 60
set forwarding-options sampling family inet output flow-server 192.168.0.38 port 9995
set forwarding-options sampling family inet output flow-server 192.168.0.38 autonomous-system-type origin
set forwarding-options sampling family inet output flow-server 192.168.0.38 no-local-dump
set forwarding-options sampling family inet output flow-server 192.168.0.38 version 5

Multiple routers > duplicate ifIndex'es > RRD graphs wrong

Hello, we have mutiple routers sending netflow streams to the AS-Stats collector port. Unfortunately we have duplicate ifIndex Interface IDs among the routers. We noticed that the data in as-stats_day.txt is correct, but the rrd graphs are missing huge parts of our traffic (which seems to only affect interfaces sharing the same ifIndex).

Is there anything we can do about this? We're using latest v1.6 release. Thanks

prefix-to-AS resolution feature/enhansment

Would it be difficult to implement such a feature? for example querying a local file with prefixes/ASNs to assign ASNs on orphan IP/prefix.

On our open/free wireless network we have some mikrotik boxes that don't sent any AS details on their netflow exports and the vendor by looking at their forum doesn't look too enthusiast on adding such functionality.

no rrd file generation

Greetings,

running as-stats as: ./bin/asstatd.pl -r rrd/ -k conf/knownlinks -P 0

results in no rrd file generation no matter how long the as-stats runs.

as-stats feed has been tested by pmacct either on netflow/v9 or sflow and with softflowd but with no results.

proper netflow/sflow functionality has been successfully tested by wireshark, nfacctd/sfacctd & nfdump

as-stats is disturbingly quiet doing nothing

any ideas suggestions as to how to troubleshoot this would be highly appreciated

www/peerusage.php missing

The new navigation provides a link to "Top AS peers", but the linked file www/peerusage.php is missing from the repo.

Centos Install not working

I used the script from the contrib directory, every thing works fine,
the webserver works
i can see tcpdump displaying the netflow packets on port 9000
the netstat shows all required post listening for data, the the PS -ef command also looks good.

however i get the below error in the httpd logs
[Mon Oct 29 23:58:31.984766 2018] [:error] [pid 1204] [client 192.168.5.95:6450] PHP Notice: Undefined variable: asstats in /data/as-stats/www/func.inc on line 139, referer: http://192.168.5.5/
[Mon Oct 29 23:58:31.985297 2018] [:error] [pid 1204] [client 192.168.5.95:6450] PHP Warning: Invalid argument supplied for foreach() in /data/as-stats/www/top.php on line 59, referer: http://192.168.5.5/
[Mon Oct 29 23:59:27.968855 2018] [:error] [pid 1206] [client 192.168.5.95:6634] PHP Notice: Undefined variable: asstats in /data/as-stats/www/func.inc on line 139, referer: http://192.168.5.5/as-stats/asset.php
[Mon Oct 29 23:59:27.969056 2018] [:error] [pid 1206] [client 192.168.5.95:6634] PHP Warning: Invalid argument supplied for foreach() in /data/as-stats/www/top.php on line 59, referer: http://192.168.5.5/as-stats/asset.php
[Tue Oct 30 01:23:05.290276 2018] [:error] [pid 1206] [client 192.168.5.95:25953] PHP Notice: Undefined variable: asstats in /data/as-stats/www/func.inc on line 139, referer: http://192.168.5.5/
[Tue Oct 30 01:23:05.290517 2018] [:error] [pid 1206] [client 192.168.5.95:25953] PHP Warning: Invalid argument supplied for foreach() in /data/as-stats/www/top.php on line 59, referer: http://192.168.5.5/
[Tue Oct 30 01:23:07.412953 2018] [:error] [pid 1206] [client 192.168.5.95:25953] PHP Notice: Undefined variable: asstats in /data/as-stats/www/func.inc on line 139, referer: http://192.168.5.5/as-stats/top.php
[Tue Oct 30 01:23:07.413152 2018] [:error] [pid 1206] [client 192.168.5.95:25953] PHP Warning: Invalid argument supplied for foreach() in /data/as-stats/www/top.php on line 59, referer: http://192.168.5.5/as-stats/top.php

need help here please

Regards

Clifford Dsouza

Incorrect Bandwidth on Juniper MX

Dear Manuel!
Thank you for your work!
Forced to turn to you for help, so as to solve the problem for a month I didn't get :(

We have 2 border routers of Juniper MX-series, one MX80 and one MX240.
I tried to configure your scripts with each of them using Netflow v5/v8 and IPFIX and with the same settings got different results, and different from the indications by SNMP.

The results of MX240 like the truth at least 50-70% when the results of MX80 like no more than 20% of truth.
Here is my current sampling settings:

sampling {
sample-once;
input {
rate 100;
max-packets-per-second 65535;
}
family inet {
output {
flow-inactive-timeout 15;
flow-active-timeout 60;
flow-server 192.168.90.100 {
port 9000;
autonomous-system-type origin;
no-local-dump;
source-address 192.168.90.91;
version 5;
}
}
}
}

As I said - using Netflow v5/v8 or IPFIX - gives the same result. And here is graphs compare.

MX240 IP-transit 10G port.

telia

MX240 peering 10G port.

data

MX80 IP-transit 10G port.

retn

MX80 peering 1G port.

msk

I tried to change various settings of sampling rate as on the router and in your script, and your tips from the next issue: #4

Change $ascache_flush_interval = 10 gave a small positive result is higher-quality graphs, but to solve the problem of incorrect bandwidth I never got.

Asking for your help! I would very much like to use the product and send you a donation.

gaps in graphs

Hello!
I'm using netflow v8 and collect it from juniper mx series.
Why my graphs with gaps?
image

Documentational issue for IOS on C6880-X

I've had huge issues trying to get this working together with a Cisco C6880-X running regular IOS 15.2 (Advanced Enterprise license). Despite being a regular IOS software the Netflow configuration looks nothing at all like the IOS example, looks more like the IOS XR example, but it's different from that too.

After lot's of trial and error, asking around on IRC, google and tcpdump this is what I ended up with and it's working for me. Thought I should share it so that others will have an easier time getting this setup.

flow record ASSTAT-RECORD
 match ipv4 source address
 match ipv4 destination address
 match transport source-port
 match transport destination-port
 match interface input
 match interface output
 match flow direction
 collect routing source as
 collect routing destination as
 collect counter bytes long
 collect counter packets long
 collect timestamp sys-uptime first
 collect timestamp sys-uptime last
flow record ASSTAT-RECORD-V6
 match ipv6 source address
 match ipv6 destination address
 match transport source-port
 match transport destination-port
 match interface input
 match interface output
 match flow direction
 collect routing source as
 collect routing destination as
 collect counter bytes long
 collect counter packets long
 collect timestamp sys-uptime first
 collect timestamp sys-uptime last
flow exporter ASSTAT-EXPORT
 destination 86.107.242.83
 source Loopback0
 transport udp 9000
flow monitor ASSTAT-MONITOR
 exporter ASSTAT-EXPORT
 cache timeout inactive 5
 cache timeout active 5
 cache entries 16384
 record ASSTAT-RECORD
flow monitor ASSTAT-MONITOR-V6
 exporter ASSTAT-EXPORT
 cache timeout inactive 5
 cache timeout active 5
 cache entries 16384
 record ASSTAT-RECORD-V6
sampler flow-sampler
 mode random 1 out-of 1024
int Te5/1
 ip flow monitor ASSTAT-MONITOR sampler flow-sampler input
 ip flow monitor ASSTAT-MONITOR sampler flow-sampler output
 ipv6 flow monitor ASSTAT-MONITOR-V6 sampler flow-sampler input
 ipv6 flow monitor ASSTAT-MONITOR-V6 sampler flow-sampler output

Missing AS number

Hi,

There is a missing AS number in the list of them, and because it reads from the static file with no dynamic lookup, it has issues.

Add this line:
23456_tab_TRANS-AS_tab_IANA Reserved AS_tab_US

Further down the track, it would be good to do the AS numbers in a database with a "last updated" record and update them dynamically through whois

Food for thought.

. in knowlinks

I have problems using . in short tag or description in knownlinks file.

Please, fix it or write it in README.me to avoid future problems

Use of uninitialized value

I am using pmacct/nfprobe as a netflow/agent with AS statistics enabled. as-stats is working nicely on my 32bit gentoo system with this patch and the graphs are colorfully generated.

I do get though quite a few "Use of uninitialized value in new at /data/as-stats/bin/asstatd.pl" which is this line

any hints on how to further debug this?

As-stats for 100g link

Recently we migrated our IX links from 10g to 100g, on 10g all stats were perfectly running, after migrations we failed to get graphs for the 100g link one on juniper routers. do any one faced similar issue.

regards

unpack fails in asstatd.pl

Hello,

I've recently tried to upgrade from 1.4.2 to 1.6, and am having problems running the updated asstatd.pl:

as-stats@flows:$ /opt/as-stats/bin/asstatd.pl -r /opt/as-stats/rrd -k /opt/as-stats/conf/knownlinks -p 8990 -a 65000
'/' must follow a numeric type in unpack at /opt/as-stats/bin/asstatd.pl line 201.
as-stats@flows:
$

The line in question (201) uses unpack() to read Netflowv9 data:

https://github.com/manuelkasper/AS-Stats/blob/master/bin/asstatd.pl#l201

Perl version is 5.14.2, x86_64 (from debian wheezy) and all system packages are up to date at the time of writing.

I'm no expert on unpack (or perl in general) but I can happily supply more info/output if requested.

Tom

ERROR: No DS called...

Hello,

I'm using the last version of source and getting this error on httpd-error.log.

ERROR: No DS called '%DSNAME%'

Where %DSNAME% = tag from knownlinks file plus "_in" or "_v6_in"

This is runing on FreeBSD 11, I double check knownlinks file for spaces, wrong interface index, etc, and I can find anything wrong on my configuration.

Any ideas of what can cause this error?

sFlow only?

Seems like my Juniper ex4550 does not support NetFlow.
I've successfully enabled sFlow and can see packets coming in via tcpdump on port 6343.

root@vm100:/opt/AS-Stats/rrd# tcpdump -i eth1 port 6343 -n tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes 20:09:18.729260 IP 172.16.0.2.56580 > 172.16.0.1.6343: sFlowv5, IPv4 agent 172.16.0.2, agent-id 16, length 1260 20:09:18.800624 IP 172.16.0.2.56580 > 172.16.0.1.6343: sFlowv5, IPv4 agent 172.16.0.2, agent-id 16, length 1316 20:09:18.871397 IP 172.16.0.2.56580 > 172.16.0.1.6343: sFlowv5, IPv4 agent 172.16.0.2, agent-id 16, length 1372 20:09:18.952754 IP 172.16.0.2.56580 > 172.16.0.1.6343: sFlowv5, IPv4 agent 172.16.0.2, agent-id 16, length 1420 20:09:19.030568 IP 172.16.0.2.56580 > 172.16.0.1.6343: sFlowv5, IPv4 agent 172.16.0.2, agent-id 16, length 1372

The sFlow packets are coming from 172.16.0.2.
What do I need to put in knownlinks ?

I ran this
./asstatd.pl -r ../rrd/ -k ../conf/knownlinks -p 0 -a 62020

But it is not creating any rrd files and no debug to know if its receiving any sFlow packets or not

Can't use bareword ("as_list") as a HASH ref while "strict refs" in use at /var/www/localhost/htdocs/AS-Stats/bin/rrd-extractstats.pl line 57.

Hi,

If I try to run rrd-extractstats.pl it fails with this error.

metro ~ # su -l -s /bin/sh -c '/var/www/localhost/htdocs/AS-Stats/bin/rrd-extractstats.pl /var/www/localhost/htdocs/AS-Stats/rrd/ /var/www/localhost/htdocs/AS-Stats/conf/knownlinks /var/www/localhost/htdocs/AS-Stats/asstats/asstats_day.txt' as-stats
No directory, logging in with HOME=/
Can't use bareword ("as_list") as a HASH ref while "strict refs" in use at /var/www/localhost/htdocs/AS-Stats/bin/rrd-extractstats.pl line 57.

I’m using perl 5.30.1

generate-asinfo generates wrong information

I've just noticed it some months ago but didn't raised an issue here and also couldn't managed it to make a fix.

Currently the generate-asinfo.py generates broken output. The information seems to be ok if you look manually into it, but if you load the asinfo.txt often ripe-entries are broken. Also information from other databases, which cymru collected seems sometimes a bit "wrong".

I'm not sure if the python script needs to be adjusted or if as-stats should be adjusted to show up the information from a "new format" from cymru. I'm sorry that I can't give an example right now.

For whom who it will fix, I also noticed that you can't query 300k asn at once, via netcat to cymru, this should be may split up in future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.