Pro Python System Administration (2nd ed.) [Sileika 2014-11-27].pdf
(
5285 KB
)
Pobierz
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance
About the Author �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xvii
About the Technical Reviewers �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xix
Acknowledgments �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xxi
Introduction �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xxiii
■
Chapter 1: Reading and Collecting Performance Data Using SNMP �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½1
■
Chapter 2: Managing Devices Using the SOAP API �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½37
■
Chapter 3: Creating a Web Application for IP Address Accountancy �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½79
■
Chapter 4: Integrating the IP Address Application with DHCP �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½111
■
Chapter 5: Maintaining a List of Virtual Hosts in an Apache Configuration File �½�½�½�½�½�½�½�½�½�½�½�½143
■
Chapter 6: Gathering and Presenting Statistical Data from Apache Log Files �½�½�½�½�½�½�½�½�½�½�½�½�½�½163
■
Chapter 7: Performing Complex Searches and Reporting on Application Log Files �½�½�½�½�½�½189
■
Chapter 8: A Website Availability Check Script for Nagios�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½217
■
Chapter 9: Management and Monitoring Subsystem �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½241
■
Chapter 10: Remote Monitoring Agents �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½275
■
Chapter 11: Statistics Gathering and Reporting �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½301
■
Chapter 12: Distributed Message Processing System�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½331
■
Chapter 13: Automatic MySQL Database Performance Tuning �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½349
■
Chapter 14: Using Amazon EC2/S3 as a Data Warehouse Solution �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½367
Index �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½391
v
Introduction
The role of the system administrator has grown dramatically over the years. The number of systems supported
by a single engineer has also increased. As such, it is impractical to handcraft each installation, and there is a
need to automate as many tasks as possible. The structure of systems varies from organization to organization,
therefore system administrators must be able to create their own management tools. Historically, the most popular
programming languages for these tasks were UNIX shell and Perl. They served their purposes well, and I doubt they
will ever cease to exist. However, the complexity of current systems requires new tools, and the Python programming
language is one of them.
Python is an object-oriented programming language suitable for developing large-scale applications. Its syntax
and structure make it very easy to read—so much so that the language is sometimes referred to as “executable
pseudocode.” The Python interpreter allows for interactive execution, so in some situations an administrator can use
it instead of a standard UNIX shell. Although Python is primarily an object-oriented language, it is easily adopted
for procedural and functional styles of programming. Given all that, Python makes a perfect fit as a new language for
implementing system administration applications. There are a large number of Linux system utilities already written
in Python, such as the Yum package manager and Anaconda, the Linux installation program.
The Prerequisites for Using this Book
This book is about using the Python programming language to solve specific system administration tasks. We look at
the four distinctive system administration areas: network management, web server and web application management,
database system management, and system monitoring. Although I explain in detail most of the technologies used in
this book, bear in mind that the main goal here is to display the practical application of the Python libraries so as to
solve rather specific issues. Therefore, I assume that you are a seasoned system administrator. You should be able to
find additional information yourself; this book gives you a rough guide for how to reach your goal, but you must be
able to work out how to adapt it to your specific system and environment.
As we discuss the examples, you will be asked to install additional packages and libraries. In most cases, I provide
the commands and instructions to perform these tasks on a Fedora system, but you should be ready to adopt the
instructions to the Linux distribution that you are going to use. Most of the examples also work without many
modification on a recent OS X release (10.10.X).
I also assume that you have a background in the Python programming language. I introduce the specific
libraries that are used in system administration tasks, as well as some lesser known or less often discussed language
functionality, such as the generator functions or the class internal methods, but the basic language syntax is
not explained here. If you want to refresh your Python skills, I recommend the following books:
Pro Python
by
Marty Alchin and J. Burton Browning (Apress, 2012; but watch for a new edition due to be released in early 2015);
Python Programming for the Absolute Beginner
by Mike Dawson (Course Technology PTR, 2010); and
Core Python
Applications Programming
by Wesley Chun (Prentice Hall, 2012)
All examples presented in this book assume the Python version 2.7. This is mostly dictated by the libraries that
are used in the examples. Some libraries have been ported to Python 3; however, some have not. So if you need to run
Python 3, make sure you check that the required libraries have Python 3 support.
xxiii
■
IntroduCtIon
The Structure of this Book
This book contains 14 chapters, and each chapter solves a distinctive problem. Some examples span multiple
chapters, but even then, each chapter deals with a specific aspect of the particular problem.
In addition to the chapters, several other organizational layers characterize this book. First, I grouped the
chapters by the problem type. Chapters 1 to 4 deal with network management issues; Chapters 5 to 7 talk about the
Apache web server and web application management; Chapters 8 to 11 are dedicated to monitoring and statistical
calculations; and Chapters 12 and 13 focus on database management issues.
Second, I maintain a common pattern in all chapters. I start with the problem statement and then move on to
gather requirements and proceed through the design phase before moving into the implementation section.
Third, each chapter focuses on one or more technologies and the Python libraries that provide the language
interface for the particular technology. Examples of such technologies could be the SOAP protocol, application
plug-in architecture, or cloud computing concepts.
More specifically, here’s a breakdown of the chapters:
Chapter 1: Reading and Collecting Performance Data Using SNMP
Most network-attached devices expose the internal counters via the Simple Network Management Protocol (SNMP).
This chapter explains basic SNMP principles and the data structure. We then look at the Python libraries that provide
the interface to SNMP–enabled devices. We also investigate the round robin database, which is the de facto standard
for storing the statistical data. Finally, we look at the Jinja2 template framework, which allows us to generate simple
web pages.
Chapter 2: Managing Devices Using the SOAP API
Complicated tasks, such as managing the device configuration, cannot be easily done by using SNMP because
the protocol is too simplistic. Therefore, advanced devices, such as the Citrix Netscaler load balancers, provide the
SOAP API interface to the device management system. In this chapter, we investigate the SOAP API structure and the
libraries that enable the SOAP–based communication from the Python programming language. We also look at the
basic logging functionality using the built-in libraries. This second edition of the book includes examples of how to
use the new REST API to manage the load balancer devices.
Chapter 3: Creating a Web Application for IP Address Accountancy
In this chapter, we build a web application that maintains the list of the assigned IP addresses and the address
ranges. We learn how to create web applications using the Django framework. I show you the way the Django
application should be structured, tell how to create and configure the application settings, and explain the URL
structure. We also investigate how to deploy the Django application using the Apache web server.
Chapter 4: Integrating the IP Address Application with DHCP
This chapter expands on the previous chapter, and we implement the DHCP address range support. We also look
at some advanced Django programming techniques, such as customizing the response MIME type and serving AJAX
calls. This second edition adds new functionality to manage dynamic DHCP leases using OMAPI protocol.
Chapter 5: Maintaining a List of Virtual Hosts in an Apache Configuration File
This is another Django application that we develop in this book, but this time our focus is on the Django
administration interface. While building the Apache configuration management application, you learn how to
customize the default Django administration interface with your own views and functions.
xxiv
Plik z chomika:
musli_com
Inne pliki z tego folderu:
A Learner's Guide to Programming Using the Python Language (2009).pdf
(17233 KB)
Beginning Python (2005).pdf
(17909 KB)
apprenez_a_programmer_en_python.pdf
(13106 KB)
A Primer on Scientific Programming with Python (4th ed.) [Langtangen 2014-08-02].pdf
(7148 KB)
A Primer on Scientific Programming with Python (3rd ed.) [Langtangen 2012-07-04].pdf
(5392 KB)
Inne foldery tego chomika:
3D Design - Programming
ActionScript
Actionscript - Flash - Flex - Air
Ada
ADO
Zgłoś jeśli
naruszono regulamin