Darren, I appreciate the fact that you wrote a script in 15 min. Do you expect our end users each to write a script or a program and be well versed in sheel/awk to get the basic information they want i.e. cumulative stats and the rate of change? I think we really need to make it easy for people to get that info.
I like Jim's suggestion of putting the functionality in a library so other sub commands can use it as well. It doesn't need to be a standalone library if all we have is few things. But keep these separate (at least in source files) so later if they need to be pulled into one library, it will be easy. Cheers, Sunay Darren Reed wrote: > James Carlson wrote: >> Darren Reed writes: >>> When I've had an Internet connection via an ISP that >>> meters traffic (you have a 'quota' of x gb/month), >>> I've run a cron job on the end-of-month day to dump >>> out the output from ipfstat and clear the counters >>> back to 0. Thus at any time during the month, using >>> ipfstat gives me a reasonable approximation of the >>> current quota use. >> >> I think it'd be nice if that cron job didn't have to run with >> privileges sufficient to write to the kernel. >> >> I agree that the delta tool doesn't necessarily have to be part of >> dlstat itself. Perhaps if it were made a common library (along with >> the rest of the column-formatting stuff that Brussels cleaned up), >> that would address most of the concerns. > > A C library? > > To me that seems like making a mountain out of a mole hill... > > 15 minutes and I came up with a perl script to print out what > has changed between two dumps of netstat output - and that's > just a very basic script. > > How long would it take to write in C? Substantially longer > because you've got to go through all sorts of hoops to handle > text input safely. For those that don't like perl, well, use > python or your other favourite scripting langauge. > > Darren > > ./statdiff netstat st.1 st.2 > tcpInAckBytes 308 > ipInReceives 6 > ipOutRequests 5 > tcpOutDataSegs 5 > tcpOutDataBytes 308 > tcpOutSegs 5 > tcpRttUpdate 4 > tcpInInorderSegs 4 > ipInDelivers 6 > tcpInAckSegs 4 > tcpInSegs 6 > tcpInInorderBytes 208 > > > #!/bin/perl > > if ($#ARGV ne 2) { > print STDERR "Usaage: <format> <file1> <file2>\n"; > exit(1); > } > > if ($ARGV[0] == "netstat") { > %fdata1 = (); > open(F, "<$ARGV[1]"); > &netstatfile(\%fdata1); > close(F); > %fdata2 = (); > open(F, "<$ARGV[2]"); > &netstatfile(\%fdata2); > close(F); > > } > > foreach $k (keys %fdata1) { > if ($fdata1{$k} ne $fdata2{$k}) { > print "$k\t".int($fdata2{$k} - $fdata1{$k})."\n"; > } > } > > exit(0); > > sub netstatfile { > while (<F>) { > chop; > if (/^(\S+)/i) { > s/^$1//; > } > if (/=/) { > while (/\s+/) { > s/\s+//; > } > if (/^([a-z]+)=(\d+)/i) { > $_[0]{$1} = $2; > s/$1=$2//; > } > if (/^([a-z]+)=(\d+)/i) { > $_[0]{$1} = $2; > s/$1=$2//; > } > } > } > } > > _______________________________________________ > crossbow-discuss mailing list > crossbow-discuss at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/crossbow-discuss -- Sunay Tripathi Distinguished Engineer Solaris Core Operating System Sun MicroSystems Inc. Solaris Networking: http://www.opensolaris.org/os/community/networking Project Crossbow: http://www.opensolaris.org/os/project/crossbow