ChessBrain: a Linux-Based Distributed Computing Experiment
The SuperNode server has a Bot called Shannon (implemented as a thread) that connects to on-line game servers and maintains a presence. Members of the game server type commands to challenge ChessBrain or to watch the current game being played. It has been fun programming Shannon, which now understands a variety of commands. There is a great deal of potential in on-line bots that can be instructed to perform actions on behalf of their hosts.
During the development of ChessBrain, I downloaded the source code to a Free Internet Chess Server (FICS) and compiled it on an old Pentium 200 MMX Toshiba laptop running Linux. FICS is written in C, and it compiled using GCC without incident. The game server allows users to telnet to port 5000 and sign in with a user name and password. After a few months the traffic increased, and we moved the FICS server to another ChessBrain machine at our secondary domain at distributedchess.net. Users now have several options for watching ChessBrain play on-line. They can telnet directly to the game server where ChessBrain is playing or use one of our viewer programs.
After ChessBrain could play on an on-line game server, I wrote a Java game viewer to allow people to watch live games. As an alternative to the Java viewer, I also wrote viewers based in PHP and Macromedia Flash (www.chessbrain.net/viewers.html). ChessBrain contributor Anthony Bravo wrote a Java-based network viewer to show the active PeerNodes throughout the world. Users can click on nodes to see how many machines are active in a given country. All of the viewers on the ChessBrain site use SOAP to communicate with the SuperNode.
As a security precaution, browser plugins such as Java and Macromedia's Flash ActionScript don't allow the program to connect to a server other than the one from which the applet was downloaded. To work around this issue, I wrote a simple XML proxy script that accepts an HTTP GET request on one server and connects to the SuperNode server on behalf of the client. For example, if you wanted to query the SuperNode server for the current game position, you could enter the following URL into your browser: http://www.chessbrain.net/xmlproxy.php?command=CBSGetPos. The server would respond with a SOAP package like the one in Figure 4. On Mozilla you can view the page source to see the actual SOAP document.
Listing 1. A ChessBrain XML Response Package
<?xml version="1.0" ?> <env:Envelope xmlns:env= http://www.w3.org/2001/12/soap-envelope xmlns:enc= "http://www.w3.org/2001/12/soap-encoding"> <env:Body> <cbs:CBSGetPosResponse > <return> rn1qk2r/p2p1ppp/bb2pn2/1p6/1P6/ P2Q1NP1/1BP1PP1P/RN2KB1R b KQkq - </return> </cbs:CBSGetPosResponse> </env:Body> </env:Envelope>
Monitoring a server's health is an important part of system administration. Fortunately for developers, Linux offers many ways to tackle server monitoring. The Linux /proc virtual filesystem contains a goldmine of valuable system data, offering developers an easy way to profile and monitor system behavior. /proc/net/dev offers device data such as the number of bytes and packets sent and received on a network interface, and /proc/meminfo offers loads of memory statistics. If data mining the /proc isn't your thing, sysinfo() offers a quick and easy way to fill a structure with system statistics, such as system load, freeram and the total number of processes.
The SuperNode server offers a SOAP request that returns system information similar to what is shown in Listing 2. ChessBrain member Greg Davis wrote the first SuperNode monitor in Perl, which issues the SOAP request and displays a screen similar to the top command.
Listing 2. An XML Server Status Message
<?xml version="1.0" ?> <env:Envelope > <env:Body> <cbs:CBSSysInfoResponse > <Uptime days="1" hours="14" minutes="43" seconds="18" /> <System proccnt="546" totmem="250.13" freemem="4.38" memu="98" cpustates="3627078,0,2151891,8160852" loadavg="0.50,0.30,0.33" /> <Recv Bytes="2301480887.000000" Packets="16652816.000000" Errors="0.000000" Drop="0.000000" /> <Send Bytes="2443488824.000000" Packets="12142245.000000" Errors="0.000000" Drop="0.000000" /> </cbs:CBSSysInfoResponse> </env:Body> </env:Envelope>
- Readers' Choice Awards 2013
- Linux Kernel News - November 2013
- Mars Needs Women
- December 2013 Issue of Linux Journal: Readers' Choice
- RSS Feeds
- Sublime Text: One Editor to Rule Them All?
- Raspberry Pi: the Perfect Home Server
- Advanced Hard Drive Caching Techniques
- Web Administration Scripts
- IBM Will Minimize Impact of Future Disasters
- thanks for share, great
3 hours 32 min ago
- There are factors which are
8 hours 32 min ago
- Gnome 3 ?
9 hours 17 min ago
- Reply to comment | Linux Journal
13 hours 24 min ago
- "Redis RethinkDB 4.5%" on Best NoSQL Databases
23 hours 30 min ago
- on the ground
1 day 5 hours ago
- I was able to read the whole
1 day 7 hours ago
- since i have read the title i
1 day 10 hours ago
- Belanja Online Cari Voucher Diskon
1 day 10 hours ago
- The kernel doesn't really
1 day 22 hours ago