Another take on /proc statistics (joke of the day)
I thought this amusing. Take the following program, designed to suck stats out of /proc for the network devices: #include #include #include main() { char stuff[4096]; int fd = open("/proc/net/dev", 0); while(1) { int amount = read(fd, stuff, sizeof(stuff)); if (amount > 0) write(1, stuff, amount); sleep(1); lseek(fd, (off_t) 0, SEEK_SET); } } Run this on linux, and you'll get the same values for all the stats. how to make it work right? #include #include #include main() { char stuff[4096]; while(1) { int fd = open("/proc/net/dev", 0); int amount; amount = read(fd, stuff, sizeof(stuff)); if (amount > 0) write(1, stuff, amount); close(fd); sleep(1); } } What are the implications of this? Well, if you have an rstatd that uses /proc for statistics, it will have to (for every request) open the status files, read them, and close them. Net result: very very poor performance for an rstatd (not even counting the fact that the rstatd has to parse formatted output back to a binary format ...) ron p.s. the rstatd I have for redhat does indeed read stats out of /proc ... To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message
Another take on /proc statistics (joke of the day)
I thought this amusing. Take the following program, designed to suck stats out of /proc for the network devices: #include #include #include main() { char stuff[4096]; int fd = open("/proc/net/dev", 0); while(1) { int amount = read(fd, stuff, sizeof(stuff)); if (amount > 0) write(1, stuff, amount); sleep(1); lseek(fd, (off_t) 0, SEEK_SET); } } Run this on linux, and you'll get the same values for all the stats. how to make it work right? #include #include #include main() { char stuff[4096]; while(1) { int fd = open("/proc/net/dev", 0); int amount; amount = read(fd, stuff, sizeof(stuff)); if (amount > 0) write(1, stuff, amount); close(fd); sleep(1); } } What are the implications of this? Well, if you have an rstatd that uses /proc for statistics, it will have to (for every request) open the status files, read them, and close them. Net result: very very poor performance for an rstatd (not even counting the fact that the rstatd has to parse formatted output back to a binary format ...) ron p.s. the rstatd I have for redhat does indeed read stats out of /proc ... To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message