#!/bin/sh
vznetstat |grep -v "0 0" > netstat1.txt
sleep 60
vznetstat |grep -v "0 0" > netstat2.txt
cat netstat1.txt | cut -c 1-8 > veid1.txt
cat netstat1.txt | cut -c 20-35 | sed -e 's/\ //g' > input1.txt
cat netstat1.txt | cut -c 54-70 | sed -e 's/\ //g' > output1.txt
cat netstat2.txt | cut -c 20-35 | sed -e 's/\ //g' > input2.txt
cat netstat2.txt | cut -c 54-70 | sed -e 's/\ //g' > output2.txt
./netmake
sh ./output.sh
vnchost# cat netmake.pas
var fin0,fin1,fin2,fin3,fin4,fout:text;
tempstr,tempstr2,tempstr3,tempstr4:string;
veid:string;
begin
assign(fin0,'veid1.txt');
assign(fin1,'input1.txt');
assign(fin2,'input2.txt');
assign(fin3,'output1.txt');
assign(fin4,'output2.txt');
assign(fout,'output.sh');
reset(fin0);
reset(fin1);
reset(fin2);
reset(fin3);
reset(fin4);
rewrite(fout);
writeln(fout,'#!/bin/sh');
while not eof(fin1) do
begin
readln(fin1,tempstr);
readln(fin2,tempstr2);
readln(fin3,tempstr3);
readln(fin4,tempstr4);
readln(fin0,veid);
writeln(fout,'echo "VPS ',veid,'";');
writeln(fout,'echo "Input traffic in kilobytes:"');
writeln(fout,'echo "(',tempstr2,'-',tempstr,')/1024"|bc');
writeln(fout,'echo "Output traffic in kilobytes:"');
writeln(fout,'echo "(',tempstr4,'-',tempstr3,')/1024"|bc');
writeln(fout,'echo ""');
end;
{ for veid:=1 to count do writeln(net1[0,veid], ' ', net2[0,veid]);}
close(fin0);
close(fin1);
close(fin2);
close(fout);
end.
#!/bin/sh vznetstat |grep -v "0 0" > netstat1.txt sleep 60 vznetstat |grep -v "0 0" > netstat2.txt cat netstat1.txt | cut -c 1-8 > veid1.txt cat netstat1.txt | cut -c 20-35 | sed -e 's/\ //g' > input1.txt cat netstat1.txt | cut -c 54-70 | sed -e 's/\ //g' > output1.txt cat netstat2.txt | cut -c 20-35 | sed -e 's/\ //g' > input2.txt cat netstat2.txt | cut -c 54-70 | sed -e 's/\ //g' > output2.txt ./netmake sh ./output.sh
vnchost# cat netmake.pas var fin0,fin1,fin2,fin3,fin4,fout:text; tempstr,tempstr2,tempstr3,tempstr4:string; veid:string; begin assign(fin0,'veid1.txt'); assign(fin1,'input1.txt'); assign(fin2,'input2.txt'); assign(fin3,'output1.txt'); assign(fin4,'output2.txt'); assign(fout,'output.sh'); reset(fin0); reset(fin1); reset(fin2); reset(fin3); reset(fin4); rewrite(fout); writeln(fout,'#!/bin/sh'); while not eof(fin1) do begin readln(fin1,tempstr); readln(fin2,tempstr2); readln(fin3,tempstr3); readln(fin4,tempstr4); readln(fin0,veid); writeln(fout,'echo "VPS ',veid,'";'); writeln(fout,'echo "Input traffic in kilobytes:"'); writeln(fout,'echo "(',tempstr2,'-',tempstr,')/1024"|bc'); writeln(fout,'echo "Output traffic in kilobytes:"'); writeln(fout,'echo "(',tempstr4,'-',tempstr3,')/1024"|bc'); writeln(fout,'echo ""'); end; { for veid:=1 to count do writeln(net1[0,veid], ' ', net2[0,veid]);} close(fin0); close(fin1); close(fin2); close(fout); end.