Beispiel #1
0
 def __init__(self, filename="otomat.cnf"):
     #recive_report.__init__(self)
     self.filename = filename
     config = conf.otomat_conf(self.filename)
     self.port = config.server_port()
     self.host = config.server_host()
     self.sql_host = config.db_host()
     self.sql_user = config.db_user()
     self.sql_password = config.db_password()
     self.sql_defdb = config.db_defaultdb()
     #ThreadPool
     self.MaxThreads = config.server_worker()
Beispiel #2
0
	def __init__(self, filename="otomat.cnf"):
		#recive_report.__init__(self)
		self.filename = filename
		config = conf.otomat_conf(self.filename)
		self.port = config.server_port()
		self.host = config.server_host()
		self.sql_host = config.db_host()
		self.sql_user = config.db_user()
		self.sql_password = config.db_password()
		self.sql_defdb = config.db_defaultdb()
		#ThreadPool
		self.MaxThreads = config.server_worker()
    def __init__(self,filename="/etc/otomat/otomat.cnf"):
        self.filename = filename
	config = conf.otomat_conf(self.filename)
	self.host = config.rrdtool_host()
	self.rrdtool_dir = config.rrdtool_dir()
	# graph
	self.graph_cpu = config.graph_cpu()
	self.graph_mem = config.graph_mem()
	self.graph_disk = config.graph_disk()
	self.graph_network = config.graph_network()
        self.graph_login = config.graph_login() 
	self.graph_dir = config.graph_dir()
        #self.time = str(int(time.time()))
        #self.time = start_time
	self.graph_list = [self.graph_cpu,self.graph_mem,self.graph_disk,self.graph_network,self.graph_login]
    def __init__(self,filename="/etc/otomat/otomat.cnf",graph=None,title="北京壹號車 系統報告"):
        self.filename = filename
	config = conf.otomat_conf(self.filename)
	# rrdtool
	self.rrdtool_cpu = config.rrdtool_cpu()
	self.rrdtool_mem = config.rrdtool_mem()
	self.rrdtool_disk = config.rrdtool_disk()
	self.rrdtool_host = config.rrdtool_host()
	self.rrdtool_network = config.rrdtool_nic()
	self.rrdtool_dir = config.rrdtool_dir()
	self.rrdtool_login = config.rrdtool_login()
	# sql
	self.host = config.db_host()
	self.user = config.db_user()
	self.password = config.db_password()
	self.defaultdb = config.db_defaultdb()
 def __init__(self, filename="/etc/otomat/otomat.cnf"):
     self.filename = filename
     config = conf.otomat_conf(self.filename)
     self.host = config.rrdtool_host()
     self.rrdtool_dir = config.rrdtool_dir()
     # graph
     self.graph_cpu = config.graph_cpu()
     self.graph_mem = config.graph_mem()
     self.graph_disk = config.graph_disk()
     self.graph_network = config.graph_network()
     self.graph_login = config.graph_login()
     self.graph_dir = config.graph_dir()
     #self.time = str(int(time.time()))
     #self.time = start_time
     self.graph_list = [
         self.graph_cpu, self.graph_mem, self.graph_disk,
         self.graph_network, self.graph_login
     ]
 def __init__(self,
              filename="/etc/otomat/otomat.cnf",
              graph=None,
              title="北京壹號車 系統報告"):
     self.filename = filename
     config = conf.otomat_conf(self.filename)
     # rrdtool
     self.rrdtool_cpu = config.rrdtool_cpu()
     self.rrdtool_mem = config.rrdtool_mem()
     self.rrdtool_disk = config.rrdtool_disk()
     self.rrdtool_host = config.rrdtool_host()
     self.rrdtool_network = config.rrdtool_nic()
     self.rrdtool_dir = config.rrdtool_dir()
     self.rrdtool_login = config.rrdtool_login()
     # sql
     self.host = config.db_host()
     self.user = config.db_user()
     self.password = config.db_password()
     self.defaultdb = config.db_defaultdb()
Beispiel #7
0
#_*_ coding: UTF-8 _*_
import sys, time, os
reload(sys)
sys.setdefaultencoding('utf8')
import time, datetime
from otomat.conf import conf
from otomat.logs import log as logging
from otomat.plugins import rrdtool_data_collector
from otomat.plugins import rrdtool_drafting
from otomat.plugins import shell_cmd as shell

config = conf.otomat_conf('/etc/otomat/otomat.cnf')
logfile = config.report_log()
logdir = config.server_logdir()

if not os.path.exists(logdir):
    os.makedirs(logdir, 0o755)

os.chdir(logdir)
logging.set_logger(filename=logfile, mode='a')


def main(argv=sys.argv[1:]):
    t = rrdtool_data_collector.rrdtool_collector(argv)
    garph_day = rrdtool_drafting.graph_rrdtool(argv)
    garph_week = rrdtool_drafting.graph_rrdtool(argv)
    garph_month = rrdtool_drafting.graph_rrdtool(argv)
    logging.info(
        ("The otomat-report-server has been launched successfully !!!"))
    while True:
        t.rrdb()
Beispiel #8
0
    def __init__(self, filename = '/etc/otomat/otomat.cnf'):
	    self.filename = filename
	    config = conf.otomat_conf(self.filename)
	    self.port = config.server_port()
	    self.host = config.server_host()
	    self.client_nic = config.nic_port()
Beispiel #9
0
import sys
#import StringIO
import socket
#import pickle
from otomat.conf  import  conf  
from otomat.plugins import cpu
from otomat.plugins import disk
from otomat.plugins import mem
from otomat.plugins import network
from otomat.plugins import hostname
from otomat.plugins import login_user
from otomat.plugins import ip_address
from otomat.logs import log as logging


config = conf.otomat_conf('/etc/otomat/otomat.cnf')
logfile = config.client_log()
logdir = config.client_logdir()
if not os.path.exists(logdir):
	os.makedirs(logdir,0o755)
#print logfile
#print logdir
os.chdir(logdir)
logging.set_logger(filename =logfile, mode = 'a')

#
def os_release():
 	s = []
	f = open ('/etc/issue')
	s = f.read()
	return s.split()[0]
Beispiel #10
0
def pysql(recv_data):
    data = recv_data
    config = conf.otomat_conf('/etc/otomat/otomat.cnf')
    hostname = config.db_host()
    username = config.db_user()
    password = config.db_password()
    defdata = config.db_defaultdb()
    conn = MySQLdb.connect(host=hostname,user=username,passwd=password,db=defdata)
    cursor = conn.cursor()
    #args = [('client','172.16.209.219','0.0','1036570','389505024L',
    #   '647065600L','15.300000000000001','2080370688L','2080370688L',
    #   '0L','0.0','30414569','2494730240','47665602560',
    #   '4.7000000000000002','30414569','81069')]
    hostname = data['hostname']
    hostip = data['host_ip']
    cpu_loadavg = str(data['cpu_loadavg'])
    cpu_user = str(data['cpu_user'])
    cpu_nice = str(data['cpu_nice'])
    cpu_system = str(data['cpu_system'])
    cpu_iowait = str(data['cpu_iowait'])
    cpu_steal = str(data['cpu_steal'])
    cpu_idle = str(data['cpu_idle'])
    mem_total = str(data['mem_total'])
    mem_freed = str(data['mem_freed'])
    mem_used = str(data['mem_used'])
    mem_buffers_used = str(data['mem_buffers_used'])
    mem_buffers_freed = str(data['mem_buffers_freed'])
    mem_used_percent = str(data['mem_used_percent'])
    swap_total = str(data['swap_total'])
    swap_freed = str(data['swap_freed'])
    swap_used = str(data['swap_used'])
    swap_used_percent = str(data['swap_used_percent'])
    disk_total = str(data['disk_total'])
    disk_used = str(data['disk_used'])
    disk_freed = str(data['disk_freed'])
    disk_used_percent = str(data['disk_used_percent'])
    nic_recv = str(data['networktraffic_recv'])
    nic_recv_err = str(data['networktraffic_recv_error'])
    nic_sent = str(data['networktraffic_sent'])
    nic_sent_err = str(data['networktraffic_sent_error'])
    user_name = str(data['login_user_name'])
    user_num = str(data['login_user_num'])
    ###############################
    args_cpu = (hostname,hostip,cpu_loadavg,cpu_user,cpu_nice,cpu_system,
    cpu_iowait,cpu_steal,cpu_idle)
    args_mem = (hostname,hostip,mem_total,mem_freed,mem_used,mem_buffers_used,mem_buffers_freed,mem_used_percent,swap_total,swap_freed,swap_used,swap_used_percent)
    args_disk = (hostname,hostip,disk_total,disk_used,disk_freed,disk_used_percent)
    args_network = (hostname,hostip,nic_recv,nic_recv_err,nic_sent,nic_sent_err)
    args_login = (hostname,hostip,user_num,user_name)
    ###############################
    # sqltext cpu,mem,network,disk,login
    sqltext_cpu = "insert into `cpu` (Hostname,Host_ip,TIME,CPU_Loadavg,CPU_User,CPU_Nice,CPU_System,CPU_Iowait,CPU_Steal,CPU_Idel\
        ) value (\
        %s,%s,(NOW()),%s,%s,%s,%s,%s,%s,%s)"
    sqltext_mem = "insert into `mem` (Hostname,Host_ip,Time,MEM_Total,MEM_Freed,MEM_Used,\
        MEM_Buffers_Freed,MEM_Buffers_Used,MEM_Used_Percent,SWAP_Total,SWAP_Freed,SWAP_Used,SWAP_Used_Percent\
        ) value (\
        %s,%s,(NOW()),%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    sqltext_disk = "insert into `disk` (Hostname,Host_ip,TIME,DISK_Total,DISK_Used,DISK_Freed,DISK_Used_Percent\
        ) value (\
        %s,%s,(NOW()),%s,%s,%s,%s)"
    sqltext_network = "insert into `network` (Hostname,Host_ip,TIME,Networktraffic_recv,Networktraffic_recv_err,\
        Networktraffic_sent,Networktraffic_sent_err) value (\
        %s,%s,(NOW()),%s,%s,%s,%s)"
    sqltext_login = "******"

    #args = [('client','172.16.209.219','0.0','1036570','389505024L',
    #   '647065600L','15.300000000000001','2080370688L','2080370688L',
    #   '0L','0.0','30414569','2494730240','47665602560',
    #   '4.7000000000000002','30414569','81069')]
    #####################################
    # mysql.execute(sqltext,args,mode=otomat_sql.DICTCURSOR_MODE)
    cursor.execute(sqltext_cpu,args_cpu)
    cursor.execute(sqltext_mem,args_mem)
    cursor.execute(sqltext_network,args_network)
    cursor.execute(sqltext_disk,args_disk)
    cursor.execute(sqltext_login,args_login)
    cursor.close()
    conn.commit()
    conn.close()
    '''
Beispiel #11
0
 def __init__(self, filename='/etc/otomat/otomat.cnf'):
     self.filename = filename
     config = conf.otomat_conf(self.filename)
     self.port = config.server_port()
     self.host = config.server_host()
     self.client_nic = config.nic_port()
Beispiel #12
0
def pysql(recv_data):
    data = recv_data
    config = conf.otomat_conf('/etc/otomat/otomat.cnf')
    hostname = config.db_host()
    username = config.db_user()
    password = config.db_password()
    defdata = config.db_defaultdb()
    conn = MySQLdb.connect(host=hostname,
                           user=username,
                           passwd=password,
                           db=defdata)
    cursor = conn.cursor()
    #args = [('client','172.16.209.219','0.0','1036570','389505024L',
    #   '647065600L','15.300000000000001','2080370688L','2080370688L',
    #   '0L','0.0','30414569','2494730240','47665602560',
    #   '4.7000000000000002','30414569','81069')]
    hostname = data['hostname']
    hostip = data['host_ip']
    cpu_loadavg = str(data['cpu_loadavg'])
    cpu_user = str(data['cpu_user'])
    cpu_nice = str(data['cpu_nice'])
    cpu_system = str(data['cpu_system'])
    cpu_iowait = str(data['cpu_iowait'])
    cpu_steal = str(data['cpu_steal'])
    cpu_idle = str(data['cpu_idle'])
    mem_total = str(data['mem_total'])
    mem_freed = str(data['mem_freed'])
    mem_used = str(data['mem_used'])
    mem_buffers_used = str(data['mem_buffers_used'])
    mem_buffers_freed = str(data['mem_buffers_freed'])
    mem_used_percent = str(data['mem_used_percent'])
    swap_total = str(data['swap_total'])
    swap_freed = str(data['swap_freed'])
    swap_used = str(data['swap_used'])
    swap_used_percent = str(data['swap_used_percent'])
    disk_total = str(data['disk_total'])
    disk_used = str(data['disk_used'])
    disk_freed = str(data['disk_freed'])
    disk_used_percent = str(data['disk_used_percent'])
    nic_recv = str(data['networktraffic_recv'])
    nic_recv_err = str(data['networktraffic_recv_error'])
    nic_sent = str(data['networktraffic_sent'])
    nic_sent_err = str(data['networktraffic_sent_error'])
    user_name = str(data['login_user_name'])
    user_num = str(data['login_user_num'])
    ###############################
    args_cpu = (hostname, hostip, cpu_loadavg, cpu_user, cpu_nice, cpu_system,
                cpu_iowait, cpu_steal, cpu_idle)
    args_mem = (hostname, hostip, mem_total, mem_freed, mem_used,
                mem_buffers_used, mem_buffers_freed, mem_used_percent,
                swap_total, swap_freed, swap_used, swap_used_percent)
    args_disk = (hostname, hostip, disk_total, disk_used, disk_freed,
                 disk_used_percent)
    args_network = (hostname, hostip, nic_recv, nic_recv_err, nic_sent,
                    nic_sent_err)
    args_login = (hostname, hostip, user_num, user_name)
    ###############################
    # sqltext cpu,mem,network,disk,login
    sqltext_cpu = "insert into `cpu` (Hostname,Host_ip,TIME,CPU_Loadavg,CPU_User,CPU_Nice,CPU_System,CPU_Iowait,CPU_Steal,CPU_Idel\
        ) value (\
        %s,%s,(NOW()),%s,%s,%s,%s,%s,%s,%s)"

    sqltext_mem = "insert into `mem` (Hostname,Host_ip,Time,MEM_Total,MEM_Freed,MEM_Used,\
        MEM_Buffers_Freed,MEM_Buffers_Used,MEM_Used_Percent,SWAP_Total,SWAP_Freed,SWAP_Used,SWAP_Used_Percent\
        ) value (\
        %s,%s,(NOW()),%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    sqltext_disk = "insert into `disk` (Hostname,Host_ip,TIME,DISK_Total,DISK_Used,DISK_Freed,DISK_Used_Percent\
        ) value (\
        %s,%s,(NOW()),%s,%s,%s,%s)"

    sqltext_network = "insert into `network` (Hostname,Host_ip,TIME,Networktraffic_recv,Networktraffic_recv_err,\
        Networktraffic_sent,Networktraffic_sent_err) value (\
        %s,%s,(NOW()),%s,%s,%s,%s)"

    sqltext_login = "******"

    #args = [('client','172.16.209.219','0.0','1036570','389505024L',
    #   '647065600L','15.300000000000001','2080370688L','2080370688L',
    #   '0L','0.0','30414569','2494730240','47665602560',
    #   '4.7000000000000002','30414569','81069')]
    #####################################
    # mysql.execute(sqltext,args,mode=otomat_sql.DICTCURSOR_MODE)
    cursor.execute(sqltext_cpu, args_cpu)
    cursor.execute(sqltext_mem, args_mem)
    cursor.execute(sqltext_network, args_network)
    cursor.execute(sqltext_disk, args_disk)
    cursor.execute(sqltext_login, args_login)
    cursor.close()
    conn.commit()
    conn.close()
    '''