Click here to Skip to main content
15,849,306 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming26-Aug-21 4:52
mveRichard Deeming26-Aug-21 4:52 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 5:04
samflex26-Aug-21 5:04 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 6:08
samflex26-Aug-21 6:08 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming26-Aug-21 6:19
mveRichard Deeming26-Aug-21 6:19 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 7:41
samflex26-Aug-21 7:41 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming26-Aug-21 22:28
mveRichard Deeming26-Aug-21 22:28 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex27-Aug-21 4:21
samflex27-Aug-21 4:21 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming27-Aug-21 5:10
mveRichard Deeming27-Aug-21 5:10 
Sorry, missed the return statement:
C#
static async Task<int> Main(string[] args)
{
    System.Collections.Concurrent.ConcurrentDictionary<string, string> urlToStatus = new();
    
    IEnumerable<Task<bool>> tasks = args.Select(async url =>
    {
        bool result = await ServerStatusByAsync(url);
        urlToStatus.TryAdd(url, result ? "UP" : "DOWN");
    });
    
    bool[] results = await Task.WhenAll(tasks);
    
    StringBuilder body = new("Please find the status of the servers below:");
    foreach (var kvp in urlToStatus)
    {
        body.AppendLine();
        body.AppendFormat("{0}: {1}", kvp.Key, kvp.Value);
    }
    
    await SendEmailAsync("Server Status", body.ToString());
    await Task.Delay(3000);
    
    // Return the number of servers which were down:
    return results.Count(result => !result);
}

Running it is still the same, except you now need to pass a list of URLs to test, rather than a list of server names to ping.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

General(SOLVED) Re: I am having problem creating a script to monitor Rest/API services. Pin
samflex27-Aug-21 6:27
samflex27-Aug-21 6:27 
QuestionBest, cheap, ASP.NET Core hosting? Pin
Chris Maunder4-Aug-21 9:36
cofounderChris Maunder4-Aug-21 9:36 
AnswerRe: Best, cheap, ASP.NET Core hosting? Pin
jkirkerx11-Aug-21 12:15
professionaljkirkerx11-Aug-21 12:15 
GeneralRe: Best, cheap, ASP.NET Core hosting? Pin
Chris Maunder11-Aug-21 12:56
cofounderChris Maunder11-Aug-21 12:56 
GeneralRe: Best, cheap, ASP.NET Core hosting? Pin
jkirkerx11-Aug-21 13:50
professionaljkirkerx11-Aug-21 13:50 
AnswerRe: Best, cheap, ASP.NET Core hosting? Pin
Deepak Vasudevan13-Sep-21 22:42
Deepak Vasudevan13-Sep-21 22:42 
GeneralRe: Best, cheap, ASP.NET Core hosting? Pin
Chris Maunder14-Sep-21 5:38
cofounderChris Maunder14-Sep-21 5:38 
AnswerRe: Best, cheap, ASP.NET Core hosting? Pin
Moo v This17-Nov-21 3:53
Moo v This17-Nov-21 3:53 
Questionhow to run default page as login page in web app blazor Pin
Member 1129177422-Jul-21 3:54
Member 1129177422-Jul-21 3:54 
Questionncaught ReferenceError:System is not defined at (index):18 dx.light.css:1 Failed to load resource:the server responded with a status of 404(Not Found) Pin
Member 146901009-Jul-21 8:15
Member 146901009-Jul-21 8:15 
AnswerRe: ncaught ReferenceError:System is not defined at (index):18 dx.light.css:1 Failed to load resource:the server responded with a status of 404(Not Found) Pin
SeeSharp29-Jul-21 8:38
SeeSharp29-Jul-21 8:38 
JokeEste site aceita link? Pin
Ronaldo Luis Gonçalves6-Jul-21 4:37
Ronaldo Luis Gonçalves6-Jul-21 4:37 
AnswerRe: Este site aceita link? Pin
SeeSharp29-Jul-21 9:05
SeeSharp29-Jul-21 9:05 
QuestionHow to Upgrade Publish website page in latest version at Visual Studio 2012 Pin
Robymon4-Jul-21 1:39
Robymon4-Jul-21 1:39 
AnswerRe: How to Upgrade Publish website page in latest version at Visual Studio 2012 Pin
Richard Deeming4-Jul-21 22:36
mveRichard Deeming4-Jul-21 22:36 
QuestionHTTPPOST of EditReport not comiting data to database Pin
Carl Cummings (Canada)2-Jul-21 18:34
professionalCarl Cummings (Canada)2-Jul-21 18:34 
AnswerRe: HTTPPOST of EditReport not comiting data to database Pin
Richard Deeming4-Jul-21 22:34
mveRichard Deeming4-Jul-21 22:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.