Page 1 of 1

SQL error when loading new plugin

Posted: Thu May 24, 2018 8:13 pm
by dfmco
Plugin loads but I got this at the top of the plugin management screen:

SQL Error [nagiosxi] : ERROR: syntax error at or near "send_sns"
LINE 1: ...gios XI','nagiosadmin',8,'User installed plugin \'send_sns.p...

Any idea what this is and how to make sure the plugin function is not affected? I am attempting to configure alerts using Amazon AWS SNS service.

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 9:57 am
by tgriep
Can you post the plugin here as well as the command configurations you have setup for the Notification commands?
It looks like there could be a misplaced option or a typo in the command.

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 1:15 pm
by dfmco
I said plugin but I meant command. Sorry for the confusion:

Command name: notify-service-by-sns
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" | aws sns publish --topic-arn arn:aws:sns:us-west-2:024374954588:OnshoreitInternal --subject "Onshore IT Service Alert $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" --message "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"

Set as a misc command and it works from a command line if run as the nagios user.

I have a contact template set up to run that command but I don't think I have it set correctly so I tried adding the host and service commands into the Alert Settings tab (manage notification commands) for a contact that I created directly in CCM and a user that currently gets alerts. I see in the notification logs that the command is sent but nothing comes through.

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 1:49 pm
by tgriep
OK, the command looks OK but I think the error is coming from the Manage Notification settings.
Can you provide a screen capture of that so we can view it?

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 2:56 pm
by dfmco
Was this the screen you wanted?

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 3:03 pm
by tgriep
No, we would need to see the screen where the error is generated.
Or where ever this "send_sns" is defined.

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 3:12 pm
by dfmco
See my post from Fri May 25, 2018 12:15 pm. That is the command definition. I attached a screen shot as well. I don't see any error generated at all but if I run from the command line, I get the mail and sms but if I alert on a failure and cause the failure to happen, I don't get the notification. Could it be a path issue to the aws command perhaps? I will check....

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 3:15 pm
by dfmco
Here is the path to the Nagios command:
[nagios@nagiosvpn ~]$ which aws
~/.local/bin/aws
does that need to be in the command line maybe 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" | ~/.local/bin/aws sns publish --topic-arn arn:aws:sns:us-west-2:024374954588:OnshoreitInternal --subject "Onshore IT Service Alert $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" --message "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$""

Or should I use /home/nagios/.local/bin/aws instead?

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 3:37 pm
by dfmco
RESOLVED!

It was the path. I set it to the full path and it worked!

I was working the issue with notifications on another ticket and that bled into here. I was more concerned with the SQL error. It is all working now but I am worried that I don't know why I got the SQL error or if it is still an issue that will bite me later. Is there anything we can do to troubleshoot the plugin problem and make sure no issues are brewing?

Thanks!

Re: SQL error when loading new plugin

Posted: Fri May 25, 2018 3:50 pm
by scottwilkerson
dfmco wrote:RESOLVED!

It was the path. I set it to the full path and it worked!

I was working the issue with notifications on another ticket and that bled into here. I was more concerned with the SQL error. It is all working now but I am worried that I don't know why I got the SQL error or if it is still an issue that will bite me later. Is there anything we can do to troubleshoot the plugin problem and make sure no issues are brewing?

Thanks!
Perfect! Glad to hear it is working.