[python-win32] Python for System Administration
Tim.Golden at viacom-outdoor.co.uk
Tue Dec 12 14:05:56 CET 2006
| Sorry for the intrusion.
Not often we see you around these parts!
| I'm working on a book proposal about IronPython, with Manning.
| I'd like to also include some sections about 'general' system
| administration tasks (on windows computers and networks) that can be
| achieved with Python.
Personally I'm delighted to see attention given to this
subject in a book. (Or anywhere, for that matter). Altho'
I'm not a sysadmin, I've spent a fair amount of time
helping our sysadmins here and answering admin-y questions
on the Python lists. I think Python's potential here --
especially under Windows -- is hugely underrated. Of
course Powershell may sweep that potential away; who knows?
Unsurprisingly perhaps, a lot of my recommendations
involve WMI. Now I've no idea if WMI is still a concept
under .NET or how it's invoked if it is. At present,
you use the pywin32 GetObject method to invoke it.
Is that still possible under IronPython? Or is there
some -- possibly built-in -- equivalent?
Anyway, examples of some of the vaguely sysadmin-y
things I've either done myself or helped with. I
suppose people's definition of sys-adminy varies a
bit. I think I've been quite generous here; some of
the examples are more development-y than admin-y.
+ Copy details from Outlook Contacts to Active Directory fields
+ Run through an Exchange mailbox pulling out large attachments
and replacing them with a link to the same file on some NAS.
+ (subsequent to previous job) Rip through a network drive
finding (large) duplicate files and replacing them with
links or stubs. We had intended to use Junction Points
for this one but our understanding of them was vague at the
time (and isn't much better now, I think) so we didn't.
+ Watch our two Citrix servers for the occasional rogue
process which would take one CPU up to 100% until it
was killed. (This was a WMI one).
+ Monitor hard disks which were approaching capacity.
(This was WMI too). This was only a short-term measure
as our IT Director was happy to throw money at hardware,
in this case, extra disks.
+ Monitor the call queue on our helpdesk database and
alert techs/managers when new/updated calls come in.
This one's been running for about three years now.
(Not without a restart).
+ For the same system, use CherryPy to generate a simple
webpage version of the call queue and call details.
+ Lots of bits and pieces in AD, eg making department names
align with a list from HR, making capitalisation consistent,
bulk uploads etc.
+ Semi-automatic signature generation for Outlook with
optional image and link. This is just about to be replaced
now by some bought-in solution which is a bit more automatic,
sitting on the Exchange server itself and hooking in after the
user's sent an email. My version just allowed the IT/Marketing
teams to generate an email shortcut to a Python script which
would generate the signature file and set it as the user's
+ Rip through a Linux image store accessed principally by
Macs using Samba (cross-system or what?!) converting filenames
which differed only by case into some other system.
+ Find home directories belonging to users who no longer
existed or whose accounts were disabled.
+ Finding Outlook Contacts without a company photo.
+ Generating a contacts page for the company intranet showing
details from Outlook plus a portrait where available. (For
the record, this one used -- and still uses -- Xitami's
LRWP mechanism). This one's been running for five years
now and is easily the most used part of the Intranet.
+ Dump the company's entire Exchange GAL to some format
(CSV, I think) for export to some other part of the company.
+ Add everyone in a CSV list to a particular NT group
(this was before AD; using the win32net functions).
+ Various things with Subversion hooks / Trac and so on.
+ Determine which users were still running Win98 / some
older OS. (This was a WMI special)
+ Remove / archive user files from a network drive which
hadn't been accessed for at least 12 months and/or which
belonged to a user whose account was disabled.
I'm sure there were some other things ("Oh, Tim,
could you just...?") but at least this gives you
something of a flavour. I know that at least one
user is using the WMI module to monitor the Win32
servers in his ISP because we worked together on
performance improvements in the last release.
Food for thought, I hope.
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
More information about the Python-win32