uptime

服务器“异常”的几个可能性预警

喜夏-厌秋 提交于 2019-12-05 11:06:32
提到服务器宕机检测,大家会想到,宕机能够很快知道,这个有什么可做的?实际上,很多时候服务器宕机,并不总是被及时感知。服务器宕机,ping或者ssh这是最简单的做法,但真正的工程实践,没这么简单。 想要获知服务器宕机怎么办?可以通过服务器宕机实时检测: 1)发现宕机。 2)提前告警。 3)告知宕机的详细原因,如硬件故障,内核bug,网络异常等等。 4)自动报修生成工单。 我们知道,进行全网物理机宕机准确探测与实时发现,可以给宕机分析提供第一现场,获取第一现场的日志。也可以尽早将宕机数据推送给业务或运营感知并处理,如自动报修,业务迁移等,从而尽可能将业务影响降到最低。 更重要的是,准确的宕机发现数据可以为宕机预测提供准确的标注数据,为后期宕机预测提供数据基础,并且这些数据提供给运营部门进行整体分析,提升处理效率。 那么,如何可以准确发现宕机,减少误报呢?我们可以有以下操作,比如: 心跳源检测异常 顾名思义,通过心跳源,初步发现异常。通常心跳变化会有三类消息,update消息,delete消息和insert消息。心跳逻辑在于,正常情况下SA服务端与NC建立长连接,每数秒缓存一次心跳,每几分钟打包上报一次,但当NC异常时,长连接感知后,立即上报异常,并修改路由表。所以心跳异常做到秒级感知。 update消息,在有心跳发生变化情况下都会有,心跳异常和心跳恢复正常时都会发起,是主要的心跳来源。

Linux 系统信息查询大全

十年热恋 提交于 2019-12-05 01:53:50
Linux常用系统命令 # uname -a # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # 查看CPU信息 # hostname # 查看计算机名 # lspci -tv # 列出所有PCI设备 # lsusb -tv # 列出所有USB设备 # lsmod # 列出加载的内核模块 # env # 查看环境变量资源 # free -m # 查看内存使用量和交换区使用量 # df -h # 查看各分区使用情况 # du -sh <目录名> # 查看指定目录的大小 # grep MemTotal /proc/meminfo # 查看内存总量 # grep MemFree /proc/meminfo # 查看空闲内存量 # uptime # 查看系统运行时间、用户数、负载 # cat /proc/loadavg # 查看系统负载磁盘和分区 # mount | column -t # 查看挂接的分区状态 # fdisk -l # 查看所有分区 # swapon -s # 查看所有交换分区 # hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备) # dmesg | grep IDE # 查看启动时IDE设备检测状况网络 # ifconfig #

Uptime iOS Objective-C - millisecond precision

懵懂的女人 提交于 2019-12-05 00:56:58
问题 I'm trying to get uptime for iOS. I was using mach_absolute_time - but I found that it paused during sleep. I found this snippet: - (time_t)uptime { struct timeval boottime; int mib[2] = {CTL_KERN, KERN_BOOTTIME}; size_t size = sizeof(boottime); time_t now; time_t uptime = -1; (void)time(&now); if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { uptime = now - boottime.tv_sec; } return uptime; } It does the trick. BUT, it's returning whole seconds. Any way to get

How do I know if a system has powered on?

荒凉一梦 提交于 2019-12-04 22:00:55
问题 I am writing a script that powers on a system via network. And then i need to run a few commands on the other host. How do I know whether the system has powered on? My programming language is Perl and the target host is RHEL5. Is there any kernel interrupt or network boot information that indicates the system has powered on and the os has loaded? [In a different scenario] I was also wondering just in case if i just switch on my Machine manually. when is it exactly said to have powered on. and

Cmd/PowerShell/SQL server: Is there any way to see how long a windows service has been running?

三世轮回 提交于 2019-12-04 20:13:57
So I managed to check if a sevice is running with sc query "ServiceName" | find "RUNNING" or net start | find "Service Name", or in SQL Server using xp_servicecontrol. Is there any way to see the uptime of a service? How can I see the uptime of a service? As long as your service has it's own process name, this should work. PowerShell_v4> (Get-Process lync).StartTime Friday, October 17, 2014 11:46:04 If you're running under svchost.exe, i think you need to grab that from Event Log. PowerShell_v4> (Get-WinEvent -LogName System | ? Message -match 'DHCPv6 client service is started' | select -First

iOS后台倒计时

笑着哭i 提交于 2019-12-04 16:44:50
场景 我们经常遇到这样的场景,比如电商类App到零点的时候开始抢购,比如商品限购倒计时等等。这种场景下需要我们将客户端的时间与服务器保持一致,最重要的是,要防止用户通过断网修改系统时间,来影响客户端的逻辑。下面是我个人的分析和实现步骤,只为了帮助有同样需求的人,知识有限,欢迎大神们补充。 如果不想看分析的同学,可以直接调到 “奉上代码” 处查看具体实现。 分析 研究之前,对京东做了一下抓包,数据如下 京东抓包秒杀数据 12345 "miaoshaInfo": { "title": "京东秒杀", "miaoshaRemainTime": "79836", "miaosha": true }, 数据中可以看出,京东秒杀商品返回了秒杀剩余的时间。通过进入后台,再次进入前台,以及断网修改时间的尝试,发现并不影响倒计时的运行。 仿“京东秒杀”实现思路 1、程序进入后台时计时器不停止,这种做法网上有较多案例。例如: iOS 后台完成倒计时的功能 这种方案简书里面就有很多,有兴趣的同学可以在搜索一下。对于这种方案,我个人觉得有一定的审核风险,并没有使用。 2、在程序进入后台和进入前台时分别记录时间,程序进入前台获得时间差 IntervalTime,然后在定时器响应的时候获得正确的剩余时间(miaoshaRemainTime - IntervalTime)。我用的是这个方案,不过这个方案有个缺点

/proc/uptime in Mac OS X

六眼飞鱼酱① 提交于 2019-12-04 11:17:19
问题 I need the EXACT same output as Linux's "cat /proc/uptime". For example, with /proc/uptime, you'd get 1884371.64 38646169.12 but with any Mac alternative, like "uptime", you'd get 20:25 up 20:26, 6 users, load averages: 3.19 2.82 2.76 I need it to be exactly like cat /proc/uptime, but on Mac OS X. 回答1: Got it... $sysctl -n kern.boottime | cut -c14-18 87988 Then I just converted that to readable format (don't remember how): 1 Days 00:26:28 回答2: There simply is no "/proc" directory on the

【linux】linux命令--uptime查看机器存活多久和平均负载 解读平均负载含义

丶灬走出姿态 提交于 2019-12-04 07:03:47
一.uptime命令,查看机器存活时间和平均负载 键入命令: uptime 该结果和 top命令查看结果最上面一行的 是一样的显示。 返回数据介绍: #当前服务器时间: 19:56:44 #当前服务器运行时长 up 22 days, 8:54 #当前用户数 10 users #当前的负载均衡 load average: 0.07, 0.11, 0.11,分别取最近1分钟,5分钟,15分钟的平均负载 二.查看平均负载和【正在运行进程数量/总进程数量】 键入命令: cat /proc/loadavg 返回的数据介绍: 前3个数字表示平均进程数量外,后面的1个分数,分母表示系统进程总数,分子表示正在运行的进程数;最后一个数字表示最近运行的进程ID 三.平均负载、可运行状态的进程、不可中断状态的进程 到这里,理解一个概念 【平均负载】/【平均进程数量】 1.平均负载 简单来说,平均负载是指单位时间内,系统处于可运行状态和不可中断状态的平均进程数,也就是平均活跃进程数,它和 CPU 使用率并没有直接关系。 2.可运行状态的进程 所谓可运行状态的进程,是指正在使用 CPU 或者正在等待 CPU 或者正在等待 CPU 的进程,也就是我们常用 ps 命令看到的,处于 R 状态(Running 或 Runnable)的进程。 3.不可中断状态的进程 不可中断状态的进程则是正处于内核态关键流程中的进程

使用 supervisor 管理进程遇到的问题

ぐ巨炮叔叔 提交于 2019-12-03 18:12:03
# supervisorctl status unix:///var/tmp/supervisor.sock refused connection # supervisord -c /etc/supervisord.conf Error: could not find config file /etc/supervisor/supervisord.conf For help, use /usr/bin/supervisord -h # whereis supervisord.conf supervisord: /usr/bin/supervisord /etc/supervisord.conf /etc/supervisord # supervisord -c /etc/supervisord.conf Unlinking stale socket /var/tmp/supervisor.sock # unlink /tmp/supervisor.sock unlink: cannot unlink `/tmp/supervisor.sock’: No such file or directory # unlink /var/tmp/supervisor.sock # supervisorctl status unix:///var/tmp/supervisor.sock no

How do I know if a system has powered on?

☆樱花仙子☆ 提交于 2019-12-03 13:06:33
I am writing a script that powers on a system via network. And then i need to run a few commands on the other host. How do I know whether the system has powered on? My programming language is Perl and the target host is RHEL5. Is there any kernel interrupt or network boot information that indicates the system has powered on and the os has loaded? [In a different scenario] I was also wondering just in case if i just switch on my Machine manually. when is it exactly said to have powered on. and when is the OS is supposed to have booted completely for a network related operation such as executing