Setup check_mk

Check_MK is a monitoring solution which is originally based on Nagios. It has been extended with a nice web gui including a lot of new features which simplify the setup of a monitoring system. It is available as Enterprise edition and as RAW (Open Source) edition.

There is a limited english documentation available. https://mathias-kettner.de/checkmk.html

Steps to install and configure Check_MK on CentOS7:

Download CentOS7 image (minimal is sufficient) http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso

Install Centos following the standard documention. After you have successfull installed Centos login to the system using SSH.

ssh root@centos7

First install all available updates.

yum update

Second some packages are required to be able to install check_mk successfully.

yum -y install epel-release
yum makecache all
yum -y install php-mcrypt

Download fping (http://pkgs.repoforge.org/fping/?C=M;O=D) and install it:

cd /root
wget http://pkgs.repoforge.org/fping/fping-3.10-1.el7.rf.x86_64.rpm
rpm -i fping*.rpm

Furthermore it is required to change SELINUX.

vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

change to

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Reboot the Centos machine to apply the new SELINUX settings.

init 6

Download check_mk RAW edition for CentOS7 and install it:

https://mathias-kettner.de/support/1.2.6p16/check-mk-raw-1.2.6p16-el7-34.x86_64.rpm
rpm -i check-mk-raw*.rpm

After you have installed Check_MK you have to create your monitoring side. In this example I call it “internal”.

omd create internal
omd start internal

Now you should be able to access check_mk using your browser http://centos7/internal. The last part of the URL is the name of the created side.

check_mk_login

Login using the default credentials

User: omdadmin
Password: omd

check_mk_dashboard

That’s all for the setup in part 2 I will describe how to configure ESXi or vCenter monitoring.

VMware tools repository

You can install the VMware tools using the Wizzard in the vSphere client but this is not the best solution. VMware is offering an repository which you can use to install the VMware tools using your package manager.

URL of the repository: http://packages.vmware.com/tools/esx/5.5/index.html

Example for Redhat 6 64bit running on ESXi 5.5:


cd /etc/yum.repos.d/

vi VMware-Tools.repo
[vmware-tools]

name=VMware Tools
baseurl=http://packages.vmware.com/tools/esx/5.5/rhel6/x86_64
enabled=1
gpgcheck=1
gpgkey=http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub

Collect ESXi stats with powershell and send it to Graphite server

I was not quite happy with the statistics from the vCenter. It is not possible to get an overview overall my ESXi servers. :-( Someone pointed me to the tool Graphite that this is a cool solution to visualize such kind of statistics. So I decided to give it a try.

I created and virtual machine running Centos and Graphite as target for my collected statistics. I will post an How to later.

Furthermore I had to create an powershell script which collects the stats of each ESXi in my cluster, transform it a graphite compatible format and transfer it to the graphite server.

#vCenter settings
$vCenter = "VCENTER-IP"
$user = "USERNAME"
$password = "PASSWORD"
$cluster = "YOUR-CLUSTER"
#Graphite server 
$remoteHost = "GRAPHITE-SERVER-IP"

#Socket to send results to Graphite server	 
$socket = new-object System.Net.Sockets.TcpClient($remoteHost, 2003)
$stream = $socket.GetStream()
$writer = new-object System.IO.StreamWriter $stream

Write-Host "Connected"
#Connect to vCenter
Connect-VIServer -Server $vCenter -User $user -Password $password 

#Get all ESXi hosts from Cluster
$esxhosts = Get-VMHost -Location $cluster | Sort

#Collect stats foreach ESXi server and bring it in a Graphite compatible format
foreach ($esxName in $esxhosts){

	$allstats = Get-Stat -Entity (Get-VMHost $esxName) -MaxSamples 1 -Realtime -Stat cpu.usage.average,disk.usage.average,net.usage.average | Sort
	Write-Host $esxName
	foreach($stat in $allstats){
		#Get Timestamp of stats and convert to UNIX timestamp
		$time = $stat.Timestamp
		$date = [int][double]::Parse((Get-Date -Date $time -UFormat %s))
		#Filter only average stats (Stats for CPU's are available foreach CPU and as average of all CPU's)
		$instance = $stat.Instance
		if($instance -eq [DBNull]::Value){
			#create a base for the graphite tree
			$base = "dc.vmware.prod."
			#remove the .usage.average
			$type = (($stat.MetricId).Replace(".usage.average",""))
			#remove the domain from the esxi name
			$name = (($esxName.Name).Replace(" ","")).Replace(".your-domain.de","")
			$value = $stat.Value
			#build the graphite compatible string
			$result = "$base$name.$type $value $date"
			#Console output just for testing
			Write-Host "Sent Result: $result"
			#send result to graphite server
			$writer.WriteLine($result)
			$writer.Flush()
		}
	}
	Write-Host " "
}
## Close the streams
$writer.Close()
$stream.Close()
#disconnect from vcenter
Disconnect-VIServer -Server $vCenter -Confirm:$false -Force
Write-Host "Done"

Below is a screenshot of an Graphite graph displaying the CPU average usage of all ESXi servers.

That’s it :-)

OpenSource RedHat Satellite Server – Spacewalk

I found this software during my search for a management solution for a virtual appliance farm running hundreds of CentOS based virtual machines. As CentOS is binary compatible to RedHat it makes sense to use a RedHat satellite server equivalent for software management.

Spacewalk is an open source (GPLv2) Linux systems management solution. It is the upstream community project from which the Red Hat Network Satellite product is derived.

What Can Spacewalk Do?

Spacewalk is an open source (GPLv2) Linux systems management solution that allows you to:

* Inventory your systems (hardware and software information)
* Install and update software on your systems
* Collect and distribute your custom software packages into manageable groups
* Provision (kickstart) your systems
* Manage and deploy configuration files to your systems
* Monitor your systems
* Provision and start/stop/configure virtual guests
* Distribute content across multiple geographical sites in an efficient manner.

Link to Spacewalk