source: trunk/third/moira/backup/report.pl @ 24319

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