Exemplo n.º 1
0
def do_ping():
    color = str(settings.get_color())
    check_database()
    cnx = mysql.connector.connect(user="******", password="******", host="localhost", database="iisc")
    cursor = cnx.cursor()
    cursor.execute("select ip from tree")
    for ip in cursor:
        if ip:
            update_database(str(ip[0]))
            graph_for_ping(str(ip[0]), color)
        else:
            pass
    cursor.close()
    cnx.close()
def get_host():
	color = str(settings.get_color())
	cnx = mysql.connector.connect(user='******', password='******', host='localhost', database='iisc')
	cursor = cnx.cursor()
	cursor.execute("select ip from host")
	for ip in cursor:
		last_hour(ip[0],color)
		last_24hour(ip[0],color)
		last_week(ip[0],color)
		last_4week(ip[0],color)
		last_6months(ip[0],color)
		last_1year(ip[0],color)
	cursor.close()
	cnx.close()
def internet_bandwidth_graph():
	color = str(settings.get_color())
	if not os.path.exists('database/proxy_ib.rrd'):
		rrdtool.create("database/proxy_ib.rrd", "--step", "300", "--start", "0",
		"DS:speed:GAUGE:600:U:U",
		"RRA:AVERAGE:0.5:1:10080",
		"RRA:AVERAGE:0.5:5:8934",
		"RRA:AVERAGE:0.5:60:8784",
		"RRA:AVERAGE:0.5:1440:3660"
		)

	f = open("temp/speed.txt").readline().rstrip()
	rrdtool.update("database/proxy_ib.rrd","N:%s" % f)
	rrdtool.graph("images/proxy_ib.png", "-a", "PNG", "--title",
	"Internet Bandwidth", "--width", "900", "--height", "200",
	"--vertical-label", "MB/s",
	"DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
	"AREA:sp"+color+":Speed"
	)
	rrdtool.graph("images/proxy_ib1hr.png", "-a", "PNG", "--title",
	"Internet Bandwidth", "--start", "end-1h", "--width", "900", "--height", "200",
	"--vertical-label", "MB/s",
	"DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
	"AREA:sp"+color+":Speed"
	)
	rrdtool.graph("images/proxy_ib1week.png", "-a", "PNG", "--title",
	"Internet Bandwidth", "--end", "00:00", "--start", "end-1w", "--width", "900", "--height", "200",
	"--vertical-label", "MB/s",
	"DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
	"AREA:sp"+color+":Speed"
	)
	rrdtool.graph("images/proxy_ib4week.png", "-a", "PNG", "--title",
	"Internet Bandwidth", "--end", "00:00", "--start", "end-4w", "--width", "900", "--height", "200",
	"--vertical-label", "MB/s",
	"DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
	"AREA:sp"+color+":Speed"
	)
	rrdtool.graph("images/proxy_ib24week.png", "-a", "PNG", "--title",
	"Internet Bandwidth", "--end", "00:00", "--start", "end-24w", "--width", "900", "--height", "200",
	"--vertical-label", "MB/s",
	"DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
	"AREA:sp"+color+":Speed"
	)
	rrdtool.graph("images/proxy_ib1year.png", "-a", "PNG", "--title",
	"Internet Bandwidth", "--end", "00:00", "--start", "end-1y", "--width", "900", "--height", "200",
	"--vertical-label", "MB/s",
	"DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
	"AREA:sp"+color+":Speed"
	)
def get_host():
    color = str(settings.get_color())
    cnx = mysql.connector.connect(user='******',
                                  password='******',
                                  host='localhost',
                                  database='iisc')
    cursor = cnx.cursor()
    cursor.execute("select ip from host")
    for ip in cursor:
        last_hour(ip[0], color)
        last_24hour(ip[0], color)
        last_week(ip[0], color)
        last_4week(ip[0], color)
        last_6months(ip[0], color)
        last_1year(ip[0], color)
    cursor.close()
    cnx.close()
Exemplo n.º 5
0
def do_ping():
    color = str(settings.get_color())
    check_database()
    cnx = mysql.connector.connect(user='******',
                                  password='******',
                                  host='localhost',
                                  database='iisc')
    cursor = cnx.cursor()
    cursor.execute("select ip from tree")
    for ip in cursor:
        if ip:
            update_database(str(ip[0]))
            graph_for_ping(str(ip[0]), color)
        else:
            pass
    cursor.close()
    cnx.close()
Exemplo n.º 6
0
def apply_histo_linecolor(wrps, colors=None):
    """
    Uses ``histo.SetLineColor``. Colors from settings, if not given.

    :param wrps:    HistoWrapper iterable
    :param colors:  Integer list
    :yields:        HistoWrapper
    """
    n = 0
    for wrp in wrps:
        if hasattr(wrp, "histo"):
            if colors:
                color = colors[n%len(colors)]
                n += 1
            else:
                color = settings.get_color(wrp.sample)
            if color:
                wrp.histo.SetLineColor(color)
        yield wrp
Exemplo n.º 7
0
def apply_histo_linecolor(wrps, colors=None):
    """
    Uses ``histo.SetLineColor``. Colors from settings, if not given.

    :param wrps:    HistoWrapper iterable
    :param colors:  Integer list
    :yields:        HistoWrapper
    """
    n = 0
    for wrp in wrps:
        if hasattr(wrp, "histo"):
            if colors:
                color = colors[n % len(colors)]
                n += 1
            else:
                color = settings.get_color(wrp.sample)
            if color:
                wrp.histo.SetLineColor(color)
        yield wrp
Exemplo n.º 8
0
def internet_bandwidth_graph():
    color = str(settings.get_color())
    if not os.path.exists('database/proxy_ib.rrd'):
        rrdtool.create("database/proxy_ib.rrd", "--step", "300", "--start",
                       "0", "DS:speed:GAUGE:600:U:U",
                       "RRA:AVERAGE:0.5:1:10080", "RRA:AVERAGE:0.5:5:8934",
                       "RRA:AVERAGE:0.5:60:8784", "RRA:AVERAGE:0.5:1440:3660")

    f = open("temp/speed.txt").readline().rstrip()
    rrdtool.update("database/proxy_ib.rrd", "N:%s" % f)
    rrdtool.graph("images/proxy_ib.png", "-a", "PNG", "--title",
                  "Internet Bandwidth", "--width", "900", "--height", "200",
                  "--vertical-label", "MB/s",
                  "DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
                  "AREA:sp" + color + ":Speed")
    rrdtool.graph("images/proxy_ib1hr.png", "-a", "PNG", "--title",
                  "Internet Bandwidth", "--start", "end-1h", "--width", "900",
                  "--height", "200", "--vertical-label", "MB/s",
                  "DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
                  "AREA:sp" + color + ":Speed")
    rrdtool.graph("images/proxy_ib1week.png", "-a", "PNG", "--title",
                  "Internet Bandwidth", "--end", "00:00", "--start", "end-1w",
                  "--width", "900", "--height", "200", "--vertical-label",
                  "MB/s", "DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
                  "AREA:sp" + color + ":Speed")
    rrdtool.graph("images/proxy_ib4week.png", "-a", "PNG", "--title",
                  "Internet Bandwidth", "--end", "00:00", "--start", "end-4w",
                  "--width", "900", "--height", "200", "--vertical-label",
                  "MB/s", "DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
                  "AREA:sp" + color + ":Speed")
    rrdtool.graph("images/proxy_ib24week.png", "-a", "PNG", "--title",
                  "Internet Bandwidth", "--end", "00:00", "--start", "end-24w",
                  "--width", "900", "--height", "200", "--vertical-label",
                  "MB/s", "DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
                  "AREA:sp" + color + ":Speed")
    rrdtool.graph("images/proxy_ib1year.png", "-a", "PNG", "--title",
                  "Internet Bandwidth", "--end", "00:00", "--start", "end-1y",
                  "--width", "900", "--height", "200", "--vertical-label",
                  "MB/s", "DEF:sp=database/proxy_ib.rrd:speed:AVERAGE",
                  "AREA:sp" + color + ":Speed")
Exemplo n.º 9
0
	cnx.close()
print """
|_ _|_ _/ ___|  ___  | \ | | ___| |___      _____  _ __| | __
 | | | |\___ \ / __| |  \| |/ _ \ __\ \ /\ / / _ \| '__| |/ /
 | | | | ___) | (__  | |\  |  __/ |_ \ V  V / (_) | |  |   < 
|___|___|____/ \___| |_| \_|\___|\__| \_/\_/ \___/|_|  |_|\_\
	                                                     
 __  __             _ _             
|  \/  | ___  _ __ (_) |_ ___  _ __ 
| |\/| |/ _ \| '_ \| | __/ _ \| '__|
| |  | | (_) | | | | | || (_) | | Version: 0.2  
|_|  |_|\___/|_| |_|_|\__\___/|_| By: Shashank Suresh Kulal
"""
#i = 1
#while True:
color = settings.get_color()
do_ping(color)
	#sys.stdout.write("Ping done %s times.\r" % str(i))
	#sys.stdout.flush()
	#i += 1
print "Entering Bandwidth function"
functions.internet_bandwidth()
print "Entering Bandwidth function"
functions.internet_bandwidth_graph()
print "Entering pingraph"
pinggraph.get_host()
print "Entering tree ping"
tree.do_ping()
	#time.sleep(60)
i_speed.check_db()
print "Exiting python script"