Skip to content
Snippets Groups Projects
Commit 3e5fa98a authored by mcmlxxix's avatar mcmlxxix
Browse files

open file in binary mode :|

/T parameter to list column totals
/R parameter to reverse listing
parent ba18d4c0
Branches
Tags
No related merge requests found
writeln("\r\nSynchronet System/Node Statistics Log Viewer v1.02\n");
var reverse = false;
var pause = false;
while(argv.length > 0) {
switch(argv.shift().toUpperCase()) {
case "/REVERSE":
case "/R":
reverse = true;
break;
case "/PAUSE":
case "/P":
pause = true;
break;
(function() {
writeln("\r\nSynchronet System/Node Statistics Log Viewer v1.02\n");
var sfile = new File(system.ctrl_dir + "csts.dab");
var list = [];
var reverse = false;
var show_totals = false;
var total_logons = 0;
var total_timeon = 0;
var total_uls = 0;
var total_ulb = 0;
var total_dls = 0;
var total_dlb = 0;
var total_posts = 0;
var total_emails = 0;
var total_fbacks = 0;
while(argv.length > 0) {
switch(argv.shift().toUpperCase()) {
case "/REVERSE":
case "/R":
reverse = true;
break;
case "/TOTALS":
case "/T":
show_totals = true;
break;
}
}
}
var sfile = new File(system.ctrl_dir + "csts.dab");
var list = [];
if(!file_exists(sfile.name))
throw(sfile.name + " does not exist");
if(!sfile.open('r+'))
throw("error opening " + sfile.name);
while(sfile.position <= file_size(sfile.name) - 40) {
timestamp = sfile.readBin();
logons = sfile.readBin();
timeon = sfile.readBin();
uls = sfile.readBin();
ulb = sfile.readBin();
dls = sfile.readBin();
dlb = sfile.readBin();
posts = sfile.readBin();
emails = sfile.readBin();
fbacks = sfile.readBin();
yesterday = timestamp-(24*60*60); /* 1 day less than stamp */
list.unshift(
strftime("%x",yesterday) +
format(" T:%5lu L:%3lu P:%3lu E:%3lu F:%3lu U:%6luk %3lu D:%6luk %3lu",
timeon,logons,posts,emails,fbacks,ulb/1024,uls,dlb/1024,dls)
);
}
if(reverse)
list.reverse();
for each(var i in list)
print(i);
sfile.close();
if(!file_exists(sfile.name))
throw(sfile.name + " does not exist");
if(!sfile.open('r+b'))
throw("error opening " + sfile.name);
while(sfile.position <= file_size(sfile.name) - 40) {
var timestamp = sfile.readBin();
var logons = sfile.readBin();
var timeon = sfile.readBin();
var uls = sfile.readBin();
var ulb = sfile.readBin();
var dls = sfile.readBin();
var dlb = sfile.readBin();
var posts = sfile.readBin();
var emails = sfile.readBin();
var fbacks = sfile.readBin();
if(show_totals) {
total_logons += logons;
total_timeon += timeon;
total_uls += uls;
total_ulb += uls;
total_dls += uls;
total_dlb += uls;
total_posts += posts;
total_emails += emails;
total_fbacks += fbacks;
}
list.unshift(
strftime("%x",timestamp-(24*60*60)) +
format(" T:%5lu L:%3lu P:%3lu E:%3lu F:%3lu U:%6luk %3lu D:%6luk %3lu",
timeon,logons,posts,emails,fbacks,ulb/1024,uls,dlb/1024,dls)
);
}
sfile.close();
if(reverse)
list.reverse();
for each(var i in list)
writeln(i);
if(show_totals) {
writeln("");
writeln(format("%-*s: %d",20,"Total Time",total_timeon));
writeln(format("%-*s: %d",20,"Total Logons",total_logons));
writeln(format("%-*s: %d - %dk",20,"Total U/L",total_uls, total_ulb));
writeln(format("%-*s: %d - %dk",20,"Total D/L",total_dls, total_dlb));
writeln(format("%-*s: %d",20,"Total Posts",total_posts));
writeln(format("%-*s: %d",20,"Total E-Mails",total_emails));
writeln(format("%-*s: %d",20,"Total Feedback",total_fbacks));
}
writeln("");
})();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment