Thursday, June 9, 2011

Adding Windows machines to Nagios

Adding Windows machines to Nagios
Nagios is an open source powerful monitoring system that enables you to monitor your servers, services, application and so on. It has also ability to monitor Windows based servers, but in order to communicate with Windows servers, you should install Nagios agent on each machine. I am going to explain that how to configure the Nagios for Windows machine and also how to install Nagios Client agent on the Windows machine.
Here is the general idea:
Nagios(Monitoring Server(Linux)) -----àcheck_nt ---------------àNSClient++ ----àCPU
Nagios(Monitoring Server(Linux))  -----àcheck_nt --------------àNSClient++ ----àMemory
Nagios (Monitoring Server(Linux)) ----àcheck_nt ---------------àNSClient++ ----àDisk Space
Nagios(Monitoring Server(Linux))  -----àcheck_nt --------------àNSClient++ ----àProcesses
Nagios(Monitoring Server(Linux))  -----àcheck_nt --------------àNSClient++ ----àServices

Configure Nagios:
1.       Login as su (Super User)
2.       vi /usr/local/nagios/etc/nagios.cfg
3.       remove (#) sign from the following line:
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
Save the file and exit.
4.       Go to /usr/local/nagios/etc/objects/ directory.(cd /usr/local/nagios/etc/objects)
5.       Edit windows.cfg (vi windows.cfg)
6.       Under Host Group Definitions, define a hostgroup for windows machines. An example can be like this:
define hostgroup{
                hostgroup_name             myWindows
                alias                                       Windows Machines
                }
7.       Under Service Definitions, create services for Uptime of the server, CPU load, Memory Usage, and C:\ disk usage like this:
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        Uptime
                check_command             check_nt!UPTIME
                }
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        CPU Load
                check_command             check_nt!CPULOAD!-l 5,85,95
                }
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        Memory Usage
                check_command             check_nt!MEMUSE!-w 90 –c 95
                }
define service{
                use                                        generic-service
                hostgroup_name             myWindows
                service_description        C:\ Drive Space
                check_command             check_nt!USEDDISKSPACE!-l c -w 85 –c 95
                }

which –w means Warning and –c means Critical.
8.       Now, you should define your hosts for windows machines that we are going to monitor, something like this for each host:

Define host{
                use                         myWindows
                host_name         xxxxxxxx
                alias                       yyyyyyy
                address                                xxxxxxxx.xxx.xxx
                }
Replace  xxxxxxxx with actual hostname and yyyyyyy with a longer name associated with the host and xxxxxxx.xxx.xxx with fully qualified name of host.

9.       Test nagios configuration   with this command:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
You should see these lines from the output:
Total Warnings: 0
Total Errors:   0
If you see any error, check your configuration file.
10.   Restart Nagios:  restart nagios service

Nagios agent for Windows OS(NSCLIENT++):
Nsclient++ is a secure monitoring daemon for Windows OS. Nsclient++ has to install in Windows machine in order to talk with Linux machine and nagios. You can download the latest version(msi) of nsclinet++ from this link:  http://nsclient.org/nscp/downloads
Run installation and put the fully qualified name of the Windows machine into the Allowed Hosts and then check all options and don’t check the NSCA if you are not sure. At the end, check Start Services.
Regards,
Khosro Taraghi

Friday, April 22, 2011

SBR600 Project - Release 0.3 :: How My Package Works

Hello,
I thought that it can be useful if I explain about my spec file and describe the major parts of this file for more clarification. It is simple. If the Arch is ARM, it follows the lines bellow. If the Arch is not ARM, it continues as a regular kernel package like before.
You can download my spec file from this link:  SPEC File
I am going to explain the major parts. I took the following lines from spec file (explanations are after commands which are started with #:

%prep
%setup -q
mkdir -p tmp
#Here, I made a temporary file for saving module files for later use. Modules files #are created by kernel and we will use that with dracut to make initramfs or #ramdisk.
%build
make ARCH=arm omap3_beagle_defconfig
#configuration of kernel source for a particular architecture, which is ARM in #this case, and select the config file. In this case, I selected #omap3_beagle_defconfig for my ARM board.
make clean
make uImage
#Compile the kernel. If you are testing on your own computer (different #architecture than ARM), you should use CROSS COMPILE
make modules
#Compile kernel modules
make modules_install INSTALL_MOD_PATH=tmp
#Install the modules into tmp directory that I mentioned above for later use.
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p %{buildroot}/boot
#Prepare /boot directory for installing kernel and initramfs
cp arch/arm/boot/uImage %{buildroot}/boot/uImage-%{version}
#Copy the compiled kernel to the /boot directory with proper name.
ln -f %{buildroot}/boot/uImage-%{version} %{buildroot}/boot/uImage.bin
#Keep track of each installation of kernel by using ln command and make the last #one as a default for kernel
#mkdir -p %{buildroot}/%{_sysconfdir}
#cp -p %{SOURCE1} %{buildroot}/%{_sysconfdir}
#These two lines are not usable for release 0.3, but I mentioned here because I #used in previous versions. Because I wanted to make a small initramfs, I used a #small version of dracut.conf for using during the installation of package. So, I #imported dracut.conf by SOURCE1 and copied into the /etc directory.
mkdir -p %{buildroot}/lib/modules/%{version}
#Make a directory for copying the modules from tmp directory to proper #destinations.
cp -p -r tmp/lib/modules/%{version}/* %{buildroot}/lib/modules/%{version}
#Copy modules
%post
dracut -H -f /boot/initramfs-%{version}.img %{version}
#Making initramfs by dracut for last kernel
ln -f /boot/initramfs-%{version}.img /boot/initramfs.img
#keep track of each initramfs by using ln command and select the last one as a #default.

I hope you enjoyed from this article.
Best regards,
Khosro Taraghi

SBR600 Project Release 0.3


Hello Everybody,

Today, I released my SBR600 project version 0.3. I tested my last package several times and it worked successfully. It was actually an extension of my project version 0.2. Not only I changed version 0.2 to works with any kernel, including the new kernels, but also I merged my package with primary kernel package. So, when the Arch is ARM, it installs my package (RPM-based kernel for ARM) and when the Arch is something else, it works as a regular kernel installation. In other words, I could create a RPM-based kernel for ARM which was my project. I built my package on both ARM and Primary architecture to make sure that it works.
This is the output of "ll" command before installing of last version of kernel in my ARM board:

[root@fedora-arm khosro]# ll /boot/
total 7824
drwxr-xr-x 2 root root 4096 Apr 14 2011 grub
-rw-r--r-- 1 root root 2071652 Apr 14 2011 initramfs-2.6.32.img
-rw-r--r-- 1 root root 2071652 Apr 14 2011 initramfs.img
-rw-r--r-- 1 root root 1909048 Apr 14 2011 uImage-2.6.32
-rw-r--r-- 1 root root 1909048 Apr 14 2011 uImage.bin

And here is the output of "ll" command after installing my package which shows the new files: (pay attention to link files):

[root@fedora-arm ~]# ll /boot/
total 11900
drwxr-xr-x 2 root root 4096 Apr 14 2011 grub
-rw-r--r-- 1 root root 2071652 Apr 14 2011 initramfs-2.6.32.img
-rw-r--r-- 2 root root 2070985 Dec 31 1999 initramfs-2.6.35.img
-rw-r--r-- 2 root root 2070985 Dec 31 1999 initramfs.img
-rw-r--r-- 1 root root 1909048 Apr 14 2011 uImage-2.6.32
-rw-r--r-- 2 root root 2003236 Apr 21 2011 uImage-2.6.35
-rw-r--r-- 2 root root 2003236 Apr 21 2011 uImage.bin

The 2.6.35 is the last version of kernel up to this point that I wrote this blog.
Now, this is the output of booting my ARM board with new kernel (also, pay attention to “uname” command after logging to system):

## Booting kernel from Legacy Image at 80200000 ...
Image Name: Linux-2.6.35
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2003172 Bytes = 1.9 MB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 81600000 ...
Image Name: boot initramfs
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 2631748 Bytes = 2.5 MB 
Load Address: 81600000
Entry Point: 81600000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Data Size: Linux version 2.6.35 (mockbuild@koji3.laptop.org) (gcc version 4.4.5 20101112 (Red Hat 4.4.5-2) (GCC) ) #1 Thu Apr 21 14:40:04 EDT 2011
CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c53c7f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: OMAP3 Beagle Board
Memory policy: ECC disabled, Data cache writeback
OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp )
SRAM: Mapped pa 0x40200000 to va 0xfe400000 size: 0x100000
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024
Kernel command line: console=ttyS2,115200n8 root=/dev/mmcblk0p2 rootfstype=ext2 eq rootdelay=1 nohz=off
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 128MB 128MB = 256MB total
Memory: 253360k/253360k available, 8784k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xd0800000 - 0xf8000000 ( 632 MB)
lowmem : 0xc0000000 - 0xd0000000 ( 256 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0027000 ( 124 kB)
.text : 0xc0027000 - 0xc037d000 (3416 kB)
.data : 0xc0394000 - 0xc03c58c0 ( 199 kB)
Hierarchical RCU implementation.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:402
Clocking rate (Crystal/Core/MPU): 26.0/332/720 MHz
omap_hwmod: l3_hwmod: cannot be enabled (3)
omap_hwmod: l4_core_hwmod: cannot be enabled (3)
omap_hwmod: l4_per_hwmod: cannot be enabled (3)
omap_hwmod: l4_wkup_hwmod: cannot be enabled (3)
Reprogramming SDRC clock to 332000000 Hz
GPMC revision 5.0
IRQ: Found an INTC at 0xfa200000 (revision 4.0) with 96 interrupts
Total of 96 interrupts on 1 active controller
OMAP GPIO hardware version 2.5
OMAP clockevent source: GPTIMER12 at 32768 Hz
Console: colour dummy device 80x30
Calibrating delay loop... 742.58 BogoMIPS (lpj=2899968)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
regulator: core version 0.5
NET: Registered protocol family 16
Found NAND on CS0
Registering NAND on CS0
Unable Setting up Logical Volume Management: No volume groups found
[ OK ]
Checking filesystems
Checking all file systems.
[/sbin/fsck.ext2 (1) -- /] fsck.ext2 -a /dev/mmcblk0p2
/dev/mmcblk0p2: Superblock last mount time is in the future.
(by less than a day, probably due to the hardware clock being incorrectly set) FIXED.
/dev/mmcblk0p2: Superblock last write time is in the future.
(by less than a day, probably due to the hardware clock being incorrectly set). FIXED.
/dev/mmcblk0p2: clean, 46024/425152 files, 301506/1699840 blocks (check after next mount)
[ OK ]
Remounting root filesystem in read-write mode: [ OK ]
Mounting local filesystems: [ OK ]
Enabling /etc/fstab swaps: [ OK ]
Entering non-interactive startup
FATAL: Module ipv6 not found.
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
FATAL: Module ipv6 not found.
Mounting other filesystems: [ OK ]
Retrigger failed udev events[ OK ]
Starting sshd: [ OK ]

Fedora release 13 (Goddard)
Kernel 2.6.35 on an armv7l (console)
fedora-arm login: root
Password:
Last login: Fri Dec 31 19:01:49 on console
[root@fedora-arm ~]# uname -a
Linux fedora-arm 2.6.35 #1 Thu Apr 21 14:40:04 EDT 2011 armv7l armv7l armv7l GNU/Linux

These are the pictures form koji that shows my successful build:





These are the all links for downloading packages for release 0.3:
Thanks to everyone who helped me on this project, especially Chris Tyler.

Best Regards,
Khosro Taraghi
 



 


Monday, April 4, 2011

A Rough RPM-based Kernel for Fedora ARM - Release 0.2 SBR600 Project

Hello,
I already made a RPM package for kernel 2.6.32 which is installed in ARM architecture. This is a rough package which means I used some hardcode instead of macros since I was experimenting with this. However, it is very close to final package (I hope). I released this package for my SBR600 project as release 0.2. It installs kernel 2.6.32 and initramfs in your Beagle ARM board and changes your current kernel version to 2.6.32. It keeps the previous version too. Here is a brief explanation about my spec file that I hope it would be useful for you. Also, at the end, I added my spec and srpm files so that you can download them for further review.
I will focus on important parts of spec file:
  1. %prep:   Make a temporary directory for kernel modules so that they will use later for dracut
  2. %build:   Make config file for kernel, compile kernel, make modules, install modules for later use via dracut
  3. %install:  Preparing /boot directory and copying kernel, using "ln" command to keep track of installed kernels, preparing /etc directory for copying dracut.conf in this directory, and preparing installed modules with kernel for ARM which is used with dracut
  4. %post:   Install initramfs with dracut and use "ln" command to keep track of each installed initramfs
These are my spec, rpm, and srpm files: spec file, rpm file, and srpm file
This is a picture of koji that shows I made package successfully.

I will post more details very soon.

Best Regards,
Khosro Taraghi

Sunday, April 3, 2011

Fedora/ARM Cross Toolchain - Cross-compiling for ARM

Hello,
These are quick instructions to install Fedora/ARM cross toolchain in your computer if your computer has i386 or x86_64 architecture. So, after installation, you are able to cross compile your source code for ARM architeture in your i386 or x86_64 computer. These are the commands you should run:

# cd /etc/yum.repos.d/
# wget http://ftp.linux.org.uk/pub/linux/arm/fedora/cross/cross.repo
# yum install armv5tel-redhat-linux-gnueabi-gcc
This will install everything necessary to run the C compiler and  cross-build ARM libraries and binaries that are entirely binary  compatible with the native Fedora/ARM libraries and binaries.

Regards,
Khosro Taraghi

Tuesday, March 15, 2011

Boot up the ARM board with initramfs and generic kernel

Hello everyone,
Today, I am going to explain that how you can boot up the ARM board manually with a generic kernel and initramfs that I made it last time. Please see my previous blog post for more details about initramfs and compiling the kernel.

These are the steps for booting up the board with short explanations:
  1. mmc init    ----------->After getting prompt with Uboot, this command gets your access to SD card
  2. fatload mmc 0 0x80200000 uImage.bin   -----------> This command loads the uImage.bin or uImage to that address in the memory. uImage is your compiled kernel.
  3. fatload mmc 0 0x81600000 uImage.ramdisk  -----------> To load initramfs to that address in memory. The addresses are in hexadecimal notation.
  4. setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rootfstype=ext2 eq rootdelay=1 nohz=off     ---------------> These are the boot args for kernel. When the kernel loads, it uses these arguments during the boot process. You can change the args according to your specification but  mine works with these args without any problems.
  5. bootm 0x80200000 0x81600000    -----------------> This will execute the kernel and initramfs in the memory, which we loaded in the steps 2 and 3, and you will get prompt to log in to the system.
That is all steps that you need to boot your board and get prompt for loging in. Here is a part of the output of my ARM board that shows booting kernel and loading initramfs from images that I already loaded in the memory:

Booting kernel from Legacy Image at 80200000 ...
Image Name: Linux-2.6.28-omap1
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2577980 Bytes = 2.5 MB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Loading init Ramdisk from Legacy Image at 81600000 ...
Image Name: boot initramfs
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 2631748 Bytes = 2.5 MB
Load Address: 81600000
Entry Point: 81600000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ... 
.
.
.
Regards,
Khosro Taraghi

Monday, March 7, 2011

SBR600 Project - Release 0.1 Update

Hi,
I updated my project (release 0.1) with recent news and accomplishments. Please click on this link Last Update to see the results.

All the best,
Khosro Taraghi