Perl is a powerful programming language that grew out of the traditional system administration toolbox. Over the years it has adapted and expanded to meet the challenges of new operating systems and new tasks. Until now, however, no book has recognized this deep history by concentrating solely on using Perl for system administration.
If you know a little Perl, and you need to perform system administration tasks, this is the right book for you. Readers with varying levels of both Perl programming experience and system administration experience will all find something of use within these pages.
Each chapter in this book addresses a different system administration domain and ends with a list of the Perl modules used in that chapter and references to facilitate deeper exploration of the information presented. The chapters are as follows:
The introduction describes the material covered by the book in more detail, how it will serve you, and what you need to get the most from it. The material in this book is powerful and meant to be used by powerful people (e.g., Unix superusers and NT/2000 administrators). The introduction provides some important guidelines to help you write more secure Perl programs.
This chapter is about keeping multiplatform filesystems tidy and properly used. We start by looking at the salient differences between the native filesystems for each operating system. We then explore the process of walking or traversing filesystems from Perl and how that can be useful. Finally, we look at manipulating disk quotas from Perl.
This chapter discusses how these user accounts manifest themselves on two different operating systems. The crux of this chapter is a rudimentary account system written in Perl. In the process of building this system, we examine the mechanisms necessary for recording accounts in a simple XML-based database, creating these accounts, and deleting them.
Chapter 4, "User Activity" explores different process control mechanisms for all three operating systems. These range from the simple (e.g., MacOS processes) to the more complex (e.g., WinNT/2000 Windows Management Instrumentation). We put these mechanisms to work with administration helper scripts. Finally, we look at how to track file and network operations from Perl.
Name services allow hosts on a TCP/IP network to communicate with each other amicably. This chapter takes a historical perspective by starting with host files, moving to Network Information Service, and finally to the glue of the Internet, Domain Name Service. Each step of the way we show how Perl can make professional management of these services easier.
As the complexity of the information we deal with increases over time, so does the importance of the directory services we use to access this information. System administrators are increasingly being called upon to not only use these services, but to build tools for their management. This chapter discusses some of the more popular directory service frameworks such as LDAP and ADSI, and shows you how to work with them from Perl.
Over time, more uses for relational databases are being found in the system administration realm. As a result, system administrators need to become familiar with SQL database administration. This chapter explains two SQL database frameworks, DBI and ODBC, and provides examples of them in action.
This chapter demonstrates how Perl can make better use of email as a system administration tool. After discussing the basics of sending and parsing email via Perl, we look at several interesting applications, including Unsolicited Commercial Email (a.k.a. spam) analysis and managing tech support email.
System administrators are often awash in a sea of log files. Every machine, operating system, and program can (and often does) log information. This chapter looks at the logging systems offered by Unix and NT/2000. We discuss approaches for analyzing all of this information so it can work for you.
The final chapter heads right into the maelstrom called "security." We demonstrate how Perl can make hosts and networks more secure. In addition, we discuss several network monitoring techniques, including use of the Simple Network Management Protocol (SNMP) and network sniffing.
Some of the chapters assume some basic knowledge about a topic that you may not already have. For those who are new to these topics, this book includes several mini-tutorials to bring you up to speed quickly. These include introductions to the Revision Control System (RCS), Lightweight Directory Access Protocol (LDAP), Structured Query Language (SQL), eXstensible Markup Language (XML), and the Simple Network Management Protocol (SNMP).
Copyright © 2001 O'Reilly & Associates. All rights reserved.