]>
Commit | Line | Data |
---|---|---|
6ce88475 | 1 | #!/moira/bin/perl |
7c9fee00 | 2 | # $Header$ |
6ce88475 | 3 | |
c8130e9e | 4 | chdir($ARGV[0]); |
6ce88475 | 5 | |
6 | ($sec, $min, $hour, $mday, $month) = localtime($^T); | |
7 | @MONTHS = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
8 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); | |
9 | printf("\t\t\tMOIRA SUMMARY for %s %d\n\n", $MONTHS[$month], $mday); | |
10 | ||
11 | open(MACHINES, "machine") || die "Cannot open machine file for input.\n"; | |
12 | ||
13 | $total = 0; | |
14 | ||
15 | while (<MACHINES>) { | |
7c9fee00 | 16 | split(/\|/, $_, 4); |
6ce88475 | 17 | $TYPES{$_[2]}++; |
18 | $total++; | |
19 | } | |
20 | ||
21 | close(MACHINES); | |
22 | delete $TYPES{"NONE"}; | |
23 | ||
7c9fee00 | 24 | printf("%5d Machines by type (both workstations & servers):\n", $total); |
6ce88475 | 25 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $TYPES{$_}, $_, (100 * $TYPES{$_} + $total/2)/$total)), keys(%TYPES)); |
26 | print reverse sort(@values); | |
27 | print "\n"; | |
28 | undef %TYPES; | |
29 | ||
30 | ||
3d058c8a | 31 | open(CLUSTERS, "clusters") || die "Cannot open clusters file for input.\n"; |
6ce88475 | 32 | |
33 | $total = 0; | |
34 | ||
35 | while (<CLUSTERS>) { | |
36 | $total++; | |
37 | } | |
38 | ||
39 | close(CLUSTERS); | |
40 | delete $TYPES{"NONE"}; | |
41 | ||
7c9fee00 | 42 | printf("%5d Clusters\n\n", $total); |
6ce88475 | 43 | |
44 | ||
7ceec60a | 45 | open(PRINTERS, "printers") || die "Cannot open printers file for input.\n"; |
6ce88475 | 46 | |
47 | $total = 0; | |
48 | ||
7ceec60a | 49 | while (<PRINTERS>) { |
50 | split(/\|/, $_, 11); | |
51 | if ($_[9]) { $auth++; } | |
6ce88475 | 52 | $total++; |
53 | } | |
54 | ||
7ceec60a | 55 | close(PRINTERS); |
6ce88475 | 56 | |
57 | printf("%5d Printers, %d with authentication (%d%%).\n\n", $total, $auth, | |
58 | (100 * $auth + $total/2)/$total); | |
59 | ||
60 | ||
61 | if (1) { | |
62 | open(USERS, "users") || die "Cannot open users file for input.\n"; | |
63 | ||
64 | $total = 0; | |
65 | ||
66 | while (<USERS>) { | |
7c9fee00 | 67 | s/\|/\e/g; s/\\\e/\|/g; |
26534cc3 | 68 | split(/\e/, $_, 28); |
69 | $total++; $STATUS{$_[8]}++; | |
70 | if ($_[8] != 3) { $classtotal++; $CLASS{$_[10]}++; } | |
71 | if ($_[8] == 1) { $CLASSA{$_[10]}++; } | |
72 | if ($_[8] == 1 || $_[8] == 6) { $pototal++; $POTYPE{$_[26]}++; } | |
6ce88475 | 73 | } |
74 | ||
75 | close(USERS); | |
76 | delete $STATUS{"NONE"}; | |
77 | delete $CLASS{""}; | |
78 | ||
7c9fee00 | 79 | sub bytotal { substr($b, 12, 5) <=> substr($a, 12, 5); } |
6ce88475 | 80 | undef @values; |
81 | printf("%5d Non-deactivated users by class:\n", $classtotal); | |
82 | printf(" class total %%total active %%active\n"); | |
7c9fee00 | 83 | printf(" in DB accounts in class\n"); |
6ce88475 | 84 | grep(push(@values, sprintf(" %-8s %5d %2d %5d %3d\n", |
85 | $_, $CLASS{$_}, (100 * $CLASS{$_} + $classtotal/2)/$classtotal, | |
86 | $CLASSA{$_}, (100 * $CLASSA{$_} + $CLASS{$_}/2)/$CLASS{$_})), | |
87 | keys(%CLASS)); | |
88 | print sort bytotal @values; | |
7c9fee00 | 89 | printf(" Totals %5d 100 %5d\n", $classtotal, $STATUS{'1'}); |
6ce88475 | 90 | print "\n"; |
91 | undef %CLASS; | |
92 | ||
93 | @STATUS = ("Registerable (0)", | |
94 | "Active (1)", | |
95 | "Half Registered (2)", | |
96 | "Deleted (3)", | |
97 | "Not registerable (4)", | |
98 | "Enrolled/Registerable (5)", | |
99 | "Enrolled/Not Registerable (6)", | |
100 | "Half Enrolled (7)" ); | |
101 | ||
102 | undef @values; | |
103 | printf("%5d Users by status:\n", $total); | |
104 | grep(push(@values, sprintf(" %5d %-29s %2d%%\n", $STATUS{$_}, $STATUS[$_], (100 * $STATUS{$_} + $total/2)/$total)), keys(%STATUS)); | |
105 | print reverse sort(@values); | |
106 | print "\n"; | |
107 | undef %STATUS; | |
108 | undef @STATUS; | |
109 | ||
110 | undef @values; | |
111 | printf("%5d Active or enrolled users by pobox type:\n", $pototal); | |
7c9fee00 | 112 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $POTYPE{$_}, $_, (100 * $POTYPE{$_} + $pototal/2)/$pototal)), keys(%POTYPE)); |
6ce88475 | 113 | print reverse sort(@values); |
114 | print "\n"; | |
115 | undef %POTYPE; | |
116 | ||
117 | } | |
118 | ||
119 | open(LISTS, "list") || die "Cannot open list file for input.\n"; | |
120 | ||
121 | $total = 0; | |
122 | ||
123 | while (<LISTS>) { | |
7c9fee00 | 124 | split(/\|/, $_, 8); |
6ce88475 | 125 | $total++; |
126 | if ($_[2]) { $active++; } | |
127 | if ($_[3]) { $public++; } | |
128 | if ($_[4]) { $hidden++; } | |
129 | if ($_[5]) { $maillist++; } | |
130 | if ($_[6]) { $group++; } | |
131 | } | |
132 | close(LISTS); | |
133 | ||
7c9fee00 | 134 | printf("%5d Lists (non-exclusive attributes):\n", $total); |
6ce88475 | 135 | printf(" %5d %-9s %2d%%\n",$active, "active", (100 * $active + $total/2)/$total); |
136 | printf(" %5d %-9s %2d%%\n",$public, "public", (100 * $public + $total/2)/$total); | |
137 | printf(" %5d %-9s %2d%%\n",$hidden, "hidden", (100 * $hidden + $total/2)/$total); | |
138 | printf(" %5d %-9s %2d%%\n",$maillist, "maillist", (100 * $maillist + $total/2)/$total); | |
139 | printf(" %5d %-9s %2d%%\n",$group, "group", (100 * $group + $total/2)/$total); | |
140 | print "\n"; | |
141 | ||
142 | ||
143 | open(FILSYS, "filesys") || die "Cannot open filesys file for input.\n"; | |
144 | ||
145 | $total = 0; | |
146 | while (<FILSYS>) { | |
7c9fee00 | 147 | split(/\|/, $_, 15); |
6ce88475 | 148 | $total++; |
149 | $FSTYPE{$_[4]}++; | |
150 | $LTYPE{$_[13]}++; | |
151 | } | |
152 | close(FILSYS); | |
153 | # remove dummy entry | |
154 | delete $LTYPE{""}; | |
155 | $FSTYPE{"ERR"}--; | |
156 | $total--; | |
157 | ||
158 | undef @values; | |
159 | printf("%5d Filesystems by protocol type:\n", $total); | |
160 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $FSTYPE{$_}, $_, (100 * $FSTYPE{$_} + $total/2)/$total)), keys(%FSTYPE)); | |
161 | print reverse sort(@values); | |
162 | print "\n"; | |
163 | undef %FSTYPE; | |
164 | ||
165 | undef @values; | |
166 | printf("%5d Filesystems by locker type:\n", $total); | |
167 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $LTYPE{$_}, $_, (100 * $LTYPE{$_} + $total/2)/$total)), keys(%LTYPE)); | |
168 | print reverse sort(@values); | |
169 | print "\n"; | |
170 | undef %LTYPE; | |
171 | ||
172 | ||
7c9fee00 | 173 | open(QUOTA, "quota") || die "Cannot open quota file for input.\n"; |
6ce88475 | 174 | |
7c9fee00 | 175 | $total = 0; |
176 | while (<QUOTA>) { | |
177 | split(/\|/, $_, 6); | |
178 | $total++; | |
179 | $QTYPE{$_[1]}++; | |
180 | # $QVALUE{$_[4]/100}++; | |
6ce88475 | 181 | } |
7c9fee00 | 182 | close(QUOTA); |
183 | # remove dummy entry | |
184 | ||
185 | undef @values; | |
186 | printf("%5d Quotas by type:\n", $total); | |
187 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $QTYPE{$_}, $_, (100 * $QTYPE{$_} + $total/2)/$total)), keys(%QTYPE)); | |
188 | print reverse sort(@values); | |
189 | print "\n"; | |
190 | undef %QTYPE; | |
191 | ||
192 | #undef @values; | |
193 | #printf("%5d Quotas by value:\n", $total); | |
194 | #printf(" Quota Occurances\n"); | |
195 | #foreach $value (sort {$a<=>$b} keys(%QVALUE)) { | |
196 | # $total += $QVALUE{$value}; | |
197 | # if | |
198 | #} | |
199 | #grep(push(@values, sprintf(" %5d %6d\n", $_, $QVALUE{$_})), sort {$a <=> $b} keys(%QVALUE)); | |
200 | #print sort(@values); | |
201 | #print "\n"; | |
202 | #undef %QVALUE; | |
203 | ||
204 | ||
205 | exit 0; | |
206 |