Skip to Content
监控运维实践:原则与策略
book

监控运维实践:原则与策略

by Mike Julian
November 2020
Intermediate to advanced
142 pages
3h 12m
Chinese
Posts & Telecom Press
Content preview from 监控运维实践:原则与策略
88
|
第
8
章
# 当前时间(纪元时间)
current_time=$(date +%s)
# 距离启动开关还有多少时间
timeleft=$((current_time - last_touch))
if
[ $timeleft -gt $TIME_LIMIT ];
then
echo "Dead man's switch activated: job failed!"
fi
这个脚本使用起来也很简单:把代码放入独立的
cron
作业中,每分钟运行一次,然后将之
前的备份作业修改成这样:
run-backup.sh && touch deadman.dat
现在,如果状态文件的修改时间超过一定时长,就会自动触发失能开关。
我必须提醒你,这只是一个初级的实现,还有很大的改进空间,但核心思想没有问题。
好消息是有些托管服务可以做到这一点,而不需要你自己来设计。通过
Google
搜索
cron
作业监控,你会找到很多选项。
8.13
 记录日志
日志可以分成
3
个独立的问题来看待:日志采集、日志存储和日志分析。
8.13.1
 采集
我喜欢将日志的位置分为两组:
syslog
中的日志和其他日志。
如果日志已经由
syslog
守护进程处理,那么只需配置该守护进程来执行将日志转发到另一
个服务器这一操作。请参考
syslog
守护进程文档,了解具体的操作方法。
syslog
转发
:
UDP
与
TCP
关于使用
UDP
还是
TCP
来转发
syslog
,目前还存在争论。从
UDP
方面讲,由于不需
要确认,你可以在服务器崩溃之前发送服务器的“最后一口气” ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java数据科学实战

Java数据科学实战

Michael R. Brzustowicz, PhD
可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115550750