0

I try to make script/command in nagios3 at write in new file some data but nagios will not do that. I try that simple bash command:

printf "something" > /path-to-file/new-file

But nagios don't open/write file. I try direct i definition of nagios commando and to make bash script and start from nagios but same - nothing happens.

Look like:

define command{ command_name service-notify-sms command_line /usr/bin/printf '%s\n\n%s\n%s\n%s' "To: $CONTACTPAGER$ " "Service : $SERVICEDESC$ " "State: $SERVICESTATE$ " "Date/Time: $LONGDATETIME$ " > /var/spool/sms/outgoing/$CONTACTPAGER$ }

define contact{ service_notification_commands service-notify-sms host_notification_commands host-notify-sms

I think about at nagios need some privilege to write file or I think wrong? Maybe nagios can't write file or have some another command, not standard bash ">"?

It's look in /var/log/syslog:

Jun 13 08:58:00 nagios nagios3: HOST NOTIFICATION: user-sms;Nagios;CUSTOM (UP);host-notify-sms;OK - localhost responds to ICMP. Packet 1, rtt 0.010ms;nagiosadmin;test

I founded about only one question: Is this possible at Nagios write in file or not? It someone do some like that?

Gruja
  • 19
  • 7
  • Showing the nagios configuration might help with the debugging. – thrig Jun 08 '16 at 14:20
  • define command{ command_name service-notify-sms command_line /usr/bin/printf '%s\n\n%s\n%s\n%s' "To: $CONTACTPAGER$ " "Service : $SERVICEDESC$ " "State: $SERVICESTATE$ " "Date/Time: $LONGDATETIME$ " > /var/spool/sms/outgoing/$CONTACTPAGER$ } – Gruja Jun 08 '16 at 15:10
  • Where else in the nagios configuration is `service-notify-sms` used? – thrig Jun 08 '16 at 17:48
  • define contact{ service_notification_commands service-notify-sms host_notification_commands host-notify-sms – Gruja Jun 08 '16 at 17:52
  • 1
    Permissions to the spool directory? – lazyfrosch Jun 09 '16 at 10:34
  • @lazyfrosch this is so unusually because I think direct permission but it's not, because I try all: change owner, permissions on spool dir and file/script ... – Gruja Jun 09 '16 at 15:01
  • 1
    do you see "service-notify-sms" in the Nagios log? Ideally, in a line that starts with SERVICE NOTIFICATION – Keith Jun 09 '16 at 16:02
  • @Keith yes, and everything stay it's OK – Gruja Jun 09 '16 at 16:07
  • I don't know ... I just want to know are somebody do some command to write in file on the end from nagios? and if everything was ok? – Gruja Jun 09 '16 at 17:19
  • 1
    sudo -H -u nagios bash -c '/usr/bin/printf > /var/spool/sms/outgoing/$CONTACTPAGER$' – malyy Jun 13 '16 at 07:55

1 Answers1

0

That was at must nagios user be in group smsd ...

Gruja
  • 19
  • 7