linux上c语言 获得网络接口的统计值
这个东东,蛮好玩的。其实就是读取了/proc/net/dev 文件。
struct netdev_stats {
unsigned long long rx_packets_m; /* total packets received */
unsigned long long tx_packets_m; /* total packets transmitted */
unsigned long long rx_bytes_m; /* total bytes received */
unsigned long long tx_bytes_m; /* total bytes transmitted */
unsigned long rx_errors_m; /* bad packets received */
unsigned long tx_errors_m; /* packet transmit problems */
unsigned long rx_dropped_m; /* no space in linux buffers */
unsigned long tx_dropped_m; /* no space available in linux */
unsigned long rx_multicast_m; /* multicast packets received */
unsigned long rx_compressed_m;
unsigned long tx_compressed_m;
unsigned long collisions_m;
/* detailed rx_errors: */
unsigned long rx_length_errors_m;
unsigned long rx_over_errors_m; /* receiver ring buff overflow */
unsigned long rx_crc_errors_m; /* recved pkt with crc error */
unsigned long rx_frame_errors_m; /* recv'd frame alignment error */
unsigned long rx_fifo_errors_m; /* recv'r fifo overrun */
unsigned long rx_missed_errors_m;&nb
相关文档:
进程在操作系统中都有一个户口,用于表示这个进程。这个户口操作系统被称为PCB(进程控制块),在linux中具体实现是
task_struct数据结构,它记录了一下几个类型的信息:
1.状态信息,例如这个进程处于可执行状态,休眠,挂起等。
2.性质,由于unix有很多变种,进程有自己独特的性质。
3.资源,资源的链接比如内存, ......
#!/bin/bash
cpu=`top -b -n 1 | grep -w Cpu | awk '{print$5}'| awk -F '%' '{printf"%d",$1}'`
if [ $cpu -le 50 ]
then
echo "cpu: $((100 - cpu))%" > test.txt
mail -s "服务器紧急, CPU占用率过高!" yourmail@domail.com < test.txt
fi
mem=`top -b -n 1 | grep -w Me ......
第一部分:Linux基础应用
1、《Linux从入门到精通》
http://www.gouhuo.com/study/linuxbook.zip
2、 Linux 系统安全与优化中文版
这本书的英文版“Get Acquainted with Linux Security and Optimization System”(简称LinuxSOS)是Linux文档计划(Linux Document Project)中比较新的一本指南。这本书不是L ......
2009年12月28日是Linux创始人Linus的40岁生日。
19年前,在圣诞节后赫尔辛基商店开业的第一天,Linus冲向电脑商店,用圣诞节和生日礼金购买了他的第一台PC:一台DX33 80386计算机,4 Megs RAM,40 Megabyte硬盘,没有协同处理器。Linus之所以选择80386,而 ......