Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation of testing pop/imap server connection

Rakshith August 30, 2018

Hi Team,
There are over 20 pop/imap server configured in jira and we have to test the connection for each pop/imap server configured everyday manually as part of daily check.

Is there a way to automate this task such that jira admins will receive mail if there is any connection failure?

Thanks,
Rakshith

1 answer

0 votes
Grigory Salnikov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2018

Hello, @Rakshith and welcome to the Community!

Have you considered using something like Zabbix or a custom script to regularly check the email servers' availability? 

Rakshith August 30, 2018

Hello Greg,

I thought of using below curl command to get the connection status and then use findstr to search for the string "The connection was successful."

curl -u test:test -d "@data.txt" -H "Content-Type: application/x-www-form-urlencoded" -X POST 'https://sswauat.catlin.com/secure/admin/VerifyPopServerConnection!update.jspa' > result.html

Usually checking connection would take 4-5secs to get the connection status but the above command finishes execution in 2 sec.So the html output says connection status as "Testing the connection ..."

Capture.PNG

 

I need to add a delay before curl redirects output to result.html so that connection testing is complete and html gets connection status as either "The connection was successful." or "Unfortunately no connection was possible."

 

Thanks,

Rakshith

Grigory Salnikov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2018

You can add your command up in a bash script along with a "sleep <n>"  command, where <n> is a number of seconds.

Rakshith August 30, 2018

I tried with below in the batch script but still facing same problem

@echo off
(curl -u username:password -d "@data.txt" -H "Content-Type: application/x-www-form-urlencoded" -k -X POST 
"<base url>secure/admin/VerifyPopServerConnection!update.jspa" 
Sleep 10 )> result.html

Grigory Salnikov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2018

Hm, I think it would be better if we use the following options instead:

(from manpage)

--connect-timeout <seconds>
    Maximum  time  in  seconds  that you allow the connection to the
    server to take.  This only limits  the  connection  phase,  once
    curl has connected this option is of no more use.  Since 7.32.0,
    this option accepts decimal values, but the actual timeout  will
    decrease in accuracy as the specified timeout increases in deci‐
    mal precision. See also the -m, --max-time option.

    If this option is used several times, the last one will be used.
-m, --max-time <seconds>
    Maximum  time  in  seconds that you allow the whole operation to
    take.  This is useful for preventing your batch jobs from  hang‐
    ing  for  hours due to slow networks or links going down.  Since
    7.32.0, this option accepts decimal values, but the actual time‐
    out will decrease in accuracy as the specified timeout increases
    in decimal precision.  See also the --connect-timeout option.

    If this option is used several times, the last one will be used.

Check this out, it might help.

Rakshith August 30, 2018

I tried with -m option earlier but it was of no use.

--connect-timeout also didnt help much as once curl has connected this option is of no more use but we want the delay after curl has connected and before curl gets disconnected

Is there a way to make curl wait for few secs before it can wait before it fetches the result from the website?
All the options we used till now doesnt actually lengthen the execution time of only curl.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events