dsastats.dist

来自「ftam等标准协议服务器和客户端的源代码。」· DIST 代码 · 共 1,058 行 · 第 1/2 页

DIST
1,058
字号
#!/bin/sh## next 4 lines configured by make dsastatsLOGFILE="QUIPULOG"TAILORFILE="QUIPUTAILOR"LOCALORG="QUIPULOCALORG"ETCDIR="QUIPUETCDIR"logfile=$LOGFILEsummary="FALSE"noreport="FALSE"savetotals="FALSE"archive="FALSE"grandtot="FALSE"alldsas="FALSE"dsastub="quipu"while [ $# -gt 0 ]do	case $1 in	-s|-summary)		summary="TRUE"; shift;;	-n)		noreport="TRUE"; shift;;	-t)		savetotals="TRUE"; shift;;	-a)		archive="TRUE"; shift;;	-g)		grandtot="TRUE"; shift;		if [ $1 != "" ]; then			dsastub=$1; shift		fi;;	*)		logfile=$1; shift;;	esacdoneif [ ! -r $logfile ]; then	echo "No such file <$logfile>" >&2	exit 1filogdir=`echo $logfile | awk -F/ '{ for (i=1;i < NF;i++) printf "%s/", $i }'`if [ $archive = "TRUE" ]; then        if [ ! -d $logdir/dsastats.arch ];then                mkdir $logdir/dsastats.arch                if [ $? = 0 ]; then                        echo "dsastats.arch directory created"                else                        echo "can't create dsastats.arch directory"			exit 1                fi        fifiif [ $grandtot = "TRUE" ]; then	noreport="FALSE"	savetotals="FALSE"	archive="FALSE"else	echo $logfile | grep -s ".usage"	if [ "$?" = "0" ]; then		dsaname=`basename $logfile .usage`		dsastub=$dsaname	else		dsaname=` grep mydsa $TAILORFILE | \		awk -F@ '{split($NF,parts, "=") 			  print parts[2] }' |sed 's/"//g'`	fifiecho "$LOCALORG" |tr "A-Z" "a-z" >/tmp/dsastats$$.localorg# try and sort out the format of the time into something a bit nicernicetime () {awk ' BEGIN {	montharray[1] = "Jan"	montharray[2] = "Feb"	montharray[3] = "Mar"	montharray[4] = "Apr"	montharray[5] = "May"	montharray[6] = "Jun"	montharray[7] = "Jul"	montharray[8] = "Aug"	montharray[9] = "Sep"	montharray[10] = "Oct"	montharray[11] = "Nov"	montharray[12] = "Dec"}	{			monthno = substr($0, 1, 2) + 0		dayno = substr($0, 4, 2) + 0		time = substr($0, 7, 8)		printf("%s on %02d %s", time, dayno, montharray[monthno])	} '}if [ $grandtot != "TRUE" ]; thenstarttime=`head -1 $logfile | nicetime`endtime=`tail -1 $logfile | nicetime`echo "fordsa $dsaname" >/tmp/dsastats$$.2echo "starts $starttime" >>/tmp/dsastats$$.2echo "ends   $endtime" >>/tmp/dsastats$$.2sed 's/[^)]*)  //' < $logfile | awk ' BEGIN {	gotfirst = "FALSE"}/^(Add|Read|List|Modify|Modifyrdn|Remove|Search|Compare|Getedb) \(.*/	{	split ($2,opids,":")	lastassoc = opids[1]}{	if (gotfirst == "TRUE")	{		split($0, op, ":")		if (op[1] != "DSA control")		{			print saveline			saveline = $0		}		else			saveline = "DSAControl " lastassoc ": " $(NF-1) " " $(NF)	}	else	{		gotfirst = "TRUE"		saveline = $0	}}END {	print saveline} ' >/tmp/dsastats$$.1cat $ETCDIR/quipulocaladds /tmp/dsastats$$.1 | awk 'BEGIN {	nextdsa = 1;	lastcn=0	conns_open["dummy"] = ""	locadd["dummy"] = 0        while (getline > 0)        {		if (substr($0, 1, 1) == "#")			break                no_localadds++                locadd[no_localadds] = $0        }}/^Bind.*/	{	conn_op[$2] = 1	conn [$2 "#" 1] = conn[$2 "#" 1] " " $0	conns_open[$2] = $2}/^(Add|Read|List|Modify|Modifyrdn|Remove|Search|Compare|Getedb|DSAControl) \(.*/	{	split ($2,opids,":")	opid = opids[1]	conn_op[opid]++	split ($0,oper,":")	if (oper[2] == " ") 		conn [opid "#" conn_op[opid]] = $1 " ROOT"	else		conn [opid "#" conn_op[opid]] = $1 oper[2]	lastcn = opid}/^Unbind.*/	{	if (conn[$2 "#" 0] == "") 	{		print conn[$2 "#" 1]		if (chain[$2] == 1)			print "\tChained " chain[$2] " operation"		else			print "\tChained " chain[$2] " operations"	} 	else 	{		print conntype[$2] " " conn[$2 "#" 1]		for ( i=2; i<= conn_op[$2]; i++) 			print "  " conn[$2 "#" i]	}	print ""	conn_op[$2] = 0	conns_open[$2] = ""}/ has started / {	for (j in conns_open)	{		if (conns_open[j] != "")		{			if (conn[j "#" 0] == "") 			{				print conn[j "#" 1]				if (chain[j] == 1)					print "\tChained " chain[j] " operation"				else					print "\tChained " chain[j] " operations"			} 			else 			{				print conntype[j] " " conn[j "#" 1]				for (i = 2; i <= conn_op[j]; i++)					print "  " conn[j "#" i]			}			print ""			conn_op[j] = 0			conns_open[j] = ""		}	}}/^X500 DAP.*/	{	split ($5,opids,":")	opid = opids[1]	conn_op[opid] = 0	split ($0,oper,":")	conn [opid "#" 0] = "from" oper[2]	conn [opid "#" 1] = "DAP"	conntype [opid] = "remote"	y = index($0, ":")	thisadd = substr($0, y+1)	for (z =1 ; z <= no_localadds; z++)		if (substr(thisadd, 2, length(locadd[z])) == locadd[z])		{			conntype [opid] = "local"			break		}}/^QUIPU DSP.*/	{	split ($5,opids,":")	opid = opids[1]	conn_op[opid] = 0	split ($0,oper,":")	conn [opid "#" 0] = "Quipu DSP from" oper[2]	conn [opid "#" 1] = "QuipuDSP"	conntype [opid] = "remote"	y = index($0, ":")	thisadd = substr($0, y+1)	for (z =1 ; z <= no_localadds; z++)		if (substr(thisadd, 2, length(locadd[z])) == locadd[z])		{			conntype [opid] = "local"			break		}}/^X500 DSP.*/	{	split ($5,opids,":")	opid = opids[1]	conn_op[opid] = 0	split ($0,oper,":")	conn [opid "#" 0] = "from" oper[2]	conn [opid "#" 1] = "DSP"	conntype [opid] = "remote"	y = index($0, ":")	thisadd = substr($0, y+1)	for (z =1 ; z <= no_localadds; z++)		if (substr(thisadd, 2, length(locadd[z])) == locadd[z])		{			conntype [opid] = "local"			break		}}/^DAP Originator.*/ {	split ($0,dn,":")	if (dn[2] != " ")		conn [lastcn "#" conn_op[lastcn]] = conn [lastcn "#" conn_op[lastcn]] "\n\tDAP Originator: " dn[2]	else		conn [lastcn "#" conn_op[lastcn]] = conn [lastcn "#" conn_op[lastcn]] "\n\tDAP Originator:  anonymous"}/^Bound.*/ {	split ($6,opids,":")	opid = opids[1]	conn[opid "#" 0] = ""	conn[opid "#" 1] = $0	conn_op[opid] = 1}/^Chain.*/ 	{	chain[opid]++}/^Trying.*/	{	split ($0,dn,":")	if (dsa[dn[2]] == 0) 	{		dsa[dn[2]] = nextdsa		dsadn[nextdsa]=dn[2]		try[nextdsa]++		nextdsa++	} 	else		try[dsa[dn[2]]]++}/^Failed.*/	{	split ($0,dn,":")	fail[dsa[dn[2]]]++}END {	print "Connections: " 	for (i=1; i< nextdsa; i++) 	{		printf "  %-30s: tried %s", dsadn[i], try[i]		if (fail[i] != 0)			print ", failed " fail[i]		else 			print	}} ' >> /tmp/dsastats$$.2fiif [ $grandtot = "TRUE" ]; then	if [ $dsastub = "all" ];then		dsastub='*'		alldsas="TRUE"	fi	inputfiles="$logdir/dsastats.arch/$dsastub.*" 2>/dev/nullelse	readtots="$logdir/$dsastub.stattot"	touch $readtots	inputfiles="$readtots /tmp/dsastats$$.2"ficat /tmp/dsastats$$.localorg $ETCDIR/quiputechusers $inputfiles |tr "A-Z" "a-z" | awk 'BEGIN {	summary = "'$summary'"	noreport = "'$noreport'"	grantot = "'$grandtot'"	savetotals = "'$savetotals'"	alldsas = "'$alldsas'"	if (grantot != "TRUE")		totfile = "'$readtots'"	else		totfile = "/tmp/junk" # seems to help awk along	ua[1] = ""	ua[2] = ""	techies["dummy"] = 0	getline	localorg = $0        while (getline > 0)        {		if (substr($0, 1, 1) == "#")			break                no_techs++                techies[$0] = 0        }	gotdspbind = "FALSE"	originators["dummy"] = 0	usernames["dummy"] = 0	userorgnames["dummy"] = 0	realaccessed["dummy"] = 0	realuse["dummy"] = 0	realbinds["dummy"] = 0	sysaccessed["dummy"] = 0	starttime = ""}/^dsaname/ {	dsaname = substr($0, 9, length($0)-9+1)	next}/^starttime/ {	if (starttime == "")		starttime = substr($0, 11, length($0)-11+1)	next}/^endtime/ {	endtime = substr($0, 9, length($0)-9+1)	next}/^localanon/ {	localanon += substr($0, 11, length($0)-11+1)	next}/^remoteanon/ {	remoteanon += substr($0, 12, length($0)-12+1)	next}/^localnoauthdap/ {	localnoauthdap += substr($0, 16, length($0)-16+1)	next}/^remotenoauthdap/ {	remotenoauthdap += substr($0, 17, length($0)-17+1)	next}/^localnoauthdsp/ {	localnoauthdsp += substr($0, 16, length($0)-16+1)	next}/^remotenoauthdsp/ {	remotenoauthdsp += substr($0, 17, length($0)-17+1)	next}/^localsimple/ {	localsimple += substr($0, 13, length($0)-13+1)	next}/^remotesimple/ {	remotesimple += substr($0, 14, length($0)-14+1)	next}/^localprotected/ {	localprotected += substr($0, 16, length($0)-16+1)	next}/^remoteprotected/ {	remoteprotected += substr($0, 17, length($0)-17+1)	next}/^lreadops/ {	lreadops += substr($0, 10, length($0)-10+1)	next}/^rreadops/ {	rreadops += substr($0, 10, length($0)-10+1)	next}/^lcompareops/ {	lcompareops +=substr($0, 13, length($0)-13+1)	next}/^rcompareops/ {	rcompareops +=substr($0, 13, length($0)-13+1)	next}/^llistops/ {	llistops += substr($0, 10, length($0)-10+1)	next}/^rlistops/ {	rlistops += substr($0, 10, length($0)-10+1)	next}/^lsearchops/ {	lsearchops += substr($0, 12, length($0)-12+1)	next}/^rsearchops/ {	rsearchops += substr($0, 12, length($0)-12+1)	next}/^lmodifyops/ {	lmodifyops += substr($0, 12, length($0)-12+1)	next}/^rmodifyops/ {	rmodifyops += substr($0, 12, length($0)-12+1)	next}/^lmodifyrdnops/ {	lmodifyrdnops += substr($0, 15, length($0)-15+1)	next}/^rmodifyrdnops/ {	rmodifyrdnops += substr($0, 15, length($0)-15+1)	next}/^laddops/ {	laddops += substr($0, 9, length($0)-9+1)	next}/^raddops/ {	raddops += substr($0, 9, length($0)-9+1)	next}/^getedbs/ {	getedb += substr($0, 8, length($0)-8+1)	next}/^techbinds/ {	techbinds += substr($0, 11, length($0)-11+1)	next}/^dsaread/ {	dsaread += substr($0, 9, length($0)-9+1)	next}/^dsaother/ {	dsaother += substr($0, 10, length($0)-10+1)	next}/^spotshadows/ {	spotshadows += substr($0, 13, length($0)-13+1)	next}/^usernames/ {	tmp = substr($0, 11, length($0)-11+1)	n = split(tmp, ta, ":")	usernames[ta[1]] += ta[2]	next}/^sysaccessed/ {	tmp = substr($0, 13, length($0)-13+1)	n = split(tmp, ta, ":")	sysaccessed[ta[1]] += ta[2]	next}/^realaccessed/ {	tmp = substr($0, 14, length($0)-14+1)	n = split(tmp, ta, ":")	realaccessed[ta[1]] += ta[2]	next}	/^fordsa/ {	dsaname = substr($0, 8, length($0)-8+1)}/^starts/ {	if (starttime == "")		starttime = substr($0, 8, 40)}/^ends/ {	endtime = substr($0, 8, 40)}# add any originators from last DSP connection examined to usernames array/ bind/ {	if (gotdspbind == "TRUE")		for (origuser in originators)			if (originators[origuser] != 0)			{				usernames[origuser]++				if (origuser == "anonymous")					if (remote == "TRUE")						remoteanon++					else						localanon++

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?