Linux?????????????????
???????????? ???????[ 2015/5/18 13:38:54 ] ??????????????
????CPU??????
????/proc/stat??????????cpu????????2-8?ж????CPU?????????????????(user)??????nice????(nice)??????????(sys)?????????(idle)?????IO????(iowait)??????ж?????(hardirq)?????ж?????(softirq)????man proc??
????$ cat /proc/stat
????cpu 2339504870 2641995 716723851 70316975284 7219566 328971 304057999 0 0
????cpu0 211214357 275710 57674236 2778331292 3688175 10421 12279511 0 0
????cpu1 140100049 278788 47142039 2857686940 180452 32028 14960093 0 0
????...
?????????t1~t2?????????cpu????????????t1??t2???????cpu??????
????t1_all = t1(user + nice + sys + idle + iowait + hardirq + sortirq)
????t1_used = t1(user + nice + sys + iowait + hardirq + sortirq)
????t2_all = t2(user + nice + sys + idle + iowait + hardirq + sortirq
????t2_used = t2(user + nice + sys + iowait + hardirq + sortirq)
????cpu_usage = (t2_used - t1_used) / (t2_all - t1_all)
????????CPU??????
????/proc/$pid/stat????????????????cpu????????14??15??16??17?ж??????????????(user)??????????(sys)???????????????????(user_child)???????????????????(sys_child)??
????$cat /proc/24076/stat
????24076 (redis-server) S 1 24076 24076 0 -1 4202560 5755 147 0 0 1864 3298 0 0 20 0 3 0 70238536 159555584 5145 18446744073709551615 1 1 0 0 0 0 0 4097 17610 18446744073709551615 0 0 17 4 0 0 0 0 0
????t1??t2???????/proc/stat??/proc/$pid/stat????????cpu?????????????cpu????
????t1_all = t1(user + nice + sys + idle + iowait + hardirq + sortirq)
????t1_pid = t1(user + sys + user_child + sys_child)
????t2_all = t2(user + nice + sys + idle + iowait + hardirq + sortirq)
????t2_pid = t2(user + sys + user_child + sys_child)
????pid_cpu_usage = (t2_pid - t1_pid) / (t2_all - t1_all)
?????????????
????/proc/meminfo???????????????????
????$ cat /proc/meminfo
????MemTotal: 198450624 kB
????MemFree: 184950332 kB
????mem_usage = 1 - MemFree / MemTotal
??????load
????/proc/uptime???3?а??????1min??5min??15min???????load?????????л???IO?????????????state?R??D??
????$cat /proc/loadavg
????0.02 0.09 0.08 1/2362 855
???????????????
????/proc/net/dev?????????????????????????1??2??10??11?з???????????????????????recv_bytes?????????????(recv_packets)???????????(send_bytes)?????????(send_packets)??
????$cat /proc/net/dev
????Inter-| Receive | Transmit
????face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
????lo:25047448261 37947893 0 0 0 0 0 0 25047448261 37947893 0 0 0 0 0 0
????eth0:2566932970457 7620547348 0 0 2 0 0 62732 728662220296 6145797287 0 0 0 0 0 0
????eth1:2023304550582 7268848253 0 0 0 0 0 77924 742443231982 6129090809 0 0 0 0 0 0
????t1~t2??????????????
????avg_recv_bytes = (t2_recv_bytes - t1_recv_bytes) / (t2 - t1)
????avg_send_bytes = (t2_send_bytes - t1_send_bytes) / (t2 - t1)
??????????????????????
???????statfs???????????????????????????
????struct statfs {
????long f_type; /* type of file system (see below) /
????long f_bsize; / optimal transfer block size /
????long f_blocks; / total data blocks in file system /
????long f_bfree; / free blocks in fs /
????long f_bavail; / free blocks avail to non-superuser */
????...
????};
????disk_usage = 1 - f_bfree / f_blocks
?????????д???
????/proc/diskstats?????????IO???????4??6??8??10??13?з???????????????(read)?????????????(read_sec)??????д????(write)??????д??????(write_sec)??????IO??????(io_ms)??
????$cat /proc/diskstats
????8 4 sda4 3 0 12 8 0 0 0 0 0 8 8
????8 5 sda5 87928 55284 2842138 17349 1230958 7932106 73380432 4931382 0 503343 4947504
????8 16 sdb 393 35 3418 37 17 2 152 0 0 37 37
????8 32 sdc 788 114 10690 10132 14550036 226568635 1929026928 623148463 0 4917530 623154797
????t1~t2?????????????д??????????????IO?????????????
????avg_read = (t2_read - t1_read) / (t2 - t1)
????avg_read_sec = (t2_read_sec - t1_read_sec) / (t2 - t1)
????avg_write = (t2_write - t1_write) / (t2 - t1)
????avg_write_sec = (t2_write_sec - t1_write_sec) / (t2 - t1)
????io_util = (t2_io_ms - t1_io_ms) / (t2 - t1) (t1~t2??????IO?????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11