linux历史记录配置文件,配置文件历史记录

python文件csrf_exempt

def nginxhistory(request):

if request.method == "POST":

ret = request.POST.get('code')

id2 = request.GET['abc']

ret = str(ret)

ret1 = ret.replace('\r','')

ret2 = NginxET.objects.values_list('message', flat=True).get(id=id2)

ret2 = str(ret2)

dir1 = NginxET.objects.values_list('dirname', flat=True).get(id=id2)

file1 = NginxET.objects.values_list('filename', flat=True).get(id=id2)

text1_lines = ret1.splitlines()

text2_lines = ret2.splitlines()

d = difflib.HtmlDiff()

diff = d.make_file(text1_lines,text2_lines)

if text1_lines == text2_lines:

return HttpResponse('配置文件没有更新不需要写入数据库^-^!!!!!!')

else:

date1 = datetime.datetime.now()

date2 = date1 + datetime.timedelta(hours=14)

date = date2.strftime('%Y-%m-%d %H:%M:%S')

NginxEThistory.objects.create(dirname=dir1,filename=file1,message=ret2,onlinetime=date)

NginxET.objects.filter(id=id2).update(message=ret1,updatetime=date)

all_server = NginxET.objects.all()

paginator = Paginator(all_server,20)

try:

page = int(request.GET.get('page','1'))

except ValueError:

page = 1

try:

all_server = paginator.page(page)

except :

all_server = paginator.page(paginator.num_pages)

return render_to_response('nginxet.html',

{'all_host_list': all_server, 'page': page, 'paginator':paginator},context_instance=RequestContext(request))

html文件{% extends "index.html" %}

{% block title %}OMS{% endblock %}

{% block css %}

{% endblock %}

{% block content %}

{% if all_host_list %}

IDIP地址文件名上线时间更新时间

{% for all_host in all_host_list %}

{{ forloop.counter }}{{ all_host.dirname }}{{ all_host.filename }}{{ all_host.onlinetime }}{{ all_host.updatetime }} 内容展示

历史

最近一次更改比较

推送

{% endfor %}

{% endif %}

搜索

历史搜索

{% if all_host_list.has_previous %}

上一页

{% endif %}

第{{ all_host_list.number }}页,共{{ all_host_list.paginator.num_pages }}页

{% if all_host_list.has_next %}

下一页

{% endif %}

 

全部更新

{% endblock %}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以记录常用的linux命令,特别是比较长的,非常有用。使用方法:把该Q可执行文件考备份到linux上,任何目录都行,第一次执行用./q的方式执行,第一次执行之后q程序会被加到系统目录,以后每次执行都可以像使用系统命令一样。例如 1.查看保存过的命令 [root@localhost ~]# q 1_____clear 2_____tar -xzvf 3_____tar -czvf 4_____rpm -ivh 5_____lsnrctl status 6_____lsnrctl start 7_____lsnrctl stop 8_____vi /home/oracle/ora/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 9_____/opt/lampp/lampp start 10_____/opt/lampp/lampp restart 11_____/opt/lampp/lampp stop 2.添加新命令 [root@localhost ~]# q -a "sqlplus /as sysdba" 1_____clear 2_____tar -xzvf 3_____tar -czvf 4_____rpm -ivh 5_____lsnrctl status 6_____lsnrctl start 7_____lsnrctl stop 8_____vi /home/oracle/ora/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 9_____/opt/lampp/lampp start 10_____/opt/lampp/lampp restart 11_____/opt/lampp/lampp stop 12_____sqlplus /as sysdba 3.删除命令 [root@localhost ~]# q -d 12 1_____clear 2_____tar -xzvf 3_____tar -czvf 4_____rpm -ivh 5_____lsnrctl status 6_____lsnrctl start 7_____lsnrctl stop 8_____vi /home/oracle/ora/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 9_____/opt/lampp/lampp start 10_____/opt/lampp/lampp restart 11_____/opt/lampp/lampp stop 4.执行保存过的命令 [root@localhost ~]# q 10 Stopping XAMPP for Linux 1.8.1... XAMPP: Stopping Apache with SSL... XAMPP: Stopping MySQL... XAMPP: XAMPP-ProFTPD is not running. XAMPP stopped.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值