Fast Class Based Weighted Fair Queuing (CBWFQ) QoS Poller

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Snowboarding360
Posts: 11
Joined: Wed Jun 15, 2005 7:47 am

Fast Class Based Weighted Fair Queuing (CBWFQ) QoS Poller

Post by Snowboarding360 »

Cisco Class Based Weighted Fair Queuing (CBWFQ) QoS Stats Poller for Windows Only

I created this high speed Visual Basic polling program a couple of years ago for monitoring Class Based Weighted Fair Queuing using Cacti and thought I would throw it out there in the chance that anyone might have a use for it. The perl script for CBWFQ polling that has been passed around has several deficits, one of these is that it is very slow, especially since there are several snmp queries it must perform each time it is executed against a single class and stat. This can really slow things down when you are querying devices amongst high latency links across the globe. It also doesn't work well with multiple CBWFQ enabled interfaces on a single device. One note.. I did see a recent posting on 16-Nov by Instigater - http://forums.cacti.net/viewtopic.php?t=17775 - with an updated perl script that looks pretty good, so take a look at that and see if it suits your needs as well. However, this still is slow since it does not cache OIDs.

How does this program function?

This program uses its own SNMP engine for enhanced speed. The first time it is kicked off against a router, it determines all the QoS enabled interfaces, as well is the OIDs needed to acccess statistics for each element. Since this takes numerous SNMP queries for each element, the OIDs are cached in a table that this program will create in the Cacti database. Therefore the program only needs to make a single request to the router for each class stat! The program requeries a device and updates the cache if it gets a SNMP_NO_SUCH_NAME response back from the router be polled. This covers the cases if the router is rebooted and the OIDs do not remain persistent, or the interfaces are modified.



REQUIREMENTS

The latest MYSQL ODBC drivers
http://dev.mysql.com/downloads/connector/odbc/

The latest VB6 runtime files available from Microsoft
http://www.microsoft.com/downloads/deta ... laylang=en

The Latest MDAC available from Microsoft
http://www.microsoft.com/data/

I've used this program extensively with Cacti version 0.8.6 g, h, and i.

INSTALLATION

1. Place CBWFQ_VB.EXE and CBWFQ_VB.ini in your Cacti\scripts directory. If CBWFQ_VB.INI does not exist, it will be automatically be created with default values the first time the application is executed, however, it will most likely not function until you at least configure the database parameters.

2. Place CBWFQ_VB.XML in your Cacti\resource\script_queries directory

3. Import the graph templates, data templates, and the data query.

4. Edit the ini file and make sure you change the index delimiator character as described below if necessary. It must be a character that is not in the names of your CBWFQ class names on your routers. Once you set it, you can't ever use this character in the names for your CBWFQ classes on your routers unless you change this parameter and requry each router within cacti, so choose something distinct.

5. Make sure the IIS accounts have read, write, and execute access to your scripts directory in cacti. This is needed to execute the data query. Also make sure whatever account the Cacti poller runs as has read, write, and execute access to your Cacti\scripts directory.



CONFIGURING THE INI FILE

The first time the program is executed, it will automatically create an ini configuration file with some default values that you will need to edit, the only items of most concern are the database parameters. Here is a description of each parameter in the ini file:

LogFile (full_path\filename) or RunningDirectory
Specifies where to place the log. This includes the path and file name. If you specify RunningDirectory, which is the default value, then it will create the log file in whatever directory the program is in.

ScreenLogLevel - (0-7)
Specifies how much data is logged when running the program. You should leave this at its default unless you are running the program outside of Cacti for testing purposes. Any other value will cause debug output to be sent to Cacti for every run, causing Cacti to see unknown values.

FileLogLevel - (0-7)
Specifies how much data is logged to file. The log file must be manually purged, and logging can take up resources, so unless you're having problems, it's good to keep this at 1 (or 0 if you're not interested in seeing errors). 4 and 7 are the most useful settings. Also see logging option below.

SNMPTimeout - (MilliSeconds)
Self explanatory

SNMPRetires - (Recommended 2-3)
Self explanatory

Logging - (0-1)
0 - Turn all logging off. Can speed up the program a little.
1 - Logging on - default

DB_User
The username used to log into the Cacti database. Must have read/write/create permissions.

DB_Pass
The password used for the username specified by DB_User to login to the database.

DB_Host
The database host name or address.

DB_Port (Default = 3306)
The database TCP port

CacheAgeMinutes
Number of minutes until the OID cache entry retrieved for CBWFQ information from routers is purged from the database if the OID is not accessed. This is needed in case you delete/rename/change a router, interface, or class.

IndexDelimiator - Default is _
Choose a good delimiator character for the program to use to build the indexes for the data queries. This has to be a character that isn't used or going to be used in any of the names for your CBWFQ classes.


GENERAL NOTES

The execution syntax is:

cbwfq_vb <hostname> <community> index
cbwfq_vb <hostname> <community> query <prepolicybyte|postpolicybyte|dropbyte|index|interface|class|direction>
cbwfq_vb <hostname> <community> get <prepolicybyte|postpolicybyte|dropbyte> <index>
cbwfq_vb drop (Deletes the CBWFQ_VB table from the Cacti database
Attachments
cbwfq_vb.zip
Version 1.2
(41.38 KiB) Downloaded 1085 times
QueryExecuted.gif
QueryExecuted.gif (9.24 KiB) Viewed 32102 times
SampleGraph.gif
SampleGraph.gif (32.2 KiB) Viewed 32102 times
Last edited by Snowboarding360 on Tue Jul 24, 2007 8:10 am, edited 10 times in total.
Jesper
Posts: 45
Joined: Mon Mar 11, 2002 7:00 pm

Interesting

Post by Jesper »

This looks very interesting, but I'm getting a XML parse error when I attempt to import the templates. Which version of Cacti was used to export the templates? I'm using 0.8.6i...
/Jesper
Snowboarding360
Posts: 11
Joined: Wed Jun 15, 2005 7:47 am

Import These XML Files Instead

Post by Snowboarding360 »

Hi, I just update the zip file attached to the message above with new XML files that I exported to screen within Cacti. I tested these files and they work fine. I used the export to file option previously which mangled the files somehow. Let me know how these work and thanks for letting me know! BTW I'm using 0.8.6i.
Jesper
Posts: 45
Joined: Mon Mar 11, 2002 7:00 pm

Success!

Post by Jesper »

Works!
Templates just imported without errors! Thank you,
/Jesper
airwalk
Cacti User
Posts: 103
Joined: Fri Aug 18, 2006 11:22 am
Location: MSK, RU

Post by airwalk »

what DSN should I create in ODBC?

If I run your program the log shows me:

Terminating with ERROR: OpenConn():[MySQL][ODBC 3.51 Driver]Unknown database 'cacti'

What if I run mysql on non-standard port?
Snowboarding360
Posts: 11
Joined: Wed Jun 15, 2005 7:47 am

Post by Snowboarding360 »

Very good point! If you download the file again, there is an option now in the ini file for DB_Port. The program uses a DSNLess connection, so you don't need to setup a DSN, you only need to install the MYSql ODBC drivers and specify the connection parameters in the ini file. Hope that helps!
Last edited by Snowboarding360 on Tue Jul 24, 2007 8:05 am, edited 1 time in total.
airwalk
Cacti User
Posts: 103
Joined: Fri Aug 18, 2006 11:22 am
Location: MSK, RU

Post by airwalk »

Snowboarding360 wrote:Very good point! If you download the file again, there is an option now in the ini file for DB_Port. The program uses a DNSLess connection, so you don't need to setup a DSN, you only need to install the MYSql ODBC drivers and specify the connection parameters in the ini file. Hope that helps!
Thanks, that seemed to work but I still experiencing problems.
If I set fileloglevel=4 then I receive good results:

11.12.2006 10:55:13 10.163.1.1 [PID:24068]: Script Started: Got Arg #0: 10.163.1.1
11.12.2006 10:55:13 10.163.1.1 [PID:24068]: Script Started: Got Arg #1: public
11.12.2006 10:55:13 10.163.1.1 [PID:24068]: Script Started: Got Arg #2: get
11.12.2006 10:55:13 10.163.1.1 [PID:24068]: Script Started: Got Arg #3: DropByte
11.12.2006 10:55:13 10.163.1.1 [PID:24068]: Script Started: Got Arg #4: FastEthernet0/0_VOIP_Outbound
11.12.2006 10:55:13 10.163.1.1 [PID:24068]: ReturnGet(): 784181
11.12.2006 10:55:14 10.163.1.1 [PID:5920]: Script Started: Got Arg #0: 10.163.1.1
11.12.2006 10:55:14 10.163.1.1 [PID:5920]: Script Started: Got Arg #1: public
11.12.2006 10:55:14 10.163.1.1 [PID:5920]: Script Started: Got Arg #2: get
11.12.2006 10:55:14 10.163.1.1 [PID:5920]: Script Started: Got Arg #3: PrePolicyByte
11.12.2006 10:55:14 10.163.1.1 [PID:5920]: Script Started: Got Arg #4: FastEthernet0/0_VOIP_Outbound
11.12.2006 10:55:14 10.163.1.1 [PID:5920]: ReturnGet(): 1075976558
11.12.2006 10:55:14 10.163.1.1 [PID:5948]: Script Started: Got Arg #0: 10.163.1.1
11.12.2006 10:55:14 10.163.1.1 [PID:5948]: Script Started: Got Arg #1: public
11.12.2006 10:55:14 10.163.1.1 [PID:5948]: Script Started: Got Arg #2: get
11.12.2006 10:55:14 10.163.1.1 [PID:5948]: Script Started: Got Arg #3: PostPolicyByte
11.12.2006 10:55:14 10.163.1.1 [PID:5948]: Script Started: Got Arg #4: FastEthernet0/0_VOIP_Outbound
11.12.2006 10:55:14 10.163.1.1 [PID:5948]: ReturnGet(): 1075192377

If I goto graphs then it always shows "0.0" result. Setting cacti log to debug again shows good results:


12/11/2006 01:50:12 PM - CMDPHP: Poller[0] Host[6] DS[246] CMD: C:\Inetpub\wwwroot\cacti\scripts\CBWFQ_VB 10.163.1.1 public get PostPolicyByte FastEthernet0/0_VOIP_Outbound, output: 1075192377
12/11/2006 01:50:12 PM - CMDPHP: Poller[0] Host[6] DS[246] CMD: C:\Inetpub\wwwroot\cacti\scripts\CBWFQ_VB 10.163.1.1 public get PrePolicyByte FastEthernet0/0_VOIP_Outbound, output: 1075976558
12/11/2006 01:50:13 PM - CMDPHP: Poller[0] Host[6] DS[246] CMD: C:\Inetpub\wwwroot\cacti\scripts\CBWFQ_VB 10.163.1.1 public get DropByte FastEthernet0/0_VOIP_Outbound, output: 784181

But if I goto Datasource and turn on debug I see the following:

DS:PostPolicyByte:COUNTER:600:0:U \
DS:PrePolicyByte:COUNTER:600:0:U \
DS:DropByte:COUNTER:600:0:U \


What could be wrong?
Snowboarding360
Posts: 11
Joined: Wed Jun 15, 2005 7:47 am

Post by Snowboarding360 »

Everything looks like it's working good. The data source is displaying correctly in debug mode, but you should also see something like what I copied and pasted below underneath the DS configuration. The other thing I noticed from the logs, which were from two different polls, was that the traffic values did not change between the polls, which would be a 0 result. Maybe this was just because there was no VOIP calls at the time, but can you check a larger snippet of the log file to make sure the values retrieved from the router are incrementing? When you do a show policy interface XXXX command several times in a row, are the values incrementing for the class?


RRA:AVERAGE:0.5:6:2880 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:1:105120 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:6:2880 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:1:105120 \
RRA:MAX:0.5:288:797 \
RRA:LAST:0.5:6:2880 \
RRA:LAST:0.5:24:775 \
RRA:LAST:0.5:1:105120 \
RRA:LAST:0.5:288:797 \
airwalk
Cacti User
Posts: 103
Joined: Fri Aug 18, 2006 11:22 am
Location: MSK, RU

Post by airwalk »

Everything works fine now. Thank you for pointing to the right direction.
This was really due to the absence of VoIP traffic at that moment.
mauri
Posts: 3
Joined: Wed Jan 24, 2007 11:18 am

linux version

Post by mauri »

Hi,

I would really like to use this script, but our cacti runs on linux.
Could you release the source?, so someone can migrate it to linux.

Thanks.
bd200x
Posts: 5
Joined: Fri Nov 04, 2005 12:54 am

Different database name

Post by bd200x »

Is it possible to include an option in the .ini file for database name. There doesnt seem to be one.

When I run the script I get the following error:

C:\Inetpub\wwwroot\utilisation\scripts>CBWFQ_VB 192.168.200.2 18390mdhywe index
Terminating with ERROR: OpenConn():[MySQL][ODBC 3.51 Driver]Access denied for us
er: 'web_cactiuser@localhost' to database 'cacti'

My database is called 'web_cacti' not 'cacti' but I cannot find anywhere to change this, is it hardcoded in the .exe file?

Thanks
Attachments
cacti.jpg
cacti.jpg (25.03 KiB) Viewed 29767 times
Snowboarding360
Posts: 11
Joined: Wed Jun 15, 2005 7:47 am

New Version with Database Name Option

Post by Snowboarding360 »

Hi, that was easy enough to do. I've uploaded a new version (1.1 above). The only difference is the addition of the DB_Name ini parameter. Let me know if that works out for you. [/img]
Last edited by Snowboarding360 on Tue Jul 24, 2007 8:09 am, edited 1 time in total.
bd200x
Posts: 5
Joined: Fri Nov 04, 2005 12:54 am

Post by bd200x »

Thanks very much for that. It appears to be talking to the database now.
smilerza
Posts: 21
Joined: Thu Jul 07, 2005 9:47 am

Post by smilerza »

I have a Cisco 3845 with E3 ATM interface with outbound QoS configured. My QoS classes are detected successfully but I get an error when polling for statistics.

Here's the error from the cacti log file:

06/14/2007 05:30:42 PM - CMDPHP: Poller[0] Host[34] DS[1602] WARNING: Result from CMD not valid. Partial Result: Terminating with ERR
06/14/2007 05:30:42 PM - CMDPHP: Poller[0] Host[34] DS[1602] CMD: C:\Inetpub\wwwroot\cacti\scripts\CBWFQ_VB 10.203.253.101 public get PrePolicyByte ATM1/0.1-aal5 layer_voip-ctrl_Outbound, output: U

Here's the error from the CBWFQ_VB.log log file:

***Class Based Weighted Fair Queueing for Cacti***
Written by Darren Dizak
Free to use as long as unmodified
14/06/2007 17:32:42 [PID:2224]: Starting Main
14/06/2007 17:32:42 [PID:2224]: OpenConn(): Opening database connection
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Script Started: Got Arg #0: 10.203.253.101
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Script Started: Got Arg #1: public
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Script Started: Got Arg #2: get
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Script Started: Got Arg #3: PostPolicyByte
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Script Started: Got Arg #4: ATM1/0.1-aal5
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Script Started: Got Arg #5: layer_voip-ctrl_Outbound
14/06/2007 17:32:42 10.203.253.101 [PID:2224]: Terminating with ERROR: ReturnGet():Invalid format for <interface_class>

I did try changing the index delimiter to no avail.

Any ideas?
Last edited by smilerza on Fri Jul 20, 2007 5:01 am, edited 1 time in total.
Rossco
Cacti User
Posts: 76
Joined: Sat Jan 15, 2005 4:52 pm
Location: London, England

parsing of command line options

Post by Rossco »

Hi

Thanks for contributing the app - I'm really excited by it.

Unfortunately, I get the same issue as above - from examining the log file and trying it on the commandline, it is down to interface names with spaces in them e.g.

GigabitEthernet0/0.3-802.1Q vLAN subif

The spaces between Q and vLAN and subif cause a problem. When being parsed by the app, it is treating the spaces as argument seperators hence your log output.

Wrapping this argument in inverted commas doesnt seem to make any difference unfortunately.

I'm hoping this will be a quick fix for you :-)

Many thanks

Rossco
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests