Netmon - a simple PHP based network monitor
Written by FIRESTORM_v1
Legal Disclaimer: The software is provided AS-IS with no guarantee of fitness or merchantability. I can't even guarantee that it will even work on your configuration. That being said, you can not hold me responsible if it causes your servers to crash, loss of Internet access, death, destruction or cancerous growth. Don't sue me if this happens to you. I'm not saying it will, but I am not saying that it won't either.
Description:
Netmon is a simple to install and simple to use server monitoring PHP script that allows you to at-a-glance see the status of your network and Internet access. This software was initially written because I was having problems keeping computers online and after a a few weeks of asking "Is it still up?" I got tired and after several nights of frustration came up with an initial monitoring application.
After a few weeks, I expanded the initial script to include MySQL connectivity allowing the server information to be stored and easily modified so that I could change, add and remove servers at will without need to touch the actual PHP source. A few weeks later, and a quick study of SNMP, I was able to now poll all of the servers and workstations on my network for uptime and that information is now displayed as an option.
Netmon works off of the commandline utilities ping and snmpget (and wakeonlan if you choose to install it) If it pings a server and the server responds, then Netmon will flag it as "Online" and will then try to pull SNMP uptime based on the settings entered. If the ping comes back as Unreachable or any other errors, then it will mark it as "Offline" and move on to the next server.
System Requirements:
This software requires only a few basic components to get working correctly. Please keep in mind that I wrote this on a RedHat 7.3 server and as such, this list largely peratins to that system. In time I will be upgrading the server at which time I will re-release the software and provide a more current list of requirements.
A special note: Netmon is NOT a standalone application, it is a PHP script that executes every time the main page is refreshed. I recommend running it in your favorite web browser and leave the browser window open but minimized so that it will continue to monitor as long as the browser is left open.
Hardware:
Any Linux machine that can run Linux, Apache, MySql and PHP (LAMP) and a network adapter.
Software:
Apache
PHP 4 or better with register_globals set to ON. This presents a security risk, so it's best to run this on a server that is internal only, at least until I have time to rewrite the code.
ucd-snmp and ucd-snmp-tools for your Linux version. Redhat users can use the following links:
ucd-snmp for i386
ucd-snmp-utils for i386
WakeOnLan - for WOL support.
WakeOnLan - not architecture dependent
A computer with a web browser for running and configuring Netmon. The browser must support Javascript for the form buttons.
Screenshots
A screenshot of Netmon in action!
Installation:
The installation is very simple. Run the included netmon.sql script to create the necessary database tables, assign a password to the netmon user, then place the netmon script in a web-accessable location on your server, usually /var/www/html.
If you change the name of the netmon script, (in this release it's called netmon4.php) you will need to edit the netmon script and find the line that says:
$this_file_name='netmon4.php';
Make sure that you include the .php extension otherwise the page won't operate correctly.
Files
The netmon script. Make sure you rename it to netmon.php!
The netmon SQL file. This goes into the MySQL database.
Walkthrough: Netmon Configuration
Netmon will work out of the box, however there some additional features that you can enable to make sure you get the most out of the application. Each feature has its own save button and must be used every time a feature is adjusted. The save buttons are grouped by feature and don't interoperate, meaning that if you adjust the Meta Refresh delay but click on "Save HTML Link option" you won't be saving the Meta refresh data.
Use HTTP Meta Refresh to update results:
This option toggles whether or not the index Netmon page refreshes at regular intervals. Remember! Netmon will only check the servers once per page refresh or when you click "Refresh page" or your reload button in your browser. I highly recommend leaving this option set.
Meta Refresh Delay:
This option adjusts the refresh interval above in seconds. I personally use 300 seconds which is about 5 minutes.
DHCP Subnet options:
Still in development
This is the DHCP Subnet generator. When you click on the "Generate /etc/dhpd.conf" button, this will generate the file that you can copy and paste into your server's dhcpd.conf file. As of this release, it will only generate hosts, but in the next release, this will be fully functional. The DHCP Subnet dropdown will show all available distinct subnets that you have added in the Server List. This sets the subnet that the dhcpd.conf generator will use to create the file, only servers in this subnet will be used. If you have multiple subnets, they will be displayed here, but only one can be selected.
Edit DHCP options for 192.168.0
Still under development.
This will be where you can edit options for the subnet you selected above. Right now it is nonfunctional.
Show HTML Link to server if online:
If enabled, you will see the word "Link" next to each online server if you provided an HTML Link when you added the server, Otherwise a "--" will be displayed. This allows you to globally enable/disable the HTML Link from showing across all servers regardless if they contain an HTML Link or not.
Enable Show All Servers button:
This allows you to override the "Server Visible" option for all the servers listed in the Netmon database regardless if it is visible or not, Additionally, this will also ping the server and show if it's online or not.
Dead Server Report:
Enable Dead Servers Report will allow you to toggle the Dead Servers report option. The Dead Servers Report contains information about the servers such as the last time the server was seen online and what it's SNMP uptime was if it was SNMP enabled. If the Dead Server Report is enabled, you will be presented with an option on where to display the information.
Main Page, seperate from Table
This shows the servers sorted by subnet and IP, their last seen online time and their SNMP uptime in it's own seperate table.
Main Page, integrated with Table
This shows the Dead Servers information integrated with the same rows as the Server table.
Seperate page with Link on Main page
This provides you with a link to open the Dead Servers report seperately from the main table. This page will not refresh on its own.
Use SNMP for polling:
This option globally enables or disables SNMP polling. If unchecked, Netmon will not attempt to poll any server for SNMP information even if it's individual settings are set.
Internet Connection Test:
This option allows you to enable or disable the Internet Connection check and to change whether or not it is executed along with the other servers. The Internet Connection will always show up on the main page at the top and will always say "Internet". This can also be adjusted from the Server List page.
Notification Type:
Right now the only option that works is E-mail. You can set it to either Email you or to take no action. If set to email, you will see a location to enter your email address. Some ISPs may filter out email so there is no guarantee of whether or not you'll get it. See the "Troubleshooting" section below for some possible workarounds.
Walkthrough: Adding A Server
When you use Netmon for the first time, the only server that will be shown is the Internet connection, and that will have an IP of 127.0.0.1. You can click on the "Server List" button and it will take you to the page where you can add/edit/delete servers. For the servers that are already listed, (none if it's a new installation) you will be able to click on a button marked "Edit/Delete Server" that will give you options for making changes to that server's configuration in Netmon. To add a server, scroll down to the bottom and fill out the form below and click "Add Server".
Server Name:
This is the name that will show up on the row for the server. This doesn't have to be the DNS name of the machine, just something so you know what it is.
Server Address:
This is the server IP address in dotted quad formation. You can not use DNS names here, only IPs.
Server MAC Address:
This is used by the WakeOnLan option and the DHCP Generator option. It must be entered in 00:11:22:33:44:55 format otherwise the DHCP and WakeOnLan options won't work correctly.
Include Server in dhcpd.conf generation:
This option shows whether or not you want this server to show up in the DHCP Generator. If you check it and leave the MAC address blank, you will get an error in the DHCP generator. If you do not want the server to appear, you can leave this unchecked.
Server Visible on Status Page:
This dictates whether or not the server is actively checked by Netmon on page refresh. If this is unchecked(disabled) but you use Show All Servers, the server will be visible.
SNMP Enabled:
This option shows whether or not Netmon will attempt to poll the sys.SysUpTime.0 SNMP object if the IP responds. If you leave this checked and the server doesn't respond to SNMP, it will not return a value. By default, Netmon uses the SNMP community 'public'.
Server State:
This is used to bring a server "In Service"(IS) or "Out Of Service"(OOS). This is primarily used for when you are working on a server but don't want to get notified every 5 minutes that it is up or down. IS means that the server is in service and is expected to be up, if it isn't and Send Alerts is enabled for this server, you will get a notification about the server state change. OOS means that Netmon will still check the server, but will not send a notification if the server comes online or drops offline.
HTML Link for Server:
This is a tool for you to add whatever link you want to add as a shortcut to get to that server. Most commonly this is used to point the browser to the Configuration page on a home router or to Webmin of a linux server. You can use whatever HTML Link you want, but it will only show in the "Link" column on the main page if the server is online.
Updating/Deleting a server
Deleting/Updating a server can be done from the Server List page. Locate the server you want to edit and click on "Edit/Delete Server". You will be presented with a page that reflects the server's current settings. Make your changes and click "Save Settings" to save your changes. If you click Delete, you will be prompted to type in "YES" into a text field to confirm deletion. This command can not be undone, hence the verification.
Troubleshooting / FAQ
Q: What kind of servers can I add to Netmon? Will it test across subnets?
A: Yes. If you can ping it from the server, then Netmon can too. Netmon uses the commandline ping command to try and reach a server. If it doesn't get a positive ping back, then it will mark the server offline and move on. That being said, if you are monitoring remote sites with netmon, first make sure that you can ping the server to ensure that Netmon will be able to give you accurate date. Keep in mind that firewalls, IDSs and routers all can affect pinging ability.
Q: I keep getting the index page over and over again when I attempt to click on any of the buttons!
A: This is usually because more recent versions of PHP have register_globals set to OFF. You will need to edit /etc/php.ini and edit/add register_globals=ON. Make sure however that you understand the security risks in doing so. As stated above, I do not recommend nor hold any responsibility for someone trashing your system if you leave this web-readable without some security measure in place. At bare minimum, make a .htaccess/.htpasswd file so you are prompted for a password to keep out malicious people from exploting the PHP register_globals issue.
Q: Wake on Lan doesn't seem to work with my network card!
A: Wake on lan is a hit-or-miss, although most newer motherboards with on-board NICs, most newer NICs all support WOL already. WOL will not work with USB NICs and wireless adapters.
Q: Why doesn't SMS messaging work?
A: It's broken. I tried to implement it, but it failed. For now don't use it. I hope to release a new version soon. If you absoloutely must have SMS alerts, you can try using the email formatted like this: (yourphonenumber)@yourprovider.com or 1231234567@sprintpcs.com for example. Make sure that you format your phone number in 10 digit format with no dashes or spaces. You might want to check with your provider if they support email-to-phone features.
Q: Why isn't email notifications working?
A: That's probably because your provider is blocking email from coming from an internal IP address. A fix would be to install a mail server on the machine that runs netmon and have it forward to your ISP's mail server, or if you have a smartphone like I do, create an email account on the server and have your phone log in and check the email once every few minutes. This is the solution I use and it works quite well. Your mileage may vary.
Q: Are there any plans to include future code changes/features/security fixes?
A: At some point, yes but I don't know when. I have a major rewrite planned when I move the server over to a platform with a newer PHP version, (Yes I'll be fixing the register_globals issue). I also plan soon to allow you to group by server type, so that a VMware Server shows its VMs under it in Netmon as opposed to sorted by subnet and IP like they are now.
Q: Why is Netmon so slow?
Netmon can work only as fast as its underlying commands work. If you have a lot of offline servers, this might take some time for the page to load. I have tested Netmon with 16 computers, and when they're all online, the page loads in 2-3 secconds, but if most of them are offline, then sometimes it takes 10 secconds or more to finish. This is due primarily to the ping command timing out.
Modified 01/26/08 by FIRESTORM_v1