Happy Noobing, Keep Noobing, be the best noobs!
Categories: Citrix Web Interface, NetScaler & AGEE, VBScript, 593 wordsSend feedback •Once a while, I am getting users calling “Service Unavaible” after logon to Access Gateway. By checking, found that one of the Application Pools in IIS was down. I have set seperate application pool for each Citrix Web Interface site, so if one application pool is down, only one site is affected. But how do I monitor this? By googling, I found the following from http://forums.webhostautomation.com/showthread.php?t=11141, and I am only showing this here to thank the author for his wonderful idea. I have created a scheduled task to run this vbscript on the two Web Interface servers every 30 minutes for 24 hours, so I will be notified by email fairly quickly once there is a problem. In the script, I am using my own SendEmail to use SMTP server, as there is no Outlook client installed on that IIS server.
===Code Starts==========================================================
‘ Variables that need to be defined for the script to work
‘http://forums.webhostautomation.com/showthread.php?t=11141
Const LogDir = “C:\Source\AppPoolLog”
ToAddress = “user@it.com”
FromAddress = “user@it.com”showAppPools ‘Runs showAppPools Sub
‘ This will get the list of all app pools on the server
Sub showAppPools
Dim obj,apool
set obj = GetObject("IIS://localhost/W3SVC/apppools")
for each apool in obj
apppoolStatus apool.name
Next
set obj = nothing
End Sub‘ This will get the status of the app pool
Sub apppoolStatus(apppool)
Dim obj
set obj = GetObject("IIS://localhost/W3SVC/apppools/” & apppool)
Select Case obj.apppoolstate
Case 0
writetoLog apppool,"0″ ‘Do not know what this status is
Case 1
writetoLog apppool,"1″ ‘Do not know what this status is
Case 2
writetoLog apppool,"Up”
Case 3
writetoLog apppool,"3″ ‘Do not know what this status is
Case 4
writetoLog apppool,"DOWN”
startapppool apppool
SendEmail GetComputerName,apppool
writetoLog apppool,"Restarted”
End Select
set obj = nothing
End Sub‘ This will write information to a log file
Sub writetoLog(apppool,response)
Dim fso
lday = datepart("d",date)
lmonth = datepart("m",date)
lyear = datepart("yyyy",date)
logdate = lyear & lmonth & lday
set fso = CreateObject ("Scripting.FileSystemObject")
Set objFSOwriteline = FSO.OpenTextFile(LogDir & “\” & logdate & “.log", 8,True)
objFSOwriteline.WriteLine(response & “,” & apppool & “,” & now())
objFSOwriteline.close
Set objFSOwriteline = nothing
set fso = nothing
End Sub‘ This starts the down app pool
Sub startapppool(apppool)
Dim obj
set obj = GetObject("IIS://localhost/W3SVC/apppools/” & apppool)
obj.start
set obj = nothing
End Sub‘ This send a email regarding the down/restarted app pool
Sub emailSendCDOSYS(apppool)
Dim Mailer
Set Mailer=CreateObject("CDO.Message")
Message = “===============================================” & VbCrLf
Message = Message & “Application Pool: ” & apppool & ” has been restarted” & VbCrLf
Message = Message & “Date/Time: “& now() &"” & VbCrLf
Message = Message & “===============================================” & VbCrLf
Subject = “Application Pool: ” & apppool & ” has been restarted”
Mailer.TextBody = Message
Mailer.Subject = Subject
Mailer.To = ToAddress
Mailer.From = FromAddress
Mailer.Send
set Mailer = Nothing
End Subsub SendEmail(ServerName, apppool)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = “user@it.com”
objEmail.To = “user@it.com”
objEmail.Subject = “Application pool: ” & apppool & ” is restarted on ” & ServerName
objEmail.Textbody = “Application Pool error.”
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
“smtp.it.com”
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.SendEnd Sub
Function GetComputerName
Set objWMISvc = GetObject( “winmgmts:\\.\root\cimv2″ )
Set colItems = objWMISvc.ExecQuery( “Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strComputerName = objItem.Name
Next
GetComputerName = strComputerName
End Function
===Code ends============================================Permalink
Categories: MOM, VBScript, 483 wordsSend feedback •Situation: HPBOID.exe and HPBPRO.exe are running wild on print servers. This is caused by HP Printer Toolbox, see more details here: http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?lang=en&cc=us&objectID=c00601047&jumpid=reg_R1002_USEN.
Requirements: To take preventive action on this issue
Suggestions:
1. Install the HP fix. This may need reboot of the server if the HPBOID.exe and HPBPRO.exe is held by some process. And also if you have hundreds of servers to handle. Have to do this at some stage, I guess, with a detailed plan.
2. Schedule a script to run to loop all of your servers and kill these two processes. Put ServerList.txt in C:\ root or change location in the script. Get a copy of my script at: http://www.ozctx.com/dl/scripts/VBScripts/KillProcess.txt
3. Make MOM to alert you when the processes going wild.
3.1 Make an event rule to generate an event for you when the count of the process goes over your threshold.
* In Rule Groups, Create your own rule group (I guess it is a good idea to put your own rules under one folder for better maintenance)
* Under your own rule group, create another rule group called “Windows Servers", right click the new rule group, click “Associate with Computer Group …", choose the computer groups you need to monitor. In my case, this is “Microsoft Windows 2000 Servers” and “Microsoft Windows 2003 Servers". After you have done this, you will see in the details pane “Bound to Computer Groups:” are populated with your choice.3.2 Create another Event Rule to catch the custom events
* in Event Rules, create a rule with following details:
** Rule name: Generate Event 90001 - Count Process - HPBOID.exe
** Provider: Schedule every 1 hours (who added this ’s’)
** Response type: Launch a script, then click New, make name “_Count_HPBOID_Process", the underscore can make your own scripts stand out.
(Thank you, Anders Bengtsson, I am copying the script from you, http://www.myitforum.com/forums/m_141782/mpage_1/key_/tm.htm#141782 )Code:
strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set objShell = CreateObject("Wscript.Shell")Set colProcesses = objWMIService.ExecQuery _("Select * from Win32_Process Where Name = 'HPBOID.exe'")If colProcesses.Count > 20 ThenConst EVENT_WARNING = 90001Set objShell = CreateObject("Wscript.Shell")objShell.LogEvent EVENT_WARNING, _"There are more then 20 instances of HPBOID.exe running."End If* Then you have a scheduled script to check the process count for you every hour. If the count goes over the threshold, an event is created in Event Log - Applications.
* Under Event Rule, create another rule to monitor this event id 90001
** Rule Name: Email Alert on Event 90001 - HPBOID Process Count
** Data Provider: Application
** Criteria: with event id 90001
** Schedule: Always process data
** Alert: Generate Alert with severity “Critical Error”
** Response: Send notification to a notification groupDone, you will get email alert as scheduled.
Permalink
Categories: VBScript, MFCOM, 326 wordsSend feedback •Tommo asked me is it a quick job to use MFCOM to send message to everyone on one server before scheduled reboot. I quickly checked MFCOM language reference, and found one method:
SendMessage.Findings: when listing sessions, farm-widely, you will get all user sessions, such as ObjFarm.Sessions. But listing sessions by server, as ObjServer.Sessions, it will list the following sessions as well:
Console
ICA-tcp (session id 65536 listening)
RDP-tcp (session id 65537 listening)So in the following script, I have to use to If/elseif to include only session with active state and with non-empty username.
Code:
<package><job id="MFCOM_Send_Message"><comment>File: MFCOM_Send_Message.wsfDescription: Send Message to users who have active sessions on the server.Requirements: WSH 5.5 or higher.Created: 20/5/2008Author: PaulloSendMessage Parameters:ServerNameSessionIDUserNameClientNameTitleMessageMessageStyle 0 = OK Button OnlyTimeout Display time in millisecondsWaitingTime Waiting for response time in milliseconds</comment><runtime><description>Send Message to users.</description><example>CScript //nologo MFCOM_Send_Message.wsf SERVERNAME</example></runtime><reference object="MetaFrameCOM.MetaFrameFarm"/><script language="VBScript">Dim ArgObj, ServerName, ObjServer, ObjSessions, ObjSessionSet ArgObj = WScript.ArgumentsServerName = ArgObj(0)WScript.Echo "Server Name: " & ServerNameSet ObjServer = CreateObject("MetaFrameCOM.MetaFrameServer")ObjServer.Initialize 6, ServerNameFor Each ObjSession in ObjServer.SessionsSessionID = ObjSession.SessionIDUserName = ObjSession.UsernameClientName = ObjSession.ClientNamestrTitle = "System Maintenance Reminder"strMsg = "Please log off in 5 minutes due to regular system maintenance."SessionState = ObjSession.SessionState' WScript.echo "SessionID = " & SessionID & "; UserName = " & UserName & "; ClientName = " & ClientName & "; SessionState = " & SessionState & ";"If UserName = "" Then' When listing sessions for a server, it is listing the listening sessions as well.Elseif SessionState <> 1 Then' Only send message to Active SessionsElseObjSession.SendMessage ServerName,SessionID, UserName, ClientName, strTitle, strMsg, 0, 120000, 120000End IfNext</script></job></package>Permalink