Follow me!

LinkedIn Twitter

Who's Online

We have 155 guests online

Python News



  

HowTo monitor the Netscaler using Python and Soap instead of SNMP
Programming HowTo's - Python HowTo's
Written by Allen Sanabria   
Sunday, 07 February 2010 16:29

In this HowTo, I will show you how you can get statistics off of the Netscaler without using SNMP. You might be asking why would I want to do that?? Well like many other devices that support SNMP, the Netscaler makes use of dynamic OID creation. For those of you that do not understand what I mean. Dynamic OID creation, is the way that Networking devices give OID's to variables that are not static in the device itself.

Here are some common static variables/OID's, amongst most devices out there.

  • CPU Utilization
  • Disk Utilization
  • Memory Utilization
  • TCP Statistics

Here are some common, non-static variables/OID's..

  • A Load Balanced Virtual Server
  • Statistics about LUNS
  • Statistics about Services

Now you can get these statistics off of the SNMP based device. But if and when this device is rebooted, more then likely the OID has changed. Now you are stuck with the task, of finding the new OID. Since the Netscalers have a SOAP Based API, we can get those same statistics with out ever needing to know the OID.

Here I have attached a script that I wrote, using Python and Suds to connect to the Netscaler. This script works perfectly with Zenoss and its DataPoint structure.

 Download Get Netscaler Stats
File Title:Get Netscaler Stats (Details)
File Type:py
File Version:1.0.1
File Size:10.00 Kb
License:
File Author:Allen Sanabria
File HomePage:
Downloads:61
Rating: ( Votes)
Your Vote:

Before you proceeed any further, you will need to download SUDS from here https://fedorahosted.org/suds/.
You should also check this HowTo that I wrote, it contains some examples on how to connect to the Netscaler using the Python Virtual Shell.
http://www.linuxdynasty.org/how-to-get-information-from-the-netscaler-using-python-and-suds.html

Here are some examples on how you will run the script...

python getns_stats.py -t http -i "nsip" -u "login" -p "passwd"
OK|httptotrxresponsebytes=116454007709 httpresponsesrate=0 httppostsrate=0 httptotposts=3960332 httptotgets=5621562 httperrserverbusy=9540 httprequestsrate=0 httprxresponsebytesrate=0 httptotothers=3505 httptxresponsebytesrate=0 httptotrequests=9585399 httperrserverbusyrate=0 httprxrequestbytesrate=0 httptotresponses=9569809 httpgetsrate=0 httptottxresponsebytes=0 httpothersrate=0 httptotrxrequestbytes=21823753173

python getns_stats.py -t tcp -i "nsip" -u "login" -p "passwd"
OK|tcpcurserverconn=379 tcpcurclientconnclosing=4 tcptotrxbytes=169757271745 tcpclientconnopenedrate=0 tcpcurserverconnopening=0 tcptottxpkts=497006339 tcprxpktsrate=25 tcpactiveserverconn=4 tcpcurserverconnclosing=374 tcptxbytesrate=1902 tcprxbytesrate=1641 tcpcurclientconnopening=0 tcpcurclientconn=16 tcpcurserverconnestablished=5 tcptotrxpkts=460755860 tcptxpktsrate=31 tcpcurclientconnestablished=12 tcpserverconnopenedrate=10 tcptottxbytes=108830467243

Both the Stats, above are actually static in The Netscaler. But I actually included them in the script, because I can. The stats I will show you below are not static..

python getns_stats.py -n test_vs -t lbvserver -i "nsip" -u "login" -p "passwd"
OK|totalresponses=18238 establishedconn=0 pktssentrate=0 totalrequestbytes=18807153 hitsrate=0 totalrequests=18299 requestbytesrate=0 requestsrate=0 totalpktsrecvd=25490 pktsrecvdrate=0 curclntconnections=0 totalresponsebytes=815662173 totalpktssent=70190 responsebytesrate=0 tothits=18303 cursrvrconnections=0 responsesrate=0

python getns_stats.py -n test_svc -t service -i "nsip" -u "login" -p "passwd"
OK|totalresponses=2070 throughputrate=0 totalrequestbytes=3309175 totalrequests=2071 svrestablishedconn=0 surgecount=0 requestbytesrate=0 requestsrate=0 activetransactions=0 throughput=0 curclntconnections=0 totalresponsebytes=25849781 responsebytesrate=0 cursrvrconnections=8 responsesrate=0

python getns_stats.py
Please provide the Netscaler IPAddress and username/password
pass the --help for more options

python getns_stats.py -h
usage: getns_stats.py [options] arg --username=username --password=password --netscaler=netscalerip

options:
-h, --help show this help message and exit
-i HOSTNAME, --hostname=HOSTNAME
Here you will put the netscaler IPAddress or the
netscaler hostname

-u USERNAME, --username=USERNAME Your username

-p PASSWORD, --password=PASSWORD Your password

-l LIST, --list=LIST List all the names of the Virtual Servers and
Services. Example --list=lbvserver, --list=service

-n NAME, --name=NAME Virtual Server that you want to grab statistics for.

-t TYPE, --type=TYPE Here you either pass service, lbvserver, tcp or http.
example... --name=foobar --type=lbvserver or
--type=tcp or --type=http or --name=foobar
--type=service

 



Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! StumbleUpon! Yahoo! Free Joomla PHP extensions, software, information and tutorials.
Comments
Search RSS
Only registered users can write comments!

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated on Thursday, 11 February 2010 10:46