C# Get BIOS Events using C# [duplicate] - c#

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.

Related

monitor internet usage in .net

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.

Anybody uses WMI? Whats the future?

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.

how do i monitor network systems?

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.

how to create a vpn software

I want to create an application which creates a VPN between some endpoints, something like hamachi and i do not have a starting point. I haven't found any resource to explain how to create such a network application.I want to use c# because i have some experience with it.
I really need some help, anything that can put me on the right way. Thanks.
There are a number of distinct elements of VPN software that you'll have to figure out:
What technology/standard will your program use to provide the privacy? Some common ones are IPSEC, L2TP, PPTP, SSH, and SSL. Web searches ought to turn up rich information (including RFCs) on all of these. If you're doing this as a learning exercise, rather than needing actual security, you could also design your own.
Are you implementing a client, a server, or both?
What operating system(s) will you support? This affects what you need to do to convince it to route packets through your application.
Do you plan to interoperate with software implementing some standard?
You might want to take a look at SSH tunneling and see if it solves your needs.

What to use for Messaging with C#

So my company stores alot of data in a foxpro database and trying to get around the performance hit of touching it directly I was thinking of messaging anything that can be done asynchronously for a snappier user experience. I started looking at ActiveMQ but don't know how well C# will hook with it. Wanting to hear what all of you guys think.
edit : It is going to be a web application. Anything touching this foxpro is kinda slow (probably because the person who set it up 10 years ago messed it all to hell, some of the table files are incredibly large). We replicate the foxpro to sql nightly and most of our data reads are ok being a day old so we are focusing on the writes. plus the write affects a critical part of the user experience (purchasing), we store it in sql and then just message to have it put into foxpro when it can. I wish we could just get rid of the foxpro, unfortunately the company doesn't want to get rid of a very old piece of software they bought that depends on it.
ActiveMQ works well with C# using the Spring.NET integrations and NMS. A post with some links to get you started in that direction is here. Also consider using MSMQ (The System.Messaging namespace) or a .NET based asynchronous messaging solution, with some options here.
MSMQ (Microsoft Message Queueing) may be a great choice. It is part of the OS and present as an optional component (can be installed via Add/Remove Programs / Windows Components), meaning it's free (as long you already paid for Windows, of course). MSMQ provides Win32/COM and System.Messaging APIs. More modern Windows Communication Foundation (aka Indigo) queued channels also use MSMQ.
Note that MSMQ is not supported on Home SKUs of Windows (XP Home and Vista Home)
Its worth mentioning that the ActiveMQ open source project defines a C# API for messaging called NMS which allows you to develop against a single C# / .Net API that can then use various messaging back ends such as
ActiveMQ
MSMQ
TibCo's EMS
any STOMP provider
any JMS provider via StompConnect
You may want to look at MSMQ. It can be used by .NET and VFP, but you'll need to rewrite to use them. Here's an article that tells you how to use MSMQ from VFP. https://learn.microsoft.com/en-us/previous-versions/visualstudio/foxpro/ms917361(v=msdn.10)
Sorry if this isn't what you are asking for...
Have you considered some sort of cache behind the scenes that acts a bit like the "bucket system" when using asynchronous sockets in c/c++ using winsock? Basicly, it works by accepting requests, and sends an immediate response back to the web app, and when it finally gets around to finding your record, it updates it on the app via AJAX or any other technology of your choice. Since I'm not a C# programmer I can't provide any specific example. Hope this helps!
Does the Fox app use .CDX indexes? If so, you might be able to improve performance by adding indexes without needing to change any program code. If it uses .IDX indexes, though, the change would have to be done in the actual app.
As the problem is with writes, I would look more towards >removing< any unneeded indexes on the tables. As is common in RDBMS, every index on a FoxPro table slows down a write operation as the indexes need to be updated, and as you aren't reading directly from (or presumably directly querying) the table you shouldn't need very many indexes. You might also want to look at any triggers or field rules on the tables as they may be slowing down the write operation. Be sure your referential integrity is still preserved, though..

Categories

Resources