473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to Monitor services using asp.net?

Is there a way to monitor a windows service using asp.net? I would like to
have a web page listing 5-6 services and their status (running, stopped etc).
Any tips on how to do this would be appreciated.
Nov 18 '05 #1
3 5726
Hi Anders,

Here is the piece of code that displays the services in the machine and also
there status.
Here in this code i am building a temp DataTable which inserting those
values into it.
so that it can be bind to Datagrid for display purpose.
using System.ServiceProcess;
DataTable dtSrvName = new DataTable();

dtSrvName.Columns.Add(new
DataColumn("ServiceName",Type.GetType("System.Stri ng")));

dtSrvName.Columns.Add(new
DataColumn("ServiceType",Type.GetType("System.Stri ng")));

dtSrvName.Columns.Add(new
DataColumn("Status",Type.GetType("System.String")) );

System.ServiceProcess.ServiceController[] arrSrvCtrl;

arrSrvCtrl = System.ServiceProcess.ServiceController.GetService s();

foreach(System.ServiceProcess.ServiceController tmpSC in arrSrvCtrl)

{

DataRow drSrvName = dtSrvName.NewRow();
if(tmpSC.Status==ServiceControllerStatus.Running )

{

drSrvName[0] = tmpSC.DisplayName.ToString();

drSrvName[1] = tmpSC.ServiceType.ToString();

drSrvName[2] = tmpSC.Status.ToString();

}

else if(tmpSC.Status== ServiceControllerStatus.Paused )

{

drSrvName[0] = tmpSC.DisplayName.ToString();

drSrvName[1] = tmpSC.ServiceType.ToString();

drSrvName[2] = tmpSC.Status.ToString();

}

else

{

drSrvName[0] = tmpSC.DisplayName.ToString();

drSrvName[1] = tmpSC.ServiceType.ToString();

drSrvName[2] = tmpSC.Status.ToString();

}

dtSrvName.Rows.Add(drSrvName);

}

DataGrid1.Visible = true;

DataGrid1.DataSource = dtSrvName;

DataGrid1.DataBind();

lblStatus.Text = "";

Label1.Text = "";


Hope this helps you.

Thanks
Raghavendra
"AndersBj" <An******@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
Is there a way to monitor a windows service using asp.net? I would like to
have a web page listing 5-6 services and their status (running, stopped etc). Any tips on how to do this would be appreciated.

Nov 18 '05 #2
Thank you, I will try this as soon as possible!
"Raghavendra T V" wrote:
Hi Anders,

Here is the piece of code that displays the services in the machine and also
there status.
Here in this code i am building a temp DataTable which inserting those
values into it.
so that it can be bind to Datagrid for display purpose.
using System.ServiceProcess;
DataTable dtSrvName = new DataTable();

dtSrvName.Columns.Add(new
DataColumn("ServiceName",Type.GetType("System.Stri ng")));

dtSrvName.Columns.Add(new
DataColumn("ServiceType",Type.GetType("System.Stri ng")));

dtSrvName.Columns.Add(new
DataColumn("Status",Type.GetType("System.String")) );

System.ServiceProcess.ServiceController[] arrSrvCtrl;

arrSrvCtrl = System.ServiceProcess.ServiceController.GetService s();

foreach(System.ServiceProcess.ServiceController tmpSC in arrSrvCtrl)

{

DataRow drSrvName = dtSrvName.NewRow();
if(tmpSC.Status==ServiceControllerStatus.Running )

{

drSrvName[0] = tmpSC.DisplayName.ToString();

drSrvName[1] = tmpSC.ServiceType.ToString();

drSrvName[2] = tmpSC.Status.ToString();

}

else if(tmpSC.Status== ServiceControllerStatus.Paused )

{

drSrvName[0] = tmpSC.DisplayName.ToString();

drSrvName[1] = tmpSC.ServiceType.ToString();

drSrvName[2] = tmpSC.Status.ToString();

}

else

{

drSrvName[0] = tmpSC.DisplayName.ToString();

drSrvName[1] = tmpSC.ServiceType.ToString();

drSrvName[2] = tmpSC.Status.ToString();

}

dtSrvName.Rows.Add(drSrvName);

}

DataGrid1.Visible = true;

DataGrid1.DataSource = dtSrvName;

DataGrid1.DataBind();

lblStatus.Text = "";

Label1.Text = "";


Hope this helps you.

Thanks
Raghavendra
"AndersBj" <An******@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
Is there a way to monitor a windows service using asp.net? I would like to
have a web page listing 5-6 services and their status (running, stopped

etc).
Any tips on how to do this would be appreciated.


Nov 18 '05 #3
Simply drag the service from the Visual Studio.NET server explorer window
onto your web form.
You then have some objects you can interact with.
The only issue may be security since the standard ASPNET account doesn't
have permission to interact with windows services. Therefore you may need
to use impersonation to run under a different user account. For testing
purposes you can have it use your username and password.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"AndersBj" <An******@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
Is there a way to monitor a windows service using asp.net? I would like to
have a web page listing 5-6 services and their status (running, stopped
etc).
Any tips on how to do this would be appreciated.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: vooose | last post by:
Suppose execution of a particular thread T1 hits Monitor.Enter(obj); //critical section and blocks at the first line. (ie someone else is in the critical section) Now suppose more threads...
3
by: maxim iulian | last post by:
I want to create o program in C# that's monitor IIS server. Thank's a lot ! Maxim Iulian *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get...
10
by: Mark | last post by:
I am working on a monitor system - web page that will show what processes are running on different computers. How would I get such information? All I need is a name of a process (title on a taskbar...
15
by: Jim Hubbard | last post by:
Is it possible to emulate a monitor (create a virtual monitor) using vb.net? Any code snippets or pointers to helpful articles would be very much appreciated.
1
by: Duncan S | last post by:
I am writing a service that uses the second monitor as a notice board the service runs okay if started when a user logs on. however the screen is blanked when the user logs out. is there any way a...
3
by: xerc | last post by:
So, this may not even be possible, but if so, I was hoping someone could point me in the right direction or give me the right terminology to use for searches of code example. Aside from monitoring...
1
by: dipak5801 | last post by:
i want to know how to monitor services using SNMP protocol. what is MIB and how can i get this information. anyone provide me training mateiral or step by step process using snapshot . thanks in...
1
by: vel | last post by:
Hi, How to monitor the local system services for each time interval using C#. I have to check whether the services are running properly or not. if any failur occurs i have to send a mail. Pls...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.