summaryrefslogtreecommitdiffstats
path: root/cacheserver
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-23 01:58:33 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2006-03-23 01:58:33 +0800
commit8f19c634c937b71e67d3b5a580091882a02bf6cb (patch)
treeef6eebff3ce56a164c18db0983572f5810b5cb97 /cacheserver
parent3e47888f1f7a32ac83c3421375c31c3d4560d308 (diff)
downloadpttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.tar
pttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.tar.gz
pttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.tar.bz2
pttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.tar.lz
pttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.tar.xz
pttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.tar.zst
pttbbs-8f19c634c937b71e67d3b5a580091882a02bf6cb.zip
show statistics for utmpserver2.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3296 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'cacheserver')
-rw-r--r--cacheserver/utmpserver2.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/cacheserver/utmpserver2.c b/cacheserver/utmpserver2.c
index 96ac7304..c38855f9 100644
--- a/cacheserver/utmpserver2.c
+++ b/cacheserver/utmpserver2.c
@@ -13,6 +13,9 @@ FILE *fp;
FILE *logfp;
#endif
+clock_t begin_clock;
+time_t begin_time;
+int count_flooding, count_login;
#ifdef NOFLOODING
#define MAXWAIT 1024
@@ -132,6 +135,25 @@ void processlogin(int cfd, int uid, int index)
#endif
}
+void showstat(void)
+{
+ clock_t now_clock=clock();
+ time_t now_time=time(0);
+
+ time_t used_time=now_time-begin_time;
+ clock_t used_clock=now_clock-begin_clock;
+
+ printf("%.24s : real %.0f cpu %.2f : %d login %d flood, %.2f login/sec, %.2f%% load.\n",
+ ctime(&now_time), (double)used_time, (double)used_clock/CLOCKS_PER_SEC,
+ count_login, count_flooding,
+ (double)count_login/used_time, (double)used_clock/CLOCKS_PER_SEC/used_time*100);
+
+ begin_time=now_time;
+ begin_clock=now_clock;
+ count_login=0;
+ count_flooding=0;
+}
+
int main(int argc, char *argv[])
{
struct sockaddr_in clientaddr;
@@ -224,6 +246,7 @@ int main(int argc, char *argv[])
if( (time(NULL) - flooding[uid].lasttime) < 20 )
++flooding[uid].count;
if( flooding[uid].count > 10 ){
+ count_flooding++;
if( nWaits == MAXWAIT )
flushwaitqueue();
waitqueue[nWaits].uid = uid;
@@ -236,7 +259,10 @@ int main(int argc, char *argv[])
flooding[uid].lasttime = time(NULL);
#endif
+ count_login++;
processlogin(cfd, uid, index);
+ if(count_login>=4000 || time(NULL)-begin_time>30*60)
+ showstat();
#ifndef FAKEDATA
close(cfd);
#endif