Phones and Perl
Mar. 3rd, 2004 01:57 pmWell, it looks like I'm returning my Ericsson. Unless someone's got a Bluetooth, colour screen, non-camera phone that they're inclined to swap.
Had security doing the rounds checking mobiles. 30 have been confiscated, and we have a load of people getting disciplinaries. Probably just verbals though.
Thankfully I switched back to my 5210 last night, and so wasn't in any danger (not that I actually got checked).
I suppose it is a 'site rule' but I can't help but feel it's a little heavy handed. After all, it's _far_ easier to rip off a company using root/NT Domain Admin privileges.
Sigh. The only potential compromise phone that I can see is the Nokia 6810 (it's very similar spec wise to the 6800 and the 6820, the major difference being - no camera.). Unfortunately, it also isn't available yet. So I guess I'm stuck with my 5210, a bluetooth headset that I can't use at the moment, and returning my phone. Oh and waiting for the new nokia, so I can have one of those instead.
Of course, that doesn't help the various people who happen to have personal phones, either those that got busted, or those that didn't. (yeah, there were a few. But the inspection served it's purpose, and they're going to be a lot more careful) .
And Whee! I've found another place to spew my diatribes onto the world. Liberally pilfering previous LJ comments to dump upon the world of SINergy.
Oh and my contribution to the world for today. A little script, in perl, that adds up usage in a directory tree, and figure out who's the greedy lil' git who owns it.
And yes, I'm aware that quotas allow users to track usage. But that doesn't help with large filesystems, where no body really knows who owns what, and what things are - when you're talking about 2 Tb that's not a trivial matter...
Stuff to read: Computer world Daily shark
BOFH: We who are about to dial salute you
Had security doing the rounds checking mobiles. 30 have been confiscated, and we have a load of people getting disciplinaries. Probably just verbals though.
Thankfully I switched back to my 5210 last night, and so wasn't in any danger (not that I actually got checked).
I suppose it is a 'site rule' but I can't help but feel it's a little heavy handed. After all, it's _far_ easier to rip off a company using root/NT Domain Admin privileges.
Sigh. The only potential compromise phone that I can see is the Nokia 6810 (it's very similar spec wise to the 6800 and the 6820, the major difference being - no camera.). Unfortunately, it also isn't available yet. So I guess I'm stuck with my 5210, a bluetooth headset that I can't use at the moment, and returning my phone. Oh and waiting for the new nokia, so I can have one of those instead.
Of course, that doesn't help the various people who happen to have personal phones, either those that got busted, or those that didn't. (yeah, there were a few. But the inspection served it's purpose, and they're going to be a lot more careful) .
And Whee! I've found another place to spew my diatribes onto the world. Liberally pilfering previous LJ comments to dump upon the world of SINergy.
Oh and my contribution to the world for today. A little script, in perl, that adds up usage in a directory tree, and figure out who's the greedy lil' git who owns it.
And yes, I'm aware that quotas allow users to track usage. But that doesn't help with large filesystems, where no body really knows who owns what, and what things are - when you're talking about 2 Tb that's not a trivial matter...
#!/bin/perl
#recursively adds up file sizes beneath a directory.
#stores each size against user and group id.
#simply really :)
use strict;
use warnings;
use File::Find;
#define some hashes to store our results
my %usage_by_user;
my %usage_by_group;
#Explain how it works.
if ( $#ARGV == -1 )
{
print "Usage: $0 \n";
print "For current directory, "." may be used\n";
exit 2;
}
foreach my $directory ( @ARGV )
{
if ( -d $directory )
{
print "Usage for: $directory\n";
#Here's the magic. Running a find, with this subroutine.
#essentially recurse through the directory tree, and foreach item,
#do an lstat, and add it's file size to the appropriate hash table for
#that UID or GID.
#perldoc -f lstat to see what the fields are. I'd imagine you have no
#problems guessing that 4 = UID, 5 = GID, and 7 = file size.
#12 is also a good one to use, because that counts number of 'blocks'
#that a file uses, and hence it's space on disk.
find sub {
my @stat = lstat;
$usage_by_user{$stat[4]} += $stat[7];
$usage_by_group{$stat[5]} += $stat[7];
#print "@stat\n";
}, $directory;
print "By User(id):\n";
#print out the uids and users in order of how much they're using.
#the sort is being passed a 'sort by values in the hash' sub.
foreach my $uid (
sort { $usage_by_user{$b} <=> $usage_by_user{$a} }
keys ( %usage_by_user )
)
{
my $user = (getpwuid($uid))[0];
print $user ? $user : "unknown", "($uid) = $usage_by_user{$uid}\n";
}
print "\nBy Group(id):\n";
foreach my $gid (
sort { $usage_by_group{$b} <=> $usage_by_group{$a} }
keys ( %usage_by_group )
)
{
my $group = (getgrgid($gid))[0];
print $group ? $group : "unknown", "($gid) = $usage_by_group{$gid}\n";
}
} #if -d
else { print "$directory is not a directory\n"; }
}
Stuff to read: Computer world Daily shark
BOFH: We who are about to dial salute you