mutt

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

mutt

Post by vvz »

Hello!
if I'm sending from command line
echo " TEST" | /usr/bin/mutt -s "test" my@gmail
I got this message

if in my commands.cfg I have
# '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$\n" >> tmp/tmp.mail.log 2>&1
I can read messages from services in tmp.mail.log
but if i now pipi this messages to mutt like this
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$\n" | /usr/bin/mutt -s "sent by nagios" [email protected]
I'm not able to receive any messages on my email

Any ideas ?
Thank you
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: mutt

Post by abrist »

Any useful information in the maillog?

Code: Select all

tail -25 /var/log/maillog
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
yancy
Posts: 523
Joined: Thu Oct 06, 2011 10:12 am

Re: mutt

Post by yancy »

vvz,

Also I would recommend taking a look at nagios.debug to see what the command actually looks like when run by Nagios.

Code: Select all

cat  /usr/local/nagios/var/nagios.debug | grep " Running command"
once you have identified the command, try running that as the Nagios user.

Keep in mind, you may need to adjust the debug level of Nagios and restart.

http://nagios.sourceforge.net/docs/3_0/configmain.html


-Yancy
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: mutt

Post by vvz »

give me a sec guys
I'll give you full info
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: mutt

Post by slansing »

Sounds good, thanks!
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: mutt

Post by vvz »

I have a threshhold = 3 users is critical
and I have in nagios.log
[1383942020] SERVICE ALERT: hp;Current users logged in;CRITICAL;HARD;1;USERS CRITICAL - 3 users currently logged in
[1383942020] SERVICE NOTIFICATION: root;hp;Current users logged in;CRITICAL;notify-service-by-email;USERS CRITICAL - 3 users currently logged in
[1383942020] SERVICE NOTIFICATION: nagiosadmin;hp;Current users logged in;CRITICAL;notify-service-by-email;USERS CRITICAL - 3 users currently logged in
in my nagios.debug
[1383942071.230613] [016.0] [pid=31142] Checking service 'Current users logged in' on host 'hp'...
[1383942071.230751] [016.1] [pid=31142] Check result output will be written to '/var/lib/nagios3/spool/checkresults/checkwJ09Mt' (fd=7)
[1383942080.237695] [016.0] [pid=31142] Starting to reap check results.
[1383942080.237790] [016.1] [pid=31142] Starting to read check result queue '/var/lib/nagios3/spool/checkresults'...
[1383942080.237841] [016.1] [pid=31142] Processing check result file: '/var/lib/nagios3/spool/checkresults/cSiVGfq'
[1383942080.238088] [016.1] [pid=31142] Handling check result for service 'Current users logged in' on host 'hp'...
[1383942080.238112] [016.0] [pid=31142] ** Handling check result for service 'Current users logged in' on host 'hp'...
[1383942080.238122] [016.1] [pid=31142] HOST: hp, SERVICE: Current users logged in, CHECK TYPE: Active, OPTIONS: 0, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: Yes, RETURN CODE: 2, OUTPUT: USERS CRITICAL - 3 users currently logged in |users=3;1;2;0\n
[1383942080.238156] [016.1] [pid=31142] Service is in a non-OK state!
[1383942080.238166] [016.1] [pid=31142] Host is currently UP, so we'll recheck its state to make sure...

and in my mail.log and mail.err nothing since 11:52:08 now 13:27:00


in the morning I tried echo"something" | /usr/bin/mailx -s " test: my@gmail - instead of mutt
and I got in my mail.err
Nov 8 09:27:10 linuxmint postfix/postmap[10174]: fatal: open database /etc/postfix/transport.db: Permission denied
Nov 8 09:27:25 linuxmint postfix[10192]: error: to submit mail, use the Postfix sendmail command
Nov 8 09:27:25 linuxmint postfix[10192]: fatal: the postfix command is reserved for the superuser
Nov 8 10:52:59 linuxmint postfix/postmap[18921]: fatal: open /etc/postfix/transport.db: Permission denied
that's the reason I'm trying to use mutt instead of mailx, mutt works just fine except - luanching email generated by nagios
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: mutt

Post by abrist »

Does mutt have its own logs? If so, can you post a good sized tail of that here in code wraps?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: mutt

Post by vvz »

may be this from nagios.debug - only notification option is on give you more
I've restarted nagios and what I have
[1383943699.188668] [032.0] [pid=32390] Notification viability test passed.
[1383943699.188680] [032.1] [pid=32390] Current notification number: 3 (incremented)
[1383943699.188703] [032.1] [pid=32390] Service notification will NOT be escalated.
[1383943699.188715] [032.1] [pid=32390] Adding normal contacts for service to notification list.
[1383943699.227815] [032.0] [pid=32390] 2 contacts were notified. Next possible notification time: Fri Nov 8 13:52:19 2013
[1383943699.227860] [032.0] [pid=32390] 2 contacts were notified.
[1383943759.026421] [032.0] [pid=32390] ** Service Notification Attempt ** Host: 'hp', Service: 'Current users logged in', Type: 0, Options: 0, Current State: 2, Last Notification: Wed Dec 31 17:00:00 1969
[1383943759.026466] [032.0] [pid=32390] Notification viability test passed.
[1383943759.026477] [032.1] [pid=32390] Current notification number: 1 (incremented)
[1383943759.026490] [032.1] [pid=32390] Service notification will NOT be escalated.
[1383943759.026500] [032.1] [pid=32390] Adding normal contacts for service to notification list.
[1383943759.066813] [032.0] [pid=32390] 2 contacts were notified. Next possible notification time: Fri Nov 8 13:53:19 2013
[1383943759.066859] [032.0] [pid=32390] 2 contacts were notified.
[1383943819.116160] [032.0] [pid=32390] ** Service Notification Attempt ** Host: 'hp', Service: 'Current users logged in', Type: 0, Options: 0, Current State: 2, Last Notification: Fri Nov 8 13:49:19 2013
[1383943819.116226] [032.1] [pid=32390] We haven't waited long enough to re-notify contacts about this service.
[1383943819.116251] [032.1] [pid=32390] Next valid notification time: Fri Nov 8 13:53:19 2013
[1383943819.116267] [032.0] [pid=32390] Notification viability test failed. No notification will be sent out.
[1383943879.159857] [032.0] [pid=32390] ** Service Notification Attempt ** Host: 'hp', Service: 'Current users logged in', Type: 0, Options: 0, Current State: 2, Last Notification: Fri Nov 8 13:49:19 2013
[1383943879.159916] [032.1] [pid=32390] We haven't waited long enough to re-notify contacts about this service.
[1383943879.159934] [032.1] [pid=32390] Next valid notification time: Fri Nov 8 13:53:19 2013
[1383943879.159944] [032.0] [pid=32390] Notification viability test failed. No notification will be sent out.



vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: mutt

Post by vvz »

and then tcame this message
2013
[1383943999.243933] [032.0] [pid=32390] Notification viability test passed.
[1383943999.243954] [032.1] [pid=32390] Current notification number: 2 (incremented)
[1383943999.243974] [032.1] [pid=32390] Service notification will NOT be escalated.
[1383943999.244012] [032.1] [pid=32390] Adding normal contacts for service to notification list.
[1383943999.282982] [032.0] [pid=32390] 2 contacts were notified. Next possible notification time: Fri Nov 8 13:57:19 2013
[1383943999.283026] [032.0] [pid=32390] 2 contacts were notified.
[1383944059.073492] [032.0] [pid=32390] ** Service Notification Attempt ** Host: 'hp', Service: 'Current users logged in', Type: 0, Options: 0, Current State: 2, Last Notification: Fri Nov 8 13:53:19 2013

I'llcheck mutt logs right now
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: mutt

Post by vvz »

I've send email from command line and what I have in .muttdebug0

unfortunately I don't know the switch to make mutt log messages constantly
but now I'll put this switch to my commands.cfg and have a look





[2013-11-08 14:05:04] Mutt/1.5.21 (2010-09-15) debugging at level 65535
[2013-11-08 14:05:04] Reading configuration file '/etc/Muttrc'.
[2013-11-08 14:05:04] parse_attach_list: ldata = 0x6ddb80, *ldata = (nil)
[2013-11-08 14:05:04] parse_attach_list: added */.* [9]
[2013-11-08 14:05:04] parse_attach_list: ldata = 0x6ddb78, *ldata = (nil)
[2013-11-08 14:05:04] parse_attach_list: added text/x-vcard [7]
[2013-11-08 14:05:04] parse_attach_list: added application/pgp.* [2]
[2013-11-08 14:05:04] parse_attach_list: ldata = 0x6ddb78, *ldata = 0x24b7560
[2013-11-08 14:05:04] parse_attach_list: skipping text/x-vcard
[2013-11-08 14:05:04] parse_attach_list: skipping application/pgp.*
[2013-11-08 14:05:04] parse_attach_list: added application/x-pkcs7-.* [2]
[2013-11-08 14:05:04] parse_attach_list: ldata = 0x6ddb70, *ldata = (nil)
[2013-11-08 14:05:04] parse_attach_list: added text/plain [7]
[2013-11-08 14:05:04] parse_attach_list: ldata = 0x6ddb78, *ldata = 0x24b7560
[2013-11-08 14:05:04] parse_attach_list: skipping text/x-vcard
[2013-11-08 14:05:04] parse_attach_list: skipping application/pgp.*
[2013-11-08 14:05:04] parse_attach_list: skipping application/x-pkcs7-.*
[2013-11-08 14:05:04] parse_attach_list: added message/external-body [4]
[2013-11-08 14:05:04] parse_attach_list: ldata = 0x6ddb68, *ldata = (nil)
[2013-11-08 14:05:04] parse_attach_list: added message/external-body [4]
[2013-11-08 14:05:04] Reading configuration file '/usr/lib/mutt/source-muttrc.d|'.
[2013-11-08 14:05:04] Reading configuration file '/etc/Muttrc.d/charset.rc'.
[2013-11-08 14:05:04] Reading configuration file '/etc/Muttrc.d/colors.rc'.
[2013-11-08 14:05:04] Reading configuration file '/etc/Muttrc.d/compressed-folders.rc'.
[2013-11-08 14:05:04] Reading configuration file '/etc/Muttrc.d/gpg.rc'.
[2013-11-08 14:05:04] Reading configuration file '/etc/Muttrc.d/smime.rc'.
[2013-11-08 14:05:04] Reading configuration file '/home/vvz/.muttrc'.
[2013-11-08 14:05:04] ../send.c:1214: mutt_mktemp returns "/tmp/mutt-linuxmint-1000-446-14852955771080839696".
[2013-11-08 14:05:04] ../sendlib.c:2692: mutt_mktemp returns "/tmp/mutt-linuxmint-1000-446-21376901511155867325".
[2013-11-08 14:05:04] mwoh: buf[Subject: HI] is short enough
[2013-11-08 14:05:04] ../send.c:988: mutt_mktemp returns "/tmp/mutt-linuxmint-1000-446-19418744621056065059".
[2013-11-08 14:05:04] mwoh: buf[Subject: HI] is short enough
[2013-11-08 14:05:04] mutt_free_body: unlinking /tmp/mutt-linuxmint-1000-446-14852955771080839696.
~
Locked