i would like to monitor my systems in my network using c#, below is the list of things to monitor
Status of remote system(logged in, logged out, turned off)
Shutdown/reboot/logoff remote system
This is a broad question. Are you using SNMP? If these are Windows computers you can use WMI. Both of those items can be done simply with WMI.
You may find this link useful for basic WMI information.
Here is a WMI reference.
Essentially, you can think of any piece of system information you like and then search for how to retrieve it using WMI. It doesn't matter if you find samples for VBScript (which is what most examples probably will be coded for), you can convert that to C# easy.
Alternatively, you can use SNMP, which is a bit more complex and requires extra setup.
Another possibility, and more work than WMI but less setup than SNMP, is to write your own code to query various pieces of information using the actual API calls. This is overkill for most things, stick with WMI where you can.
You should be able to monitor the status of remote systems using WMI and the System.Management namespace. An introductory article is here.
To force remove shutdown, reboots and logoff, probably the easiest way is to use the Sysinternals psshutdown (details). You can use this from C# by running it as an external Process.
Related
I want to be able to pull in the error log from BIOS across a network. Looking at Win32_BIOS in MSDN I did not see anything defining the error log. Would love to do this in C# with WMI, but am open to suggestions. Is it possible?
Win32_BIOS does not have a property (don't know if that is the right term) that contains the BIOS error log. Is there a library, API, etc. that I can use to pull this information locally or from the network?
Generally, it is not possible to do this in such a way that will apply across a spectrum of motherboards as the requisite commands and interfaces will be hardware specific.
Some motherboards may contain an API call that will allow this, however, I have never come across one myself.
One of my problems, is that I support clients who often spend a lot of time monitoring if their servers (and services) are functioning properly, and that their network is up and running smoothly.
All of these tasks are easily re mediated through PowerShell, and I had a grand idea to unify all of the tasks and present them in a GUI, with the ability to tail the logs on remote servers at will.
I can execute PowerShell remotely to ascertain all of the facts I need about the servers involved, can poll and retrieve all the relevant points of data, aggregate them in a database, perform trend and abnormality analysis, that's all good.
But I want to aggregate it all into a sort of "management console" to alleviate all of the mundane tasks. Why not?
So I'm looking for some pointers as to where I can look for any frameworks, HTML based or application based, that can leverage the power of PowerShell into a somewhat modular UI interface. From what I've seen and experimented with, C# is abnormally complicated when executing PowerShell cmdlets.
Pardon my ignorance, I'm mainly a scripter. Please point me to the right direction!
I can imagine the exact GUI I want, and can grab and analyze all the data I need to accomplish it... Just not sure of the glue that connects the two.
Take a look on PowerGUI by Dell - it's designed for tasks like this.
Also you can try to do all with bare-hands coding using Windows Forms in PowerShell, like described on this TechNet blog post's series.
Also there is many PowerShell IDE's with visual Form designers - AdminScript is one of oldest.
This is a very general question, I beleive too general for StackOverflow. Here are my first thoughts as is :
1) Collecting datas on server is avery old story, begining with SNMP and continuing with WMI and more generaly "Windows Management Framework" on Windows. So client UI, you can adapt to your clients exists on the market. Have a look to Centreon, or Paessler.
2) As far as PowerShell is involved have a look to the Quest (now DELL) PowerGUI console (not the script editor)
3) If really you want it (not a good idea for me) you can write a PowerShell UI application, have a look to Sapien's PowerShell Studio. I give some clues about programming PowerShell UIs here.
we are devoloping a web application using c#.net,ASP.Net 3.5,in that we need to know the infomation of local system like what are the installed printers? is there any way to get the data using any scripting Languages? Plz let me know if any body knows the answer.
Thanks in advance
Prasad
we are devoloping a web application using c#.net,ASP.Net 3.5,in that we need to know the
infomation of local system like what are the installed printers?
Are you? Why do you formulate this as a question. Are you not sure what you are doing?
is there any way to get the data using any scripting Languages?
Maybe, maybe not. Irrelevant, though, as ASP.NET is not using scripting langauges on the server anyway. Your server sidel ogic will be ni C# or VB.NET likely (or any other .NET langauge) and by all means this is not a scripting langauge.
if yuo talk of the client side (i.e. from the browser: no way, and you have no busienss knowing. The internet is not a friendly place. Whatever rights you think you want can be abused by some bad person. And will be.
Plz let me know if any body knows the answer.
Yes, someone knows the answer. Which answers yoru question. Note: you did not ask for an answer, you asked whether anyone knows the answer.
Now, real:
Yes, you can. WMI is your friend. The main problem will be:
Understanding the WMI documentation. WMI is the Windows Management Instrumentation and you can prettya much see everything of any computer you can connect WMI to there.
Configuring IIS to allow you local access.
I guess that will help:
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
I want to write a method in C# to check which applications in my machine/server are using internet connection at a particular point in time and if possible, how much bandwidth they are using. Can anyone please help me get a head start on this?
I decided to write an answer because comments are too small.
Well, reading other Q&A on stackoverflow and looking around on the internet, I didn't find a simple solution for your problem.
Actually, for .NET processes is really simple, you just need to retrieve informations from ".NET CLR Networking - Bytes Received/Bytes Sent" performance counters, as shown in this Q&A
But in general, getting per-process used bandwidth isn't an easy work.
For example "Microsoft Network Monitor" sniffer can trace the process that generates internet packets only for TCP traffic, because probably it maps IP-port pairs with processes using them (or something similar, TCP is a connected protocol so it is simpler).
Anyway if you want to give it a try you can use the exposed API (look at this blog entry for some hint).
However, as suggested in these Q&A's (LINK 1, LINK 2), the right, and probably the only way, is to write a NDIS/TDI driver that can intercept network traffic and exposing a .NET callable API to it.
The problem is that such drivers can't be written in managed code, and so you need to implement it in C/C++.
Obviously, if you manage to find an already written driver/sniffer exposing a callable API, you can use it.
For example WinPCap has one (and some .NET wrappers like SharpPCap or PCap.Net), but I don't think (not sure) it's able to get packets's source-process information.
As digEmAll noted, in pre-Vista Windows you are reduced to writing your own driver or using a 3-rd party one. In Vista, 2008 and Windows 7 you can use the GetPerTcpConnectionEStats API (there is a large example of its usage on the MSDN page). Resource Monitor relies on this API, together with the older GetTcpTable/GetTcpRow APIs, for extended network statistics.
I found Process Monitor as a very useful tool and it served my purpose so I didnt had to write any code although i am yet to check out whether it gives any API which i can use in my application to get some information I need.
Thanks everyone for helping me out.
I used WMI way back during the .net 2.0 days. I had to use it coz there was no alternative. But today as we have a lot of functionality in BCL, does it still makes sense to use WMI? Is it supported by MS - Should I use this in my production code?
One of the things I hate about it is that I need to write string query. It is prone to typo errors, no syntax check. I could convert it to C# classes using Management Strongly Typed Class Generator (Mgmtclassgen.exe) but it still takes string arguments as path.
I would say that the WMI support in PowerShell is a pretty good indicator that WMI still has a future. I use it from time to time for remote administration to perform certain maintenance tasks.
We still actually use it in some of our production code, a toolkit for historical monitoring of various server performance and configuration details.
It was very handy for us since it was quite easy to put together some VBScript files under the control of Scheduled Tasks which did the data collection and transmission. This makes it runnable on a wide variety of Windows boxes without having to worry about compiling to the right target. It also allowed very fast bug fixing in the field since we can just ship a simple text file.
The fact that the source code is viewable is of no concern to us, it's not as if the idea of using WMI to collect data is some sort of precious IP :-)
I'm sure there's better tools but this was the simplest way we found. As far as I'm aware, it's still supported, inasmuch as they're still providing it in the later operating systems.
The only thing that burnt us (once) was the subtle changes between releases, such as objects themselves being deprecated or removed, making the WMI queries useless. We just need to watch out for that happening and adjust the scripts as necessary.
WMI Is still intensively used by monitoring systems. For example it is used by Microsoft Operations Manager. Also as already mentioned you can see WMI support in PowerShell.
I would suggest you also to check this in ServerFault as IT Administrators must be well aware about it also.