Monday 30 June 2014

How to install vmware-tools on Linux

Here is procedure ho to install vmware-tools on Linux VM that are running on vmware platform!

Your VM administrator must mount vmware tools iso to your vm machine!
When he do that, then you can procede!

Log in to your Linux VM server. You have to be root to install this!

First mount that vmware tools CD

server# mount /dev/cdrom-hdc /mnt/
mount: block device /dev/cdrom-hdc is write-protected, mounting read-only
 server#cd /mnt/
server#ls
VMwareTools-8.3.2-257589.tar.gz

Because this is read-only files system you have to untar this file somewhere where you can write!
 

server#cp VMwareTools-8.3.2-257589.tar.gz /opt
server#cd /opt
server#tar xzvf VMwareTools-8.3.2-257589.tar.gz
server#ls
VMwareTools-8.3.2-257589.tar.gz  vmware-tools-distrib
server# cd vmware-tools-distrib/
server# ls
bin  doc  etc  FILES  INSTALL  installer  lib  vmware-install.pl
server#./vmware-install.pl

Follow the procedure! There is little or no interaction! Just press Enter!
After installation is finished, new process will apear in /etc/init.d!

After you finished installation you can delete these files and unmount /mnt and that cdrom!

For vmware platform to be aware of installed vmware-tools  on some VM, on Linux machines, reboot is needed! Because of this, it is very wise to install vmware-tools during installation of OS!

Free inode and glassfish - EXPLAINED!

Recently I had issue considering file system and glassfish!

Users were complaining that glassfish application stoped working! I logged on server and check glassfish server.log!

server#cd /opt/glassfish3/glassfish/domains/domain1/logs
server# tail server.log

server.log_2013-03-05T11-03-08:[#|2013-01-03T12:16:01.092+0100|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=23;_ThreadName=Thread-2;|WARNING: 8 bytes remaining but no space left|#]
server.log_2013-03-05T11-03-08:[#|2013-01-03T12:16:01.092+0100|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=23;_ThreadName=Thread-2;|WARNING: 300 bytes remaining but no space left|#]
server.log_2013-03-05T11-03-08:[#|2013-01-03T12:16:01.092+0100|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=23;_ThreadName=Thread-2;|WARNING: 300 bytes remaining but no space left|#]
server.log_2013-03-05T11-03-08:[#|2013-01-03T12:16:01.094+0100|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=23;_ThreadName=Thread-2;|WARNING: 8 bytes remaining but no space left|#]
server.log_2013-03-05T11-03-08:[#|2013-01-03T12:16:01.094+0100|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=23;_ThreadName=Thread-2;|WARNING: 8 bytes remaining but no space left|#]

Ok, no space left on that partition! But when I checked disk free space, there was space left on all partitions!

server# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
                      9.2G  1.8G  7.0G  21% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1              97M   32M   60M  35% /boot
/dev/mapper/rootvg-optlv
                       14G  1.6G   12G  12% /opt
/dev/mapper/rootvg-varlv
                      4.9G  282M  4.4G   7% /var







So there was free space left, but from some reason glassfish could not write on file system. I checked if I can write anything on file system. It turns out that I can write on all file system except on file system where glasshfish was mounted!
 
Hm....

After some thinking I desided to check status of inodes on partitions!

server# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/mapper/rootvg-rootlv
                      612000   55749  556251   10% /
tmpfs                 490591       1  490590    1% /dev/shm
/dev/sda1              25688      39   25649    1% /boot
/dev/mapper/rootvg-optlv
                      897600   0  897600    100% /opt
/dev/mapper/rootvg-varlv
                      321280    2267  319013    1% /var


Ok, so I found the problem! There were no free inodes left. How many inodes you have on partition depends on size of that partition and what file system you use!

What is inode?
" Inode is a data structure used to represent a filesystem object, which can be one of various things including a file or a directory. "

 Bassicly, number of inodes on files system defines max number of files on directories together!

So, I had close to 900 000 files or folders on my /opt partition! Because file system considering space was not full, there was to be some folder with many small size files!

I found my problem in this folder /opt/glassfish3/glassfish/domains/domain1/generated/jsp/!
I restart my glassfish server once a day. During that restart for every glasshfish application that is running on that server, loader_directories are created! I once knew why this folders are created(but now I dont)1 Anyway, this folder are not big but they do contain many files! It is save to delete them with no hesitation! Once I delete them, I check number of inodes!

server# df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/mapper/rootvg-rootlv
                      612000   55750  556250   10% /
tmpfs                 490591       1  490590    1% /dev/shm
/dev/sda1              25688      39   25649    1% /boot
/dev/mapper/rootvg-optlv
                      897600   18998  878602    3% /opt
/dev/mapper/rootvg-varlv
                      321280    2267  319013    1% /var





I restart glassfish server

server]# /etc/init.d/GlassFish_domain1 restart

and there were no more complaines about glassfish application!

Now, every few months I deleted there folders!





 






Wednesday 25 June 2014

warning: /etc/rc.d/rc.sysinit saved as /etc/rc.d/rc.sysinit.rpmsave,warning: /etc/sysctl.conf created as /etc/sysctl.conf.rpmnew - EXPLAINED!

In case that you doing update/upgrade of some rpm packages, during this operation you may get warnings that new config files is generated or that used configuration has been moved to another name!

For instance, if you are updating rpm packages initscripts,  you will have this warning messages!


server#yum update initscripts
.
.
  Updating       : initscripts                                               1/1
warning: /etc/rc.d/rc.sysinit saved as /etc/rc.d/rc.sysinit.rpmsave
warning: /etc/sysctl.conf created as /etc/sysctl.conf.rpmnew

.
.

What does this means? As you all know, every service has configuration. Depending on how "big" update is, there might be smaller or bigger changes in configuration as well(different approach, different settings,etc.) or they just want clean configuration! If this is the case then new configuration is stored in *.rpmnew file or currently used configuration is moved in *.rpmsave file and new configuration is stored in configuration file! Will .rpmsave or .rpmnew file be created depends of service that is being updated.

.rpmsave file is created if service that is using that configuration need reboot to be applied!
.rpmnew file is created if service that is using that configuration need just need restart of service!

In my example, /etc/rc.d/rc.sysinit file is moved to /etc/rc.d/rc.sysinit.rpmsave because this changes can be only applied during server reboot.
 /etc/sysctl.conf file is moved to /etc/sysctl.conf.rpmnew because this changes can be only applied by issuing sysctl command and will be affected immediately!

Now, comes tricky part! If you reboot your servers, your new rc.sysinit configuration will be applied and this may result that some of your service do not start because they are now not in that config file. Of course, usually there are no service start in rc.sysinit file but you never know especially if you inherit server from another admin. So, if these new config files are created that you should look for difference between them.

Simple solutions are best so after config files are moved to .rpmsave, see difference between them, and just move .rpmsave to original file!

server#mv /etc/rc.d/rc.sysinit.rpmsave /etc/rc.d/rc.sysinit

and you will use same configuration that you use after reboot!

When you know all this, it can save you a lot's of troubleshooting time!

.rpmnew do not make any trouble because because service is still using original config file!





Tuesday 24 June 2014

pam_tally2(sshd:auth): user user1(1001) tally 15, deny 3 SOLVED nad EXPLAINED!

pam_tally2(sshd:auth): user user1(1001) tally 15, deny 3
In case that your are seing this message in /var/log/secure log, this means that someone 15 times tried to log in to your system with user user1! Also, user may complain that he can not connect as user1! Good thing is that in next line in secure log you have IP address of computer that tried to log in!

pam_tally2(sshd:auth): user user1 (1001) tally 15, deny 3
Jun 24 13:09:08 server1 sshd[111184]: Failed password for user1 from 192.168.0.25 port 10180 ssh2

Ok, explanation!
You are using pam.d. This is security feature for access to your system. With it you can control access to system services (like sshd) or commands(like passwd). Setting for this are located in /etc/pam.d/.

Ok, so troubleshooting!
Check you /var/log/secure.

server#tail /var/log/secure 
.
.
 Jun 24 13:09:08 server1 sshd[111184]pam_tally2(sshd:auth): user user1 (1001) tally 18, deny 3
Jun 24 13:09:08 server1 sshd[111184]: Failed password for user1 from 192.168.0.25 port 10180 ssh2


From here, we can see that pam.d module pam_tally2.so is responsible for user lockout! But from here we can also see that deny limit is 3 times and that is has been tried for 18 times to log in to system as user user1.
 Read pam.d configuration for sshd!

server#cat /etc/pam.d/sshd
#%PAM-1.0
auth       include      system-auth
auth       required     pam_tally2.so deny=3 onerr=fail lock_time=60
account    required     pam_nologin.so
account    include      system-auth
account    required     pam_tally.so
password   include      system-auth
session    optional     pam_keyinit.so force revoke
session    include      system-auth
session    required     pam_loginuid.so
session    required     pam_limits.so

From here we can see settings for failed password entry! pam.d is using module pam_tally2.so, after one failed login you have to wail or 60 seconds to try again and after 3 failed login, user account will be lock!

Issue following command
 

server# pam_tally2Login           Failures Latest failure          From
user1              18        06/24/14 14:11:58  192.168.0.25






From here we can see how many failures for user1 happened and when last try has happened!





SSH access for user user1 is locked and you want to unlock it.




Command for that is this

server#pam_tally2 -r -u user

 In are case that is

server#pam_tally2 -r -u user1
Now, when you issue pam_tally2 command there will be no failures shown and user1 will be able to log in onto system!

Important thing to know here is that once user account is locked, these is no use of trying to log onto system! Depending on your pam.d configuration,  your user account can or can not reset number of false tries! Pam.d configurations is complex and if you do know what you are doing, you can make your live much,much harder!








How to mount iso on LInux?

To mount iso image on your file system you should do next thing

server#mount -t iso9660 iso_file /mount_point -o loop

You will have only info that this is read-only file system!

In case that you do this a lot, this mounting of iso you can write simple script that will save you few seconds of your time! You may think that few seconds is nothing but i read once

"If you do some job more then twice, write a script for it"

My script look like this

server#cat mount_iso
#!/bin/bash
ISO="$1"
echo $ISO
mount -t iso9660 $ISO /mnt/ -o loop


You should put this is your /usr/bin or /bin folder so that you can execute script from anywhere in the system!

How it works?

# mount_iso rhel-server-5.9-x86_64-dvd.iso
rhel-server-5.9-x86_64-dvd.iso
[root@plavi2 iso]# ls /mnt/
Cluster            README-te.html            RELEASE-NOTES-U9-en
.

.
.

Monday 23 June 2014

How to test if your zabbix server receive data from zabbix client EXPLAINED!

Ok, so you have installed zabbix agent on your server. Process zabbix client is up and running but does zabbix server start to receive data from it?

Simplest way to this is to connect to your zabbix server and iniate zabbix_get command! With this command can get to see data from zabbix client!

How to do this?

zabbix_server#zabbix_get -s IP_ZABBIX_CLIENT -k ZABBIX_ITEM

Zabbix item can be any item that is using on zabbix client!

If you client is on IP address 192.168.0.2 and then command will look like this!

# zabbix_get -s 192.168.0.2 -k agent.version
2.2.1


In case that you see something like this, then this means that you have communication between zabbix server and zabbix client!

In case that you have this error

zabbix_server#zabbix_get -s 192.168.0.2 -k agent.version
zabbix_get [30914]: Timeout while executing operation


check IP address of your zabbix client, if you can even connect to that server or if that server is alive!

If your error is this

zabbix_server# zabbix_get -s 192.168.0.2 -k agent.version
zabbix_get [31561]: Get value error: cannot connect to [[192.168.0.2 ]:10050]: [111] Connection refused

server 192.168.0.2 is alive but zabbix agent is not installed, not running or firewall is blocking it!

Zabbix agent installation on Windows EXPLAINED!

To install zabbix agent on Windows platform, you should do following things:

1. Download package from here
2. Unzip it!
3. go in location/zabix_agents_2.2.1.win/bin
4. choose architecture that you use
5.Install zabbix agent!

#zabbix_agentd.exe -i

That is it!

In case that you have following message during installation

#zabbix_agentd.exe -i
zabbix_agentd.exe [123]:cannot open config file [C:\zabbix_agentd.conf]:[2] No such file or directory

From conf directory, copy zabbix_agentd.win.conf to C:
Rename it to zabbix_agentd.conf and try installation again




Friday 20 June 2014

How to make startup script for automated tomcat start after reboot on Linux

I you are good system admin then one of first things after installation of some new application is to make that application start after system reboot!
Some application(glassfish, websphere) have mechanism to make startup script during installation but there are application that do not do that!

In case that your developers team create new JAVA application that is running under tomcat, here is how my(and yours) startup script (should)look like

#!/bin/bash
# Run-level Startup script for the Tomcat
#
# chkconfig: 345 99 19
# description: Startup/Shutdown Tomcat
#
# Startup script for the Tomcat
CATALINA_HOME=location_of_tomcat_folder
JAVA_HOME=location_of_java_folder
PATH=$PATH:$CATALINA_HOME/bin:$JAVA_HOME/bin
DISPLAY=unix:1.0
export CATALINA_HOME JAVA_HOME PATH DISPLAY
cd $CATALINA_HOME/bin
start() {
        echo -n $"Starting Tomcat: "
        su user_that_is_running_application -c "startup.sh"
        [ RETVAL=$? ] && touch /var/lock/subsys/tomcat
        echo
        return $RETVAL
}
stop() {
        echo -n $"Stopping Tomcat: "
        su
user_that_is_running_application -c "shutdown.sh"
        [ RETVAL=$? ] && touch /var/lock/subsys/tomcat
        echo
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  *)
        echo $"Usage: $prog {start|stop}"
        exit 1
esac

exit $RETVAL


Location of this script should be in /etc/init.d/ folder. You can named it like you want. We can called it tomcat-aps.

Ok, so how to test it if your script is running OK?

First,make it executable!

#chmod +x tomcat-aps

Now,  check if there are any java process running or even better go to log folder of your tomcat application. This should be located in /location_of_tomcat/logs and see content of catalina.out file. It is best to tail this file

#tail -f /location_of_tomcat/logs/catalina.out

 and see changes in your tomcat application.

OK, now lets start application! Open new terminal window and ...

#/etc/init.d/tomcat-aps start

In your catalina.out file if everything is OK, you shoul see something like this


Jun 20, 2014 12:08:32 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Jun 20, 2014 12:08:32 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8083
Jun 20, 2014 12:08:32 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jun 20, 2014 12:08:32 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
Jun 20, 2014 12:08:32 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 9063 ms

Your application is up and running. In case that you see errors, well you have problem with starting of your application with this script! We will not troubleshot that in this post.

If every thing is OK, check in what runlevel your server is running,

#runlevel
N 3

We are doing this to see in what rcX.d folder wee will put link to are startup script!

#cd /etc/rc3.d/
#ln -s /etc/init.d/tomcat-aps S99tomcat-aps

Now, when you server in booting in runlevel 3, your tomcat-aps script will execute and your application will be up and running!

JAVA install conflict between java6 and java7 during instalation SOLVED

I had situation today considering installation of new java version 7 on server that already was running java 6.

Java that was running was 32bit and I wanted to use 64bit java and overcome Java memory issues that is following 32bit Java.

Java that was running was


#java -version
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) Server VM (build 19.0-b09, mixed mode)
 

and package name was
#rpm -qa |grep jdk

jdk-1.6.0_23-fcs 

So I downloaded latest Java 7 64bit package(jdk-7u60-linux-x64.rpm) and when I tried to installed it
 
[root]# rpm -ivh --test jdk-7u60-linux-x64.rpm
Preparing...                ########################################### [100%]
 file /etc/init.d/jexec from install of jdk-1.7.0_60-fcs.x86_64 conflicts with file from package jdk-1.6.0_23-fcs.i586
 

I moved file /etc/init.d/jexec to different location but same issue occurred.

Because I did not need to preserve old JAVA installation, I removed it

#rpm -e jdk-1.6.0_23-fcs 

and then installed new one with no problems!

Now I have

# java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

Thursday 19 June 2014

PuTTY saved session - how to migrate to another computer or restore after system failure EXPLAINED!

OK, so you decided that is time to finally format your Windows computer! Why you are doing this, is not the point of are topic! If you are administrating more than 5 servers, then there is a good chance that you have saved your putty sessions. In case that you do not know what this means, it means that you have saved IP or hostname of server, settings considering X11 and all other settings that can be set in putty under specific name that you find appropriate so that you do not have to set up these settings every time you want to connect on that server! So next time that you want to connect, you just load these settings by clicking on name of that configuration and click LOAD!

Imagine that you have more then 5 servers! So after formatting Windows system, you OS is blank and when you download putty  there is no your saved putty sessions. How to restore your saved sessions?
If you are reading this after you formatted your computer and wondering how to restore saved session, then your answer is time machine :) ! In case that you do not have time machine, then you are doomed and you will have to manually save you putty session, again! This is usually very, very boring!

So, be smart and do this before formatting or just in case that your system crashes beyond repair. You need to save you putty configuration!
Putty stores its settings in the Windows registry. To save a backup of your Putty settings, you'll need to export this registry key(HKEY_CURRENT_USER\Software\SimonTatham) to a file.

You may wonder why SimonTatham?

From Wikipedia

Simon Tatham is an English program mer known primarily for creating and maintaining PuTTY, a free software implementation of Telnet and SSH clients for Unix and Windows API platforms, along with an xterm terminal emulator

1. Click Start->Run and type "RegEdt32" in the "Open" dialog. Click "Ok"



2. One RegEdt32 starts, you'll be presented with an application which looks something like:


Search for HKEY_CURRENT_USER\Software\SimonTatham
Once you find it, right click on it and click on Export!


You will be asked where to save this .reg file. It is wise to store it in some save(save from hardware failure) place like cloud,etc.

Ok, you saved your putty configuration!!!

How to restore it?

Right click on that saved .reg. file and click on Merge! This will make necessary changes/restores in registry!

Now when you start putty, you will have your save sessions!!!





Monday 9 June 2014

Zabbix agent installation on Linux EXPLAINED!

Zabbix is free monitoring software!
It is open source!
It is server-client based! It can monitor Linux, AIX, Windows servers! I will write more detail about it later!

How to install zabbix agent on Linux? Easy!!!

Steps are:
1. download agent
2.on server create user zabbix

server#useradd zabbix

3. Move it to home dir

server#mv download_location/zabbix_agents_2.0.4.linux2_6.amd64.tar.gz /home/zabbix

4.Untar it!

server#tar xzvf zabbix_agents_2.0.4.linux2_6.amd64.tar.gz
 
server## ls
bin  conf  sbin  zabbix_agents_2.0.4.linux2_6.amd64.tar.gz

5.  In conf folder, you will find default configuration! From version 2.0.x zabbix conf file should be located in /usr/local/etc/ folder.

If you install zabbix agent this way, you will need to find somewhere service zabbix! I just copied it from some other server!

server2#scp /etc/init.d/zabbix_agentd server1:/etc/init.d/

6.To start zabbix agent, execute

server1#/etc/init.d/zabbix_agentd start

7. Check if agent is running

server1# ps aux |grep zabbix
root      2531  0.0  0.0  13436   708 ?        S    12:45   0:00 /home/zabbix/sbin/zabbix_agentd
root      2533  0.0  0.0  13436   756 ?        S    12:45   0:01 /home/zabbix/sbin/zabbix_agentd
root      2534  0.0  0.0  13444   932 ?        S    12:45   0:00 /home/zabbix/sbin/zabbix_agentd
root      2535  0.0  0.0  13444   932 ?        S    12:45   0:00 /home/zabbix/sbin/zabbix_agentd
root      2536  0.0  0.0  13444   932 ?        S    12:45   0:00 /home/zabbix/sbin/zabbix_agentd
root      2537  0.0  0.0  13444   932 ?        S    12:45   0:00 /home/zabbix/sbin/zabbix_agentd
root      2538  0.0  0.0  13444   932 ?        S    12:45   0:00 /home/zabbix/sbin/zabbix_agentd
root      3220  0.0  0.0 103248   836 pts/1    S+   13:57   0:00 grep zabbix

8. On zabbix server check if you can communicate with zabbix agent

#  /zabbix_server_location/bin/zabbix_get -s server1_IP -k agent.version
2.0.4
In case that your response is like this

/zabbix_server_location/bin/zabbix_get -s server1_IP -k agent.version
zabbix_get [9917]: Get value error: cannot connect to [[server1_IP]:10050]: [111] Connection refused

you have communication issue!

To solve this, check following:

1.Check iptables on server1! Port 10050 and 10051 need to be open!

server1#iptables -I INPUT 5 -p tcp --dport 10050 -s zabbix_server_ip -j ACCEPT
server1#iptables -I INPUT 5 -p tcp --dport 10051 -s zabbix_server_ip -j ACCEPT

2. check if zabbix_agent is running

server1#ps aux |grep zabbix

3.try telnet to zabbix server with port 10050

server1#telnet zabbix_server_ip 10050


It is wise to put zabbix agent service to start after reboot

server1#chkconfig --level 345 zabbix_agentd on



How to clear FAULT BATTERY status on APC UPS TRICK! :)

In case that you have APC SMARTUPS  series, then you know that from time to time UPS is doing self-test!

In case that you did not do that much into details, here are few things you should know!


1. Self-test is test of UPS where all that should be tested is put to test. This is scheduled task to 7 or 14 days but there is option NEVER. From my experience, you should not turn off self-test! Why, because failed self-test is usually first indication that you have faulty battery in UPS or that your battery capacity is bad.
2. If self-test is not runed from time to time depending of type of UPS, your battery capacity will be wrongly showned!
3. During UPS powering on self-test is also done!

Ok, so if your self-test failed and you status is Batteries discharged or that you have on faulty battery 

here is a trick that works for me!


Go to Diagnostic
 and repeat self-test! If you battery is not that bad, your selt-test will ends with success and faulty battery status will be cleared!

From my experience, if self-test failed from 6 to 8 time during this repeat, there is no other way than to call support for battery changing!




Friday 6 June 2014

Find disk usage by folder in Linux EXLAINED!

In case that you have running low on space on your server, it is crucial to find where is greatest disk usage!

First find on what mount point low space is!

server]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv   60G  5.9G   51G  11% /
/dev/sda1                  486M   42M  419M  10% /boot
/dev/mapper/rootvg-optlv    60G   59G   503M  99% /opt


On this server we have usage on /opt mount point.

Go there

server#cd /opt

List folder

server#ls

If your lack of space happened suddenly, first find what is created last! For instance, in last 2 minutes!

server#find . -mmin -2

Check size of showed files. Check size of folders where those files are!
If no files are shown, extend time of search. Replace -2 with -10 and so on. If you are not certain when disk usage happened, skip this!

To find disk usage of each folder in problematic space, do next!

server#du . -h -s *
59G    .
58G    data
50M     apache-tomcat-7.0.32
7.8M    apache-tomcat-7.0.32.zip

This will list usage of each folder in /opt, each file in /opt and total usage of opt. Go inside biggest folder and continue search for that big disk usage!




Delete files older then ... EXPLAINED how to do it in Linux

Lets imagine that you have folder that contains several hundreds, thousands files and from time to time you will have need to delete files older that some time.

For example: you want do delete files older that 30 days.

Steps are:

server#cd location

User find and option -mtime.
 

server#find . -mtime +30

this will list files older that 30 days. If you want to list files younger than 30 days use -mtime -30 option.

I like to use for loops.

server#for i in `find . -mtime +30`;do echo $i;rm -rf $i;done

And that is it!

Many people use this

find . OPTIONS -exec rm -rf {} \;

but I like to see what I am deleting! :)

Thursday 5 June 2014

Should graphical enviroment(init 5 runlevel, X11 packaeges) be installed and running on Linux server? EXPLAINED!

Answer on this question is not simple. It all depends what is purpose of your server.

Usually graphical enviroment is need during installation and after that step is over, you want need it any more.

But less go back in time when resources very limited and when 4GB of RAM was big deal and 1 core CPU was all you had. Then every free byte of RAM was important and every free CPU % mattered that you system would not froze :( ! Only needed packages were installed! Less packages you install, meaned that you will have more free system resources for your system to run normally!

Now days, this is less important! With new advanced and cheaper hardware, faster CPU, multi-core CPU's, faster and bigger RAM, more disk  space there is no practical relevance if your server use 1GB or 1,1GB of RAM if you have 16 or 32 GB available. Same goes for CPU usage and file space.

But, only bad system administrator would install all packages on system (by this I mean all packages that are on DVD) so you have to make some limitation during installation. If you do not need FTP, do not install it! I hope you get my point about resource available!

For X11 packages and init 5 runlevel, here is practice that I think is good. During installation of OS, I always install X11 system. After installation is over, system is by default in init 5 runlevel. I change this in init 3 runlevel. Why? Resources, resources! In 99% of time, Linux admin connect on server trough ssh connection with putty or some other client. Using GUI in Linux system administration is well, not good and it is usally something newbie would do.
In my 5 years of experience as Linux admin, 99% that I used graphical environment on server was when I need to see something on Internet for some quick troubleshooting while I am in server room!
When you need to do this, just execute this

server#startx

And graphical environment will appear!
After you are done with it, just log out and you will be back in console!

Of course depending of your server purpose, you maybe have to leave server in init 5 runlevel.








Wednesday 4 June 2014

How to insert adsense ads after post title but before post text - SOLVED and EXPLAINED!!!

Where you place your ads is probably most import thing that can have impact on your income.

Best place for ads is below post title and before text of post! Why they prefer adding ads below the post title? It is because the spot just after the post title is the best place to put ads to increase Click Through Rate (CTR). Something like this

or something like this





is best solution possible!

How to do this?

On ADSENSE:

1.First you have to go to your adsence account and create new add unit. It should be rectangle but it is not necessary. For test, we will create rectangle. Size is 300x250. Copy code of ad.
2.This is code is HTML but blogger will not show this kind of code for adsence. Instead of simple coping ad code you have to converted it so that blogger can see it.
I used this CONVERTER. Copy ad code and convert it. Copy that new code somewhere.

On Blogger:

    1. Go to Template.
    2. Backup your blog template.
    3. Click on Edit HTML button.
    4. Find this code <data:post.body/>
I am using simple theme and I have 3 times this code.
Go to line where code appears for second time.
Before this code enter following code


<div style="float: left; margin: 10px 10px 10px 0;">
YOUR ADSENSE CODE HERE
</div>

Your adsence code here is code that you have converted it in step 2 in Adsence section of this article.
Now your page will look like this



In case that you want to put your ad on center, replace left with center.

Now on adsense your newly created ad unit will have status active.

I hope that this will help you!!!











Tuesday 3 June 2014

How to hide/rename minerd procces from user on Linux?

Depending on who is using Linux server beside you, you might find this very smart thing to do.

Why this is good idea? Well, you will find your reasons if you want to do this.

OK, so...
After you compile and install, minerd will be installed. Find, where is located.

root@ubuntu-13-4:~# whereis minerd
minerd: /usr/local/bin/minerd
 

Rename it.

root@ubuntu-13-4:~# mv /usr/local/bin/minerd /usr/local/bin/minerd1





Ok, so now are program is not called minerd, it is called minerd1. You can called whatever you like.

Now, in top you will see minerd1.

Monday 2 June 2014

IBM WebSphere Application Server and Web Plugin for Apache on Linux - part 4

Ok, so we installed all components.

Now we just have to make them work together.

Steps are:
1. Connect on WAS.
 Go to Servers/Server type/Web server.

There you will see web servers that are associated with WAS

2. On server2 do next:

server2# cd /opt/IBM/WebSphere/Plugins1/bin/
server2# ls
ConfigureApachePlugin.sh   crossPlatformScripts  installRegistryUtils.sh  mod_app_server_http_eapi.so  setInstallRegistryUtilsEnv.sh  ws_ant.sh
ConfigureDomino7Plugin.sh  genHistoryReport.sh   installver.sh            mod_app_server_http.so       setupCmdLine.sh
ConfigureIHSPlugin.sh      genVersionReport.sh   libdomino5_http.so       mod_ibm_app_server_http.so   setupGSKitLibPath.sh
ConfigureSunOnePlugin.sh   historyInfo.sh        libns41_http.so          mod_was_ap20_http.so         verifyinstallver.sh
configurewebserver1.sh     ikeyman.sh            libns61_http.so          mod_was_ap22_http.so         versionInfo.sh

Script  configurewebserver1.sh copy on server1:/opt/IBM/WebSphere/AppServer/bin/ .
Execute script there.
After you do this, you new web server will appear in WAS. If this do not happen, restart WAS.

After web server webserver1 appear on WAS under, select it and click on Generate Plug-in. After this is done you will see this


on top of your page.
Replace plugin-cfg.xml from server1 on server2://opt/IBM/WebSphere/Plugins1/config/webserver1/

Restart web server on server2.

And this will be all to it.

How to test it? Well, in documentation they say that you should try to connect on application snoop on WAS.
First, test if application is running on WAS

http://IP_WAS:9080/snoop

and then try to connect on snoop through web server

http://IP_SERVER2/snoop

You should see have same response!

And that is it. You managed to access WAS application through web server on different machine!

In case of trouble, check this:
1. iptables
2. location of plugin-cfg.xml
3. check htttpd.conf and see last two lines. In these lines you have location of plugin-cfg.xml and mod*.so module.


I hope that this will help you!

IBM WebSphere Application Server and Web Plugin for Apache on Linux - part 3

OK, so we installed WAS. He is up and running.

As we mention earlier (http://sysadmin-tricks.blogspot.com/2014/05/ibm-websphere-application-server-and.html)  WAS can use web server for accessing application on WAS. There can be more that one web server and there can be different types of them. Just to make clear, WAS can use several different web servers in same time. IBM have it's own IBM HTTP server and they like to use it (I wonder why :) ) but you can use any recommended web server. 

We used apache web server.

To enable this to work, you have to install plug-in for web server.

Steps are:

1.Download plug-in
We need to install version 7 of this plug-in but there are newer version of it.
File is trial_plugins_7000_linux.ia32.tar.gz

2. server2#cd location_of_file
    server2#tar xzvf trial_plugins_7000_linux.ia32.tar.gz
    server2# ls
    Copyright.txt  JDK  notices.txt  plugin  trial_plugins_7000_linux.ia32.tar.gz  Version.txt

Here are info from Version.txt
server2#cat Version.txt
<xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE product PUBLIC "productId" "product.dtd">
<product name="IBM Web Server Plugins for WebSphere Application Server">
  <id>PLUGIN</id>
  <version>7.0</version>
</product>

3.Installation 
Older version do not need IM for installation of plug-in. Instead of this you just start install script.
You need to have X11 forwarding enabled(if you are using putty) or to have graphical environment installed.

server2# cd plugin/
server2# ls
docs                   install               lib            plg.installconfig.pak  plg.webserverplugins.pak  relabel_java.sh   swg_info_common.css
framework              installRegistryUtils  panels         plg.plgmain.pak        readme                    responsefile.txt  version.txt
index_roadmap_en.html  lafiles               plg.gskit.pak  plg.primary.pak        readme_toc.html           setup.jar
server2# ./install




In case that you do not have web browser installed on server2, deselect first option. If you do not do this, then you will have warning that you need to install web browser so that you can read guide and see possible scenarios.
Click Next.  Accept terms of use. Click Next.
Now your system is checked for system prerequirements. If you pass this,click next. Otherwise, resolve issues.

 Select web server that you use. In my case is select Apache Web Server v2.2
Click Next.
This step is important.


 Here you select is your web server local or remote in point of WAS. If WAS and webserver is on same machine, use second option. Because are web server is not on same machine as WAS we use first option.

This is where configuration of plugin will be stored.
In case that you already have some plug-in installed, you will have (like me) new folder named Plugins1,etc.
Point where your web server configuration files are stored and what port will be used.



Name your webserver. IBM convention is webserver1,webserver2,etc.






 Point where installation of web plug-in is stored.


This is important step. Enter IP or DNS of WAS server.


After this step is all Next,Next, Next...

And that is it for installation part. 
Start your web server.
server2#/etc/init.d/httpd start