• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python syslog.closelog函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中syslog.closelog函数的典型用法代码示例。如果您正苦于以下问题:Python closelog函数的具体用法?Python closelog怎么用?Python closelog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了closelog函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    parser = OptionParser()
    parser.add_option('-W', '--warning', action='store', dest='warning', default=100, type='int', help='The warning threshold we want to set')
    parser.add_option('-C', '--critical', action='store', dest='critical', default=200, type='int', help='The critical threshold we want to set')
    (options, args) = parser.parse_args()

    start = time.time()

    # syslog check start
    syslog.openlog( 'check_syslog' )
    syslog.syslog( syslog.LOG_DEBUG, 'Nagion syslog check' )
    syslog.closelog()
    # syslog check stop

    stop = time.time()
    result = int((stop - start) * 1000)
    if(result < options.warning):
        print "OK - %d ms" % result
        return 0
    if(result < options.critical):
        print "WARNING - %d ms" % result
        return 1
    else:
        print "CRITICAL - %d ms" % result
        return 2
开发者ID:frad00r4,项目名称:nagios-checks,代码行数:25,代码来源:check_syslog.py


示例2: syslog

def syslog(message, ident = "", priority = "info", facility = "syslog", options = []):
  """
  Send a string to syslog and return that same string.
  """
  priority = { "emerg":SYSLOG.LOG_EMERG, "alert":SYSLOG.LOG_ALERT, 
               "crit":SYSLOG.LOG_CRIT, "err":SYSLOG.LOG_ERR, 
               "warning":SYSLOG.LOG_WARNING, "notice":SYSLOG.LOG_NOTICE, 
               "info":SYSLOG.LOG_INFO, "debug":SYSLOG.LOG_DEBUG }.get(str(priority).lower(),0)
  facility = { "kern":SYSLOG.LOG_KERN, "user":SYSLOG.LOG_USER, 
               "mail":SYSLOG.LOG_MAIL, "daemon":SYSLOG.LOG_DAEMON, 
               "auth":SYSLOG.LOG_AUTH, "lpr":SYSLOG.LOG_LPR, 
               "news":SYSLOG.LOG_NEWS, "uucp":SYSLOG.LOG_UUCP, 
               "cron":SYSLOG.LOG_CRON, "syslog":SYSLOG.LOG_SYSLOG, 
               "local0":SYSLOG.LOG_LOCAL0, "local1":SYSLOG.LOG_LOCAL1, 
               "local2":SYSLOG.LOG_LOCAL2, "local3":SYSLOG.LOG_LOCAL3, 
               "local4":SYSLOG.LOG_LOCAL4, "local5":SYSLOG.LOG_LOCAL5, 
               "local6":SYSLOG.LOG_LOCAL6, "local7":SYSLOG.LOG_LOCAL7 }.get(str(facility).lower(),0)
  option = 0
  for opt in options:
    option += { "pid":SYSLOG.LOG_PID, "cons":SYSLOG.LOG_CONS, "ndelay":SYSLOG.LOG_NDELAY, 
                "nowait":SYSLOG.LOG_NOWAIT, "perror":SYSLOG.LOG_PERROR }.get(str(opt).lower(),0)
  message = str(message)
  ident = str(ident)
  if not ident: ident = os.path.basename(sys.argv[0])
  SYSLOG.openlog(ident = ident, logoption = option, facility = facility)
  add = ""
  for line in message.split("\n"):
    if line:
      SYSLOG.syslog(priority, add + line)
      add = " "
  SYSLOG.closelog()
  return message
开发者ID:robertwbrandt,项目名称:common,代码行数:32,代码来源:brandt.py


示例3: emit

 def emit(self, record):
     hand = syslog.openlog(facility=self.facility)
     msg = self.format(record)
     syslog.syslog(
         self.priority_names.get(record.levelname.lower(), "debug"),
         msg)
     syslog.closelog()
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:7,代码来源:handlers.py


示例4: log

def log(txt, force=False):
    global log, log_enabled
    if not log_enabled and not force:
        return
    syslog.openlog("skolesys-backup")
    syslog.syslog(txt)
    syslog.closelog()
开发者ID:BackupTheBerlios,项目名称:skolesys-svn,代码行数:7,代码来源:udevparser.py


示例5: main

def main ():#funcion principal

	logs = open("FilesOutput/CompleteTables_Logs_error.txt", 'w')#se abre archivo log

	#abrimos syslog para registrar lo que realiza el script...
	syslog.openlog("CompleteTables.py", syslog.LOG_USER)

	syslog.syslog(syslog.LOG_INFO,"this script has created the next output files CompleteTables_Logs_error.txt")

	information_DB = ReadCSV(sys.argv[1])#obtenemos la informacion de la base de datos...

	syslog.syslog(syslog.LOG_INFO, "Completando datos en tablas no relacionadas")
	#se generan las conexiones
	data_connected_import = ConnectDB(information_DB['import'][0], information_DB['import'][1], information_DB['import'][2], information_DB['import'][3])
	data_connected_export = ConnectDB(information_DB['export'][0], information_DB['export'][1], information_DB['export'][2], information_DB['export'][3])

	#se realiza el mismo proceso para las diferentes tablas...
	#insertando elementos tabla tipodispositivo
	CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "tipo_dispositivo", "tipodispositivo", "tipo", "tipodispositivo_id_seq", 1)
	#insertando elementos tabla marca
	CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "marca", "marca", "marca", "marca_id_seq", 1)		
	#insertando elementos tabla tipousuario
	CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "tipo_usuario", "tipousuario", "tipo", "tipousuario_id_seq", 0)	
	#insertando elementos tabla estadodispositivo and tabla estadousuario
	CompleteProcessInsertion(data_connected_export[1], data_connected_export[0], data_connected_import[1], data_connected_import[0], "estado", "estadodispositivo", "descripcion", "estadodispositivo_id_seq", 1)	
	
	logs.write("ok")
	logs.close()

	syslog.closelog()#cerramos syslog
	return 0	
开发者ID:Dmedina11,项目名称:MigrateDB2,代码行数:31,代码来源:CompleteTables.py


示例6: error

def error(*args):
  msg = make_msg(args)
  if sys.stderr.isatty():
    logging.error(msg)
  syslog.openlog(ident, syslog.LOG_NDELAY, facility)
  syslog.syslog(syslog.LOG_ERR, msg)
  syslog.closelog()
开发者ID:SufianHassan,项目名称:hydra,代码行数:7,代码来源:syslog.py


示例7: log_warning

def log_warning(msg, syslog_identifier, also_print_to_console=False):
    syslog.openlog(syslog_identifier)
    syslog.syslog(syslog.LOG_WARNING, msg)
    syslog.closelog()

    if also_print_to_console:
        print msg
开发者ID:Azure,项目名称:sonic-utilities,代码行数:7,代码来源:mlnx.py


示例8: log

 def log(self, msg=''):
     if msg != '':
         sys.stdout.write(self.script_path + ': ' + str(msg) + '\n')
         syslog.openlog(ident='openvpn ' + self.name + ' ' + self.instance,
                        logoption=0, facility=syslog.LOG_DAEMON)
         syslog.syslog(syslog.LOG_INFO, msg)
         syslog.closelog()
开发者ID:ginsys,项目名称:openvpn-user-defined-scripts,代码行数:7,代码来源:ovpnscript.py


示例9: log_warning

def log_warning(msg, also_print_to_console=False):
    syslog.openlog(SYSLOG_IDENTIFIER)
    syslog.syslog(syslog.LOG_WARNING, msg)
    syslog.closelog()

    if also_print_to_console:
        click.echo(msg)
开发者ID:Azure,项目名称:sonic-utilities,代码行数:7,代码来源:main.py


示例10: main

def main ():

	#abrimos syslog para registrar lo que realiza el script...
	syslog.openlog("RemoveElementsConflictiv.py", syslog.LOG_USER)
	
	information_DB = ReadCSV(sys.argv[1])#obtenemos la informacion de la base de datos...
	# #make connections...
	data_connected_import = ConnectDB(information_DB['import'][0], information_DB['import'][1], information_DB['import'][2], information_DB['import'][3])
	data_connected_export = ConnectDB(information_DB['export'][0], information_DB['export'][1], information_DB['export'][2], information_DB['export'][3])
	print "Removiendo elementos conflictivos y elementos no existentes en csv"
	#obtengo la lista de macs...
	list_macs = ReadText("FilesOutput/GetMacslist_macs_not_exists.txt")
	list_macs_persistentes=RemoveMacsNotInCSV(data_connected_export[1], data_connected_export[0], list_macs)
	
	#eliminamos los datos que presentan problemas de union y que deben almacenar su informacion en un csv...
	list_equipos_conflictivos = GetListEquiposConflictivos(data_connected_export[1], data_connected_export[0])#obtenemos la lista de elementos conflictivos...
	info_equipos_conflictivos = RecolectaInformacionEquiposConflictivos(data_connected_export[1], list_equipos_conflictivos)
	GenerateCSV(info_equipos_conflictivos, data_connected_import[1])
	DeleteEquiposConflictivos(data_connected_export[1], data_connected_export[0], list_equipos_conflictivos)

	logs = open("FilesOutput/Remove.txt", 'w')
	logs.write("ok")
	logs.close()
	syslog.closelog()#cerramos syslog

	return 0
开发者ID:Dmedina11,项目名称:MigrateDB2,代码行数:26,代码来源:RemoveElementsConflictiv.py


示例11: log

def log(statement, event=False):
    statement = str(statement)

    # Always print event related messages, even when --quiet is specified
    if options.quiet is True and event is False:
        return

    # Always log to syslog
    syslog.openlog("ha-nat")
    syslog.syslog(statement)
    syslog.closelog()

    # Always print to stdout
    print statement

    # Log to a file if one has been specified
    if options.logFile is not None:
        if not os.path.exists(os.path.dirname(options.logFile)):
            os.makedirs(os.path.dirname(options.logFile))

        logFile = open(options.logFile, 'a')
        ts = datetime.datetime.now()
        isFirst = True
        for line in statement.split("\n"):
            if isFirst:
                logFile.write("%s - %s\n" % (ts, line))
                isFirst = False
            else:
                logFile.write("%s -    %s\n" % (ts, line))
        logFile.close()
开发者ID:bhourigan,项目名称:ha-nat,代码行数:30,代码来源:ha-nat.py


示例12: send_10_log_messages_with_delay

def send_10_log_messages_with_delay():
    syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
    for ind in range(10):
        msg = str(ind + 1) + '. Test Syslog Messages being sent.'
        syslog.syslog(syslog.LOG_EMERG, msg)
        time.sleep(1)
    syslog.closelog()
开发者ID:Ankitja,项目名称:contrail-test,代码行数:7,代码来源:mylogging.py


示例13: send_test_log_message

def send_test_log_message():
    syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_KERN)
    for ind in range(5):
        msg = str(ind + 1) + '. Test Syslog Messages from different nodes.'
        syslog.syslog(syslog.LOG_EMERG, msg)
    time.sleep(1)
    syslog.closelog()
开发者ID:Ankitja,项目名称:contrail-test,代码行数:7,代码来源:mylogging.py


示例14: send_messages_of_all_facility_and_severity

def send_messages_of_all_facility_and_severity():
    dict_of_facility = {
        'LOG_KERN': 0,
        'LOG_USER': 1,
        'LOG_MAIL': 2,
        'LOG_DAEMON': 3,
        'LOG_AUTH': 4,
        'LOG_NEWS': 7,
        'LOG_UUCP': 8,
        'LOG_LOCAL0': 16,
        'LOG_CRON': 15,
        'LOG_SYSLOG': 5,
        'LOG_LOCAL1': 17}
    list_of_severity = ['LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR',
                        'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG']

    for each_facility in dict_of_facility:
        log_facility = dict_of_facility[each_facility]
        syslog.openlog(logoption=syslog.LOG_PID, facility=log_facility)
        for each_severity in list_of_severity:
            log_severity = list_of_severity.index(each_severity)
            msg = 'Test Message from ' + each_facility + \
                ' with severity ' + each_severity + '.'
            syslog.syslog(log_severity, msg)
        syslog.closelog()
        time.sleep(1)
开发者ID:Ankitja,项目名称:contrail-test,代码行数:26,代码来源:mylogging.py


示例15: warning

def warning(*args):
  msg = make_msg(args)
  if sys.stderr.isatty():
    logging.warning(msg)
  syslog.openlog(ident, syslog.LOG_NDELAY, facility)
  syslog.syslog(syslog.LOG_WARNING, msg)
  syslog.closelog()
开发者ID:SufianHassan,项目名称:hydra,代码行数:7,代码来源:syslog.py


示例16: log_error

def log_error(msg, also_print_to_console=False):
    syslog.openlog(SYSLOG_IDENTIFIER)
    syslog.syslog(syslog.LOG_ERR, msg)
    syslog.closelog()

    if also_print_to_console:
        click.echo(msg)
开发者ID:Azure,项目名称:sonic-utilities,代码行数:7,代码来源:main.py


示例17: debug

def debug(*args):
  msg = make_msg(args)
  if sys.stderr.isatty():
    logging.debug(msg)
  syslog.openlog(ident, syslog.LOG_NDELAY, facility)
  syslog.syslog(syslog.LOG_DEBUG, msg)
  syslog.closelog()
开发者ID:SufianHassan,项目名称:hydra,代码行数:7,代码来源:syslog.py


示例18: log_cef

    def log_cef(self, message_name, message_description, type='LOG_INFO',
                items=[]):
        """
            log_cef method to actually write message to syslog
            param: message_name - Generic name of message type
            param: message_description - More verbose details of the message to
                be logged
            param: type - A string representation of the syslog facility,
              LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING,
              LOG_NOTICE, LOG_INFO, LOG_DEBUG
              http://unix.superglobalmegacorp.com/Net2/newsrc/sys/syslog.h.html
            param: items - List of cef specific key/value pairs

            typical usage:

        """
        # Open a connection to syslog to the proper facility

        syslog.openlog(self.prog_name, 0, self.facility)
        label_string = ''

        # Iterating over the items list and construct the label string to send
        for row in items:
            for key, value in row.items():
                label_string = "%s%s=%s " % (
                    label_string, str(key), str(value))
        cefmsg = 'CEF:0|Mozilla|%s|1.0|%s|%s|5|%s dhost=%s' %\
            (self.prog_name, message_name, message_description,
                label_string, os.uname()[1])
        try:
            syslog_level = getattr(syslog, type)
        except AttributeError:
            raise BaseException('Unable to find syslog type')
        syslog.syslog(syslog_level, cefmsg)
        syslog.closelog()
开发者ID:rtucker-mozilla,项目名称:MozCef,代码行数:35,代码来源:MozCef.py


示例19: close

    def close(self):
        """
        Closes the handler.
        """

        syslog.closelog()
        logging.Handler.close(self)
开发者ID:fbrehm,项目名称:py_pb_logging,代码行数:7,代码来源:unix_handler.py


示例20: log

def log(msg):
	"""
		Send a message to syslog
	"""
	syslog.openlog('OpenVPN', 0, syslog.LOG_DAEMON)
	syslog.syslog(syslog.LOG_INFO, msg)
	syslog.closelog()
开发者ID:jvehent,项目名称:openvpn-netfilter,代码行数:7,代码来源:netfilter.py



注:本文中的syslog.closelog函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python syslog.openlog函数代码示例发布时间:2022-05-27
下一篇:
Python csvdata.csvFuturesData函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap