]> andersk Git - moira.git/blame - backup/report.sh
fix RCS Id strings
[moira.git] / backup / report.sh
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
45open(PRINTCAP, "printcap") || die "Cannot open printcap file for input.\n";
46
47$total = 0;
48
49while (<PRINTCAP>) {
7c9fee00 50 split(/\|/, $_, 7);
6ce88475 51 if ($_[5]) { $auth++; }
52 $total++;
53}
54
55close(PRINTCAP);
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;
68 split(/\e/, $_, $27);
6ce88475 69 $total++; $STATUS{$_[7]}++;
70 if ($_[7] != 3) { $classtotal++; $CLASS{$_[9]}++; }
71 if ($_[7] == 1) { $CLASSA{$_[9]}++; }
72 if ($_[7] == 1 || $_[7] == 6) { $pototal++; $POTYPE{$_[25]}++; }
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)",
100 "Half Enrolled (7)" );
101
102undef @values;
103printf("%5d Users by status:\n", $total);
104grep(push(@values, sprintf(" %5d %-29s %2d%%\n", $STATUS{$_}, $STATUS[$_], (100 * $STATUS{$_} + $total/2)/$total)), keys(%STATUS));
105print reverse sort(@values);
106print "\n";
107undef %STATUS;
108undef @STATUS;
109
110undef @values;
111printf("%5d Active or enrolled users by pobox type:\n", $pototal);
7c9fee00 112grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $POTYPE{$_}, $_, (100 * $POTYPE{$_} + $pototal/2)/$pototal)), keys(%POTYPE));
6ce88475 113print reverse sort(@values);
114print "\n";
115undef %POTYPE;
116
117}
118
119open(LISTS, "list") || die "Cannot open list file for input.\n";
120
121$total = 0;
122
123while (<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}
132close(LISTS);
133
7c9fee00 134printf("%5d Lists (non-exclusive attributes):\n", $total);
6ce88475 135printf(" %5d %-9s %2d%%\n",$active, "active", (100 * $active + $total/2)/$total);
136printf(" %5d %-9s %2d%%\n",$public, "public", (100 * $public + $total/2)/$total);
137printf(" %5d %-9s %2d%%\n",$hidden, "hidden", (100 * $hidden + $total/2)/$total);
138printf(" %5d %-9s %2d%%\n",$maillist, "maillist", (100 * $maillist + $total/2)/$total);
139printf(" %5d %-9s %2d%%\n",$group, "group", (100 * $group + $total/2)/$total);
140print "\n";
141
142
143open(FILSYS, "filesys") || die "Cannot open filesys file for input.\n";
144
145$total = 0;
146while (<FILSYS>) {
7c9fee00 147 split(/\|/, $_, 15);
6ce88475 148 $total++;
149 $FSTYPE{$_[4]}++;
150 $LTYPE{$_[13]}++;
151}
152close(FILSYS);
153# remove dummy entry
154delete $LTYPE{""};
155$FSTYPE{"ERR"}--;
156$total--;
157
158undef @values;
159printf("%5d Filesystems by protocol type:\n", $total);
160grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $FSTYPE{$_}, $_, (100 * $FSTYPE{$_} + $total/2)/$total)), keys(%FSTYPE));
161print reverse sort(@values);
162print "\n";
163undef %FSTYPE;
164
165undef @values;
166printf("%5d Filesystems by locker type:\n", $total);
167grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $LTYPE{$_}, $_, (100 * $LTYPE{$_} + $total/2)/$total)), keys(%LTYPE));
168print reverse sort(@values);
169print "\n";
170undef %LTYPE;
171
172
7c9fee00 173open(QUOTA, "quota") || die "Cannot open quota file for input.\n";
6ce88475 174
7c9fee00 175$total = 0;
176while (<QUOTA>) {
177 split(/\|/, $_, 6);
178 $total++;
179 $QTYPE{$_[1]}++;
180# $QVALUE{$_[4]/100}++;
6ce88475 181}
7c9fee00 182close(QUOTA);
183# remove dummy entry
184
185undef @values;
186printf("%5d Quotas by type:\n", $total);
187grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $QTYPE{$_}, $_, (100 * $QTYPE{$_} + $total/2)/$total)), keys(%QTYPE));
188print reverse sort(@values);
189print "\n";
190undef %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
205exit 0;
206
This page took 0.118459 seconds and 5 git commands to generate.