It depends on what level of monitoring you want to do. A number of the cheaper monitoring services/programs will simply connect to the target server on the default port (SMTP-25, HTTP-80,etc..) and see if a connection is made. If the server accepts the connection, the assumption is made that everything is ok. In 90+% of the cases, this will provide accurate results. There are however a number of cases where a connection is accepted by the service but other problems prevent normal operation. To provide more accurate monitoring for these cases, you'll need to understand the protocol for each service you're requesting. For http, you just need to connect to port 80 and send "GET / HTTP1.0<cflf><cflf>" and see if you get back a normal response code. You'll want to read the RFC's on the services you intend to monitor as they'll outline the messages and response codes so you'll know whether the service is reporting an error or not. Even getting back a normal response code doesn't mean everything is fine. A webserver running a scripting language might report an "OK" response code even though something is preventing the scripting lanuage (ASP,CF,Php3) from running correctly. A mail server might report a normal response although DNS isn't working and it can't resolve any domains or the virtusertable database is corrupt and it can't deliver mail. Once again, it just depends on what level of monitoring you want to do and how much effort you're willing to put into it.
This isn't a trivial application but is certainly something you can do with enough patience. If you have the ability to script a telnet session, this would probably be the easiest. The 2nd easiest method would be to use a scripting language such as Cold Fusion which has the ability to connect to services via TCP/IP with built in functions. Lastly, you could do this in C with regular sockets programming (my favorite).
Good luck,
GJ