Random Bits

Technical Log from Didik Setiawan

Insert USB Module in Linux Kernel

After I re-compile my kernel using a vanilla one, I found that my usb flashdrive can not be detected by my operating system. I check on dmesg, there are entry about my usb flashdrive on the log:

[email protected]:~$ dmesg
--- output omitted ---
[  123.616624] usb 1-1.2: new high-speed USB device number 3 using ehci-pci
[  123.710606] usb 1-1.2: New USB device found, idVendor=0951, idProduct=1666
[  123.710617] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  123.710631] usb 1-1.2: Product: DataTraveler 3.0
[  123.710634] usb 1-1.2: Manufacturer: Kingston
[  123.710637] usb 1-1.2: SerialNumber: 60A44C3FACDBBDB1796E36C9
--- output omitted ---

But, after a moment I wait, there is no notification about new flashdrive inserted. I check using blkid, still there is no sign of the thing.

[email protected]:~$ sudo blkid
[sudo] password for didik: 
/dev/sda1: LABEL="SYSTEM" UUID="70E80099E8005FA8" TYPE="ntfs" PARTUUID="ba6ded71-01"
/dev/sda2: UUID="92521783-0211-4b1d-8f66-b9a62c16fc89" UUID_SUB="fdb1cb3e-1a44-4e53-864e-b29f6fdfb153" TYPE="btrfs" PARTUUID="ba6ded71-02"
/dev/sda3: UUID="4723c4f7-9624-4b8d-9b41-3079442641b4" TYPE="swap" PARTUUID="ba6ded71-03"
/dev/sda5: LABEL="DATA" UUID="01CD0094E26EBB80" TYPE="ntfs" PARTUUID="ba6ded71-05"

Apparently, I forget to insert usb-storage module in my kernel, after I recompile it. So, I try to modprobe the needed module.

[email protected]:~$ modprobe usb-storage
modprobe: FATAL: Module usb-storage not found in directory /lib/modules/4.6.2

Okay, it seems that the file I need is not available from the kernel tree. So, I need to insert the module manually.
Time to go to kernel tree.

[email protected]:~$ cd linux-4.6.2/
[email protected]:~/linux-4.6.2$ make menuconfig

From this menu, I will include the module that I need for usb-storage. Press / to search module name. It is called USB_STORAGE.

usb-module0.png

After I found its location, I insert it with “M” become my choice between the tri-state mode.

usb-module1.png

I exit and save this configuration.
Then I make it.

[email protected]:~/linux-4.6.2$ make -j8

Note that the “8” value is changeable depends on processor specs.
Install old and new compiled module, as root of course.

[email protected]:~/linux-4.6.2$ sudo make modules_install

My new module finally installed. Now I can plug the usb drive on my computer.
Just in case you are curious about system message of the inserted device, you can use dmesg.

[email protected]:~$ dmesg
--- output omitted ---
[ 3231.314581] usb 1-1.2: USB disconnect, device number 3
[ 3233.198257] usb 1-1.2: new high-speed USB device number 4 using ehci-pci
[ 3233.292379] usb 1-1.2: New USB device found, idVendor=0951, idProduct=1666
[ 3233.292390] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3233.292395] usb 1-1.2: Product: DataTraveler 3.0
[ 3233.292399] usb 1-1.2: Manufacturer: Kingston
[ 3233.292403] usb 1-1.2: SerialNumber: 60A44C3FACDBBDB1796E36C9
[ 3233.990697] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ 3233.990994] scsi host6: usb-storage 1-1.2:1.0
[ 3233.991196] usbcore: registered new interface driver usb-storage
[ 3234.995392] scsi 6:0:0:0: Direct-Access     Kingston DataTraveler 3.0 PMAP PQ: 0 ANSI: 6
[ 3234.996242] sd 6:0:0:0: Attached scsi generic sg2 type 0
[ 3234.996655] sd 6:0:0:0: [sdb] 31293440 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 3234.998693] sd 6:0:0:0: [sdb] Write Protect is off
[ 3234.998705] sd 6:0:0:0: [sdb] Mode Sense: 2b 80 00 08
[ 3235.000537] sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 3236.101997]  sdb: sdb1
[ 3236.108153] sd 6:0:0:0: [sdb] Attached SCSI removable disk
--- output omitted ---

And modinfo to view module details.

[email protected]:~$ modinfo usb-storage
filename:       /lib/modules/4.6.2/kernel/drivers/usb/storage/usb-storage.ko
license:        GPL
description:    USB Mass Storage driver for Linux
author:         Matthew Dharm <[email protected]>
srcversion:     D0235102D9160CC35A9A1C4
alias:          usb:v*p*d*dc*dsc*dp*ic08isc06ip50in*
alias:          usb:v*p*d*dc*dsc*dp*ic08isc05ip50in*
--- output omitted ---
alias:          usb:v03EEp6906d0003dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v03EBp2002d0100dc*dsc*dp*ic*isc*ip*in*
depends:        
intree:         Y
vermagic:       4.6.2 SMP mod_unload modversions 
parm:           option_zero_cd:ZeroCD mode (1=Force Modem (default), 2=Allow CD-Rom (uint)
parm:           swi_tru_install:TRU-Install mode (1=Full Logic (def), 2=Force CD-Rom, 3=Force Modem) (uint)
parm:           delay_use:seconds to delay before using a new device (uint)
parm:           quirks:supplemental list of device IDs and their quirks (string)

Until next time.

Build Custom Linux Kernel

Install Custom Linux Kernel

To build this custom Linux Kernel, I use Ubuntu 14.04 64 bit operating system. At first, ensure all the required utilities installed correctly.

$ sudo apt-get install vim libncurses5-dev gcc make git exuberant-ctags libssl-dev

Download source from Linux Kernel Archives, for example, I use version 4.4.
https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.tar.xz

Extract the tarball file.

$ tar xJf linux-4.4.tar.xz
$ cd linux-4.4

We need to change configuration parameters to determine which settings and modules we need to build. Use make *config command as follow. Choose one that match to your favor. I usually use number 2.

1. Use default kernel configuration.

This settings comes from the kernel maintainer.

$ make defconfig

2. Use our existing configuration.

Just press “Enter” when asked for configuration options.

$ make localmodconfig

3. Manual selection with graphical menu.

$ make menuconfig

4. Duplicate our current config.

$ sudo cp /boot/config-`uname -r`* .config

Then, compile source, this process can take a while.

$ make -j4

The parameter “4” is based on processor specification. Set this at your own favor.
Install modules.

$ sudo make modules_install

Bootloader setup.

$ sudo make install

Double check bootloader setup.

$ sudo update-grub2

Reboot the system. We can check our new installed kernel with this command.

$ uname -a

Uninstall Custom Linux Kernel

Find out the version of custom kernel.
Update filesystem search index.

$ sudo updatedb

In this example, I want to remove kernel version 3.16.0-30-generic.

$ CUSTOM_KERNEL_VERSION="3.16.0-30-generic"
$ locate $CUSTOM_KERNEL_VERSION

Ensure our system has other kernel installed beside $CUSTOM_KERNEL_VERSION.
Then, delete all files & folders which contain $CUSTOM_KERNEL_VERSION name.

$ sudo rm /boot/vmlinuz-$CUSTOM_KERNEL_VERSION
$ sudo rm /boot/initrd.img-$CUSTOM_KERNEL_VERSION
$ sudo rm /boot/System.map-$CUSTOM_KERNEL_VERSION
$ sudo rm /boot/config-$CUSTOM_KERNEL_VERSION
$ sudo rm -rf /lib/modules/$CUSTOM_KERNEL_VERSION/
$ sudo rm /var/lib/initramfs-tools/$CUSTOM_KERNEL_VERSION

Do some cleaning.

$ sudo update-initramfs -k all -u
$ sudo update-grub2

Finish. Our custom kernel has been uninstalled from our system.

Certification

This story tell about my journey to obtain CCNA Certificate. It is all about my desire to obtain CCNA in 2013, but just realized in 2015. As proverb said, better late than never.

For exam preparation, I have been started since 2013. At that time, I get inspiration from some source about Cisco Certification, that is CCIE. Getting to know how can be so great the CCIE title, me who have been work out of the IT sector, determine to occupy computer networking world once more. Because to obtain the CCIE itself at that time is something impossible, then I think it must be started from entry level that is CCNA.

I try to collecting material to learn networking, especially CCNA. A matter of fact, I feel I need to learn start from the bottom again. My main material at that time is using book from Mr. Todd Lammle that is CCNA Routing and Switching Study Guide. Beside that, I also start to try simulate Cisco IOS using GNS3 and Packet Tracert.

Until 2014, I still busy explore that text book. I start to look for another learning source and I found www.cbtnuggets.com. At that site, I get training material in the form of video which content is good enough, covered about CCNA with interesting approach.

At first I follow training in the form of CCNA theory from Mr. Jeremy Ciora. Afterwards, continue with practice and hands-on lab using GNS3 and Wireshark by Mr. Keith Barker. There are exam walthrough too, thats like try out before exam which is brought by Mr. Keith Barker and Mr. Anthoni Sequiera. The questions are hard enough, so it can trigger more enthusiasm about CCNA material.

To get more confidence, I read the CCNA Routing and Switching 200-120 Official Cert Guide from Mr. Wendell Odom, though just skimming because almost the material have been covered in the Mr. Todd Lammle book. I also use flash card that I get as bonus from Mr. Todd Lammle’s CCNA book.

Beside that, I download some cheat sheet from Mr. Jeremy Stretch’s packetlife.net, which contain summaries from popular networking terminology. I also use some packet tracert trouble ticket study case which I obtain from idn.id, an Indonesian networking consultant.

At last, some stuff from the www.freeccnaworkbook.com. Interesting, because beside CCNA material exist, there are offering live lab that can be accessed, freely available. From there, we can practice hands-on lab using real Cisco device through remote connection.

There are lab replica using GNS3 that can be download. I try to using lab which called stub lab freeccnaworkbook.com to solve challenge offered. Just sign up, booking date to lab, and we can use lab at scheduled time.

The cost to use this lab is free, but if we want to more feature so our lab can be reviewed, we must donate some dollars. It can be usefull to know which points we need to extra study. Not bad to add some hands-on experience.

Here is my reference list that can be material to pass CCNA exam:

  • CCNA Routing and Switching Study Guide Book by Todd Lammle
  • CCNA Routing and Switching 200-120 Official Cert Guide Book by Wendell Odom
  • Training Videos from CBT Nuggets
  • Flashcard & Glossary from CCNA R/S Study Guide book bonus
  • Cheat Sheet from packetlife.net
  • Free CCNA Workbook
  • CCNA Packet Tracert Troubleshooting Ticket

After confident enough with material that have been studied, I decided to sign up CCNA exam, with my own money of course. With help from friend who sell CCNA voucher (I know him from internet mailing list) I can get exam price cheaper than normally one.

Something that make me worry, is that the paying method of the exam must use credit card, which I don’t have at this time. But with help from that voucher seller before, I can completing the payment process. And after all administration requirement fullfilled, I can book CCNA exam at November 12th, 2015 in Duta Wacana Christiant University Yogyakarta.

The exam itself took two hours to finish. Some questions are hard and doubtfull to answer. After I submit, the result is immediately appear. Finally, I pass the exam. Then I get temporary notification about passing CCNA as softcopy file. Based on information from the proctor, I will get email from Cisco which contain official softcopy certificate.

But, after I wait almost one month long, I don’t get the certificate as promise before. And I know from my trusted source information, that to get the certificate we must pay extra dollars to download, a less comfort policy that applied by the vendor. But we must follow because without it, we can get our official certificate.

ccna

Anyway, something to pay attention more, technically. In this exam, Cisco give more weight about hands-on lab. Therefore, we must do more practice. Then for the theory lab, get to know about material which not covered by syllabus, but still relevant with the networking topic. Myself get hard questions about VSAT and Multiple Spanning Tree, which I guess that question must exist not in CCNA, but for more advanced level, CCNP.

The journey is not over yet, CCNP and CCIE have been waiting. CCNA is only the beginning, and I still lack of experience in the networking world, therefore I still need more knowledge to gain. Who know the next chapter of our life, but hard work and determination is an absolute necessity.

Cacti Monitoring via Email Notification

Cacti can be configured so it can send email notification if something has occured in our system. This is can be useful, especially for system administrator to monitor their server condition. It can be done with help from one of cacti plugin that is thold. I do this procedure to monitor computer harddrive capacity on Windows.

So, if there is a computer which harddrive capacity near the capacity limit, cacti will send notification via email. This is useful to avoid misinformation that can bring system stop working or failed periodic system backup.

The installation procedure itself is easy enough. Before this plugin thold installation, we need to install settings plugin http://docs.cacti.net/plugin:settings. We can install those plugins concurently. Download files that are needed:

$ cd /tmp
$ wget http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz
$ wget http://docs.cacti.net/_media/plugin:thold-v0.5.0.tgz

Rename download files in order to avoid error at extract time.

$ mv plugin:settings-v0.71-1.tgz settings-v0.71-1.tgz
$ mv plugin:thold-v0.5.0.tgz thold-v0.5.0.tgz

Extract tarball files.

$ tar zxf settings-v0.71-1.tgz
$ tar zxf thold-v0.5.0.tgz

Move extrated files to folder cacti/plugins.

$ sudo mv settings thold /var/www/html/cacti/plugins/

Then we configure cacti via web interface.

cactiemail1

Install and activate plugin Setting and Thold. After success, we need to configure thos plugins. Set configuration for email. We will use gmail account for mail service configuration. Configure following parameters:

cactiemail2

We can test to send email to confirm email sending process running well.

cactiemail3

After test passed, we can save the configuration. In the notification lists menu, add our email address for thold plugin which need to be sent if some notification raised by system.

cactiemail4

Choose graph which need to monitor the threshold. In this example, I will monitor a Windows host, so I can use harddrive free space percentage to trigger the thold.

cactiemail5

Configure the following parameter:

  • Threshold Name: Desired treshold name
  • Re-Alert Cycle: Notification sending interval
  • Warning Low Threshold: Minimum limit value for threshold warning
  • Alert Low Threshold: Maximum limit valuefor threshold warning
  • Warning Notification List: List of email address notification for warning
  • Alert Notification List: List of email address notification for alert

cactiemail6

Thold has been done configured. We just need to monitor the result. Cacti will send notification contain email and graph concerned about monitored device. In the example above, cacti will check harddrive capacity of server within a day. If something has found that harddrive capacity meet the condition of below 25%, then cacti will send email notification warning. And if harddrive capacity below 10% then cacti will send email notification alert.
This is an example of email notification from cacti.

cactiemail7

Reference:
http://docs.cacti.net/plugin:thold

Cacti for Monitoring Windows Host

To monitor windows based host, we need to install custom cacti template. I use windows template to monitor computer with Windows 7, Windows Server 2008 R2 and Windows Server 2012 R2 operating system installed. Template can be download, here:

https://github.com/didiksetiawan/cacti-templates

Extract and copy files from resource/snmp_queries to cacti directory

$ sudo cp snmp_informant_standard_*.xml /usr/share/cacti/site/resource/snmp_queries/

Then we need import that xml templates from folder “template” using cacti web interface.

Log in to cacti web interface and point to Import Templates

cactiwinhost1

Browse template folder that have been downloaded and search for cacti_host_template_windows_host-snmp_informant.xml file then click import. This template is ready to use.

Next, I need to activate SNMP service in Windows host as well as others add-on for SNMP. Login to Control Panel > Programs and Features > Windows Features. Check in Simple Network Management Protocol (SNMP).

cactiwinhost2

After SNMP feature success, configure SNMP service. Log in to menu Service.

cactiwinhost3

Change configuration for service “SNMP Service”. Add appropriate parameter community, and allow SNMP so it can be accessed from anywhere host. Additionally, we can add contact address in tab Agent (optional). After SNMP installed and configured, install 3rd party software that is SNMP informant. This app can be download at http://www.snmp-informant.com/downloads.htm#SNMP_Informant-Freeware_Products. To install, we just use standard wizard procedure, no need custom configuration.

How to add device in cacti

cactiwinhost4

After the device creation success, next step is create graph for this device. It can be done automatically with click “*Create Graph for this Host”. Then select appropriate item. Then edit the Graph Trees. Add to tree in order to it can be accessed from Tree View mode. Finish, we can access graph that we created in tab graphs. Happy cactying.

cactiwinhost5

Reference:

http://everythingshouldbevirtual.com/cacti-monitoring-for-windows-servers