Thursday, August 30, 2012

Your GNOME desktop suddenly reverted to TWM in CentOS 5

Has your GNOME desktop suddenly reverted to TWM upon a regular restart? If so, you aren’t alone.

Here is what you need to do to restore your GNOME desktop:

  1. Check if you can just get away with switching back to GNOME:
    
    yum install switchdesk
    switchdesk gnome
    
    If that tells you that gnome is not installed then proceed to step 2, otherwise you should have gotten your GNOME back.
     
  2. We are going to reinstall GNOME. Run this command:
    
    yum groupinstall "GNOME Desktop Environment"
    

    Now run the command to switch desktops:
     
     switchdesk gnome
    
    
    and you should be good getting your GNOME back upon next restart of your xwindow session (Ctrl+Alt+Bcksp).
     
     Original Source from Anton
    http://blog.bordercrossingmedia.com/2009/01/your-gnome-desktop-suddenly-reverted-to-twm-in-centos-5/
     

Tuesday, October 11, 2011

Tips that matters: Install nano on Suse Linux

For those who have a bad relationship with vi, emacs and related, here is a quick tip to install nano on SLES in few seconds.

rpm –i nano-2.2.6-1.x86_64.rpm

That's all. Tips that matters, really.

Thursday, February 3, 2011

Check_ping Vs Check_Icmp over VPNs

Sometimes happens that your host is down and check_ping doesn't generate an alert notification, but why?

Many of you may know that check_ping is just a nagios wrapper to the ping command while check_icmp makes the control itself, but this is not the only difference.
This kind of issue usually happens when involves host monitoring over vpn's.

If an host is down over a vpn the result for a missing icmp echo will be "ping timeout" instead of the usual "host unreachable" if that host was in the same network.
For this reason, Nagios will interpret the timeout as a soft error and will not generate the notification.

Instead, using the check_icmp will generate a hard error and so the notification will occur.

I strongly advertise to use check_ping on local networks monitoring only, while check_icmp if you monitor hosts over vpns.

To replace the command, just open command.cfg and at the section check-host-alive, just replace check_ping with check_icmp.

Thursday, July 15, 2010

Nagios - Use an external smtp server to send notifications



One of the most important feature of Nagios is the notification system; by default Nagios will use the local mail daemon (mail) to send all the notifications.
Maybe this kind of system was working fine in past, but today, with this huge amount of spam circulating all over the world, this kind of emails from a not verified source can be filtered by the same company antispam system.
In order to avoid this issue I will explain how to configure Nagios using an external smtp server also with smtp authentication.


Since the Nagios notification event is still a triggered command, we have to download an alternative command line email client.


I suggest the powerful "sendemail" command, available at the following link:

http://caspian.dotconf.net/menu/Software/SendEmail/

Once the download is finished unpack sendemail:

[root@localhost] tar -xvf sendEmail-v1.56.tar.gz

Then copy the binary in the bin folder

[root@localhost] cp /root/sendEmail-v1.56/sendEmail /usr/local/bin/

In order to troubleshoot any eventual problem, please use the following workaround to create and give the necessary authorization to write in the sendemail log file:

[root@localhost] touch /var/log/sendEmail
[root@localhost] chmod 666 /var/log/sendEmail


(remember, by default, Nagios does not start with full administrative rights, so command sent by Nagios too)
Now we need to set some variables that we need to recall later depending on your particular environment and smtp configuration:

So edit the resource.cfg file located in:
/usr/local/nagios/etc/resource.cfg
Add the following lines with your particular smtp configuration:

$USER5$=email@address.tld

$USER7$=smtp.server.tld

#If you don't use smtp authentication skip this variables and use the version B) of commands.cfg

$USER9$=authsmtpusername
$USER10$=authsmtpassword


Save and exit (<- This commands change depending from your editor, sadly I've been in too many disputes aboute which linux editor is better, so don't expect any advice from me) After this, we are gonna change the commands.cfg file located in:
/usr/local/nagios/etc/objects/commands.cfg

First perform a backup of the config file:
cd /usr/local/nagios/etc/objects/
cp commands.cfg commands.cfg.old


Edito the commands.cfg file and you will find two commands:
'notify-host-by-email' and 'notify-service-by-email'

A) SMTP AUTHENTICATION COMMANDS
Now, if you use SMTP authentication replace the two commands with the following:

# 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" }

# 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER9$ -xp $USER10$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" }


B) NO SMTP-AUTHENTICATION
This is pretty much the same but without passing the authentication triggers to sendemail:

# 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -s $USER7$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" }

# 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -s $USER7$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" }

Now the configuration is finished. Anyway, before applying the new configuration, run the following command to check for any error or mistake:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, restart the nagios service:

service nagios restart

To troubleshoot the sendemail command run the following to check in the log file:

tail -f /var/log/sendEmail


Hope this post will be useful to you. If you have any troube or you want to suggest me a better system do not hesitate to write a line.

Regards
Daniel

Wednesday, July 14, 2010

Nagios - Missing statusmap.cgi

The Nagios installation can go really smoothly but sometimes statusmap.cgi is not compiled and the error doesn't really come up during the make. And that's why we'll found out only when the system is up and running but this nice little feauture is missing getting to this error:

Not Found
The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server


This is often caused by the missing gd libraries, so if you experience this error be sure to perform the following commands (tested on Centos, should work for Redhat as well):

[root@localhost]# yum install gd
[root@localhost]#
yum install gd-devel


Then go in your nagios source folder and lauch the following:


[root@localhost]# ./configure

[root@localhost]# make

[root@localhost]# make-cgis

[root@localhost]# make install-cgis


This should fix very well this kind of problem. If you still experience problems with your nagios application please refer the following guide (imho one of the best around):

http://www.thegeekstuff.com/2008/05/nagios-30-jumpstart-guide-for-red-hat-overview-installation-and-configuration/