The goal: Install NAGIOS for system and network monitoring.
I was looking for a quick way to have a Nagios installation up and running and I found this FAN (Fully Automated Nagios)solution.
FAN 2.4, in their own words “aims to provide a facility for Nagios including tools provided by the Nagios community”.
You can download the .iso file from the FAN official website.
I downloaded the 64 bit version (FAN-2.4-x86_64.iso) for a Centos 4/5/6 x64 Virtual Machine that I created in my vSphere 5.5 infrastructure.
The problem: No eth0 device = no network connectivity.
Everything was smooth during the installation, up to the point where you were supposed to setup the “Network Configuration”. After selecting “Edit Devices”, there was nothing in there! There was supposed to be an eth0 device, but there was none:
I opened the console of the VM through the vSphere client and issued an “ifconfig”, but only the loopback interface (lo) showed up, no eth0.
I thought that I had done something wrong during installation, so I tried again:
- I created a new x64 Centos 4/5/6 VM
- I booted the VM from its CD-ROM, which was emulated by the Fully Automated Nagios’ .iso file.
- I followed the few steps as shown in the “How to Install FAN” (actually you don’t even need to read that, as these steps are way too self-explanatory).
- I “removed the FAN CD-ROM” by deselecting the “Datastore ISO File” option from the VM settings and rebooted the VM.
The result was the same thing: no eth0 interface, just a loopback interface.
I googled for “Fully Automated Nagios eth0″, but nothing came up, just the links to FAN’s website.
I tried changing the “Adapter Type” of the single Network Adapter that I had given to this VM. I switched it from the default “E1000″ to “VMXNET 2″ and “VMXNET 3″, but the ifconfig command was still showing no eth0 device.
I added another 2 Network Adapters to the VM, just in case the loopback interface ounted as 1 and the “eth0″ needed a second adapter, but that was not the case.
- “ifup eth0″ did not work because eth0 was not found.
- “ifconfig eth0 up” did not work because there was no such device.
I tried then googling for “Centos not seeing eth0″ and I got more results. These had nothing to do with FAN or Nagios for that matter, but many of them made reference to Centos 6, which is used by FAN, so that had to do for now.
I found a post that talked about “old subsystem entries” of eth0 and that I had to edit “/etc/udev/rules.d/70-persistent-net.rule” with the “vi” editor to rename eth1 to eth0. In my case, there was no “70-persistent-net.rule” file. Which made sense after all because the scenario portrayed in this post seemed to refer only to moved or copied RHEL/CentOS VMs in vSphere.
Many other posts and forum entries talked about how you needed to make sure the lines “ONBOOT=”YES” and “DEVICE=eth0″ were present in your ifcfg-eth0 file. Some of them had very similar symptoms, like this one about a CentOS 6.4 in VirtualBox and this one about “CentOS 6.3 Device eth0 does not seem to be present“.
Some other posts even claimed that it was an issue with the MAC address associated to the eth0 interface.
None of them mentioned a situation where this file did not exist at all. That’s why I decided to write this post.
I struggled mainly with 2 files:
However, I have to point out that after installing and rebooting my FAN VM, these files were non-existent. The “etc/sysconfig/networking/devices/” folder was empty and there was no “ifcfg-eth0″ file inside the “etc/sysconfig/network-scripts” directory.
This is probably why the FAN setup script was not able to find any device, as shown above.
I tried creating and modifying these files in many ways and restarting the network service (issuing the “sudo service network restart” command) after every change, but I always got an error when the system tried to bring up my newly defined eth0 device. This was quite a tiresome task.
Just for the record, in one of my working CentOS installations, these 2 files have identical content. I don’t think one is a symbolic link to another, they seem to have been created though at the same time:
[root@locfan network-scripts]# ls /etc/sysconfig/network-scripts -la
drwxr-xr-x 2 root root 4096 Jul 1 14:29 .
drwxr-xr-x 9 root root 4096 Jul 1 17:53 ..
-rw-r–r– 3 root root 141 Jul 1 17:53 ifcfg-eth0
-rw-r–r– 1 root root 254 Dec 19 2011 ifcfg-lo
[root@locfan network-scripts]# ls -la /etc/sysconfig/networking/devices/
drwxr-xr-x 2 root root 4096 Jul 1 17:50 .
drwxr-xr-x 4 root root 4096 Jul 1 09:58 ..
-rw-r–r– 3 root root 141 Jul 1 17:53 ifcfg-eth0
[root@locfan sysconfig]# cat /etc/sysconfig/networking/devices/ifcfg-eth0
[root@locfan sysconfig]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
The Solution: Simply install VMware Tools.
After I unsuccessfully tried all sorts of modifications in the previous files to make CentOS be aware of eth0, I tried what seemed to be a long shot: installing VMware tools. And I say that it was a long shot because I had previously installed another CentOS 6 in an exacttly identical VM when I deployed CactiEZ and I had no problems with the eth0 interface. I actually never installed VMware tools and my Cacti 0.8.8b is up and running.
I got the idea to install it after reading one of the forums, where someone had a similar problem and someone had asked if he had installed VMware Tools. That forum thread was closed without a solution, so I decided to give it a try.
To install VMware tools in this FAN VM with 64 bit CentOS, I followed most of the steps outlined in this “CentOS 6.2 VMware Tools Install the Easy Way“. Actually, I just omitted the first command: “yum -y install perl”.
Instead I clicked on “Install/Upgrade VMware Tools” from the “VM” – “Guest” menu of the VM console from the vSphere client.
The OS needs to have already been started prior to this.
This does not effectively complete all the installation process of VMware Tools as it actually does in a Windows VM. Instead, it just “prepares the environment”.
You need to mount the cd-rom, copy the contents, uncompress them and run the installation script yourself:
After successfully installing VMware Tools in this Centos 5.9 distribution, the eth0 interface showed up in the “ifconfig” output:
[root@locfan ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:AB:BE:DD
inet addr:10.131.17.201 Bcast:10.131.17.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:403346 errors:0 dropped:0 overruns:0 frame:0
TX packets:27932 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:29013768 (27.6 MiB) TX bytes:18388673 (17.5 MiB)lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:354632 errors:0 dropped:0 overruns:0 frame:0
TX packets:354632 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:68104932 (64.9 MiB) TX bytes:68104932 (64.9 MiB)[root@locfan ~]#
The Fully Automated Nagios guys should at least mention on their “How to Install FAN” link, that in order for the underlying OS to be able to detect a network adapter, namely eth0, you need to first install VMware tools. As simple as that.