Hello,

I am a beginner to ASP.NET. I need some directions for this task.

Information about task:

Phase 1 : Assume Server whose health to monitor is GEMINI.
Create two unattended (non UI) Windows Services (or Windows exe) written in C#.
Every specific “duration” the windows services will be invoked.Use app.config file to store this duration value.
Should check the server (GEMINI) if it is up or down.
Check the following various applications under following broad classifications in the server.
Server
IIS
SQL Server
Windows Service ( control panel --> under services u see services running)
Windows Exe
Web Service

If the application is down and the server is down it has to log data into the sql server database.

Thanks in advance!

Ramito

Recommended Answers

All 3 Replies

Welcome to daniweb! Please direct windows form application and service application questions to the C# forum. The ASP.NET forum is reserved for web application related questions.

What is your definition of a server being "UP"? A ping response, a successful test to a website, a connection to some service hosted on it...? If my webserver responds to a ping but IIS is crashed I consider the server down.

To see if a service is running you need to add a reference to System.ServiceProcess and use the following code:

using System.ServiceProcess;

namespace daniweb
{
  public static class ServiceStuff
  {
    public static bool IsServiceRunning(string ServiceName)
    {
      try
      {
        using (ServiceController ctrl = new ServiceController(ServiceName))
        {
          return (ctrl.Status == ServiceControllerStatus.Running);
        }
      }
      catch
      {
        return false;
      }
    }
  }
}

I re-read your post and maybe you weren't clear.

I am a beginner to ASP.NET. I need some directions for this task.

Create two unattended (non UI) Windows Services (or Windows exe) written in C#.

ASP.NET is not going to be an unattended Service or Exe. Perhaps you chose the wrong technology (but the right language!) or you did not explain yourself clearly

Well sorry I didnt mention the things clearly.
Well this is what my boss gave me..

PHASE I

Create two unattended (non UI) Windows Services (or Windows exe) written in C#.Net that checks Servers and Applications/Services health (make sure they are up and running).

General Requirements
1. Two windows services to build: one will run on IT Server (Gemini) and the other will run on Rackspace server.

2. Every specific “duration” the windows services will be invoked. Make sure that this duration is configurable.
Spec:
a. Use app.config file to store this duration value. The service will look at this value to determine the length of intermittent duration.

3. Log each check to a database table which includes the time, the “system” being checked and the health of the “system” (either down or up).
a. Create a few tables in HealthMonitor DB:
i. HST_HEALTHSTATUS
Fields:
HST_ID, smallint, PK, identity(1,1)
HST_Name, varchar(50)

Values:
HST_ID=1, HST_Name=Normal
HST_ID=2, HST_Name=Down
ii. STP_SYSTEMTYPE
Fields:
STP_ID, smallint, PK, identity(1,1)
STP_Name, varchar(50)

Values:
STP_ID=1, STP_Name=Server
STP_ID=2, STP_Name=IIS
STP_ID=3, STP_Name=SQL Server
STP_ID=4, STP_Name=Windows Service
STP_ID=5, STP_Name=Windows Exe
STP_ID=6, STP_Name=Web Service
iii. SMH_SYSTEMHEALTH
Fields:
SMH_ID, smallint, PK, identity(1,1)
SMH_Name, varchar(50)
SMH_IPAddress, varchar(50)
SMH_ProcessName, varchar(50)
STP_ID, smallint, FK
HST_ID, smallint, FK
MSL_ID, smallint, FK
SMH_Comment, varchar(500)
SMH_LastDateTimeHealthCheck, datetime

Values:
SMH_ID=1, SMH_Name=Rackspace, SMH_IPAddress=77.33.203.277, SMH_ProcessName=None, STP_ID=1, HST_ID=[dynamic],MSL_ID=1, SMH_Comment=[dynamic], SMH_LastDateTimeHealthCheck=[dynamic]

SMH_ID=2, SMH_Name=Gemini, SMH_IPAddress=48.140.241.55, SMH_ProcessName=None, STP_ID=1, HST_ID=[dynamic],MSL_ID=2, SMH_Comment=[dynamic], SMH_LastDateTimeHealthCheck=[dynamic]

iv. MSL_MONITORSERVICELOCATION
Fields:
MSL_ID, smallint, PK, identity(1,1)
MSL_Name, varchar(50)
Values:
MSL_ID=1, MSL_Name=Gemini
MSL_ID=2, MSL_Name=Rackspace
v. HMG_HEALTHMONITORLOG
Fields:
HMG_ID, bigint, PK, identity(1,1)
SMH_ID, smallint, FK
HST_ID, smallint, FK
HMG_DateTime, datetime
HMG_Comment, varchar(500)
vi. SAM_SYSTEMADMIN
Fields:
SAM_ID, smallint, PK, identity(1,1)
SAM _EmailAddress, varchar(100)
SAM _MobilePhone, varchar(30)
SAM _Status

4. The windows services will need to loop through all the systems (records) stored in SMH_SYSTEMHEALTH table.
a. The windows service that is running on Rackspace will only loop through systems that are specified as MSL_ID = 2. The windows service that is running on Gemini will only loop through systems that are specified as MSL_ID = 1.
b. Based on its STP_ID, the service will need to check for the health of the system appropriately. For example if STP_ID = 1, then do the ping mechanism to check the health of the system. If the STP_ID = 2, then checks the IIS windows service if it is running. If the STP_ID = 3, then attempts to connect to a database .. etc..
c. For each health check attempts, add a record in HMG table and update the HST_ID and SMH_LastDateTimeHealthCheck fields in SMH table with the appropriate values (insert comment if necessary).
d. For each failure (down) system, SMS text all users that are stored in the ADM table with status = 1.


Let me if it is clear now. Sorry for posting it in ASP.NET forum I should have posted in C#.

I will post it in C# for anything more new doubts.

Thanks in advance.

Ramito

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.