[23095] | 1 | #!/moira/bin/perl |
---|
[24319] | 2 | # $HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/backup/report.pl $ $Id: report.pl 3956 2010-01-05 20:56:56Z zacheiss $ |
---|
[23095] | 3 | |
---|
| 4 | chdir($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" ); |
---|
| 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>) { |
---|
| 16 | split(/\|/, $_, 4); |
---|
| 17 | $TYPES{$_[2]}++; |
---|
| 18 | $total++; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | close(MACHINES); |
---|
| 22 | delete $TYPES{"NONE"}; |
---|
| 23 | |
---|
| 24 | printf("%5d Machines by type (both workstations & servers):\n", $total); |
---|
| 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 | |
---|
| 31 | open(CLUSTERS, "clusters") || die "Cannot open clusters file for input.\n"; |
---|
| 32 | |
---|
| 33 | $total = 0; |
---|
| 34 | |
---|
| 35 | while (<CLUSTERS>) { |
---|
| 36 | $total++; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | close(CLUSTERS); |
---|
| 40 | delete $TYPES{"NONE"}; |
---|
| 41 | |
---|
| 42 | printf("%5d Clusters\n\n", $total); |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | open(PRINTERS, "printers") || die "Cannot open printers file for input.\n"; |
---|
| 46 | |
---|
| 47 | $total = 0; |
---|
| 48 | |
---|
| 49 | while (<PRINTERS>) { |
---|
| 50 | split(/\|/, $_, 11); |
---|
| 51 | if ($_[9]) { $auth++; } |
---|
| 52 | $total++; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | close(PRINTERS); |
---|
| 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>) { |
---|
| 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 | |
---|
| 75 | close(USERS); |
---|
| 76 | delete $STATUS{"NONE"}; |
---|
| 77 | delete $CLASS{""}; |
---|
| 78 | |
---|
| 79 | sub bytotal { substr($b, 12, 5) <=> substr($a, 12, 5); } |
---|
| 80 | undef @values; |
---|
| 81 | printf("%5d Non-deactivated users by class:\n", $classtotal); |
---|
| 82 | printf(" class total %%total active %%active\n"); |
---|
| 83 | printf(" in DB accounts in class\n"); |
---|
| 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; |
---|
| 89 | printf(" Totals %5d 100 %5d\n", $classtotal, $STATUS{'1'}); |
---|
| 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 | "Registerable, krb only (8)", |
---|
| 102 | "Active, Kerberos only (9)" ); |
---|
| 103 | |
---|
| 104 | undef @values; |
---|
| 105 | printf("%5d Users by status:\n", $total); |
---|
| 106 | grep(push(@values, sprintf(" %5d %-29s %2d%%\n", $STATUS{$_}, $STATUS[$_], (100 * $STATUS{$_} + $total/2)/$total)), keys(%STATUS)); |
---|
| 107 | print reverse sort(@values); |
---|
| 108 | print "\n"; |
---|
| 109 | undef %STATUS; |
---|
| 110 | undef @STATUS; |
---|
| 111 | |
---|
| 112 | undef @values; |
---|
| 113 | printf("%5d Active or enrolled users by pobox type:\n", $pototal); |
---|
| 114 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $POTYPE{$_}, $_, (100 * $POTYPE{$_} + $pototal/2)/$pototal)), keys(%POTYPE)); |
---|
| 115 | print reverse sort(@values); |
---|
| 116 | print "\n"; |
---|
| 117 | undef %POTYPE; |
---|
| 118 | |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | open(LISTS, "list") || die "Cannot open list file for input.\n"; |
---|
| 122 | |
---|
| 123 | $total = 0; |
---|
| 124 | |
---|
| 125 | while (<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 | } |
---|
| 134 | close(LISTS); |
---|
| 135 | |
---|
| 136 | printf("%5d Lists (non-exclusive attributes):\n", $total); |
---|
| 137 | printf(" %5d %-9s %2d%%\n",$active, "active", (100 * $active + $total/2)/$total); |
---|
| 138 | printf(" %5d %-9s %2d%%\n",$public, "public", (100 * $public + $total/2)/$total); |
---|
| 139 | printf(" %5d %-9s %2d%%\n",$hidden, "hidden", (100 * $hidden + $total/2)/$total); |
---|
| 140 | printf(" %5d %-9s %2d%%\n",$maillist, "maillist", (100 * $maillist + $total/2)/$total); |
---|
| 141 | printf(" %5d %-9s %2d%%\n",$group, "group", (100 * $group + $total/2)/$total); |
---|
| 142 | print "\n"; |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | open(FILSYS, "filesys") || die "Cannot open filesys file for input.\n"; |
---|
| 146 | |
---|
| 147 | $total = 0; |
---|
| 148 | while (<FILSYS>) { |
---|
| 149 | split(/\|/, $_, 15); |
---|
| 150 | $total++; |
---|
| 151 | $FSTYPE{$_[4]}++; |
---|
| 152 | $LTYPE{$_[13]}++; |
---|
| 153 | } |
---|
| 154 | close(FILSYS); |
---|
| 155 | # remove dummy entry |
---|
| 156 | delete $LTYPE{""}; |
---|
| 157 | $FSTYPE{"ERR"}--; |
---|
| 158 | $total--; |
---|
| 159 | |
---|
| 160 | undef @values; |
---|
| 161 | printf("%5d Filesystems by protocol type:\n", $total); |
---|
| 162 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $FSTYPE{$_}, $_, (100 * $FSTYPE{$_} + $total/2)/$total)), keys(%FSTYPE)); |
---|
| 163 | print reverse sort(@values); |
---|
| 164 | print "\n"; |
---|
| 165 | undef %FSTYPE; |
---|
| 166 | |
---|
| 167 | undef @values; |
---|
| 168 | printf("%5d Filesystems by locker type:\n", $total); |
---|
| 169 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $LTYPE{$_}, $_, (100 * $LTYPE{$_} + $total/2)/$total)), keys(%LTYPE)); |
---|
| 170 | print reverse sort(@values); |
---|
| 171 | print "\n"; |
---|
| 172 | undef %LTYPE; |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | open(QUOTA, "quota") || die "Cannot open quota file for input.\n"; |
---|
| 176 | |
---|
| 177 | $total = 0; |
---|
| 178 | while (<QUOTA>) { |
---|
| 179 | split(/\|/, $_, 6); |
---|
| 180 | $total++; |
---|
| 181 | $QTYPE{$_[1]}++; |
---|
| 182 | # $QVALUE{$_[4]/100}++; |
---|
| 183 | } |
---|
| 184 | close(QUOTA); |
---|
| 185 | # remove dummy entry |
---|
| 186 | |
---|
| 187 | undef @values; |
---|
| 188 | printf("%5d Quotas by type:\n", $total); |
---|
| 189 | grep(push(@values, sprintf(" %5d %-8s %2d%%\n", $QTYPE{$_}, $_, (100 * $QTYPE{$_} + $total/2)/$total)), keys(%QTYPE)); |
---|
| 190 | print reverse sort(@values); |
---|
| 191 | print "\n"; |
---|
| 192 | undef %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 | |
---|
| 207 | exit 0; |
---|
| 208 | |
---|