Click here to Skip to main content
15,887,906 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Is it possible to add fore ground and back ground to any app that is down? Pin
samflex2-Sep-21 3:02
samflex2-Sep-21 3:02 
Questionproject code in .net for online banking transaction Pin
Jk 0724-Aug-21 5:12
Jk 0724-Aug-21 5:12 
AnswerRe: project code in .net for online banking transaction Pin
Richard MacCutchan24-Aug-21 5:40
mveRichard MacCutchan24-Aug-21 5:40 
GeneralRe: project code in .net for online banking transaction Pin
Member 1534301831-Aug-21 22:04
Member 1534301831-Aug-21 22:04 
QuestionI am having problem creating a script to monitor Rest/API services. Pin
samflex23-Aug-21 8:11
samflex23-Aug-21 8:11 
AnswerRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming23-Aug-21 21:15
mveRichard Deeming23-Aug-21 21:15 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex24-Aug-21 5:08
samflex24-Aug-21 5:08 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
David Mujica24-Aug-21 6:04
David Mujica24-Aug-21 6:04 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex24-Aug-21 6:09
samflex24-Aug-21 6:09 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex25-Aug-21 4:18
samflex25-Aug-21 4:18 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
David Mujica25-Aug-21 5:24
David Mujica25-Aug-21 5:24 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex25-Aug-21 6:09
samflex25-Aug-21 6:09 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming25-Aug-21 6:18
mveRichard Deeming25-Aug-21 6:18 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex25-Aug-21 8:23
samflex25-Aug-21 8:23 
WOW, thank you very much sir.

You remind me so much of this super guru called Bill Wilkinson of classic ASP and JavaScript way back when I was learning classic ASP.

Just when I felt stuck and in trouble, he would come out of nowhere to help me out.

God bless you sir.

Please forgive me for additional questions.

1, does this ... (the dot dot dot) mean there is more code to go in there?
2, I use this -> YourApp.exe site1.local codeproject.com google.com for scheduling the run times, correct?
3, This -> YourApp.exe site1.local codeproject.com google.com means that I can add the five links all at once correct?

Many thanks again. I really appreciate your help.

I feel a bit better now.


UPDATE: I think I answered question #1.

This is how I *THINK* the code should look like now.

I added the email component since users will be getting emails with the status of the servers whether up or down.

Email subject should indicate Server Up or Down bases on what happens on ServerStatusBy() method

using System;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Net.NetworkInformation;
using System.Text;
using System.Configuration;

namespace showserverstatus
{
    class Program
    {
        private string statusMessage;
        static int Main(string[] args)
        {
           int result = 0;
            foreach (string site in args)
            {
                if (!ServerStatusBy(site))
                {
                    result++;
                }
            }

            return result;

        }

        static bool ServerStatusBy(string site)
        {
            Ping pingSender = new Ping();
            PingReply reply = pingSender.Send(site, 10000);
            if (reply.Status != IPStatus.Success)
            {
                Console.WriteLine("{0}: {1}", site, reply.Status);
                string statusMessage = "Shw message that Server is down"; //Dont know if I am doing this correctly.
                SendEmail(); // Send out email when server is down
                return false;

            }
            else
                statusMessage = "Shw message that Server is up"; //Dont know if I am doing this correctly.
            Console.WriteLine("IP Address: {0}", reply.Address.ToString());
             Console.WriteLine("RoundTrip time: {0}", reply.RoundtripTime);
             Console.WriteLine("Time to live: {0}", reply.Options.Ttl);
             Console.WriteLine("Don't fragment: {0}", reply.Options.DontFragment);
             Console.WriteLine("Buffer size: {0}", reply.Buffer.Length);
            SendEmail(); //Send out email when server is up.
            return true;
        }
        public static void SendEmail()
        {
            using (MailMessage mm = new(ConfigurationManager.AppSettings["FromEmail"],"joe.bloew@yahoo.com"))
            {
                mm.To.Add("joesixpack@gmail.com");
                mm.CC.Add("janeDoe@gmail.com");
                mm.Subject = statusMessage; // I would like to show Subject as either Server is down or Up based on what happened in ServerStatusBy() method.
                mm.Body = "Test";
                mm.IsBodyHtml = false;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = ConfigurationManager.AppSettings["Host"];
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = NetworkCred;
                smtp.Port = int.Parse(ConfigurationManager.AppSettings["Port"]);
                Console.WriteLine("Sending Email......");
                smtp.Send(mm);
                Console.WriteLine("Email Sent.");
                System.Threading.Thread.Sleep(3000);
                Environment.Exit(0);
            }
        }
    }
}


modified 25-Aug-21 19:11pm.

GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming25-Aug-21 22:12
mveRichard Deeming25-Aug-21 22:12 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 3:04
samflex26-Aug-21 3:04 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming26-Aug-21 3:52
mveRichard Deeming26-Aug-21 3:52 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 4:04
samflex26-Aug-21 4:04 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 5:08
samflex26-Aug-21 5:08 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming26-Aug-21 5:19
mveRichard Deeming26-Aug-21 5:19 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex26-Aug-21 6:41
samflex26-Aug-21 6:41 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming26-Aug-21 21:28
mveRichard Deeming26-Aug-21 21:28 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
samflex27-Aug-21 3:21
samflex27-Aug-21 3:21 
GeneralRe: I am having problem creating a script to monitor Rest/API services. Pin
Richard Deeming27-Aug-21 4:10
mveRichard Deeming27-Aug-21 4:10 
General(SOLVED) Re: I am having problem creating a script to monitor Rest/API services. Pin
samflex27-Aug-21 5:27
samflex27-Aug-21 5:27 

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.