Thursday, September 29, 2011

How To Install And Run Webalizer From Source Code And How To Configure Apache For Webalizer

Hello Everybody,
Today, I will explain, briefly, how to install and run Webalizer and how to configure apache for webalizer at the same machine box. First download the source code from following address: http://www.webalizer.org/download.html (Download .tgz file). Then go to the location of this file (.tgz)and run following commands:

1. yum install gcc libpng libpng-devel gd gd-devel zlib zlib-devel
2. tar xvzf webalizer-2.23-05-src.tgz
3. cd webalizer-2.23-05
4. ./configure --prefix=/webalizer ------> Here you can specify the destination of installation. You change to somewhere else.
5. make
6. make install
7. cp /webalizer/etc/webalizer.conf.sample /webalizer/etc/webalizer.conf ----> Change to your path if you already changed it.
8. vi /webalizer/etc/webalizer.conf ------>  Uncomment and change the following lines(don't forget to change the path to your path):
    LogFile        /apa2/logs/access_log
    OutputDir      /apa2/usage
    HistoryName     /webalizer/webalizer.hist
    Incremental     yes
    IncrementalName /webalizer/webalizer.current
    Quiet           yes
    FoldSeqErr      yes
    HideURL         *.gif
    HideURL         *.GIF
    HideURL         *.jpg
    HideURL         *.JPG
    HideURL         *.png

    HideURL         *.PNG
    HideURL         *.ra


9. mkdir /apa2/usage   ------> change the /apa2 to the location of your Server root.
10. vi /apa2/conf/httpd.conf ------> change the path to the location of your httpd.conf
11. Add the following lines to your httpd.conf ------> change the /apa2 to the location of your Server root.

    <IfModule mod_alias.c>

      Alias /usage/ "/apa2/usage/"
          <Directory "/apa2/usage">
          Options None
          AllowOverride None
          Order deny,allow
          Deny from all
          Allow from 127.0.0.1
          </Directory>

    </IfModule>


12. Restart apache:  ------> change the /apa2 to the location of your Server root.
    
    /apa2/bin/apachectl restart

13. To run Webalizer manually, to generate reports, use the following command:

    /webalizer/bin/webalizer   ------> Change /webalizer/ to the location of your Webalizer. For example, if you installed Webalizer in /abc, just change it to /abc/bin/webalizer

Now, whenever you want to get the new report, you should do the step 13 manually. To run this command automatically, use cron job.

14. To see the result, open the browser and enter the following url:

     http://127.0.0.1/usage/

Now, you should see the result on the browser. For any question, please leave a comment. I will try to answer as soon as possible.

Regards,
Khosro Taraghi

Saturday, September 24, 2011

How To Start sshd Service in CYGWIN

Hello All,

Today, I want to explain that how you can start the sshd service in cygwin. First, You should download the installation file from www.cygwin.com for windows. During the installation, you must expand the Admin folder and select cygrunsrv. Also, you must expand Net and select openssh. After installation, open cygwin shell, and run the following commands:
  1. ssh-host-config -y     --------> This command will create necessary configuration files.
  2. cygrunsrv -S sshd     --------> This command will run the sshd service. This is equal to "service sshd start" command.
Now your sshd service is ready. Try by doing ssh to somewhere or someone ssh to you.
Don't forget to configure your firewall in Windows.

Regards,
Khosro Taraghi

Monday, August 29, 2011

How To Install Broadcom BCM4311, BCM4312, BCM4313, BCM4321, BCM4322, BCM43224, BCM43225, BCM43227 and BCM43228 Wireless NICs On CentOS 6

Hello Everybody,

Today, I am going to explain how to install Broadcom wireless NIC cards on CentOS 6.0. First, you should determine which Wlan chip or Wlan controller do you have. Login as root and run the following command:

[root@Centos6 ~]# lspci | grep Broadcom
02:00.0 Network controller: Broadcom Corporation BCM43224 802.11a/b/g/n (rev 01) 

As you see, my computer has BCM43224 Wlan chip. So, if your computer has one of the following Wlan chips or Wlan Network Controllers (BCM4311, BCM4312, BCM4313, BCM4321, BCM4322, BCM43224, BCM43225, BCM43227 and BCM43228), your computer will install the wireless after running the instructions below:

  1. yum install kernel-headers kernel-devel gcc 
  2. Go to this link **Click Here** and download the Broadcom Linux Driver (64 or 32 bits)
  3. mkdir -p /usr/local/khosro/taraghi-wl 
  4. cd /usr/local/khosro/taraghi-wl 
  5. tar xvfz /home/khosro/Download/hybrid-portsrc_x86_64-v5_100_82_38.tar.gz (You should change the path to the actual path of your tarball that you downloaded)
  6. make -C /lib/modules/`uname -r`/build/ M=`pwd`           ====>Your output should look something like this:
    make: Entering directory `/usr/src/kernels/2.6.32-71.29.1.el6.x86_64'
     LD      /usr/local/khosro/taraghi-wl/built-in.o
     CC [M]  /usr/local/
    khosro/taraghi-wl/src/shared/linux_osl.o
     CC [M]  /usr/local/
    khosro/taraghi-wl/src/wl/sys/wl_linux.o
     CC [M]  /usr/local/
    khosro/taraghi-wl/src/wl/sys/wl_iw.o
     LD [M]  /usr/local/
    khosro/taraghi-wl/wl.o
     Building modules, stage 2.
     MODPOST 1 modules
     CC      /usr/local/
    khosro/taraghi-wl/wl.mod.o
     LD [M]  /usr/local/
    khosro/taraghi-wl/wl.ko.unsigned
     NO SIGN [M] /usr/local/
    khosro/taraghi-wl/wl.ko
    make: Leaving directory `/usr/src/kernels/2.6.32-71.29.1.el6.x86_64'
  7. rmmod bcm43xx 
  8. rmmod b43 
  9. insmod wl.ko  ====> Load the driver module 
  10. cp -vi /usr/local/khosro/taraghi-wl/wl.ko /lib/modules/`uname -r`/extra/  
  11. depmod $(uname -r) ===> To create module dependencies
  12. vim /etc/modprobe.d/blacklist.conf     ===>And add the following lines under "# framebuffer drivers" to prevent these modules from being loaded into kernel at boot time:
blacklist bcm43xx
blacklist b43

Save the file. Now, you should see the available wirelesses under Wireless Network if you click on Wired Network icon ,usually, on top right.

Regards,
Khosro Taraghi

Friday, August 19, 2011

Monitoring Network Printers

This is a quick instructions about how to monitor the network printers in Nagios monitoring system. First important things that you should know is SNMP. Your printer should support the SNMP and also enabled on printer. HP printers that support internal/external JetDirect or other printers that support JetDirect protocol are good for this purpose.
Fisrt, we should install check_hpjd plugin.  To install this plugin, we should install net-snmp and net-snmp-utils packages.
yum install net-snmp
yum install net-snmp-utils
Next step, edit the main Nagios Configuration file:
vi /usr/local/nagios/etc/nagios.cfg
and uncomment this line:
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg
and then save it. Now edit the printer configuration file and add new host definition for the networked printer that you want to monitor.
vi /usr/local/nagios/etc/objects/printer.cfg
This is the output of this file which is a sample and modify it according to your needs
# HOST DEFINITIONS
# Define a host for the printer we'll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
        use             generic-printer         ; Inherit default values from a template
        host_name       hplj2605dn              ; The name we're giving to this printer
        alias           HP LaserJet 2605dn      ; A longer name associated with the printer
        address         192.168.1.30            ; IP address of the printer
        hostgroups      network-printers        ; Host groups this printer is associated with
        }

# HOST GROUP DEFINITIONS
# A hostgroup for network printers

define hostgroup{
        hostgroup_name  network-printers        ; The name of the hostgroup
        alias           Network Printers        ; Long name of the group
        }
# SERVICE DEFINITIONS
# Create a service for monitoring the status of the printer
# Change the host_name to match the name of the host you defined above
# If the printer has an SNMP community string other than "public", change the check_command #directive to reflect that

define service{
        use                     generic-service         ; Inherit values from a template
        host_name               hplj2605dn              ; The name of the host the service is associated with
        service_description     Printer Status          ; The service description
        check_command           check_hpjd!-C public    ; The command used to monitor the service
        normal_check_interval   10      ; Check the service every 10 minutes under normal conditions
        retry_check_interval    1       ; Re-check the service every minute until its final/hard state is determined
        }

# Create a service for "pinging" the printer occassionally.  Useful for monitoring RTA, packet loss, etc.

define service{
        use                     generic-service
        host_name               hplj2605dn
        service_description     PING
        check_command           check_ping!3000.0,80%!5000.0,100%
        normal_check_interval   10
        retry_check_interval    1
        }

After editing this file, run the following command to make sure everything is fine, especially for spelling errors:
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
It supposes to show 0 and 0 errors if these is no error.
And finally restart the service:
service nagios restart

All the best,
Khosro Taraghi

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