Monday, November 25, 2013

MRTG without SNMP

$sudo apt-get install mrtg mrtgutils
$sudo nano /etc/mrtg.cfg
######################################################################
# Multi Router Traffic Grapher -- Sample Configuration File
######################################################################

# Global configuration
# Global Config Options
#-----------------------------
WorkDir: /data/webs/default/mrtg/
EnableIPv6: no
XSize[_]: 380


Thursday, November 21, 2013

Keeping the Original Partition in MDT 2012

Problem:
Out-of-box machines now-a-days are coming with a recovery partition. If you are using MDT 2012 to deploy your Windows 7 image, the Task Sequence will format the partition and you will lose that recovery partition.

Friday, July 5, 2013

Resize LVM ext4


Reduce
# Unmount the filesystem and check its' LV
umount /mnt/foo
e2fsck -f /dev/mapper/vg0-foo

# Shrink ext4 and then the LV to the desired size
resize2fs -p /dev/mapper/vg0-foo 40G
lvreduce -L 40G /dev/mapper/vg0-foo

# Before continuing, run e2fsck. If it bails because the partition
# is too small, don't panic! The LV can still be extended with
# lvextend until e2fsck succeeds, e.g.:
# lvextend -L +1G /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo

# Resize the filesystem to match the LVs size, check and mount it
resize2fs -p /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo
mount /mnt/foo

Increase

ext4 can performce online growth
$ sudo lvextend -L12G /dev/lvmvolume/lucid64root
$ sudo apt-get install lvm2
$ sudo vgchange -a y
$ sudo resize2fs /dev/lvmvolume/lucid64root


Replace the above command if your file system is xfs
$sudo xfs_growfs /dev/lvmvolume/lucid64root

$ sudo e2fsck -f /dev/lvmvolume/lucid64root
Reboot 

# Example 1: Extend LV (lvvar) from VG (vgroot) to a specific size (50G) root@linux ~ # lvextend -L50G /dev/vgroot/lvvar # Example 2: Extend LV (lvvar) from VG (vgroot) with additional 10G root@linux ~ # lvextend -L+10G /dev/vgroot/lvvar # Example 3: Extend LV (lvvar) from VG (vgroot) with the remaining space of the VG root@linux ~ # lvextend -l+100%FREE /dev/vgroot/lvvar


http://pubmem.wordpress.com/2010/09/16/how-to-resize-lvm-logical-volumes-with-ext4-as-filesystem/
http://againstentropy.blogspot.com/2012/01/resizing-root-ext4-filesystem-on-lvm.html

Wednesday, June 26, 2013

Conditional logging in Apache 2

Sometimes Apache 2’s logs can get really polluted by entries which you don’t care about and might skew your statistics. For example you wouldn’t want your own IP address in the logs because you don’t want that counted in the statistic. Although most web analyzers have filters to exclude such things, you can do this directly in Apache by not logging these. To do this you first need to set and environment variable that matches what you don’t want to log - this can use regular expressions and the matching is done on HTTP header fields like Remote_Addr or Request_URI.
Let’s say you want to exclude all internal IPs in your company from your website’s logs. You need to add this to your httpd.conf or domain_name.conf, depending on how you have your web server set up:

SetEnvIf Remote_Addr "10\.*\.*\.*" nologging
 
This just created a new variable in Apache’s environment called “nologging”. Now we will add this to the log directive in the same config file:

CustomLog log/access.log  combined env=!nologging
 
Now Apache will log everything except what is matched with the rule above. If you want to add more things to the list of non-logging, we can just continue adding rules to that variable. Let’s assume we decided not to add the favicon.ico requests to the log:

SetEnvIf Request_URI "^/favicon\.ico$" nologging
 
That’s it, no more pesky favicon requests in the logs! As you can see, the rules are pretty powerful and there are many uses for this! Also, don’t forget that you need the “log_config” and the “setenvif” module loaded in Apache! As usual you can check this using httpd -M or apache2 -M on the command line.
For more details: http://httpd.apache.org/docs/2.2/mod/mod_log_config.html

Tuesday, June 25, 2013

Moodle java script issue

Moodle has cached its own. So sometime will effected to javascript, here is the error I got when using firebug:

Uncaught TypeError: Cannot call method 'load_flowplayer' of undefined
On the httpd access_log file, you may see

192.168.0.100 - - [25/Jun/2013:10:25:11 +0400] "GET /moodle/theme/image.php/_s/cover/theme/1372141187/leaves0 HTTP/1.1" 404 674 "http://domain.com/moodle/theme/index.php?lang=en" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)" 0

To fix it, please clear cache with www.yourdomain.com/moodle/admin/purgecaches.php 

Done.