By now, hopefully, you have installed the Web server and written the HTML files for your site. In addition, if you have just gone through the steps of Chapter 14, "Announcing your Web Site to the World," your home page is probably already
getting some hitsperhaps hundreds (depending on how you count them; see the sidebar below for more on this interesting question). Before it starts to get overwhelming, you should know a few things that will help you manage the growth of your site.
This chapter presents a broad collection of tips for the day-to-day maintenance of your Web site. Most of these tasks are typically considered system administrator responsibilities, but that doesn't mean they are difficult. In fact, we think you'll
agree after reading this chapter that many of these procedures are quite easy to implementwhich is a tribute to the design and simplicity of the Windows 95 user interface.
Let's start with a discussion of the toolbox that no Webmaster should be without. Each of the tools listed in this section has its place. Knowing about them is one thing, but actually being familiar with them is another. Acquaint yourself with their
capabilities at your earliest convenience and you will be rewarded day in and day out.
We can introduce you only to these tools' purpose and let you know their basic capabilities. Most of these programs have dozens of options for all kinds of different needs and situations. It is up to you to try the programs and consult the appropriate
documentation for further information.
This is used to determine whether another computer running TCP/IP is reachable and how long it takes for a packet to make the round trip back to your computer. Whenever you have any kind of problem reaching another computer on the Net, this is the first
thing to check. If ping can't reach the other computer, either that machine isn't on the Net or it isn't in the DNS tables. Ping.exe is a DOS prompt executable in the Windows directory.
This is the Windows 95 command-line application equivalent to UNIX traceroute. This utility will display the entire route your IP packets take from your server to the host that you select.
Winipcfg.exe is a very simple, yet handy GUI tool that lives in the Windows directory. As you can see from Figure 16.1, it displays various pieces of network information about the host computer.
Figure 16.1. Winipcfg displays network configuration information.
Netstat is a handy tool for looking at the status of the LAN or the Internet. You can see active connections to all ports and get a statistical breakdown of all connections over time. Netstat.exe is a DOS prompt executable in the Windows directory.
NetAlert is a 32-bit console mode application that Chris originally wrote for Microsoft Windows NT, and it runs on 95 too.
NetAlert responds to Ctrl+C to quit.
This program will monitor status of a TCP/IP network port by checking to see if the port is listening. When the port goes down (or up) it will send either an e-mail alert or page you, or both. You can use this application to check your Internet
connection by setting it to check a well known port on your service provider's network. If NetAlert looses the connection it will alert you. All settings are contained in three configuration files:
NetAlert will display the status of the port on each check, so if you want a log, just redirect the console to a file like this:
netalert > netalert.log
Table 16.1 lists several port numbers of well-known services as defined by RFC 1060 (Assigned Numbers).
Service name |
Port number/protocol |
aliases |
#comment |
echo |
7/tcp | ||
discard |
9/tcp |
sink null | |
daytime |
13/tcp | ||
qotd |
17/tcp |
quote | |
ftp-data |
20/tcp | ||
ftp |
21/tcp | ||
telnet |
23/tcp | ||
smtp |
25/tcp |
| |
time |
37/tcp |
timserver | |
time |
37/udp |
timserver | |
rlp |
39/udp |
resource |
# resource location |
name |
42/tcp |
nameserver | |
name |
42/udp |
nameserver | |
whois |
43/tcp |
nicname |
# usually to sri-nic |
domain |
53/tcp |
nameserver |
# name-domain server |
domain |
53/udp |
nameserver | |
nameserver |
53/tcp |
domain |
# name-domain server |
nameserver |
53/udp |
domain | |
finger |
79/tcp | ||
pop3 |
110/tcp |
postoffice | |
nntp |
119/tcp |
usenet |
# Network News Transfer |
snmp |
161/udp |
snmp | |
|
|
|
Portscan version 1.2 is a 32-bit Windows GUI application that Chris ported to Windows NT. This program will get the IP address of a host name and then scan from low to high checking for listening ports. This is a good tool for administrators to check
for any open ports.
This is a very useful CGI application that can be called from HTML to count and display the number of times a page has been accessed. Counter is a Windows NT (32-bit) console application (which means it will also run as a DOS prompt executable under
Windows 95).
Please read the thorough and simple documentation (counter.txt) that comes with Counter for details about how to install and use the program from the CD. You can get the most recent version of the software from
http://www.he.net/~bbsbs/behold/counter.html
Another Web server utility worth checking out is WebStone, developed by Silicon Graphics Incorporated. This program will benchmark the performance of your Web server by submitting HTTP GET requests repeatedly. Comparison data is available versus other
Web servers on selected hardware platforms. See http://www.sgi.com/Products/WebFORCE/WebStone/.
As your site grows in sophistication over time and you add more and more HTML files, you will run into the problem of maintaining and checking a large body of code. Weblint is a free Web page that helps you analyze the syntax and accuracy of your HTML
code. It gets its name from the C program checker called lint, which has been around for years.
You can download a freeware version of Weblint v1.011 or use the service online at this URL:
http://www.unipress.com/weblint/
Weblint was developed by Neil Bowers and Clay Webster. It is a Perl script with an HTML forms-based interface. Here are some of the notes from the Unipress Web site.
You can paste or type in HTML code and have it checked. Or you can simply supply a URL of a page anywhere on the World Wide Web to be checked.
Weblint supports HTML 3.0 tags, such as TABLE, MATH, and FIG. Weblint currently performs the following checks:
After you have connected to your service provider, it is possible that your connection could drop. This could happen for various reasons. For example, your service provider might allow your connection to time out after a certain period of inactivity.
Listing 16.1 shows a Windows C++ program that will solve this problem. Keep_ISP is a program that will ping a given IP address every 12 minutes, by default. Most service providers set their ports to time out after 15 to 20 minutes of inactivity. If you
expect that your service provider has a policy of letting inactive connections time out, you should keep this program running in the background to avoid problems. Both the source code and the compiled program are included on the CD-ROM in the
\tools\keep_isp directory. You need not study the source code if you would rather not dig into C++. The program has been compiled with Visual C++ 4.0 as a 32-bit GUI application. It runs minimized as an icon by default.
/************************************************************ keep_isp.cpp Pings the ISP on regular intervals to avoid timeout. Written by Scott Zimmerman. This program is PD freeware. December 1996 ************************************************************/ #include <windows.h> #include "keep_isp.h" HINSTANCE hInst; // current instance HWND g_hWnd; char szAppName[] = "Keep_ISP"; // The name of this application char szTitle[] = "Keep_ISP"; // The title bar text char szIP[20]; int bCmdBeep = FALSE; // default = no beeps int nMinutesCmd = 12; // default time interval = 12 minutes int nMinutesElapsed = 0; BOOL InitApplication(void); BOOL InitInstance(void); LRESULT CALLBACK WndProc(HWND,UINT,WPARAM, LPARAM); int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmd, int nCmdShow) { MSG msg; LPSTR p; char buf[20]; // Check if the command line includes -b to beep if (strstr(szCmd, "-b")) bCmdBeep = TRUE; // Check if the cmd line includes a time to ping in minutes p = strstr(szCmd, "-n"); if (p != NULL) { buf[0] = *(p + 2); buf[1] = *(p + 3); buf[2] = 0; nMinutesCmd = atoi(buf); } // The IP address must be the last switch on the command line p = strstr(szCmd, "-a"); if (p == NULL) { MessageBox(0,"Missing -a for IP address", "Error", 0); return FALSE; } strcpy(szIP, p+2); hInst = hInstance; if (!hPrevInstance) { if (!InitApplication()) return FALSE; // Exit if unable to initialize } if (!InitInstance()) return FALSE; UpdateWindow(g_hWnd); ShowWindow(g_hWnd, SW_SHOWMINIMIZED); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg);// Translates virtual key codes DispatchMessage(&msg); // Dispatches message to window } return (msg.wParam); // Returns the value from PostQuitMessage } BOOL InitApplication(void) { WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; // Owner of this class wc.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_APP)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = szAppName; // Register the window class and return success/failure code. return (RegisterClass(&wc)); } BOOL InitInstance(void) { // Create a main window for this application instance. g_hWnd = CreateWindow(szAppName, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL); // If window could not be created, return "failure" return (BOOL)g_hWnd; } LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM uParam,LPARAM lParam) { char buf[100]; switch (message) { case WM_CREATE: if (SetTimer(hWnd, 1, 60000, NULL) == 0) { MessageBox(0, "Error starting timer.", "Keep_ISP", 0); PostQuitMessage(0); break; } return (DefWindowProc(hWnd, message, uParam, lParam)); case WM_TIMER: if (++nMinutesElapsed % nMinutesCmd == 0) { // Execute the DOS Ping program wsprintf(buf, "PING.EXE -n 1 -l 10 %s", (LPSTR)szIP); WinExec(buf, SW_HIDE); if (bCmdBeep) MessageBeep(-1); nMinutesElapsed = 0; } break; case WM_DESTROY: // message: window being destroyed KillTimer(hWnd, 1); PostQuitMessage(0); break; default: // Passes it on if unproccessed return (DefWindowProc(hWnd, message, uParam, lParam)); } return (0); }
Presuming an understanding of the Windows API such as that gained from a careful reading of the classic book "Programming Windows 3.1," by Charles Petzold, the only moderately interesting code in this program occurs in the WndProc function.
Keep_ISP uses the WM_CREATE message to start a Windows timer, which will call back every minute. Since the SetTimer API requires a 16-bit integer parameter for the time interval in milliseconds, the largest value you can pass is just over one minute. Here,
we ask Windows to count 60,000 milliseconds and we will keep track of the minutes for ourselves. The code for the WM_TIMER message checks if the number of minutes has elapsed, and if so, it executes a ping to the ISP and resets the elapsed time counter
back to zero.
Very little error-checking is performed in Keep_ISP. For example, it assumes that ping.exe exists somewhere in the path. Feel free to enhance it and/or distribute it; it is public domain freeware.
Keep_ISP accepts three command-line arguments, which it scans for in the WinMain function. The arguments must appear in lowercase. The first two parameters are optional. The third parameter must be present, and it must always be last on the command
line.
For example:
keep_isp -b -n15 -a123.123.123.123
In this case, beeping is turned on and the interval is set for 15 minutes. You can place a shortcut to this program in your \Windows\Start Menu\Programs\StartUp folder. Then use Explorer to right-click it, choose Properties, select the Shortcut tab, and
enter the full path and command-line parameters in the text box labeled Target. See Figure 16.2 for an example of this.
Even if you run the keep_isp.exe program shown above, other things could happen to cause the line to drop. A very cool shareware utility called RAS+ can come to the rescue. Within one second of the modem line becoming disconnected, RAS+ can call your
ISP right back and re-establish your Web site on the Internet.
RAS+95 is a replacement for the Dial-Up Networking in Win95. It is great if you have to dial multiple numbers for your Internet provider. Here is a quote from the Windows95.com Web site about RAS+95:
"Hands down, the best Windows 95 Dial-Up utility on the planet! Adds automatic redialing, billing, automatic app-launching, multiple-phone number and provider dialing, and more! Download now, ask questions later."
And we might add that it has a true one-step install process. By the way, if you haven't seen it yet, http://www.windows95.com is an amazing collection of software and is worth a regular visit just to see what's new on Windows 95 and the Internet. It is
a well-organized site, offers useful reviews of each program, and performs well too.
You can find RAS+ on the enclosed CD in the \tools directory.
There are two other miscellaneous topics that we must bring up in this chapter, because they are related to site maintenance: tape backups and uninterruptible power. To guard against the risks of hackers, viruses, and total hard-disk failure, you should
back up your site at least once a day. To avoid forgetting a daily backup, you can schedule it to occur automatically late at night with the System Agent tools that are included in the Windows 95 Plus Pack.
Now as quick as the power can go out, let's change the subject. No business Web site should be without a UPS (Uninterruptible Power Supply). Once you have announced your Web site to the world (see Chapter 14), your customers will soon start depending
upon the constant up-time of your URLeven on weekends when you're not there to plug the server back in if someone accidentally unplugs it.
There are many UPS devices available; some start at around $140.00. And remember, just in case you decide to upgrade your operating system in the future, always check the NT Hardware Compatibility List before buying. For an excellent review of several
UPS devices see the November 1995 issue of Windows NT Magazine.
Expired links can be a Web management nightmare. The Web is a rapidly changing entity, thousands of pages go up and down each day. The more links your pages have to other pages, the more likelihood of having links go bad (expire). Some Web servers
(namely, WebSite for Win95/NT from O'Reilly & Associates and Purveyor for NT from Process Software) include utilities that will help you check to make sure that all of your local links are good. As time goes on, other utilities that will check both
local and remote links will become more readily available.
There are times when a Webmaster may need to edit low-level system parameters such as network packet sizes and other performance values. Here are some quick tips on how the Windows 95 Registry is laid out and how you can go about editing it. At least it
isn't as mysterious as you might have been led to believe.
The Registry contains important Windows 95 data about user preferences, and the hardware and software installed on your computer. Many of the values kept in the Registry are similar to those that you would find in the WIN.INI and SYSTEM.INI files of a
machine running Windows 3.1. The Registry is a hierarchical database used to maintain configuration information for Windows 95 and the users of the computer.
The Registry is broken down into four main subtrees. (Note: future versions of Windows 95 might increase this number.) The root key names at the top of each subtree are prefixed with HKEY to indicate that they are handles to keys. Windows
programmers speak of a handle as a reference to an operating system resource. A key is simply a word by which you can look up an associated value (like a dictionary entry and its corresponding definition). The next sections cover the four
root keys.
This key contains information about the local computer system, including hardware and operating system data such as bus type, memory, device drivers, and startup control data. This is the subtree that you will be most concerned with.
This key contains object linking and embedding (OLE) and file-class association data.
This key contains the user profile for the user who is currently logged on, including environment variables, personal program groups, desktop settings, network connections, printers, and application preferences. This key always refers to a user in the
subtree of HKEY_USERS.
This key contains all actively loaded user profiles, including HKEY_CURRENT_USER and the default profile. Users who are accessing a server remotely do not have profiles under this key on the server; their profiles are loaded into the Registry on their
own computers.
Many of the program configuration changes you make through the GUI in Windows 95 (such as in Control Panel) will be automatically written into the Registry for you. Whenever possible, we prefer to have the friendly interface of Control Panel and other
applications write to the Registry on our behalf. Having said that, there are some advanced settings mentioned in this book that can be made only by directly editing the Registry. To make these changes, use REGEDIT.EXE as shown in Figure 16.3.
Most of the Registry values relevant to this book are found under HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet.
As you navigate through the Registry with REGEDT32, you will notice that each entry in the structure is one of three things: a root key, a subtree, or a value. Value entries don't appear until you reach the end of a given subtree. Although this might
sound complicated, the whole idea is to keep a huge amount of data organized. And the Registry serves that purpose very well, once you get used to it.
We already discussed the root keys above. The best way to think of subtrees is as branches off of the main trunk, assuming the root keys are the main trunk. Contrast that with value entries which have three parts: name, data type, and the actual value.
The name can refer to anything a program needs to store for future reference.
By default, the Registry recognizes the following five types of data. The Win32 API includes functions which programmers can call to add other data types as necessary.
This is used for binary data that will not be interpreted by Regedit. Such data can be interpreted either by the program that writes the entry or by a system function inside the Win32 API that will process the data at the appropriate time in the
execution of the program that wrote the value. This data type can be used for values that don't fit any of the other types. Because all data in digital computers always exists in binary form, usage of the other types below is a matter of
convenience when the data can be interpreted by Regedit in a human-readable form.
This data type can contain 4 bytes of data. The basic unit of memory on Intel and many other computer architectures is 4 bytes, or 32 bits. This data type is useful for storing integers.
The SZ stands for string zero, which means a NULL-terminated array of characters in C or C++. This data type indicates an expandable string of text that contains a variable that will be substituted at runtime. For example, the string
%SystemRoot% appears throughout the Registry. It will be replaced at runtime by the actual location of the Windows 95 system directory.
This data type is used to hold several string values, each one separated by NULL bytes.
This data type is used to represent a simple array of characters or byte values. As you traverse the Registry, you will come across numerous examples of its use for strings of text.
This chapter was somewhat of a grab-bag of several useful things a Web site manager needs to know. The next chapter has a more concentrated focus all about running your own SMTP/POP3 mail server. If that sounds strange, read on, and you'll see how easy it really is.