Tuesday, June 28, 2011

use listagg to convert columns into rows

SELECT id, LISTAGG(str, ',') WITHIN GROUP (ORDER BY str) AS name
FROM new_test
GROUP BY id;

gives you
1 a,b,c
2 d,e
3 f

from
1 a
1 b
1 c
2 d
2 e
3 f

Tuesday, June 21, 2011

previous not null values of a field in oracle

select lastprice, lag(lastprice ignore nulls,1) over (order by statdate) from daily_statistics

automount a specific directory with autofs

this is what we do
first umount your directory then mount the location you want to another directory and later create a symbolic link with the name you need

umount /usr/local/apache-tomcat-6.0.26/information-repository

rmdir /usr/local/apache-tomcat-6.0.26/information-repository

vi /etc/auto/master
/usr/local/mounts /etc/auto.nfs

vi /etc/auto.nfs
m_29 -fstype=nfs,rw 192.168.0.29:/u01/information-repository

mkdir /usr/local/mounts/m_29

ln -s /usr/local/mounts/m_29 /usr/local/apache-tomcat-6.0.26/information-repository

Friday, June 17, 2011

mount with UUID

get a blkid to find the UUID of the device you are after then in /etc/fstab do like this:
UUID=41c22818-fbad-4da6-8196-c816df0b7aa8 /disk1 ext3 defaults 0 0

Thursday, June 16, 2011

split the internet into 8 parts :)

1.0.0.0/255.0.0.0
2.0.0.0/254.0.0.0
4.0.0.0/252.0.0.0
8.0.0.0/248.0.0.0
16.0.0.0/240.0.0.0
32.0.0.0/224.0.0.0
64.0.0.0/192.0.0.0
128.0.0.0/128.0.0.0

Saturday, June 11, 2011

fortinet SSL VPN client automatic startup

download the client from here:
http://internal.enterprisecomponent.com/download/FortiClientSSLVPN/forticlientsslvpn_linux_4.0.2010.tar.gz

start the client and in advanced check save password and persistent connection

add the vpn client to the startup of a vnc server in ~/.vnc/xstartup

start the vncserver automatically by editing /etc/sysconfig/vncserver

and chkconifg vncserver on

Thursday, June 09, 2011

cacti add simple graph for a value from script

read this babe:
http://www.cacti.net/downloads/docs/html/how_to.html

cacti monitor link

1. add the ip address you want to monitor as a new device
2. Add the "Unix-Ping Latency" graph template to it.
3. Add a new graph of the above template to your device.

BIG thanks to: http://www.networknet.nl/apps/wp/archives/367

Monday, June 06, 2011

Linux add and load MIB

1. Copy the file the same place other MIB files are
2. add mibs +DEVICE_MIB to /etc/snmp/snmp.conf
3. snmpwalk -v2c -c public IP_ADDR enterprise