import xmlrpclib
import time
import random

#Your Python version needs to be 2.7 or higher...
#For I am the XMLRPC client, I need to contact my XMLRPC server (in our case the NetProbe)
#Ideally, with no ssl in mind, it should be as follows http://<Netprobe hostname>:<Netprobe Port>/xmlrpc
server = xmlrpclib.ServerProxy("http://netprobeHost:7036/xmlrpc")

#Empty Python Array
params = []

#Let's Create a view; "Dataview Name", "Dataview grouping"
params = ["py-queues", "Python"]
try:    #Lets create a dataview, will get an error if one is already created with the same name
    result = getattr(server, "InfraSvr06.myAPI.createview")(params[0], params[1])
except xmlrpclib.Fault, err:
    print "Error"
    print "Fault code: %d" % err.faultCode
    print "Fault string: %s" % err.faultString
del params[:] #if you want to clean up the old array

#Let's do a headline
params = ["totalQueues"]
try:
    result = getattr(server, "InfraSvr06.myAPI.Python-py-queues.addHeadline")(params[0])
except xmlrpclib.Fault, err:
    print "Error"
    print "Fault code: %d" % err.faultCode
    print "Fault string: %s" % err.faultString

#Let's do another headline!
params = ["queuesOffline"]
try:
    result = getattr(server, "InfraSvr06.myAPI.Python-py-queues.addHeadline")(params[0])
except xmlrpclib.Fault, err:
    print "Error"
    print "Fault code: %d" % err.faultCode
    print "Fault string: %s" % err.faultString

Rand_Num = random.randint(1,21)

#Using a multi-dimensional array for our Dataview
DataviewMatrix = [
        ["queueName", "currentSize", "maxSize", "currentUtilisation", "status"], #Bare in mind, the First is actually your column headings
        ["queue1", "332", "30000", Rand_Num, "online"],
		["queue2", "0", "90000", "0", "offline"],
		["queue3", "7331", "45000", "0.16", "online"]
    ]

#The matrix of our Dataview,
params[0] = DataviewMatrix
result = getattr(server, "InfraSvr06.myAPI.Python-py-queues.updateEntireTable")(params[0])

params = ["totalQueues", 3]
result = getattr(server, "InfraSvr06.myAPI.Python-py-queues.updateHeadline")(params[0], params[1])

params = ["queuesOffline", 1]
result = getattr(server, "InfraSvr06.myAPI.Python-py-queues.updateHeadline")(params[0], params[1])

bSendTestData = True

if bSendTestData:
    params[0] = "queue2.currentSize" #Imagine this as "x,y" coordinates, we're updating "row name"."column name"
    for x in xrange(1,1000):
        params[1] = "%d" % x
        try:
            getattr(server, "InfraSvr06.myAPI.Python-py-queues.updateTableCell")(params[0], params[1])
            getattr(server, "InfraSvr06.myAPI.Python-py-queues.updateHeadline")("queuesOffline", params[1])
            time.sleep(1) #Sleep for one second
        except xmlrpclib.Fault, err:
            print "Error"
            print "Fault code: %d" % err.faultCode
            print "Fault string: %s" % err.faultString
