|
Profile
Personal Photo
Rating
Options
Personal Statement
kprestage doesn't have a personal statement currently.
Personal Info
kprestage
Power user
Age Unknown
Gender Not Set
Location Unknown
Birthday Unknown
Interests
No Information
Statistics
Joined: 17-May 07
Profile Views: 8,577*
Last Seen: 29th August 2010 - 01:05 AM
Local Time: Sep 8 2010, 02:45 AM
192 posts (0 per day)
Contact Information
No Information
No Information
No Information
No Information
* Profile views updated each hour
|
Topics
Posts
Blog
Comments
Friends
My Content
29 Oct 2009
Some people have asked for this on the wishlist, so I thought I would take a stab at it.
CODE -- Version: 4.0 -- Date: 2009-10-29 -- Description: Counts the number of instances of a process that are running -- Arguments: process name, minimum count, maximum count ---------------------------------------------------------------------------------------------------------- -- This function is called by INM to retrieve a script configuration function OnConfigure() -- The variable returned must be called "Config" so INM can find it. Config = LuaScriptConfigurator() -- Author. Config:SetAuthor("Kevin Prestage") -- Description. Config:SetDescription("Counts the number of instances of a process that are running") -- Minimum build version of INM, set to zero for if no specific build version is required. Config:SetMinBuildVersion(4.0) -- Script version (major/minor) Config:SetScriptVersion(1,0) -- A parameter configuration, add them in the order the script is extracting them. Config:AddArgument("Process Name","Enter the process name as it appears in task manager",LuaScriptConfigurator.CHECK_NOT_EMPTY) Config:AddArgument("Minimum Instance(s)","Monitor will go into alarm if the number of instance running falls below this number.",LuaScriptConfigurator.CHECK_NOT_EMPTY) Config:AddArgument("Minimum Instance(s)","Monitor will go into alarm if the number of instance running rises above this number.",LuaScriptConfigurator.CHECK_NOT_EMPTY) -- Set the entry point, this is the function called by INM Config:SetEntryPoint("main") -- Done with configuration, return the object return Config end -- This is the entry point function main() processname = GetArgument(0) min = tonumber(GetArgument(1)) max = tonumber(GetArgument(2)) ok = true result = "" count = 0 SetExitStatus("OK",true) --Query WMI for a list of all processes running on the machine. Query = TLuaWMIQuery(); b = Query:Execute("Select * from Win32_Process where Name = \"" .. processname .. "\""); --if the query failed, set the result. if (b == false) then result = "An error occurred querying WMI. " .. Query:GetErrorDescription(); else while (Query:NextInstance()) do count = count + 1 end if (count < min) then result = "The number of running instances is " .. count .. " which is less than " .. min ok = false elseif (count > max) then result = "The number of running instances is " .. count .. " which is more than " .. max ok = false else result = "The number of running instances is " .. count .. " which is between " .. min .. " and " .. max ok = true end end SetExitStatus(result,ok); end
21 Mar 2008
CODE -----------------------------------------------------------------
-- Name: ServiceRunning.lua -- Author: Kevin Prestage -- Required INM version: 3.3 -- Version: 1.0 -- Date: 2008-03-21 -- Description: This script will check the -- running state of a service. -- -- Arguments: -- 1) The name of the service to check -- 2) "true" or "false". Use true to check if the service IS running. -- flase will verify that the service is NOT running. ---------------------------------------------------------------------------------------------------------- --Start a timer so we can monitor the performance of this script. Timer = TLuaTimer(); Timer:Start(); result = ""; --this will store our result text b = true; --this is the status of the script. --set the name of the file containing safe processes. sn = GetArgument(0); state = GetArgument(1); foundit = false; --Query WMI for a list of all processes running on the machine. Query = TLuaWMIQuery(); b = Query:Execute("Select * from Win32_Service"); --if the query failed, set the result. if (b == false) then result = "An error occurred querying WMI. " .. Query:GetErrorDescription(); else while (Query:NextInstance()) do --get the process name bOk,exeName = Query:GetProperty("Name",exeName); exeName = string.lower(exeName); --print (exeName); --if the service is a match and it SHOULD be running, set foundit = true if exeName == string.lower(sn) then foundit = true; end end if foundit == true then if state == "true" then b = true; result = "The service is running!"; else b = false; result = "The service is running and it SHOULD NOT BE"; end else if state == "false" then b = true; reuslt = "The service is NOT running"; else b = false; result = "The service is NOT running and it SHOULD BE."; end end end --Store the execution time of the script. mil = Timer:Stop(); StoreStatisticalData(0,mil,0,"Milliseconds"); SetExitStatus(result,b);
14 Dec 2007
If you have ever used replication in SQL Server, you know that sometimes network and/or database problems can cause your replication agents to go into a failed state. You can configure SQL Server to send an email when this happens, but that is about the extent of the alert you will get. Unfortunately, if you miss the alert and your agent stays in a failed state for too long, you have to reinitialize all the subscribers. Not Anymore! The following lua script will go into alarm when any replication agent goes into a failed state. You can then set up an action list to send reminder alerts so that you can correct the problem before a replication reinitialization is required!
CODE -----------------------------------------------------------------
-- Name: SQLReplicationError.lua -- Author: Kevin Prestage -- Required INM version: 3.3 -- Version: 1.0 -- Date: 2007-12-13 -- Description: This script will monitor Distribution, -- Merge, Snapshot and LogReader agents on a -- server and alert you of any problems -- -- Arguments: -- 1) Server Name ----------------------------------------------------------------- function getSQL(s) sql = "select distinct " .. " case when a.runstatus = 1 then 'Start' " .. " when a.runstatus = 2 then 'Succeed' " .. " when a.runstatus = 3 then 'In progress' " .. " when a.runstatus = 4 then 'Idle' " .. " when a.runstatus = 5 then 'Retry' " .. " when a.runstatus = 6 then 'Fail' " .. " else 'Unknown' end as current_status, " .. " a.runstatus, " .. " a.start_time, " .. " a.time, " .. " a.comments, " .. " a.error_id, " .. " x.name, " .. " '" .. s .. "' " .. " from dbo.MS" .. s .. "_history a " .. " join dbo.MS" .. s .. "_history b on b.agent_id = a.agent_id " .. " join dbo.MS" .. s .. "_agents x on x.id = a.agent_id " .. " where a.time = (select max(time) from MS" .. s .. "_history where agent_id = a.agent_id) "; return sql; end servername = GetArgument(0); db = TLuaDB(); con = servername .. "@distribution"; print(con); sql = getSQL("Distribution"); sql = sql .. "union all "; sql = sql .. getSQL("LogReader"); sql = sql .. "union all "; sql = sql .. getSQL("Snapshot"); sql = sql .. "union all "; sql = sql .. getSQL("Merge"); x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER); result = ""; time = ""; status = ""; statuscode = ""; comments = ""; errorid = 0; type = ""; name = ""; if (x == true) then x = db:Execute(sql); if (db:ResultAvilable() == true) then while (db:NextRow() == true) do time = db:GetCol(4); status = db:GetCol(1); statuscode = db:GetCol(2); comments = db:GetCol(5); errorid = db:GetCol(6); name = db:GetCol(7); type = db:GetCol(8); result = result .. name .. "\t" .. type .. "\t" .. status.."\t" .. time .. "\t" .. comments .. "\t" .. errorid .. "\n"; if (status == "Fail") then x = false; end end else x = false; result = "No Agents Found."; end else result = db:GetErrorDescription(); end SetExitStatus(result, x);
28 Nov 2007
Here is a simple script. We are doing some testing with INM and we are making some frequent settings changes. While INM allows us to backup the settings file automatically once a day, week or month, we needed a little more control over this. To handle it, I created this simple script that will copy a file to a specified destination folder and set up a monitor to run this script once an hour. Using the parameters below, it will copy our settings file to the specified folder allowing us to keep a history (the copied file is tagged with the data and time)
QUOTE "d:\\Program Files\\Intellipool Network Monitor" settings.nxd d:\\INMSettingsBackup The first parameter is the directory the file is in (Leave off the trailing \) The second parameter is the name of the file that I want to copy The third parameter is the destination folder I want to put my copies. CODE ----------------------------------------------------------------------------------------------------------
-- Name: BackupFile.lua -- Version: 1.0 -- Date: 2007-11-28 -- Description: Creates a backup copy of a file in the specified folder. Files are tagged with -- the script execution time in YYYYMMDDhhmmss format. -- Arguments: -- 1) Path of file to backup -- 2) Name of file to backup -- 2) Destination Folder to copy to ---------------------------------------------------------------------------------------------------------- backuppath = GetArgument(0); backupfile = GetArgument(1); destination = GetArgument(2); --get the current date d = TLuaDateTime(); --build the path to the file to backup. fn = backuppath .. "\\" .. backupfile; --build the path to the destination file name. fn2 = destination .. "\\" .. backupfile .. "." .. d:GetDate("%Y%m%d") .. "_" .. d:GetTime("%H%M%S"); --copy the file to the destination. file = TLuaFile(); result = file:CopyFile(fn, fn2); if (result == 0) then error = GetLastError(); errdesc = FormatErrorString(error); SetExitStatus(error .. " - " .. errdesc,false); else SetExitStatus("File copied to " .. fn2,true); end
23 Nov 2007
Here is an expanded Backup Exec check that uses the new SQL Server functionality in Lua. The paramters are the name of the SQL Server that the backup exec database is on, and the name of the job you want to track. Please note, this assumes that the account INM is runing under has access to the Backup Exec database. If it does not, you will want to modify this script to use alternate credentials. In addition to alerting of a failed job, this script will also store some valuable statistics (Number of files backed up, duration in minutes, backup rate in MB/Min and total MB backed up). The script assumes an error when the status is anything other than 19 (Success) or 3 (Complete but with Exceptions).
This has only been tested on Backup Exec 11D. Here is the script....enjoy..... CODE -----------------------------------------------------------------
-- Name: BEJobStatus.lua -- Author: Kevin Prestage -- Required INM version: 3.3 -- Version: 1.0 -- Date: 2007-11-22 -- Description: Checks the status of the last occurance of the -- specified Backup exec job. Will go into alarm when the -- status is anything other than 19 (Success) or 3 -- (Complete but with Exceptions). It will also -- store statistics including duration in minutes, size of backup -- set in MB, Backup rate in MB/Minute and the total number of -- files backed up. -- -- Arguments: -- 1) Server Name -- 2) Name of the backup job. ----------------------------------------------------------------- servername = GetArgument(0); jobname = GetArgument(1); db = TLuaDB(); con = servername .. "@BEDB"; print(con); sql = "select top 1 isjobactive, finaljobstatus,actualstarttime, endtime, elapsedtimeseconds,totaldatasizebytes, totalratembmin, totalnumberoffiles, totalnumberofdirectories "; sql = sql .. "from vwJobHistorySummary "; sql = sql .. "where JobName = '" .. jobname .. "' and isjobactive = 0 "; sql = sql .. "order by actualStartTime desc"; x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER); result = ""; minutes = 0; size = 0; rate = 0; files = 0; if (x == true) then x = db:Execute(sql); if (db:ResultAvilable() == true) then db:NextRow(); status = db:GetCol(2); if (status == "19") then result = "SUCCESS"; end if (status == "3") then result = "COMPLETE W/Exceptions"; end if (result == "") then result = "The last execution of this job was not successful."; x = false; else minutes = db:GetCol(5) / 60; size = db:GetCol(6) / 1048576; rate = db:GetCol(7); files = db:GetCol(8); result = result.. " " .. minutes.. " Minutes, " .. size .. " MB, " .. rate .. " MB/Min, " .. files .. " Files Backed Up."; --print (result); StoreStatisticalData(0,minutes,0,"Minutes") StoreStatisticalData(1,size,0,"MB") StoreStatisticalData(2,rate,0,"MB/Min") StoreStatisticalData(3,files,0,"Files") end end else result = db:GetErrorDescription(); end SetExitStatus(result, x); |
Last Visitors
Guest
2 Feb 2010 - 13:59
Comments
Other users have left no comments for kprestage.
Friends
There are no friends to display.
|
|
Lo-Fi Version | Time is now: 8th September 2010 - 07:45 AM |