Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Monday, 13 March 2017

Windows Service - How To Setup Email Notification On Service Failure

Problem:

We have designed a scheduler engine, which runs as a windows service and is used for executing different kinds of scheduled tasks. At times, the service stops and we get to know that only when some users complain of not being able to see the outcome of a scheduled task. Since then we have put this scheduler under the monitoring checklist, so that the windows monitoring team have a check on this service. But it would be even more effective, if this is automated. Wonder if Windows offers an easy way of setting up an alert on service stoppage.

Solution:

Windows does offer an option to configure email notification for one or more specific events occuring. If you have built your service application to handle the exceptions and write the exception information into the windows event log, then the easier approach is to leverage the windows event notification. If you have not aready used the Windows event log, in your service application, it is recommended to do so, as windows event log is the best place to look for errors and other events. Check out Stuart Lange's article on Handling Windows Service Errors. It is a series of six articles and you may want to check out all of them. Check out the Technet article Configure Notification Options to know more about setting up email notifications using the Windows System Resource Manager.

Just in case, you don't have the option of leveraging the Windows System Resource Manager as above, then you may make use of the Recovery options under the service properties dialog. You may double click on your service on the services console window and you will see a Tab named Recovery. The Recovery option enables you to specify a recovery action three times. See the figure below:


As you may observe, you four options to choose when a service fails: Take No Action, which is the default; Restart the servive; Run a program; and Restart the computer. While Restarting the computer is not a good idea if the computer also serves various applications and services, Though you have option to specify a delay for restart and
to send out messages to other connected computers that the computer is being restarted.


But certainly Run a Program option can be leveraged to send out an email notification. You may also notice that you have option to specify different actions for the first, second and subsequent failure. It would be a good idea to to try restarting the service atleast once or twice and then try using a custom program to send out an email notification. The custom program can even be a Power Shell script.

A simple PowerShell script to send out email notification could be as below:

$Username = "MyUserName";
$Password= "MyPassword";
$message = new-object Net.Mail.MailMessage;
$message.From = "YourName@gmail.com";
$message.To.Add($email);
$message.Subject = "subject text here...";
$message.Body = "body text here...";
$smtp = new-object Net.Mail.SmtpClient("smtp.gmail.com", "587");
$smtp.EnableSSL = $true;
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.send($message);


While there are more ways you can handle this problem, I hope this helps you to 

Friday, 29 August 2014

Windows 8.1 - Switching to Local Account

Problem:

Microsoft Windows 8.1 update by default prompts to use a Microsoft live account and without noticing, I just went ahead and got signed in using my Microsoft Account. Now how do I switch to a local account?

Solution:

Yes, Windows 8.1 by default takes the users to sign in using Microsoft live account. However, if you carefull observe, you have the option to use a local account, but Microsoft ensured that you will miss that. Windows however allows users to switch between live account and local accounts.  To switch to a local account, follow these steps:


  • Goto Your Account Settings screen. You can do this by typing "Your Account" on the Windows Search screen (Windows Key + Q) .  

  • You will see a link "Disconnect" under your user account. You should click on Disconnect, which will take you through setting up your local account.

  • As a next step, Windows will have to authenticate you once again and will prompt for your current password.
  • The next step will prompt you for inputs to have your local account created. 
  • You will then be prompted for a confirmation and you click on the Singout and Finish button.


You may want to note that by switching to your local account, you will lose the synchronization with your sky drive.


Saturday, 26 April 2014

Start PXE Over IPv4

Question:

My six months old HP Laptop which was working fine all along, once did not boot and I could see the text "Start PXE over IPv4" in the black MS DOS like screen and was unresponsive to keyboard and mouse. I waited for some time and then used the power button to hard shut down and then powered it again. This time it booted normally without any issues. Though the problem did occur thereafter, I am curious to know what PXE is all about. Can you explain what it is and the reason for it showing up?

By: Anonymous

Answer:

PXE is the short form for Preboot Execution Environment.It allows PCs or laptops to boot over a network as against booting from the local hard disk. Those who have worked with Novell Netware should be familiar with this network booting, where the Network Interface Cards carry a small add on chip containing the Network Boot Program, which will perform the boot over the network.

To address the large deployment challenges, Microsoft began developing the technology that would allow for network-based installation and PXE was the solution for this. To PXE boot a PC, the BIOS should be setup to boot from network. When set so, the BIOS will first get an IP address for the PC from the PXE Server and thereafter to get the boot image using TFTP on to the RAM and then boot out of that image.

Now in your case, as you have described the issue, it just happened, without you changing any BIOS setting. Normally the BIOS have multiple boot options configured with an order of priority. Your BIOS probably had the Network boot as one of the boot options and on that occasion, for some reason, your hard drive would have been unresponsive for a moment at the time of boot, as the next choice, the BIOS would have attempted to boot from network using PXE. As it might not find a PXE server over the IPv4 network it stayed there. 

You can check the BIOS by pressing F2 when your laptop boots and check if the network boot is configured as an option. You may disable this option, if you are not using the Network booting in your environment. On a different note, you may want to check why your local hard disk was not responsive for the boot on that occasion. That could be an odd occurrence and  the disk may be just fine too.

To know more about PXE booting, check the following resources: