AOLserver includes a control port interface that can be enabled with the nscp module. This control port interface allows you to telnet to a specified host and port where you can administer the server and execute database commands while the server is running.
The control port interface is a Tcl interface. Within it, you can execute Tcl commands (including AOLserver's Tcl API commands), operating system commands, SQL commands, and even edit files with the vi editor. AOLserver's Tcl commands allow you to define users, groups and permission records, as well as execute database commands.
To administer a server with the control port interface while it is running, the nscp module must be loaded into the server. To set permissions for the server, the nsperm module must also be loaded. To execute database commands while the server is running, you must also configure database services for the server, including database drivers and pools.
An example configuration for the control port interface is shown below. Three sections of the configuration file are included. The nscp module is loaded into the /modules section for server1. The /module/nscp section defines the control port parameters, and the /module/nscp/users section defines the users who can log into the control port.
ns_section "ns/server/server1/modules" ns_param nscp nscp.so ns_section "ns/server/server1/module/nscp" ns_param port 9999 ns_param address 127.0.0.1 ns_param binary bin/nscp ns_section "ns/server/server1/module/nscp/users" ns_param user "nsadmin:t2GqvvaiIUbF2:"
Some things to notice about the configuration are:
See Chapter 4 for complete information on configuration.
To use the control port interface, follow these steps:
telnet localhost 9999
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Welcome to the AOLserver control port! login:
login: nsadmin
password:
Checking authorization Login successful! 214 commands sourcing /modules/nscp/tcsh.inputrc server1>
server1> ns_info pageroot /disk5/ohenry/servers/server1/pages
server1> !who ohenry ttyq1 Apr 27 07:57 ohenry ttyq2 Apr 27 08:41 ohenry ttyq3 Apr 27 15:01server1> !csh %
server1> exit
server1> ns_cport db devpool DB mode started. Enter SQL statements terminated with a semicolon. To return to Tcl mode, type a semicolon on a line by itself. server1> select * from names; first last age ------------------------ Al Smith 23 Hugh James 30 server1> insert into names =>(first, last, age) =>values =>('Anita', 'Bass', 38) =>; server1> ; DB mode exited; now processing Tcl commands. server1>
server1> ns_cport db Please specify one of the following db pools: devpool: Development database salespool: Sales database server1> ns_cport db devpool
server1> ? ? Show this help text ?[string] Do an apropos search on [string] of AOLserver commands ![command] Execute [command]; for example, !/bin/sh runs a shell vi Run vi and then execute the buffer, if saved exit Exit the control port [tclcommand] Execute [tclcommand] within AOLserver ns_menu An easy-to-use menu with basic administration commands ns_cport db [pool] Evaluate SQL statements directly commands
server1> ?write ns_rwlock - Create, destroy, and manipulate read/write locks ns_write - Write raw content back to the client ns_writecontent - Write content to a file ns_writefp - Write file contents to the connection
An interactive interface for administering AOLserver is available when you execute the ns_menu command in the control port interface.
When you type ns_menu in the control port interface, the following menu is displayed:
server1> ns_menu 1. Logging 2. Thread info 3. Caching 4. Change password 5. Restart server Your choice [1-5]:
Type a menu number between 1 and 5 at the prompt. Each choice corresponds to a sub-menu. The sub-menus are described below.
If you type 1 at the top level menu, the logging menu is displayed:
1. Tail 2. Adjust Your choice [1-2]:
The logging menu allows you to view the server log and adjust the logging level of the available logging realms. The menu options are described below:
Available realms: nsd.pidfile nsd.dns nsd.adp nsd.sched nslog nsd.return nsd.socket nsperm nsd.tcl nsd.fastpath nsd.cache nsd.db nsd.mime nscp nsd nsd.geturl Your choice: nsd The current logging level for realm nsd is 'notice' Possible logging levels are: fatal bug error warning notice debug Enter new level: debug Done.
If you type 2 at the top level menu, information about the state of the server is displayed. For example:
Min threads: 2 Max threads: 20 Current threads: 2 Idle threads: 2 Stopping threads: 0
If you type 3 at the top level menu, the caching menu is displayed:
1. View stats Your choice [1-1]:
The menu option is described below:
Currently registered caches are: adp fastpath Your choice: fastpath Max size: 5120000 Current size: 34213 entries: 32 flushed: 0 hits: 20 misses: 20 hitrate: 50
If you type 4 at the top level menu, you can change a user's nsperm password. (Note that a user's nsperm password is not necessarily the same as the user's control port password.) For example:
This will change a user's password in the nsperm module. Enter user name: nsadmin Enter user's old password or the nsadmin password: Enter new password: Re-enter new password:
Passwords are not echoed to the screen. To change the password of a user other than yourself, enter the nsadmin password when prompted for the user's old password.
If you type 5 at the top level menu, the server is restarted. This option only works if the nsd binary exists in the directory [ns_info home]/bin/nsd.