Wednesday, January 25, 2012

How to list or remove rpms of a specific architecture


Sometimes we gets package conflict errors because packages of different architectures are installed in same  system. We have to check the architecture of the system using "uname -a" command and remove the packages of other architecture. how can we remove a i386 rpm? how can we remove a x86_64 rpm?

For finding all i386 and i686 rpms
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$'

To find a particular i386 package
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$'  | grep "package-name"

For finding all x86_64 rpms
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.x86_64$'

To find a particular x86_64 package
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.x86_64$'  | grep "package-name"

To remove all i386 and i686 rpms (This is not recommended. You better grep out the one you want to remove using the above commands and remove it manually)
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$' | xargs rpm -ev

Sometimes you will get dependecy error. You can then use --nodeps option
eg:
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$' | grep openssl
rpm -ev openssl-0.9.8e-20.el5.i686 --nodeps

To remove all x86_64 rpms (This is not recommended. You better grep out the one you want to remove using the above commands and remove it manually)
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.x86_64$'  | xargs rpm -ev

Tuesday, January 24, 2012

How to enable check dns on nagios server


This post explains how to enable check_dns for client systems on a nagios server.

check_dns command checks whether dns is working or not  in a system by checking resolution of a domain to it. If it is resolving it means dns is working properly in the system.

Following is the syntax of the command you can use to check prior to the configuration.

/usr/local/nagios/libexec/check_dns -H IP_address_of_system_to_check -s google.com
it checks the server whether google.com is resolving from it.

For the command to work you have to add the following entry in commands.cfg

[root@nagios-1-1 objects]# vi commands.cfg
### check dns ###
define command {
        command_name    check_dns
        command_line    $USER1$/check_dns -H $ARG1$ -s $HOSTADDRESS$
}
[root@nagios-1-1 objects]#

Now add the server(server to check the dns) to hosts.cfg
[root@nagios-1-1 objects]# vi hosts.cfg
define host{
host_name            dns.server
alias                      dns.server
address                 178.x.x.x
use                        basic-host
contact_groups      admins
}
[root@nagios-1-1 objects]#

Now on services.cfg add as follows
[root@nagios-1-1 objects]# vi services.cfg
### Check DNS ###
define service{
        use                                       basic-service
        host_name                           dns.server
        contact_groups                    admins
        service_description              CHECK DNS for google.com on  dns.server
        check_command                 check_dns!google.com
}
[root@nagios-1-1 objects]#

Thats it. Now verify the configuration and restart the service
#service nagios restart