]> andersk Git - moira.git/blame - backup/report.pl
Command line printer manipulation client, and build goo.
[moira.git] / backup / report.pl
CommitLineData
6ce88475 1#!/moira/bin/perl
7c9fee00 2# $Header$
6ce88475 3
c8130e9e 4chdir($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" );
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>) {
7c9fee00 16 split(/\|/, $_, 4);
6ce88475 17 $TYPES{$_[2]}++;
18 $total++;
19}
20
21close(MACHINES);
22delete $TYPES{"NONE"};
23
7c9fee00 24printf("%5d Machines by type (both workstations & servers):\n", $total);
6ce88475 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
3d058c8a 31open(CLUSTERS, "clusters") || die "Cannot open clusters file for input.\n";
6ce88475 32
33$total = 0;
34
35while (<CLUSTERS>) {
36 $total++;
37}
38
39close(CLUSTERS);
40delete $TYPES{"NONE"};
41
7c9fee00 42printf("%5d Clusters\n\n", $total);
6ce88475 43
44
7ceec60a 45open(PRINTERS, "printers") || die "Cannot open printers file for input.\n";
6ce88475 46
47$total = 0;
48
7ceec60a 49while (<PRINTERS>) {
50 split(/\|/, $_, 11);
51 if ($_[9]) { $auth++; }
6ce88475 52 $total++;
53}
54
7ceec60a 55close(PRINTERS);
6ce88475 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>) {
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
75close(USERS);
76delete $STATUS{"NONE"};
77delete $CLASS{""};
78
7c9fee00 79sub bytotal { substr($b, 12, 5) <=> substr($a, 12, 5); }
6ce88475 80undef @values;
81printf("%5d Non-deactivated users by class:\n", $classtotal);
82printf(" class total %%total active %%active\n");
7c9fee00 83printf(" in DB accounts in class\n");
6ce88475 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;
7c9fee00 89printf(" Totals %5d 100 %5d\n", $classtotal, $STATUS{'1'});
6ce88475 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)",
3b912c38 100 "Half Enrolled (7)",
101 "Registerable, krb only (8)",
102 "Active, Kerberos only (9)" );
6ce88475 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);
7c9fee00 114grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $POTYPE{$_}, $_, (100 * $POTYPE{$_} + $pototal/2)/$pototal)), keys(%POTYPE));
6ce88475 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>) {
7c9fee00 126 split(/\|/, $_, 8);
6ce88475 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
7c9fee00 136printf("%5d Lists (non-exclusive attributes):\n", $total);
6ce88475 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>) {
7c9fee00 149 split(/\|/, $_, 15);
6ce88475 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
7c9fee00 175open(QUOTA, "quota") || die "Cannot open quota file for input.\n";
6ce88475 176
7c9fee00 177$total = 0;
178while (<QUOTA>) {
179 split(/\|/, $_, 6);
180 $total++;
181 $QTYPE{$_[1]}++;
182# $QVALUE{$_[4]/100}++;
6ce88475 183}
7c9fee00 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
This page took 0.094039 seconds and 5 git commands to generate.