Grafana email alerts configuration - monitoring

I'm using currently Grafana version: v7.1.1
I would like to configure the email alerts in the config folder of Grafana, I followed the steps I found online but I did not manage, I get an error every-time I try to send a test email
Failed to send alert notifications
here's the smtp from defaults.ini that I found in config:
##############################################
host = smtp-mail.outlook.com:587
user = my.name#hotmail.com
password =xxxxxxxxxxx
;cert_file =
;key_file =
skip_verify = false
from_address = my.name#hotmail.com
from_name = Grafana
ehlo_identity =
startTLS_policy =
##########################################
when I checked the error log, I found the following:
error="Failed to send notification to email addresses: my.name#hotmail.com: dial tcp 52.97.163.2:995: i/o timeout"
Can anyone tell me if I'm doing something wrong here? or how I can fix it?
Thanks

Related

imaplib.IMAP4.error set a failure message when connecting (Python)

I'm having trouble defining a message in the Gmail login code when the credentials are wrong.
def connect():
imap_host = 'imap.gmail.com'
email = 'cryp#gmail.com'
password = input("Password: ")
M = imaplib.IMAP4_SSL(imap_host)
M.login(email, password)
try:
os.system('cls')
print('Connected.')
except imaplib.IMAP4.error:
os.system('cls')
print('Failed to connect.')
connect()
Below is the message that appears.
raise self.error(dat[-1])
imaplib.error: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'
and not this:
print('Falha ao Conectar.')
The message Connected appears correctly when I type the email and password correctly, however when I make an error this message appears instead of Failed to connect.

Twilio WhatsApp messages are in 'queued' status

Okay so I got approval from WhatsApp and Twilio (after Facebook Business verification) to use the WhatsApp API for sending out appointment reminders to my clients. I configured the message templates and they got approved too. Check the image below:
I have written a code in Python where I pick my data from a PostgreSQL server hosted on cloud (using psycopg2) and then it sends out messages to the phone numbers fetched using a query. Here is the code:
from twilio.rest import Client
import psycopg2
import time
account_sid = 'AC54xxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth_token = 'f1384yyyyyyyyyyyyyyyyyyyyyyyyyyy'
connection_string = ""
conn = psycopg2.connect(user = "xxxx",
password = "yyyyyy",
host = "zzzzzzzzzzzzzzz.zzzzzzzzzzzz",
port = "ABCD",
database = "some_db")
cur = conn.cursor()
cur.execute("""query to pick data""")
rows = cur.fetchall()
client_phone_list = []
phone_list_not_received = []
session_date_list = []
session_time_list = []
client_first_name_list = []
for row in rows:
session_date_list.append(row[0])
session_time_list.append(row[1])
client_first_name_list.append(row[2])
client_phone_list.append(row[3])
cur.close()
conn.close()
client = Client(account_sid, auth_token)
message_reminder_template = """Hello {},
This is a reminder about your session today at {}. Please be on time to utilize the full length of
the session and avoid distress :)
We look forward to taking care of you!"""
for i in range(len(client_phone_list)):
first_name = client_first_name_list[i]
appointment_time = session_time_list[i]
message_body = message_reminder_template.format(first_name, appointment_time)
print(message_body)
message = client.messages.create(body = str(message_body),
from_ = 'whatsapp:+1(mytwilionumber)',
to = 'whatsapp:+91'+client_phone_list[i])
time.sleep(10)
text_status = message.status
print(text_status)
Whenever I run this code the message status returned is always 'queued'. I have checked that I am not using the 'Test Credentials' but the 'Live Credentials'.
I have also checked the error_code and error_message which returns as NULL. So there is no error but the messages are not getting sent. How can I change that?
Any help would be hugely appreciated.
Also note that the message body used in the code above is approved as a template from WhatsApp.
Twilio developer evangelist here.
At the point that you make the API request to send the message the status will be returned to code as "queued". That's this point in your code here:
message = client.messages.create(body = str(message_body),
from_ = 'whatsapp:+1(mytwilionumber)',
to = 'whatsapp:+91'+client_phone_list[i])
What you do next will not work though:
time.sleep(10)
text_status = message.status
print(text_status)
Waiting 10 seconds and then reading the status from the message object that was returned when you created the message will still return "queued".
If you want to fetch the message status after 10 seconds to see if it has been sent then you will need to make a second call to the messages API, like so:
time.sleep(10)
latest_message = client.messages(message.sid).fetch()
print(latest_message.status)
For a more efficient method of keeping track of the status of your messages, check out this tutorial on receiving webhooks for message status updates.
Let me know if that helped at all.

Cannot connect to SAP B1 9.1 server using SAPbobsCom.dll when using IP address

I have never seen this and searched a long time and without an answer, I have a need to connect to SAP B1 9.1 using the SAPbobsCOM.dll to sync user objects between our different instances of SAP. We can use the server name to connect to the local server, but the name does not resolve for the remote server and we need to use the IP address. Locally we get an error if we try to connect via IP address : The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) the same error if we try the remote server.
I have the reference added to the dll and there is no error accessing the methods or properties.
Here is the code I use to connect:
var comp = new Company();
comp.DbServerType = BoDataServerTypes.dst_MSSQL2014;
comp.Server = "192.168.1.200"; // server name SAP91
comp.CompanyDB = "SBO_SAP91";
comp.LicenseServer = "192.168.1.200:30000";
comp.UserName = "Admin"; // SAP Admin user
comp.Password = "Admin";
var noth = comp.MinimalSupportedVersion;
var connected = (comp.Connect() == 0 ? "Connected" : "Not Connected");
System.Diagnostics.Debug.WriteLine(comp.GetLastErrorDescription());
var CONN = comp.CompanyName;
I am really unsure as to how I can connect and read all objects locally when using the server name but not quite sure why it doesn't work by IP address, any help on this would be appreciated as we have to manually sync the user objects until this can be resolved.
Thank you
You did not registered the IP address in the SLD.
Regards.

How to send a email automatically from a .net application without using smtp server?

In my lab smtp server is blocked.I had gone through the EAsendmail package but i couldn't succeed in sending email from the application directly without using going through smtp server.
here is the code
SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();
//Set sender email address, please change it to yours
oMail.From = "yaswanthmdh#gmail.com";
//Set recipient email address, please change it to yours
oMail.To = "manojsr6#gmail.com";
//Set email subject
oMail.Subject = "direct email sent from c# project";
//Set email body
oMail.TextBody = "this is a test email sent from c# project directly";
//Set SMTP server address to "".
SmtpServer oServer = new SmtpServer("");//173.194.40.246,"74.125.237.181");
//Set 465 port
oServer.Port = 465;
//detect SSL/TLS automatically
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
//Gmail user authentication
//For example: your email is "gmailid#gmail.com", then the user should be the same
oServer.User = "yaswanthmdh#gmail.com";
oServer.Password = "";
try
{
Console.WriteLine("start to send email directly ...");
oSmtp.SendMail(oServer, oMail);
Console.WriteLine("email was sent successfully!");
}
catch (Exception ep)
{
Console.WriteLine("failed to send email with the following error:");
Console.WriteLine(ep.Message);
}
after running this code i am getting timeout error.
is there any other way to send an email other than through smtp?
is there any way to send an email from application through http?
No. That's how email works. Just like you need a web server to serve web pages, you need an SMTP server to send email. You'll have to talk to your IT Infrastructure department, and get them to either set something up for you or allow requests to whatever SMTP server you're trying to use.
If you just need to test sending email, you can use something like Papercut, for the time being, and then depending on where and how you deploy your application in production, it may no longer be a problem.

LuaSocket - TCP 2nd message not sending

I've been searching Google for awhile and there seems to be no offers on fixing this problem I have here.
I am using LuaSocket as a simple way to connect to a external server I created, and I am able to connect to it successfully and send a signal.
However, when I try to send a second message later on, the external server does not seem to be receiving the message, even though I am still connected to the socket.
socket = require("socket")
host, port = ip, port
tcp = assert(socket.tcp())
tcp:settimeout( 0 )
tcp:connect(host, port);
msg = {
["status"]="connect",
["usrName"]=username
}
msg = Json.Encode(msg)
tcp:send(msg); -- This message, the server received this message.
-- Later in my code, I attempt to send another message.
msg = {
["status"]="anotherMessage",
["usrName"]=username
};
msg = Json.Encode(msg)
tcp:send(msg); -- This message is not sending, even though i'm still connected.
You need to show what happens on the other side as it may be simply not reading even though the connection may be open. You also don't say what exactly happens when "message is not sending"; do you get an error? the script finishes but the message is not sent?
There are several things you can try:
Switch to the (default) synchronous send until you get it working; remove tcp:settimeout(0), as your send may simply fail with "timeout" message if the other side is not ready to read the message.
Check the error message from :send call to see if it's timing out or not.
local ok, err = tcp:send(msg)
Use socket.select to check if the other side it ready to accept the message you are sending.
Try adding "\r\n" at the end of your serialized JSON.

Resources