Friday, August 22, 2008

My First VB Script

As I am typing this blog, I am working on a monitoring script to ensure the Oracle services are up and running. I think I need to pick up a book to understand more about scripting in Windows environment.

Option Explicit
Dim objWMIService
Dim allServices
Dim s
Dim objProcess
dim objShell
Dim Mesg
Dim Command
Dim objEnv
Dim Subject


Set objShell = Wscript.CreateObject ("Wscript.shell")
Set ObjEnv =objShell.Environment("Process")
Set allServices = GetObject("winmgmts:").ExecQuery _
("SELECT * FROM Win32_Service")


For Each s in allServices
If s.Name = "OracleMTSRecoveryService" and s.State = "Stopped" Then
        Mesg = s.Name + " is down, "
End If
If s.Name = "OracleORACLEAgent" and s.State = "Stopped" Then
        Mesg = s.Name + " is down, "
End If
If s.Name = "OracleORACLEHTTPServer" and s.State = "Stopped" Then
        Mesg = s.Name + " is down, "
End If
If s.Name = "OracleORACLETNSListener" and s.State = "Stopped" Then
        Mesg = s.Name + " is down, "
End If
If s.Name = "OracleServiceLIVE" and s.State = "Stopped" Then
        Mesg = s.Name + " is down, "
End If
Next


Subject = "Oracle is down"
If Mesg = "" Then
        'Wscript.echo "Do nothing"
Else
        Command =  "C"\Scripts\postie -host:smtphost -to:someone@somewhere.com "
        Command = Command + "-from:" + ObjEnv("COMPUTERNAME") + " "
        Command = Command + "-s:" + chr(34) + Subject + chr(34) + " "
        Command = Command + "-msg:" + chr(34) + Mesg + chr(34)
        objShell.run Command
End If

Plenty of room for improvement to the above script. I hope to be able to drive the service monitoring via a input file so that the VB script does not have to be modified.

Labels:

Thursday, March 29, 2007

Windows as NFS Server

My colleague wanted to install something from a DVD disc on an old Sun Server. Too bad, it is far too old, it only has a CDROM drive. His notebook has a DVD drive, but it is running Windows. So, how can the Solaris 'mount' that drive ?

Not many people know that Microsoft has this piece of software called Windows Services for UNIX (SFU). If you install it, make sure you do a custom installation. Select all the modules and that include the NFS server module. Once that is done, you need to reboot the server.

Read How to: Set Up Server for NFS. It works exactly as any other NFS server, except the command and syntax.

Windows (x.x.x.x):
   nfsshare -o ro anon=yes cdrom=D:
Solaris:
   mount x.x.x.x:cdrom /mnt
Apart from NFS server, SFU offers a platform (Korn shell, C shell) for you to compile (gcc) codes. It also comes with a number of services, such as telnet daemon. IMHO, all systems engineers should install it. The only drawback is that it does not come with an X11 server. For X11 server, I need to rely on Cygwin/X.

Labels: , , , ,