]> andersk Git - moira.git/blob - db/report.sh
Used /bin/sh format instead of /bin/csh format, by accident.
[moira.git] / db / report.sh
1 #! /bin/sh
2
3 PATH=/etc:/usr/ucb:/bin:/usr/bin:.:/etc/athena:/bin/athena
4
5 DATADIR=$1
6 TMPDIR=/tmp/report.tmp
7 mkdir ${TMPDIR}
8 cd ${TMPDIR}
9
10 awk -F\| '$8 != 3 {print $10} \
11         ($8==1 || $8==6) && $26=="POP" {pop += 1} \
12         ($8==1 || $8==6) && $26=="SMTP" {smtp += 1} \
13         ($8==1 || $8==6) && $26=="NONE" {nopob += 1} \
14         END {   nopob -= 1; total = pop + smtp + nopob; \
15                 printf("%5d Active users by pobox:\n", total) > "pobox.summary"; \
16                 printf("\t%5d POP boxes\t\t%2d%%\n", pop, (100 * pop + total/2)/total) > "pobox.summary"; \
17                 printf("\t%5d foreign boxes\t%2d%%\n", smtp, (100 * smtp + total/2)/total) > "pobox.summary"; \
18                 printf("\t%5d without boxes\t%2d%%\n", nopob, (100 * nopob + total/2)/total) > "pobox.summary";} \
19 ' < ${DATADIR}/users | sort | uniq -c | sort -r -n > ./users.all
20 awk -F\| '$8==1 {print $10}' < ${DATADIR}/users | sort | uniq -c | sort -r -n > ./users.active
21
22 cat ./users.active ./users.all | awk \
23 '       BEGIN {all=0; lastx=100000;}
24         all==0 && lastx<$1 {all += 1} \
25         all==0 && NF==2 {active[$2]=$1; lastx=$1} \
26         all==1 && NF==2 {printf("\t%-8s %5d  %5d  %3d\n", $2, $1, active[$2], (100 * active[$2] + $1/2)/$1)} \
27 ' | grep -v "%" | sort +2rn | (echo "   class    total active    %"; cat - -) > ./users.summary
28
29 awk '{total+=$2;active+=$3}\
30 END {printf("\t%-8s %5d  %5d\n", "Totals", total, active)}' < ./users.summary > ./users.summary1
31 cat users.summary1 >> users.summary
32
33 awk -F\| ' \
34         NR != 1 {total += 1; active += $3; public += $4; \
35                 hidden += $5; maillist += $6; group += $7;} \
36         END {   printf("%d Lists:\n", total); \
37                 printf("\t%5d active\t%2d%%\n", active, (100 * active)/total); \
38                 printf("\t%5d public\t%2d%%\n", public, (100 * public)/total); \
39                 printf("\t%5d hidden\t%2d%%\n", hidden, (100 * hidden)/total); \
40                 printf("\t%5d maillists\t%2d%%\n", maillist, (100 * maillist)/total); \
41                 printf("\t%5d groups\t%2d%%\n", group, (100 * group)/total);} \
42 ' < ${DATADIR}/list > ./list.summary
43
44 awk '{total+=1}\
45 END {printf("%5d Clusters\n", total)}' < ${DATADIR}/cluster > ./cluster.summary
46
47
48 awk -F\| ' \
49         NR != 1 {total += 1; t[$5] += 1; l[$14] += 1;} \
50         $2!=0   {printf("%s\n",$2) > "filesys.phys" } \
51         END{    printf("%d Filesystems by protocol type:\n", total); \
52                 printf("\t%5d NFS\t%2d%%\n", t["NFS"], (100 * t["NFS"] + total/2)/total); \
53                 printf("\t%5d AFS\t%2d%%\n", t["AFS"], (100 * t["AFS"] + total/2)/total); \
54                 printf("\t%5d RVD\t%2d%%\n", t["RVD"], (100 * t["RVD"] + total/2)/total); \
55                 printf("\t%5d FSGROUP\t%2d%%\n", t["FSGROUP"], (100 * t["FSGROUP"] + total/2)/total); \
56                 printf("\t%5d MUL\t%2d%%\n", t["MUL"], (100 * t["MUL"] + total/2)/total); \
57                 printf("\t%5d ERROR\t%2d%%\n\n", t["ERR"], (100 * t["ERR"] + total/2)/total); \
58                 printf("%d Filesystems by locker type:\n", total); \
59                 printf("\t%5d HOMEDIR\t%2d%%\n", l["HOMEDIR"], (100 * l["HOMEDIR"] + total/2)/total); \
60                 printf("\t%5d SYSTEM\t%2d%%\n", l["SYSTEM"], (100 * l["SYSTEM"])/total); \
61                 printf("\t%5d PROJECT\t%2d%%\n", l["PROJECT"], (100 * l["PROJECT"] + total/2)/total); \
62                 printf("\t%5d COURSE\t%2d%%\n", l["COURSE"], (100 * l["COURSE"])/total); \
63                 printf("\t%5d PERSONAL\t%2d%%\n", l["PERSONAL"], (100 * l["PERSONAL"] + total/2)/total); \
64                 printf("\t%5d ACTIVITY\t%2d%%\n", l["ACTIVITY"], (100 * l["ACTIVITY"] + total/2)/total); \
65                 printf("\t%5d EXTERN\t%2d%%\n", l["EXTERN"], (100 * l["EXTERN"] + total/2)/total); \
66                 printf("\t%5d OTHER\t%2d%%\n", l["OTHER"], (100 * l["OTHER"])/total); \
67  } \
68 ' < ${DATADIR}/filesys > ./filesys.summary
69
70 awk -F\| 'NR!=1 {total += 1; print $3} \
71         END {printf("%5d Machines by type (workstations and servers):\n", total)>"machine.summary"} \
72 '< ${DATADIR}/machine | sort | uniq -c | sort -r -n > machine.types
73 awk '{printf("\t%-8s %4d\n", $2, $1)}' < machine.types >> machine.summary
74
75 sort ./filesys.phys | uniq -c | awk '{printf("%s %s\n", $2, $1)}' > phys.num
76 awk -F\| '{printf("%s %s\n", $2, $1)}' < ${DATADIR}/machine | sort > machine.num
77 sed 's/\|/ /g' < ${DATADIR}/nfsphys | sort | join - phys.num | awk '{printf("%s %s %s %s\n", $2, $4, $6, $12)}' | sort | join - machine.num | awk '$3>0&&$4>0{printf("\t%8d    %4d    %s:%s\n", $3, $4, $5, $2)}' | sort -n -r > phys.usage
78
79 awk -F\| ' \
80         NR != 1 {total += 1; auth += $6} \
81         END {   printf("%5d Printers, %d with authentication (%d%%)\n", \
82                         total, auth, (100 * auth)/total) } \
83 ' < ${DATADIR}/printcap > ./printcap.summary
84
85 echo "                  MOIRA SUMMARY" for `ls -ls ${DATADIR}/values | awk '{printf("%s %s", $6, $7)}'` > ./report.out
86 echo "" >> report.out
87 cat machine.summary >> report.out
88 echo "" >> report.out
89 cat cluster.summary >> report.out
90 echo "" >> report.out
91 cat printcap.summary >> report.out
92 echo "" >> report.out
93 awk '{printf("%5d Users by class (total in database, registered for use, %% registered):\n", $2)}' < users.summary1 >> report.out
94 cat users.summary >> report.out
95 echo "" >> report.out
96 cat pobox.summary >> report.out
97 echo "" >> report.out
98 cat list.summary >> report.out
99 echo "" >> report.out
100 cat filesys.summary >> report.out
101 echo "" >> report.out
102 awk '{total+=1}\
103 END {printf("%5d NFS Physical partitions in use (only those with quota shown):\n", total)}' < ${DATADIR}/nfsphys >> report.out
104 echo '  allocated| no. of | Server and partition' >> report.out
105 echo '    quota  |lockers |' >> report.out
106 cat phys.usage >> report.out
107
108 cp report.out ${DATADIR}/report
109
110 cd /
111 rm -rf ${TMPDIR}
112
113 exit 0
This page took 0.132541 seconds and 5 git commands to generate.