Cacti / plugin_syslog

Syslog Plugin for Cacti
GNU General Public License v2.0
21 stars 16 forks source link

Syslog 3.1 both ticket and alert commands not working #149

Closed bmfmancini closed 3 years ago

bmfmancini commented 3 years ago

Hey guys,

I am seeing that on Syslog 3.1 while the log shows the command you input is executing the command is never actually called I made a dead-simple script to accept any input from Syslog and echo to a file

it never actually gets called

!/bin/bash

echo $@ >> /tmp/syslog.test

I have the script put in like so

image

I have tried with '' with and without quotes

Here is the log message

2021-02-19 12:40:46 - SYSTEM SYSLOG NOTICE: Executing '/var/www/html/cacti/cli/test.sh ''details'''

Here are the permissions of the script

-rwxr-xr-x 1 apache apache 41 Feb 19 12:37 /var/www/html/cacti/cli/test.sh

No errors show up in the log

the email function does work

bmfmancini commented 3 years ago

I found out this is happening because the alert name is not being escaped properly the shell is interpreting some of the messages

each time the command is run this spits out to the console sh: line 1: User: command not found

I found extra single quotes leading and ending the command being put there by the command function

bmfmancini commented 3 years ago
                                              if ($alert['open_ticket'] == 'on' && strlen(read_config_option('syslog_ticket_command'))) {
                                    if (is_executable(read_config_option('syslog_ticket_command'))) {
                                        exec(read_config_option('syslog_ticket_command') .
                                            " --alert-name='" . clean_up_name($alert['name']) . "'" .
                                            " --severity='"   . $alert['severity'] . "'" .
                                            " --hostlist='"   . implode(',',$hostlist) . "'" .
                                            " --message='"    . $alert['message'] . "'");
bmfmancini commented 3 years ago

Issue was on my end sorry guys I had a single quote in the command field on the form facepalm moment