NetSurf – A graphical-browser for emergency browsing

>In this post I will investigate a commandline graphical browser(run without X) which I was unaware of till two days back.I am pretty much well versed with lynx and elinks. . The new found(mentioned the source in the resource section at the bottom of the post) one called netsurf .I have tried to install it from the source available on Fedora 12 ,but failed to do so due to lack of patience.

Now I am sitting on Debian Lenny as it in the repository so it;s really make easy to install and use it.So I get it like below:


bhaskar@bhaskar-laptop_06:00:11_Fri Nov 19:~> sudo aptitude install netsurf
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following NEW packages will be installed:
netsurf
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 411kB of archives. After unpacking 1217kB will be used.
Writing extended state information... Done
Get:1 http://http.us.debian.org stable/main netsurf 1.2-1 [411kB]
Fetched 411kB in 1min52s (3641B/s)
Selecting previously deselected package netsurf.
(Reading database ... 112830 files and directories currently installed.)
Unpacking netsurf (from .../netsurf_1.2-1_i386.deb) ...
Processing triggers for menu ...
Processing triggers for man-db ...
Setting up netsurf (1.2-1) ...
Processing triggers for menu ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Reading task descriptions... Done

Once it is installed it just a cakewalk.I invoked it like below:

bhaskar@bhaskar-laptop_06:07:41_Fri Nov 19:~> /usr/bin/netsurf http://linux-nfs.org

(netsurf:5351): libglade-WARNING **: could not find signal handler 'on_menupopup_navigate_activate'.

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

(netsurf:5351): Gtk-WARNING **: gtk_menu_attach_to_widget(): menu already attached to GtkMenuItem

Now the gtk-thing pop up like below;

Now few noticeable thing about it that it doesn’t support tab feature.And lot of normal plug-in might be missing.But in case of headless server it will be as useful as other cli-browser.Second it heavily depend on GTK, so you have to have it installed in the system to get it work.

Plus you need to check out the dependency when building from source from their web site to get it straight.

Resources:

1) http://soosck.wordpress.com/2010/11/16/netsurf-graphical-web-browser-command-line-css/

Hope this will help.

Cheers!
Bhaskar

Advertisements

The mystery behind LUN(Logical Unit Number)

>After being amazed and bewildered for sometime and listening to people talking so geeky about it ;I decided to unearth few intricacies about it.As we all know few parts of the world where people making simple thing complicated to others which benifit few blunt headed idiots to get cheap credit and save thier arse.

Oh! by the way forgot to mention that(those of you ignore the title)this is all about telling some intricacies about LUN(Logical Unit Number) .So without much ado lets dive into it.

Let me give you a clear cut definition I have come across so far is this “A LUN is a Logical Unit Number. It can be used to refer to an entire physical disk, or a subset of a larger physical disk or disk volume. The physical disk or disk volume could be an entire single disk drive, a partition (subset) of a single disk drive, or disk volume from a RAID controller comprising multiple disk drives aggregated together for larger capacity and redundancy. LUNs represent a logical abstraction or, if you prefer, virtualization layer between the physical disk device/volume and the applications.”

So how can you detect the LUN?

So there are two common ways to detect it,one is through /proc filesystes check and second is create a initrd image with it so time of os boot it can be detected.

Take the first case by scanning the /proc filesystem check; we need to the following to get a sense of it or aware of it:


bhaskar@bhaskar-laptop_06:55:52_Wed Nov 17:~> sudo cat /proc/scsi/scsi
Password:
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: ST9160821AS Rev: 3.BH
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: Optiarc Model: DVD RW AD-7560A Rev: DH10
Type: CD-ROM ANSI SCSI revision: 05

As you can see it from the out of that scan of /proc filesystem.Now the next one getting the LUN thing detected when the os boots.

Detect LUNs automatically at system boot

The second method of configuring LUNs for a Linux system with only LUN 0 configured involves setting the parameter for the SCSI mid-layer driver that controls how many LUNs are scanned during a SCSI bus scan. The following procedure works for both 2.4 and 2.6 kernels, but it assumes the SCSI mid-layer driver is compiled as a scsi_mod module that is loaded automatically at system boot time. For Linux 2.4 kernels, to set the maximum number of disk devices under Linux to properly detect all volumes, you need to set the max_scsi_luns option for the SCSI mid-layer driver. For example, if max_scsi_luns is set to 1 this limits SCSI bus scans to only LUN 0. This value should be set to the respective maximum number of disks the kernel can support, for example, 128 or 256. In Linux 2.6 kernels, the same procedure applies, except that the parameter has been renamed from max_scsi_luns to max_luns.

1. Edit the /etc/modules.conf file.
2. Add the following line:
* options scsi_mod max_scsi_luns= (where is the total number of luns to probe.
3. Save the file.
4. Run the mkinitrd command to rebuild the ram-disk associated with the current kernel. You can use the following figures examples of what mkinitrd command to run for your operating system. refers to the ‘uname –r’ output which displays the currently running kernel level, for example:. 2.4.21-292-smp.
For SUSE distributions, use the following command:

cd /boot
mkinitrd –k vmlinuz- -i initrd-

For Red Hat distributions, use the following command:

cd /boot
mkinitrd –v initrd-.img

5. Reboot the host.
6. Verify that the boot files are correctly configured for the newly created initrd image in the /boot/grub/menu.lst file.

The basics behind it somewhat is this LUNs are created as a basic part of the storage provisioning process using software tools that typically accompany the particular storage platform. However, there is not a 1-to-1 ratio between drives and LUNs. Many LUNs can easily be carved out of a single disk drive.

For example, a 500 GB drive can be partitioned into one 200 GB LUN and one 300 GB LUN, which would appear as two unique drives to the host server. Conversely, storage administrators can employ Logical Volume Manager software to combine multiple LUNs into a larger volume. Veritas Volume Manager from Symantec Corp. is one example of this software. In actual practice, disks are first gathered into a RAID group for larger capacity and redundancy (e.g., RAID-50), and then LUNs are carved from that RAID group.

LUNs are often referred to as logical “volumes,” reflecting the traditional use of drive volume letters, such as volume C: or volume F: on your computer. But some experts warn against mixing the two terms, noting that the term “volume” is often used to denote the large volume created when multiple LUNs are combined with volume manager software. In this context, a volume may involve numerous LUNs and can confuse storage allocation.

Once created, LUNs can also be shared between multiple servers. For example, a LUN might be shared between an active and standby server. If the active server fails, the standby server can immediately take over. However, it can be catastrophic for multiple servers to access the same LUN simultaneously without a means of coordinating changed blocks to ensure data integrity. Cooordinating data changes requires clustering software, such as a clustered volume manager, a clustered file system, a clustered application or a network file system using NFS or CIFS.

LUN scaling and performance

LUNs are based on disks, so LUN performance and reliability will vary for the same reasons. For example, a LUN carved from a Fibre Channel 15K rpm disk will perform far better than a LUN of the same size taken from a 7,200 rpm SATA disk. This is also true of LUNs based on RAID arrays where the mirroring of a RAID-0 group may offer significantly different performance than the parity protection of a RAID-5 or RAID-6/dual parity (DP) group. Proper RAID group configuration will have a profound impact on LUN performance.

An organization may utilize hundreds or even thousands of LUNs, so the choice of storage resources has vast implications for a storage administrator. Not only is it necessary to supply an application with adequate capacity (in gigabytes), but the LUN must also be drawn from disk storage with suitable characteristics.

LUN management tools

Since an enterprise array may host more than 10,000 LUNs, software tools are vital for efficient LUN creation, manipulation and reporting. Such management tools are readily available; almost every storage vendor provides some type of management software to accompany products ranging from direct-attached storage (DAS) devices to enterprise arrays.

Administrators typically opt for vendor-specific or heterogeneous tools. A data center with one storage array or a single-vendor shop would do well with the indigenous LUN management tool that accompanied their storage system. Multivendor shops should at least consider heterogeneous tools that allow LUN management across all of the storage platforms.

A LUN management tool should also support the entire storage provisioning process. Features should include mapping to specific array ports and masking specific host bus adapters (HBA), along with comprehensive reporting. The LUN management tool should also be able to reclaim storage that is no longer needed. Although a few LUN management products support autonomous provisioning, some administrators have reservations about such automation.

SAN zoning and masking

LUNs are the basic vehicle for delivering storage, but provisioning SAN storage isn’t just a matter of creating LUNs or volumes; the SAN fabric itself must be configured so that disks and their LUNs are matched to the appropriate servers. Proper configuration helps to manage storage traffic and maintain SAN security by preventing any server from accessing any LUN.

Zoning makes it possible for devices in a Fibre Channel network to see each other. By limiting the visibility of end devices, servers (hosts) can only see and access storage devices that are placed into the same zone. In more practical terms, zoning allows certain servers to see one or more ports on a disk array. Bandwidth, and thus minimum service levels, can be reserved by dedicating certain ports to a zone or isolate incompatible ports from one another.

Zoning is an important element of SAN security and high-availability SAN design. Zoning can typically be broken down into hard and soft zoning. With hard zoning, each device is assigned to a zone, and that assignment can never change. In soft zoning, the device assignments can be changed by the network administrator.

LUN masking adds granularity to this concept. Just because you zone a server and disk together doesn’t mean that the server should be able to see all of the LUNs on that disk. Once the SAN is zoned, LUNs are masked so that each host server can only see specific LUNs.

Suppose that a disk has two LUNs: LUN_A and LUN_B. If we zoned two servers to that disk, both servers would see both LUNs. However, we can use LUN masking to allow one server to see only LUN_A and mask the other server to see only LUN_B. Port-based LUN masking is granular to the storage array port, so any disks on a given port will be accessible to any servers on that port. Server-based LUN masking is a bit more granular; a server will see only the LUNs assigned to it, regardless of the other disks or servers connected.

Adding/Removing a Logical Unit Through rescan-scsi-bus.sh

The sg3_utils package provides the rescan-scsi-bus.sh script, which can automatically update the logical unit configuration of the host as needed (after a device has been added to the system). The rescan-scsi-bus.sh script can also perform an issue_lip on supported devices. For more information about how to use this script, refer to rescan-scsi-bus.sh –help.
To install the sg3_utils package, run yum install sg3_utils.

Known Issues With rescan-scsi-bus.sh

When using the rescan-scsi-bus.sh script, take note of the following known issues:

In order for rescan-scsi-bus.sh to work properly, LUN0 must be the first mapped logical unit. The rescan-scsi-bus.sh can only detect the first mapped logical unit if it is LUN0. The rescan-scsi-bus.sh will not be able to scan any other logical unit unless it detects the first mapped logical unit even if you use the –nooptscan option.

A race condition requires that rescan-scsi-bus.sh be run twice if logical units are mapped for the first time. During the first scan, rescan-scsi-bus.sh only adds LUN0; all other logical units are added in the second scan.

A bug in the rescan-scsi-bus.sh script incorrectly executes the functionality for recognizing a change in logical unit size when the –remove option is used.

The rescan-scsi-bus.sh script does not recognize ISCSI logical unit removals.

Resources:

1) http://publib.boulder.ibm.com/infocenter/dsichelp/ds6000ic/index.jsp?topic=%2Fcom.ibm.storage.smric.help.doc%2Ff2c_linuxlunconfig_2hsaga.html

2) http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/html/Online_Storage_Reconfiguration_Guide/rescan-scsi-bus.html

Hope this will help.

Cheers!
Bhaskar

Server monitoring by Monit and Munin

In this article I am going to show your how you can keep an eye on your server/desktop/laptop visually through web browser. For that I am going to use two tools to do the job for you; those are monit and munin .

I am on Debian Lenny to implement those two tools.So the first thing first get those software in the system.Here we go:

Monit:

Before try to install it I tried to query the existing package database to whether it installed or not(or I might have installed some time back!!)

bhaskar@bhaskar-laptop_18:12:03_Tue Nov 16:/etc/monit> sudo dpkg -s monit
Package: monit
Status: install ok installed
Priority: optional
Section: admin
Installed-Size: 696
Maintainer: Stefan Alfredsson
Architecture: i386
Version: 1:4.10.1-4
Depends: libc6 (>= 2.7-1), libssl0.9.8 (>= 0.9.8f-5)
Conffiles:
/etc/default/monit cf582dd57fac58748aba3d7cf174f011
/etc/monit/monitrc d0127e44088e2c13e6eaef8f3cb95c9f
/etc/init.d/monit 3c19420528fdb85fd2669f6f7257a552
Description: A utility for monitoring and managing daemons or similar programs
monit is a utility for monitoring and managing daemons or similar
programs running on a Unix system. It will start specified programs
if they are not running and restart programs not responding.
.
monit supports:
* Daemon mode - poll programs at a specified interval
* Monitoring modes - active, passive or manual
* Start, stop and restart of programs
* Group and manage groups of programs
* Process dependency definition
* Logging to syslog or own logfile
* Configuration - comprehensive controlfile
* Runtime and TCP/IP port checking (tcp and udp)
* SSL support for port checking
* Unix domain socket checking
* Process status and process timeout
* Process cpu usage
* Process memory usage
* Process zombie check
* Check the systems load average
* Check a file or directory timestamp
* Alert, stop or restart a process based on its characteristics
* MD5 checksum for programs started and stopped by monit
* Alert notification for program timeout, restart, checksum, stop
resource and timestamp error
* Flexible and customizable email alert messages
* Protocol verification. HTTP, FTP, SMTP, POP, IMAP, NNTP, SSH, DWP,
LDAPv2 and LDAPv3
* An http interface with optional SSL support to make monit
accessible from a webbrowser

It seems it’s there.Ok,now it has deflated lot of file in the system and as I am not going to mention those in details,but should show you where it kept :

bhaskar@bhaskar-laptop_18:17:15_Tue Nov 16:~> whereis monit
monit: /usr/sbin/monit /etc/monit /usr/share/man/man1/monit.1.gz

We should be concerned about the configuration file it.Because we need to define everything in this file to get noticed by it.I changed into /etc/monit dir ,where I found the config file named monitrc.Let’s have a view of it:


bhaskar@bhaskar-laptop_18:20:12_Tue Nov 16:~> cd /etc/monit
bhaskar@bhaskar-laptop_18:20:18_Tue Nov 16:/etc/monit> ls

monitrc
bhaskar@bhaskar-laptop_18:20:20_Tue Nov 16:/etc/monit> sudo vim monitrc
###############################################################################
2 ## Monit control file
3 ###############################################################################
4 ##
5 ## Comments begin with a '#' and extend through the end of the line. Keywords
6 ## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
7 ##
8 ## Below you will find examples of some frequently used statements. For
9 ## information about the control file, a complete list of statements and
10 ## options please have a look in the monit manual.
11 ##
12 ##
13 ###############################################################################
14 ## Global section
15 ###############################################################################
16 ##
17 ## Start monit in the background (run as a daemon) and check services at
18 ## 2-minute intervals.
19 #
20 set daemon 60
21 #
22 #
23 ## Set syslog logging with the 'daemon' facility. If the FACILITY option is
24 ## omitted, monit will use 'user' facility by default. If you want to log to
25 ## a stand alone log file instead, specify the path to a log file
26 #
27 set logfile syslog facility log_daemon
28 #
29 #
30 ## Set the list of mail servers for alert delivery. Multiple servers may be
31 ## specified using comma separator. By default monit uses port 25 - this
32 ## is possible to override with the PORT option.
33 #
34 set mailserver bhaskar-laptop # primary mailserver
35 # backup.bar.baz port 10025, # backup mailserver on port 10025
36 # localhost # fallback relay
37 #
38 #
39 ## By default monit will drop alert events if no mail servers are available.
40 ## If you want to keep the alerts for a later delivery retry, you can use the
41 ## EVENTQUEUE statement. The base directory where undelivered alerts will be
42 ## stored is specified by the BASEDIR option. You can limit the maximal queue
43 ## size using the SLOTS option (if omitted, the queue is limited by space
44 ## available in the back end filesystem).
45 #
46 # set eventqueue
47 # basedir /var/monit # set the base directory where events will be stored
48 # slots 100 # optionaly limit the queue size
49 #
50 #
51 ## Monit by default uses the following alert mail format:
52 ##
53 ## --8<--
54 ## From: monit@$HOST # sender
55 ## Subject: monit alert -- $EVENT $SERVICE # subject
56 ##
57 ## $EVENT Service $SERVICE #
58 ## #
59 ## Date: $DATE #
60 ## Action: $ACTION #
61 ## Host: $HOST # body
62 ## Description: $DESCRIPTION #
63 ## #
64 ## Your faithful employee, #
65 ## monit #
66 ## --8<-- 67 ## 68 ## You can override this message format or parts of it, such as subject 69 ## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc. 70 ## are expanded at runtime. For example, to override the sender: 71 # 72 set mail-format { from: monit@bhaskar-laptop.localdomain } 73 # 74 # 75 ## You can set alert recipients here whom will receive alerts if/when a 76 ## service defined in this file has errors. Alerts may be restricted on 77 ## events by using a filter as in the second example below. 78 # 79 set alert root@bhaskar-laptop.localdomain # receive all alerts 80 # set alert manager@foo.bar only on { timeout } # receive just service- 81 # # timeout alert 82 # 83 # 84 ## Monit has an embedded web server which can be used to view status of 85 ## services monitored, the current configuration, actual services parameters 86 ## and manage services from a web interface. 87 # 88 set httpd port 2812 and 89 use address bhaskar-laptop # only accept connection from localhost 90 allow bhaskar-laptop # allow localhost to connect to the server and 91 allow admin:admin # require user 'admin' with password 'admin' 92 # 93 # 94 ############################################################################### 95 ## Services 96 ############################################################################### 97 ## 98 ## Check general system resources such as load average, cpu and memory 99 ## usage. Each test specifies a resource, conditions and the action to be 100 ## performed should a test fail. 101 # 102 check system bhaskar-laptop.localdomain 103 if loadavg (1min) > 4 then alert
104 if loadavg (5min) > 2 then alert
105 if memory usage > 75% then alert
106 if cpu usage (user) > 70% then alert
107 if cpu usage (system) > 30% then alert
108 if cpu usage (wait) > 20% then alert
109 #
110 #
111 ## Check a file for existence, checksum, permissions, uid and gid. In addition
112 ## to alert recipients in the global section, customized alert will be sent to
113 ## additional recipients by specifying a local alert handler. The service may
114 ## be grouped using the GROUP option.
115 #
116 check file apache_bin with path /usr/sbin/apache2
117 # if failed checksum and
118 # expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
119 if failed permission 755 then unmonitor
120 if failed uid root then unmonitor
121 if failed gid root then unmonitor
122 alert security@bhaskar-laptop.localdomain on {
123 permission, uid, gid, unmonitor
124 } with the mail-format { subject: Alarm! }
125 # group server
126 #
127 #
128 ## Check that a process is running, in this case Apache, and that it respond
129 ## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
130 ## and number of children. If the process is not running, monit will restart
131 ## it by default. In case the service was restarted very often and the
132 ## problem remains, it is possible to disable monitoring using the TIMEOUT
133 ## statement. This service depends on another service (apache_bin) which
134 ## is defined above.
135 #
136 check process apache2 with pidfile /var/run/Apache2/apache2.pid
137 start program = "/etc/init.d/apache2 start"
138 stop program = "/etc/init.d/apache2 stop"
139 if cpu > 60% for 2 cycles then alert
140 if cpu > 80% for 5 cycles then restart
141 if totalmem > 200.0 MB for 5 cycles then restart
142 if children > 250 then restart
143 if loadavg(5min) greater than 10 for 8 cycles then stop
144 if failed host bhaskar-laptop.localdomain port 80 protocol http
145 and request "/monit/doc/next.php"
146 then restart
147 # if failed port 443 type tcpssl protocol http
148 # with timeout 15 seconds
149 # then restart
150 if 3 restarts within 5 cycles then timeout
151 depends on apache_bin
152 group server
153 #
154 #
155 ## Check device permissions, uid, gid, space and inode usage. Other services,
156 ## such as databases, may depend on this resource and an automatically graceful
157 ## stop may be cascaded to them before the filesystem will become full and data
158 ## lost.
159 #
160 # check device datafs with path /dev/sdb1
161 # start program = "/bin/mount /data"
162 # stop program = "/bin/umount /data"
163 # if failed permission 660 then unmonitor
164 # if failed uid root then unmonitor
165 # if failed gid disk then unmonitor
166 # if space usage > 80% for 5 times within 15 cycles then alert
167 # if space usage > 99% then stop
168 # if inode usage > 30000 then alert
169 # if inode usage > 99% then stop
170 # group server
171 #
172 #LVM
173
174 check device Bhaskar-laptop-data with path /lvm
175 if space usage > 80% then alert
176
177 #Tmp
178 check device tmp with path /tmp
179 if space usage > 90% then alert
180
181 ## Check a file's timestamp. In this example, we test if a file is older
182 ## than 15 minutes and assume something is wrong if its not updated. Also,
183 ## if the file size exceed a given limit, execute a script
184 #
185 # check file database with path /data/mydatabase.db
186 # if failed permission 700 then alert
187 # if failed uid data then alert
188 # if failed gid data then alert
189 # if timestamp > 15 minutes then alert
190 # if size > 100 MB then exec "/my/cleanup/script"
191 #
192 #
193 ## Check directory permission, uid and gid. An event is triggered if the
194 ## directory does not belong to the user with uid 0 and gid 0. In addition,
195 ## the permissions have to match the octal description of 755 (see chmod(1)).
196 #Bin
197 check directory bin with path /bin
198 if failed permission 755 then unmonitor
199 if failed uid 0 then unmonitor
200 if failed gid 0 then unmonitor
201 #
202 #LVM
203 check directory lvm with path /lvm
204 if failed uid 0 then unmonitor
205 if failed gid 0 then unmonitor
206
207 #Home
208 check directory home with path /home
209 if failed uid 0 then unmonitor
210 if failed gid 0 then unmonitor
211
212 # Var
213 check directory var with path /var
214 if failed uid 0 then unmonitor
215 if failed gid 0 then unmonitor
216
217
218
219
220 ## Check a remote host network services availability using a ping test and
221 ## check response content from a web server. Up to three pings are sent and
222 ## connection to a port and a application level network check is performed.
223 #
224 # check host myserver with address 192.168.1.1
225 # if failed icmp type echo count 3 with timeout 3 seconds then alert
226 # if failed port 3306 protocol mysql with timeout 15 seconds then alert
227 # if failed url
228 # http://user:password@www.foo.bar:8080/?querystring
229 # and content == 'action="j_security_check"'
230 # then alert
231 #
232 #Mysql
233
234 check process mysql with pidfile /var/run/mysqld/mysqld.pid
235 group database
236 start program = "/etc/init.d/mysql start"
237 stop program = "/etc/init.d/mysql stop"
238 if failed host 127.0.0.1 port 3306 then restart
239 if 5 restarts within 5 cycles then timeout
240
241 ###############################################################################
242 ## Includes
243 ###############################################################################
244 ##
245 ## It is possible to include additional configuration parts from other files or
246 ## directories.
247 #
248 # include /etc/monit.d/*
249 #
250 #
"monitrc" 250L, 9699C

As it is visible from the mundane configuration file that what we are trying to monitor.It has a big advantage that monit can take decision about the service i.e if some service is down and it needs to up,it can do so.It is just not mere status showing software.

Now we can configure it start when the system boots.So we will define a runlevels for it .We will use a software called sysv-rc-conf ,(aptitude install sysv-rc-conf).Here is invocation of it:

sysv-rc-conf

sysv-rc-conf/>

Now you can see the highlighted section for the monit service.As I have mentioned in configuration file that the web interface of it can be accessed through port 2812 .Here is the invocation through browser:

Monit Web Interface

I hope enlarging those two above picture will give you enough insight that what you can do with it.Now if you click on any of the service on the left side of panel you can get a detailed view like below:

service-details

The above screen has a “Disable Monitoring” button at the bottom of the screen,so with that you can deactivate particular device or thing monitoring.

Munin:
It is basically a graphing system to plot thing on the browser to get a visual representation of activity happening on the network or particular device.Let’s check out whether I have it or not in y system:


bhaskar@bhaskar-laptop_18:38:14_Tue Nov 16:~> sudo dpkg -s munin
[sudo] password for bhaskar:
Package: munin
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 996
Maintainer: Munin Debian Maintainers
Architecture: all
Version: 1.2.6-10~lenny2
Depends: perl (>= 5.6.0-16), perl-modules | libparse-recdescent-perl, librrds-perl, libhtml-template-perl, libdigest-md5-perl, libtime-hires-perl, libstorable-perl, rrdtool, adduser
Recommends: munin-node, libdate-manip-perl
Suggests: www-browser, httpd
Conffiles:
/etc/cron.d/munin 98f4112ea36053af9e1dc9111ab4d973
/etc/munin/munin.conf 057d322c5776710b8b71fbf02b12edbc
/etc/munin/templates/munin-comparison-month.tmpl 31f92013656bc96f496ad9fe9bd87b8b
/etc/munin/templates/munin-comparison-year.tmpl f8fc458757219e152bc0c316208214c4
/etc/munin/templates/definitions.html 6f2cda49ff5f0a5641549ae0dd063334
/etc/munin/templates/munin-nodeview.tmpl 60791f957f0879b859274ac423850e59
/etc/munin/templates/munin-serviceview.tmpl 9d061d0a097fdedc7cec09da56b45170
/etc/munin/templates/munin-comparison-week.tmpl 0ed0ac1772a96108e621f7ec9e651e65
/etc/munin/templates/logo.png 385010f8f050d25723206b1c77f0df5e
/etc/munin/templates/munin-comparison-day.tmpl 487b8c7f6f1eaf19687d601621da6f06
/etc/munin/templates/munin-overview.tmpl 07b6ba2c872f737fd3f2bf3df82bee06
/etc/munin/templates/munin-domainview.tmpl dfa7d0b5372086423c2aa7476bd04b90
/etc/munin/templates/style.css e6f61ecb33988635e5f6961de96c71c3
/etc/logrotate.d/munin caf8f6b63086ec5e11a9a2e2d883c7a1
Description: network-wide graphing framework (grapher/gatherer)
Munin is a highly flexible and powerful solution used to create graphs of
virtually everything imaginable throughout your network, while still
maintaining a rattling ease of installation and configuration.
.
This package contains the grapher/gatherer. You will only need one instance of
it in your network. It will periodically poll all the nodes in your network
it's aware of for data, which it in turn will use to create graphs and HTML
pages, suitable for viewing with your graphical web browser of choice.
.
It is also able to alert you if any value is outside of a preset boundary,
useful if you want to be alerted if a filesystem is about to grow full, for
instance. You can do this by making Munin run an arbitrary command when you
need to be alert it, or make use of the intrinsic Nagios support.
.
Munin is written in Perl, and relies heavily on Tobi Oetiker's excellent
RRDtool. To see a real example of Munin in action, you can follow a link
from to a live installation.
Homepage: http://munin.projects.linpro.no

It seems that I have it.So the next thing to where it reside in the system :

bhaskar@bhaskar-laptop_18:57:10_Tue Nov 16:~> whereis munin
munin: /etc/munin /usr/share/munin

Oh! I forgot to tell you that I need one more piece of software called “minin-node” . Let’s check out:


bhaskar@bhaskar-laptop_18:58:53_Tue Nov 16:~> sudo dpkg -s munin-node
Package: munin-node
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 1396
Maintainer: Munin Debian Maintainers
Architecture: all
Source: munin
Version: 1.2.6-10~lenny2
Depends: perl (>= 5.6.0-16), libnet-server-perl, procps, adduser, lsb-base (>= 3.2-4), gawk
Recommends: libnet-snmp-perl
Suggests: munin, munin-plugins-extra, libwww-perl, liblwp-useragent-determined-perl, libnet-irc-perl, mysql-client, smartmontools (>= 5.37-6~bpo40+1), acpi | lm-sensors, python, ethtool, libdbd-pg-perl
Conffiles:
/etc/cron.d/munin-node 64b993c241bef6ad98b0f50f0de9d18b
/etc/init.d/munin-node 0a2e199d22c98af892cc407c63dddb5a
/etc/munin/munin-node.conf c317597f98622746dc2120d4aa1ace17
/etc/munin/plugin-conf.d/munin-node 686c0aa6a0a3eb4e973f162dc77ffe52
/etc/logrotate.d/munin-node 8afe5ab15b1f1731016d0bffadadff46
Description: network-wide graphing framework (node)
Munin is a highly flexible and powerful solution used to create graphs of
virtually everything imaginable throughout your network, while still
maintaining a rattling ease of installation and configuration.
.
This package contains the daemon for the nodes being monitored. You should
install it on all the nodes in your network. It will know how to extract all
sorts of data from the node it runs on, and will wait for the gatherer to
request this data for further processing.
.
It includes a range of plugins capable of extracting common values such as cpu
usage, network usage, load average, and so on. Creating your own plugins which
are capable of extracting other system-specific values is very easy, and is
often done in a matter of minutes. You can also create plugins which relay
information from other devices in your network that can't run Munin, such as a
switch or a server running another operating system, by using SNMP or similar
technology.
.
Munin is written in Perl, and relies heavily on Tobi Oetiker's excellent
RRDtool. To see a real example of Munin in action, you can follow a link
from to a live installation.
Homepage: http://munin.projects.linpro.no

Now I changed into the /etc/munin directory ,because I need to change the configuration file of it.Like below:

bhaskar@bhaskar-laptop_19:03:28_Tue Nov 16:/etc/munin> ls
munin.conf munin-node.conf plugin-conf.d plugins templates

Now have a look at the munin.conf file:

1 # Example configuration file for Munin, generated by 'make build'
2
3 # The next three variables specifies where the location of the RRD
4 # databases, the HTML output, and the logs, severally. They all
5 # must be writable by the user running munin-cron.
6 dbdir /var/lib/munin
7 htmldir /var/www/munin
8 logdir /var/log/munin
9 rundir /var/run/munin
10
11 # Where to look for the HTML templates
12 tmpldir /etc/munin/templates
13
14 # Make graphs show values per minute instead of per second
15 #graph_period minute
16
17 # Graphics files are normaly generated by munin-graph, no matter if
18 # the graphs are used or not. You can change this to
19 # on-demand-graphing by following the instructions in
20 # http://munin.projects.linpro.no/wiki/CgiHowto
21 #
22 #graph_strategy cgi
23
24 # Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime
25 # something changes (OK -> WARNING, CRITICAL -> OK, etc)
26 #contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm
27 #contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm
28 #
29 # For those with Nagios, the following might come in handy. In addition,
30 # the services must be defined in the Nagios server as well.
31 #contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg
32
33 # a simple host tree
34 [bhaskar-laptop.localdomain]
35 address 127.0.0.1
36 use_node_name yes
37
38 #
39 # A more complex example of a host tree
40 #
41 ## First our "normal" host.
42 # [fii.foo.com]
43 # address foo
44 #
45 ## Then our other host...
46 # [fay.foo.com]
47 # address fay
48 #
49 ## Then we want totals...
50 # [foo.com;Totals] #Force it into the "foo.com"-domain...
51 # update no # Turn off data-fetching for this "host".
52 #
53 # # The graph "load1". We want to see the loads of both machines...
54 # # "fii=fii.foo.com:load.load" means "label=machine:graph.field"
55 # load1.graph_title Loads side by side
56 # load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load
57 #
58 # # The graph "load2". Now we want them stacked on top of each other.
59 # load2.graph_title Loads on top of each other
60 # load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load
61 # load2.dummy_field.draw AREA # We want area instead the default LINE2.
62 # load2.dummy_field.label dummy # This is needed. Silly, really.
63 #
64 # # The graph "load3". Now we want them summarised into one field
65 # load3.graph_title Loads summarised
66 # load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load
67 # load3.combined_loads.label Combined loads # Must be set, as this is
68 # # not a dummy field!
69 #
70 ## ...and on a side note, I want them listen in another order (default is
71 ## alphabetically)
72 #
73 # # Since [foo.com] would be interpreted as a host in the domain "com", we
74 # # specify that this is a domain by adding a semicolon.
75 # [foo.com;]
76 # node_order Totals fii.foo.com fay.foo.com
77 #
78

I have bold the section in the file ; which is absolute must get going with it. If the directory is not present ,then please create it and point the right path.

Now take a look at the munin-node.conf file:

1 #
2 # Example config-file for munin-node
3 #
4
5 log_level 4
6 log_file /var/log/munin/munin-node.log
7 pid_file /var/run/munin/munin-node.pid
8
9 background 1
10 setseid 1
11
12 user munin
13 group munin
14 setsid yes
15
16 # Regexps for files to ignore
17
18 ignore_file ~$
19 ignore_file \.bak$
20 ignore_file %$
21 ignore_file \.dpkg-(tmp|new|old|dist)$
22 ignore_file \.rpm(save|new)$
23 ignore_file \.pod$
24
25 # Set this if the client doesn't report the correct hostname when
26 # telnetting to localhost, port 4949
27 #
28 #host_name localhost.localdomain
29
30 # A list of addresses that are allowed to connect. This must be a
31 # regular expression, due to brain damage in Net::Server, which
32 # doesn't understand CIDR-style network notation. You may repeat
33 # the allow line as many times as you'd like
34
35 allow ^127\.0\.0\.1$
36
37 # Which address to bind to;
38 host *
39 # host 127.0.0.1
40
41 # And which port
42 port 4949
43

So once more I have highlighted few thing in the this file to get going with it.And most of the thing are pretty easily understood thing.

Lets access it through browser to see the graph..here we go..this the first screen I got in my system:

Ok once I clicked on hyperlinked option I am presented with the graphs like below:

Ok, now if your click those graph then you can get little explanation of the graph too!!

Hope this will help.

Cheers!
Bhaskar

Measure website response time through curl

In this article I will show you how you can get the response time of any damn website.I am going to use curl for that purpose.As we know curl is extremly powerful to fetch lot many thing.I got this idea from one of IBM DW article and wrote a script to do just that for me.So here is the script I write:


1 #!/bin/bash
2 CURL="/usr/bin/curl"
3 GAWK="/usr/bin/gawk"
4 echo -n "Please pass the url you want to measure: "
5 read url
6 URL="$url"
7 result=`$CURL -o /dev/null -s -w %{time_connect}:%{time_starttransfer}:%{time_total} $URL`
8 echo " Time_Connect Time_startTransfer Time_total "
9 echo $result | $GAWK -F: '{ print $1" "$2" "$3}'

This is very ordinary script but it does the job it was intended to do.Here is the interaction with script below:

bhaskar@bhaskar-laptop_09:02:55_Fri Nov 12:/lvm/Adm_scripts> sudo ./measure_website_response
Please pass the url you want to measure: http://justlinux.com
Time_Connect Time_startTransfer Time_total
1.122 3.455 9.205

Hope this will help.

Cheers!
Bhaskar

Let’s deal with oddity : Remove filename with special char in them

>Let’s face it,everyone face some oddity sooner then later to deal with open system.I have had come across quite a lot over the decade and am going to share few in this article.

Sometime people forget the basic thing and make things complicated. Like when they create a simple file they put arcane character in the name and it will create havoc in later stage.For example if someone create a file with “–” or “#” or some other character in the filename.Say one has a filename like below:


bhaskar@bhaskar-laptop_18:35:12_Fri Nov 05:~> touch -- -hey

Now you cannot list it like below:

bhaskar@bhaskar-laptop_18:38:52_Fri Nov 05:~> ls -l -hey
ls: invalid option -- 'e'
Try `ls --help' for more information.

Or

delete it like below;

bhaskar@bhaskar-laptop_18:39:00_Fri Nov 05:~> rm -f -hey
rm: invalid option -- 'h'
Try `rm ./-hey' to remove the file `-hey'.
Try `rm --help' for more information.

Now this is hindering you to get rid of it or even worse to take backup from the system if that file included in the backup list.So how to get rid of it ..as we all know that file store all the information in inode..so get it..

bhaskar@bhaskar-laptop_18:42:19_Fri Nov 05:~> ls -i | grep hey
655109 -hey

Now you can get rid of that file by inode like below:

bhaskar@bhaskar-laptop_18:50:14_Fri Nov 05:~> find . -inum 655109 -exec rm -i {} \;
rm: remove regular empty file `./-hey'? Y

Hope this will help .

Cheers!
Bhaskar