...
 
Commits (1)
......@@ -66,7 +66,7 @@
uifcapi_t uifc; /* User Interface (UIFC) Library API */
const char *YesStr="Yes";
const char *NoStr="No";
char* app_title = "Synchronet UNIX Monitor v" VERSION " " PLATFORM_DESC;
char app_title[128];
int ciolib_mode=CIOLIB_MODE_AUTO;
int lprintf(char *fmt, ...)
......@@ -323,10 +323,12 @@ int drawstats(scfg_t *cfg, int nodenum, node_t *node, int *curp, int *barp) {
stats_t nstats;
char statbuf[6*78]; /* Buffer to hold the stats for passing to uifc.showbuf() */
char str[4][4][12];
char heading[128];
char usrname[128];
char tmp[128];
ulong free;
uint i,l,m;
time_t t;
time_t t, now;
int shownode=1;
if(getnodedat(cfg,nodenum,node,FALSE,NULL)) {
......@@ -338,16 +340,25 @@ int drawstats(scfg_t *cfg, int nodenum, node_t *node, int *curp, int *barp) {
username(cfg,node->useron,usrname);
getstats(cfg, 0, &sstats);
t=time(NULL);
strftime(str[0][0],12,"%b %e",localtime(&t));
free=getfreediskspace(cfg->data_dir,1024);
if(free<1000) {
free=getfreediskspace(cfg->data_dir,0);
getsizestr(str[0][1],free,TRUE);
}
else
getsizestr(str[0][1],free,FALSE);
now = time(NULL);
if(shownode) {
static client_t client;
time_t hangup = now;
getnodeclient(cfg, nodenum, &client, &hangup);
t = client.time ? client.time : now;
if(node->status != NODE_WFC && node->status != NODE_OFFLINE)
safe_snprintf(heading, sizeof(heading), "`Node #`%-3d %s `%s`: %s"
,nodenum
,sectostr(now - t, tmp)
,client.protocol
,client.addr);
else
safe_snprintf(heading, sizeof(heading), "`Node #`%-3d %s `%s`: %s `on` %.12s"
,nodenum
,sectostr(hangup - t, tmp)
,client.protocol
,client.addr
,ctime(&hangup) + 4);
snprintf(str[1][0],12,"%s/%s",getnumstr(str[3][2],nstats.ltoday),getnumstr(str[3][3],sstats.ltoday));
getnumstr(str[1][1],sstats.logons);
snprintf(str[1][2],12,"%s/%s",getnumstr(str[3][2],nstats.ttoday),getnumstr(str[3][3],sstats.ttoday));
......@@ -367,6 +378,14 @@ int drawstats(scfg_t *cfg, int nodenum, node_t *node, int *curp, int *barp) {
getnumstr(str[3][3],sstats.dls);
}
else {
free=getfreediskspace(cfg->data_dir,1024);
if(free<1000) {
free=getfreediskspace(cfg->data_dir,0);
getsizestr(str[0][0],free,TRUE);
}
else
getsizestr(str[0][0],free,FALSE);
sprintf(heading, "`Space`: %s `in` %s", str[0][0], cfg->data_dir);
snprintf(str[1][0],12,"%s",getnumstr(str[3][3],sstats.ltoday));
getnumstr(str[1][1],sstats.logons);
snprintf(str[1][2],12,"%s",getnumstr(str[3][3],sstats.ttoday));
......@@ -385,11 +404,11 @@ int drawstats(scfg_t *cfg, int nodenum, node_t *node, int *curp, int *barp) {
getsizestr(str[3][2],sstats.dlb,TRUE);
getnumstr(str[3][3],sstats.dls);
}
snprintf(statbuf,sizeof(statbuf),"`Node #`: %-3d %6s `Space`: %s"
snprintf(statbuf,sizeof(statbuf),"%s"
"\n`Logons`: %-11s `Total`: %-11s `Timeon`: %-11s `Total`: %-11s"
"\n`Emails`: %-11s `Posts`: %-11s `Fbacks`: %-11s `Users`: %-11s"
"\n`Uloads`: %-11s `Files`: %-11s `Dloads`: %-11s `Files`: %-11s",
nodenum,str[0][0],str[0][1],
heading,
str[1][0],str[1][1],str[1][2],str[1][3],
str[2][0],str[2][1],str[2][2],str[2][3],
str[3][0],str[3][1],str[3][2],str[3][3]);
......@@ -823,6 +842,8 @@ int main(int argc, char** argv) {
time_t last_semfile_check = time(NULL);
int idle_sleep=100;
SAFEPRINTF2(app_title, "Synchronet UNIX Monitor v%s%c", VERSION, REVISION);
/******************/
/* Ini file stuff */
/******************/
......