Results 1 to 8 of 8

Thread: Incorrect host name in mails

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    12

    Incorrect host name in mails

    Hello,

    I've just installed Shinken and configured it to send mail notifications on some hosts. But every mail I receive comes with an incorrect host name. In the following example, it should be "arvixe" instead of "generic-host".

    Email received:
    Code:
    Shinken Notification
    
    Notification Type: PROBLEM
    
    Service: Imap
    Host: generic-host
    Address: xxxxx.com.br
    State: CRITICAL
    
    Date/Time: 08-10-2012 Additional Info : CRITICAL - Socket timeout after 10 seconds
    My host definition:
    Code:
    define host{
        use           smtp,imap,http
        contact_groups     admins
        host_name        arvixe
        address         xxxxx.com.br
        parents         thomsongateway
        icon_set        server
        }
    Any suggestion of other configurations I could check?

    Thanks!

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    201

    Re: Incorrect host name in mails

    can you post notification command???
    it seems your command is using the host template name and not hostname or hostalias

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    12

    Re: Incorrect host name in mails

    From /etc/shinken/commands.cfg:
    Code:
    ## Notify Host by Email
    define command {
      command_name  notify-host-by-email
      command_line  /usr/bin/printf "%b" "Shinken Notification\n\nType:$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDate/Time: $DATE$\n" | /usr/bin/mail -r intranet@xxxxx.com.br -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$
    }
    
    ## Notify Service by Email
    define command {
      command_name  notify-service-by-email
      command_line  /usr/bin/printf "%b" "Shinken Notification\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATE$ Additional Info : $SERVICEOUTPUT$\n" | /usr/bin/mail -r intranet@xxxxx.com.br -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
    }
    I just remember to have added the -r option to the original commands from Shinken 1.2.

    This is the subject of the same mail received, maybe it can help:
    Code:
    Subject: ** PROBLEM alert - generic-host/Imap is CRITICAL **
    Thanks!

  4. #4
    Senior Member
    Join Date
    Aug 2011
    Posts
    201

    Re: Incorrect host name in mails

    wow..
    i would follow all used templates,
    perhaps this value "generic-host" is inherited from one template?

  5. #5
    Administrator
    Join Date
    Jun 2011
    Posts
    216

    Re: Incorrect host name in mails

    The host_name field should be overloaded with the statement. What about putting "host_name arvixe" before the use statement? If it works, sounds like a bug.

  6. #6
    Junior Member
    Join Date
    Sep 2012
    Posts
    12

    Re: Incorrect host name in mails

    Now I can see: in the notification command, the macro that produces "generic-host" is $HOSTALIAS$, not $HOSTNAME$. As in my host definition the "alias" directive is undefined, it's value is inherited from the generic host definition template (in file templates.cfg).

    I've just defined a value for the "alias" directive in my host definition, and now the mail shows the correct host name!

    What's not clear for me yet is why Shinken use two different macros for the same information in mail notifications...

    It's solved now. Thanks for helping!


  7. #7
    Administrator
    Join Date
    Jun 2011
    Posts
    216

    Re: Incorrect host name in mails

    Because Nagios did it .

  8. #8
    Administrator
    Join Date
    Dec 2011
    Posts
    278

    Re: Incorrect host name in mails

    Added something to the faq.

    Thanks

    X

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •