快速查看日志

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

#!/usr/bin/env python

-- coding: UTF-8 --

import os

nginxLogPath = './nginx.log'
phpLogPath = './php.log'
phpFpmLogPath = './php-fpm.log'
mysqlLogPath = './mysql.log'

def printMenu():
print("\033[21;32m ############# 欢迎使用日志系统 ##############\033[0m")
print("\033[21;32m 1)输入1,访问nginx日志 \033[0m")
print("\033[21;32m 2)输入2,访问php日志 \033[0m")
print("\033[21;32m 3)输入3,访问php-fpm日志 \033[0m")
print("\033[21;32m 4)输入4,访问mysql日志 \033[0m")
print("\033[21;32m 5)输入5,查看各日志路径 \033[0m")
print("\033[21;32m 6)输入6,查看各配置文件路径 \033[0m")
print("\033[21;32m 7)输入7,查看相关命令 \033[0m")
print("\033[21;32m 5)输入q退出 \033[0m")
getNum = raw_input('>>')
return getNum

def printLogPath():
print("/logs/www.ss.log")
print("/logs/php.log")
print("/logs/php-fpm.log")
print("/logs/my.log")
return

def printConf():
print("/elk.conf")
print("/etc/php.conf")
print("/etc/php-fpm.conf")
print("/etc/my.conf")
return

def printLog(num,tail_num):
n = tail_num
if (num == 1) :
os.system("tail -%s %s"%(n,nginxLogPath))
elif (num == 2) :
os.system("tail -%s %s"%(n,phpLogPath))
elif (num == 3) :
os.system("tail -%s %s"%(n,phpFpmLogPath))
elif (num == 4) :
os.system("tail -%s %s"%(n,mysqlLogPath))
elif (num == 5) :
printLogPath()
elif (num == 6) :
printConf()
return

while True:
res = printMenu()
if res == 'q':
exit()
num_list = res.split(' ')
tail_num = 10

if not num_list[0].isdigit() :
continue

if len(num_list) >=2 :
if not num_list[1].isdigit() :
continue
else:
tail_num = int(num_list[1])

num = int(num_list[0])
printLog(num,tail_num)


本文转自cloves 51CTO博客,原文链接:http://blog.51cto.com/yeqing/2050503


相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
打赏
0
0
0
0
344
分享
相关文章
日志 直接拿去用
日志 直接拿去用
libvirtd 配置日志
libvirtd 配置日志
157 0
日志服务主要功能
本文介绍日志服务主要的功能。
138 2
日志服务
日志服务监控审计在现代企业数据管理中扮演着越来越重要的角色。为了满足企业对数据监控审计的需求,日志服务提供了服务日志功能,支持记录Project内的用户操作日志等多种日志数据,并提供多种分析维度的仪表盘。通过这些功能,企业可以实时掌握日志服务的使用状况,提高运维效率。
99 2
日志服务汇总数据指南
本文为您介绍基于SLS推出的ScheduledSQL功能,对历史数据进行汇总压缩,降低使用存储成本。
日志服务汇总数据指南
3.2 日志
在项目开发中,需要经常使用日志存储网站的云心信息,.net core使用日志非常简单。
113 0
SLS日志服务
SLS日志服务。。。。
2155 0
日志
日志
121 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等