All Apps and Add-ons

how to configure the file??

otman01
Communicator

HI every one,
1) First of all, I didn't find the application installed in the : "Splunk>Apps".
2) I want to configure the file, to send email if the alert is triggred. this is the configuration that I made:
export mailDay="Daily"

export mailFrom="xxx.otmyyyan@gmail.com"
export mailTo="ggg.222@hotmail.fr"
export mailSubject="Splunk Email Alert"

Set to your mail host gateway that receives mail

export mailHost="smtp.company.com"

For SMTP Authentication

export Auth="0"
export smtpuser="xxxxx.yyyyy@gmail.com"
export smptpass="yyyyyy"

python $SPLUNK_HOME/bin/scripts/sendmailpython.py "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
But it doesn't work !!!! did i miss something?

0 Karma
1 Solution

otman01
Communicator

this is the code predented in the script file: if you have same marks!!! thank you ( I'm on windows os)

!/bin/bash

Author: Nimish Doshi

Use for scripted alerts to control how and when email is sent.

Modify the Script or the corresponding python code to reflect your usage.

SPLUNK_HOME="/Applications/splunk"

Set to Daily, Weekend, or Weekday (Weekday = Monday to Friday)

export mailDay="Daily"

export mailFrom="chiadmi.otman@gmail.com"
export mailTo="chiadmi.otman@gmail.com"
export mailSubject="Splunk Email Alert"

Set to your mail host gateway that receives mail

export mailHost="smtp.gmail.com:465"

For SMTP Authentication

export Auth="1"
export smtpuser="chiadmi.otman@gmail.com"
export smptpass="*******"

python "C:\Program Files\Splunk\bin\scriptssendmailpython.py" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"

View solution in original post

0 Karma

otman01
Communicator

this is the code predented in the script file: if you have same marks!!! thank you ( I'm on windows os)

!/bin/bash

Author: Nimish Doshi

Use for scripted alerts to control how and when email is sent.

Modify the Script or the corresponding python code to reflect your usage.

SPLUNK_HOME="/Applications/splunk"

Set to Daily, Weekend, or Weekday (Weekday = Monday to Friday)

export mailDay="Daily"

export mailFrom="chiadmi.otman@gmail.com"
export mailTo="chiadmi.otman@gmail.com"
export mailSubject="Splunk Email Alert"

Set to your mail host gateway that receives mail

export mailHost="smtp.gmail.com:465"

For SMTP Authentication

export Auth="1"
export smtpuser="chiadmi.otman@gmail.com"
export smptpass="*******"

python "C:\Program Files\Splunk\bin\scriptssendmailpython.py" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"

0 Karma

ndoshi
Splunk Employee
Splunk Employee

The original code was designed to work on Linux. If you are on windows you'll have to rewrite the shell script as a .bat file to make it work. The Linux/Unix syntax of a Bash Shell script will not work that you have above. An example sendPythonmail.bat would be something like this:

@echo off

set Auth="1"
set smtpuser="chiadmi.otman@gmail.com"
set smptpass="****"

python "C:Program Files"\Splunk\bin\scriptssendmailpython.py" "%1%" "%2%" "%3%" "%4%" "%5%" "%65" "%7%" "%8%"

You'll have to write your own script. Make sure python is installed on your windows machine as well, if you plan on testing this script outside of Splunk.

0 Karma

otman01
Communicator

Thank you for your answer I will try to rewrite the script 🙂

0 Karma

ndoshi
Splunk Employee
Splunk Employee

First, I apologize if Splunk classified this as an app. It's a TA (technology add-on) so it will not automatically install itself. Please follow the README.txt instructions. Edit both files in the bin directory and put them in the $SPLUNK_HOME/bin/scripts directory. I see you have not set your your mailHost. Is that for the example or you forgot. Set this to a proper mailHost that you have access to using.

Next in the shell script, if you need authentication, please change the first line above:

export Auth="1"

Finally, test this on the command line before your do it from a scripted alert. For example:

./sendmailpython.sh a b c d e f g h

If you get no errors and receive mail, you can now configure Splunk to use this alert script to send the results of an alert.

0 Karma