From 02608c250e56aaabf9bb187cb096a28ad8c6a844 Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Thu, 16 Jan 2014 13:34:04 -0600 Subject: [PATCH 1/6] Fleshed out "binding to socket" example --- troubleshooting_101.rst | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/troubleshooting_101.rst b/troubleshooting_101.rst index ea786789..9b8578f9 100644 --- a/troubleshooting_101.rst +++ b/troubleshooting_101.rst @@ -33,8 +33,8 @@ problem. Over time you will expand what is in your toolbelt, but to start with you must know how to use each of these: * ``top``, ``vmstat``, ``iostat``, ``systat``, ``sar``, ``mpstat`` - These help you see the current state of the system - what is running, what is - using cpu, memory? Is the disk being heavily used? There is a lot of + help you see the current state of the system - what is running, what is + using cpu, memory? Is the disk being heavily used? There is a great deal of information, and knowing how these tools work will help you pick out the bits you should focus on. * ``tcpdump``, ``ngrep`` @@ -49,7 +49,7 @@ Walk through of a diagnosis * What changed recently? * Could any of the symptoms be red herrings? -* Common culprits (is it plugged in?) +* Common culprits (is it plugged in? is it network accessible?) * Look through your logs * Communicating during an outage * 'Talking Out-Loud' (IRC/GroupChat) @@ -72,9 +72,27 @@ identify and fix them. Cannot bind to socket ^^^^^^^^^^^^^^^^^^^^^ +There are two common reasons that you can't bind to a socket: the port is +already in use, or you don't have permission. +As an example, you can see what happens when I try to start a Python +SimpleHTTPServer on a port that is already in use:: + + python -m SimpleHTTPServer 8080 + ... + socket.error: [Errno 98] Address already in use + +Here's an example of what happens when I try to bind to a privileged port +without proper permissions (in Linux, ports < 1024 are privileged):: + + python -m SimpleHTTPServer 80 + ... + socket.error: [Errno 13] Permission denied + Permission denied reading to / writing from disk ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Out of disk space ^^^^^^^^^^^^^^^^^ (finding large files, and also finding deleted-but-open files) From 27d18870ca79da38f9cfa2ce49b9f30b7009ebfa Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Thu, 16 Jan 2014 14:07:49 -0600 Subject: [PATCH 2/6] Added link to cron exaplanation site Added gotcha about line breaks in crontab file --- cron_101.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cron_101.rst b/cron_101.rst index e425de66..5ebabb37 100644 --- a/cron_101.rst +++ b/cron_101.rst @@ -129,6 +129,9 @@ Knowing this, we can see that this "crontab" means: At 12:05 every Sunday, every month, regardless of the day of the month, run the command ``copy-to-partition`` in the ``/home/jdoe/jobs`` directory. +**Caveat**: entries in your crontab must be one long line; if you try to split it up +(with the linebreak ``\`` character for example) you will get an error! + Let's take another example and create a cron job that checks disk space available every minute, every hour, every day of the month, every month, for every day of the week, and outputs it to a file named :file:``disk_space.txt``. @@ -207,6 +210,8 @@ Notes on composing good "cron expressions" variables that come from your shell initialization files (like ``.bashrc`` or ``.zshrc`` or such). In particular, make sure to specify the full path to your program if it's not in a commonly-used location like ``/usr/bin``. +- If you have problems with the syntax, or something isn't working properly, there + are websites [#]_ that will explain a particular line from crontab. Modify a specific user's crontab -------------------------------- @@ -238,4 +243,6 @@ Footnotes .. [#] `"Examples" in cron - Wikipedia, a free encyclopedia `_ +.. [#] `Crontab to plain english `_ + .. [#] `Where can I set environment variables that crontab will use?, `_ From b2399c77c31d348038164d820797b46e16c57f0a Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Thu, 16 Jan 2014 15:04:27 -0600 Subject: [PATCH 3/6] Fleshed out DHCP article --- dhcp.rst | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dhcp.rst b/dhcp.rst index 95d3b757..4005b5bf 100644 --- a/dhcp.rst +++ b/dhcp.rst @@ -1,14 +1,32 @@ DHCP **** +DHCP, or, Dynamic Host Control Protocol is a standard that allows one central +source, ie. a server or router, to automatically assign requesting hosts an IP +address. + +The most common DHCP servers on Linux platforms are the ISC's +(Internet System Consortium) ``dhcpd``, and ``dnsmasq``. On Windows platforms +there are a variety of DHCP servers, though the Microsoft DHCP server is +arguably the best in terms of support and integration. + Tools: ISC dhcpd ================ +``dhcpd`` is the most common DHCP server, and it offers excellent integration +with BIND (DNS server). Protocol ======== dhcp helper =========== +DHCP helpers are sometimes referred to as DHCP relayers. The basic idea is that +a relay agent will forward DHCP requests to the appropriate server. This is +necessary because a host that comes online on a subnet with no DHCP server +has no way of finding the correct server; it needs a DHCP assigned address to +find a route to the correct DHCP server, but can't get there because it has no +IP address! DHCP relaying solves this chicken and egg problem by acting as an +intermediary. See this wikipedia [#]_ article for more details. Defining classes, leases ======================== @@ -23,5 +41,5 @@ DNS server(s) ------------- (Tie in previous chapters re: TFTP, PXE with related options?) - +.. [#] `DHCP relaying explained `_ From 5522c58f12d94b1b33f65b5924504e3de6d6ed36 Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Fri, 17 Jan 2014 22:55:48 -0600 Subject: [PATCH 4/6] Added another cron site, fixed based on comments --- cron_101.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cron_101.rst b/cron_101.rst index 5ebabb37..2718e705 100644 --- a/cron_101.rst +++ b/cron_101.rst @@ -211,7 +211,7 @@ Notes on composing good "cron expressions" ``.zshrc`` or such). In particular, make sure to specify the full path to your program if it's not in a commonly-used location like ``/usr/bin``. - If you have problems with the syntax, or something isn't working properly, there - are websites [#]_ that will explain a particular line from crontab. + are websites [#]_ that will translate crontab to English, and vice versa. [#]_ Modify a specific user's crontab -------------------------------- @@ -243,6 +243,8 @@ Footnotes .. [#] `"Examples" in cron - Wikipedia, a free encyclopedia `_ -.. [#] `Crontab to plain english `_ +.. [#] `Crontab to plain English `_ -.. [#] `Where can I set environment variables that crontab will use?, `_ +.. [#] `English to crontab `_ + +.. [#] `Where can I set environment variables that crontab will use? `_ From fb0335f4bd6cd28db6203ab96e9c44109fee0d7c Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Fri, 17 Jan 2014 22:56:51 -0600 Subject: [PATCH 5/6] Typo --- dhcp.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhcp.rst b/dhcp.rst index 4005b5bf..5dd029a3 100644 --- a/dhcp.rst +++ b/dhcp.rst @@ -1,7 +1,7 @@ DHCP **** DHCP, or, Dynamic Host Control Protocol is a standard that allows one central -source, ie. a server or router, to automatically assign requesting hosts an IP +source, i.e. a server or router, to automatically assign requesting hosts an IP address. The most common DHCP servers on Linux platforms are the ISC's From 18ba20e1c242dc39341b82ea4acc8eca85c1fd14 Mon Sep 17 00:00:00 2001 From: mynamewastaken Date: Fri, 17 Jan 2014 23:10:28 -0600 Subject: [PATCH 6/6] Fixed code block formatting --- troubleshooting_101.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/troubleshooting_101.rst b/troubleshooting_101.rst index 9b8578f9..93c34e4a 100644 --- a/troubleshooting_101.rst +++ b/troubleshooting_101.rst @@ -75,16 +75,20 @@ Cannot bind to socket There are two common reasons that you can't bind to a socket: the port is already in use, or you don't have permission. As an example, you can see what happens when I try to start a Python -SimpleHTTPServer on a port that is already in use:: +SimpleHTTPServer on a port that is already in use: - python -m SimpleHTTPServer 8080 +.. code-block:: console + + user@opsschool ~$ python -m SimpleHTTPServer 8080 ... socket.error: [Errno 98] Address already in use Here's an example of what happens when I try to bind to a privileged port -without proper permissions (in Linux, ports < 1024 are privileged):: +without proper permissions (in Linux, ports < 1024 are privileged): + +.. code-block:: console - python -m SimpleHTTPServer 80 + user@opsschool ~$ python -m SimpleHTTPServer 80 ... socket.error: [Errno 13] Permission denied