modify which protocols show on table?

  • Bill

    Bill - 2011-08-16

    I'd like to add RDP and remove FTP - and maybe customize even further down the road.

    Is this possible?

  • Alestan

    Alestan - 2011-08-16

    Short Answer:  Yes.

    You will need to change the database schema, if you are using a database.  You will need to change the in memory struct, found in bandwidthd.h and you will need to change the Credif function in bandwidthd.c.  There is a switch in bandwidthd.c that assigns traffic based on port number, remove the case for FTP and add a case for RDP.  Let me know if you need more details

  • Bill

    Bill - 2011-08-17

    Thanks, I am using pfSense FreeBSD's add package function for bandwidthd. Therefore I do not know what bandwidthd is using in regards to a database. How can I tell? Will I need to recompile?

  • ulot

    ulot - 2011-08-19

    alestan:  I am trying to setup bandwidthd to keep a running tally of all bandwidth used by an IP and would like to see a graph that included VoIP usage.  Could you provide more details on how to make changes to which ports are graphed?  Thanks.

  • Alestan

    Alestan - 2011-08-25

    bhilton81:  Alright, two ways to figure out if it is logging to a database, one quick one slow.

    If you don't have postgresql database server installed, you aren't logging to a database. 
    If FreeBSD's binary copy of bandwidthd in its repositories doesn't have postgresql support compiled in, you aren't logging to a database. 
    I don't know how to tell if you have postgresql installed on FreeBSD, psql is the command line client, but you can have the server without the client.  Also, different distros don't agree on where to put postgresql.conf, so I guess look in whatever package manager you've got to see if it is installed.  (if psql launches and connects then you've got it installed).

    Also, look in the system log (/var/log/syslog ?), if it is supposed to be logging but doesn't have postgres support included (or the database doesn't exist or postgresql server isn't installed) it will throw an error into the syslog.  If it is working fine, it may log into the syslog when it initialises the database.

    The second way determines if bandwidthd is trying to use a database.

    In /etc/bandwidthd/bandwidthd.conf (or something similar depending on where FreeBSD sticks its config files) are a couple lines of interest.  One is output_cdf, if set to true, it will write everything it pulls in, in a text file.  To go along with that is a line titled recover_cdf, which makes it on startup pull the contents of that text file back into memory.  'graph' is the option that tells bandwidth if it should generate the graphs or let some php code do the work.  In the debian source package for bandwidthd the next two options aren't listed anymore.  Fortunately I had my old config file to pull the needed lines from:

    # Standard postgres connect string, just like php, see postgres docs for
    # details

    pgsql_connect_string "user = <user> password = '<password> dbname = <dbname> host = <dbname>"

    # Arbitrary sensor name, I recommend the sensors fully qualified domain
    # name
    sensor_id "<unique name>"

    If those are set, and postgres support is compiled into the binary, it will create the tables in the specified database (the database needs to exist though) and log traffic to the tables. 

    Make sure not to have recover_cdf True set if it is logging to the database or it will copy all entries from the cdf to the database every time it starts.  (If you want to migrate to the database from the cdf files, having it recover_cdf the first run is a good idea, but disable it as soon as it's finished.)

    Also, the way it tells what type of traffic is being sent is by port number.  So if someone isn't using the default port, it won't show up as that type of traffic.
    In either case, you will need to recompile.  In the debian source (`apt-get source bandwidthd`), the relevant sections are: bandwidthd.c:
    Line 769 (Credit function) (add a case for the default port(s) for RDP, remove the case for FTP);
    Line 139 (Statistics struct) (add an unsigned long long for FTP remove the one for RDP);
    Line 135 (PrintTableLine function)(convert the FTP entry to RDP)
    Line 455 (GraphData function) (convert FTP entry to RDP)
    Then do a search for spots where it says FTP and change it to RDP (table columns et cetera)
    Also, you'll need to edit the png file it uses as the legend.
    line 18 (pgsqlCheckTables function) (change the create table lines to include a column for RDP and not for FTP, should be able to swap in place.)
    line 582 (for loop) (change insert command and the Stats->ftp to Stats->rdp)

    You should then be able to call ./configure (-enable-pgsql if you want postgres support) && make
    When it is done, try sudo ./bandwidthd -c etc/bandwidthd.conf and watch /var/log/syslog for errors.

    ulot:  Basically the same instructions apply, only add sections to handle VoIP and don't remove the FTP section. 


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks