Thursday, March 26, 2009

APC UPS Monitoring using SNMP

I just finished configuring IPSentry to monitor our APC UPS (via SNMP).

Currently, IPSentry will send email alerts to us when the UPS batteries need replacing, etc. But if the main power is out and the battery run time remaining is under certain threshold, it will send us alerts to our cell phones instead. We also tested using it to call a script which automate the shutdown of our servers and it works. We may decide to implement it eventually, but I feel we need more observations to verify the reliability of the monitoring before doing so (since that script is so powerful and any false alarm can cause our entire shop to be shutdown).

Anyway, here are the OIDs we are now monitoring:

OIDDescription
Date Type
.1.3.6.1.4.1.318.1.1.1.2.1.2
The elapsed time since the UPS has switched to battery power.timeticks
n mins = n*6000 timeticks
.1.3.6.1.4.1.318.1.1.1.2.2.1The remaining battery capacity expressed in percent of full capacity.gauge
.1.3.6.1.4.1.318.1.1.1.2.2.2The current internal UPS temperature expressed in Celsius.gauge
.1.3.6.1.4.1.318.1.1.1.2.2.3
The UPS battery run time remaining before battery exhaustion.
timeticks
n mins = n*6000 timeticks
.1.3.6.1.4.1.318.1.1.1.2.2.4
Indicates whether the UPS batteries need replacing.
integer
noBatteryNeedsReplacing (1)
batteryNeedsReplacing (2)


Tuesday, March 24, 2009

More eLearning User Penetration Numbers

In December 2007, I wrote a script to determine the user penetration rate of eLearning, our online Learning Management System (powered by Blackboard Learning System CE6). We have subsequently upgraded the system to CE8 with all the latest service packs. Fortunately, the script continues to work.

Here are the numbers for the main Pullman campus:

Semester Undergraduate Students Graduate Students Undergraduate + Graduate Students
Total LMS % Total LMS % Total LMS
%
2007 Fall 15441 12862 83.30 1981 749 37.81 17422 13611 78.13
2008 Spring 14383 12079 83.98 1874 747 39.86 16257 12826 78.90
2008 Fall 15571 14521 93.26 1998 1165 58.31 17569 15686 89.28
2009 Spring 14650 12968 88.52 1939 936 48.27 16589 13904 83.81

Friday, March 13, 2009

Using rsync on Windows

I posted an article on an issue of SQL Memory Paged Out During Large File Copy last month, which documented my effort in finding a way to solve the issue. Yes, rsync (from Cygwin) is still our final choice.

Today I'm going to post some tips on using rsync on Windows.

To install rsync, run the Cygwin setup.exe installer and install rsync package. After that, I would recommend adding Cygwin's bin folder into your environment path. This way, you can call rsync directly from the command line.
  • Right click on My Computer. Choose Properties.
  • Click on Advanced tab.
  • Click on Environment Variables button. (The Environment Variables window will be opened)
  • Under System variables, highlight Path. Click Edit.
  • At the end of the Variable value, append ;c:\cygwin\bin (or wherever your installation path is. Don't forget the semi-colon in front).
  • Click OK | OK | OK to finish.
Now you can use rsync to copy file in the command window, like the followings:
rsync.exe \\fromserver\share\filename d:\backupfolder\filename
But there is another issue. The destination file (copied via rsync) is owned by the user account running rsync. One may prefer to have the file permissions inherited from the parent folder instead. To fix that, I use the setacl utility from SourceForge.

The following commands first change the file ownership to local Administrators group of the backup server, clear the discretionary and security access control lists (DACL, SACL) of the file, and finally set the ACLs to be inherited from the parent folder.
setacl.exe -on filename -ot file -actn setowner -ownr "n:backupserver\Administrators;s:n"
setacl.exe -on filename -ot file -actn clear -clr dacl,sacl
setacl.exe -on filename -ot file -actn setprot -op "dacl:np;sacl:np"
Put them all into a batch file, and you have a simple script to perform nightly backup using rsync.

Friday, February 20, 2009

Web Slides on Harvesting Grade Book

Diigo has a feature where you can create a "List" of bookmarks. Inside the list, you can order the bookmarks in any sequence you want, and create a slide show from it.

I just created a series called The Evolution of Harvesting Grade Book. It tells the story behind some of the transformative assessment projects our department has been working on - visualized through what is currently called the "Harvesting Grade Book".

Friday, February 13, 2009

SQL Memory Paged Out During Large File Copy

We currently use SQL server maintenance plan to generate full database backup files (nightly or weekly, depending on the application), differential and transaction log backup files throughout the day. We then run a script to robocopy (from Windows Server 2003 Resource Kit Tools) the generated backup files offsite.

Ever since we migrated our databases from SQL server 32-bit to 64-bit, we started encountering a problem where SQL server process memory was being paged out. As a result, our applications became momentarily unresponsive and unavailable to our customers. This happened consistently around the same time every night, which coincided with the time when the offsite copying of SQL database full backup files was running. Error message in the SQL server log was:
A significant part of sql server process memory has been paged out. This may result in a performance degradation. Duration: 0 seconds. Working set (KB): xxxxxx, committed (KB): xxxxxx, memory utilization: xx%.
According to this Microsoft Article: How to reduce paging of buffer pool memory in the 64-bit version of SQL Server 2005, only SQL Server 2005 Enterprise Edition can use the Lock pages in memory to reduce paging. We are running SQL Server 2005 Standard Edition. We may need to upgrade/ migrate to Enterprise Edition. This means additional costs of licensing and migration to consider.

In the mean time, our applications are failing momentarily every night. I need to come up with a better approach now.

Our requirements are pretty simple (listed in the order of importance):
  • No paging of SQL server memory.
  • Can be automated via GUI, or script.
  • Still maintain a copy of database backup files locally. (This is preferable because in the event of a problem that requires a full database restore, the process would be much faster)
  • Fast.
Is that too much to ask for?

Google helped me locate this article Technet's Ask the Performance Team Blog: Slow Large File Copy Issue. It has a pretty good explanation of what is going on (the use of buffered I/O) during the copy process which leads to the paging problem we encountered.

I followed the recommendation in the article and tested using eseutil to perform offsite copying of our database backup files. Unfortunately, it did not work as expected. SQL server process memory was still being paged out.

I continued to investigate options. Here is a list of what I have looked into:
  • cat (from Cygwin)
  • split to remote share and cat to combine (from Cygwin)
  • split locally, copy to remote share, and cat to combine (from Cygwin)
  • rsync (from Cygwin)
  • Symantec Backup Exec backup agent
  • Symantec Backup Exec SQL backup agent
  • Windows NTBackup
  • SQL backup to remote share
  • SQL backup using MIRROR TO clause (Eliminated since it is available in SQL Server 2005 Enterpise Edition only)
  • SQL database mirroring and backup from mirrored databases (Eliminated since backup option is not available in the read-only mirrored databases)
  • SQL backup to a file server cluster volume. After database backup files are generated, failover to the other file server node for the offsite backup to run against (Not recommended due to additional complexity. We may better off migrate to SQL Server 2005 Enterprise Edition)
After some testings, the winner (or the best compromise) is rsync.

We continue to use SQL server maintenance plan to generate all database backup files. The files are kept locally on the SQL server. We then run a script to rsync the files offsite. It never pages out our SQL server process memory. It still takes a long time to run, but compare to other approaches, this is the fastest one.

Our largest database is the webctdatabase of our Blackboard LMS. It is now about 400GB, and it takes about 15 hours for rsync to copy it offsite.

Wednesday, February 11, 2009

SQL Injection Exploit... of a Mom



It's brilliant.

SQL Script to Generate a List of Sections (& Instructors) from Blackboard Learning System CE8

We need to generate a list of all courses/ sections hosted in our Learning Management System (powered by Blackboard Learning System CE8, formerly known as WebCT).

In Blackboard's terminology, all courses and sections are learning contexts. They are hierarchical and their parent-child relationships along with other information are stored in the database. So, the challenge here is to figure out how to write a recursive query.

With a little help from an msdn article: Recursive Queries Using Common Table Expressions, I figured out how to do that today.

The following SQL query will generate a list of all sections ordered by the course names, and the by section names:
with temp1 (parent_learning_context_id, learning_context_id, name, level)
as
(
select parent_learning_context_id, learning_context_id,
name, 0 as level from rpt_learning_context
where parent_learning_context_id IS NULL
union all
select LC.parent_learning_context_id,
LC.learning_context_id, LC.name, level + 1
from rpt_learning_context as LC
inner join temp1 as T
on LC.parent_learning_context_id = T.learning_context_id
)
select T.parent_learning_context_id, LC.name,
T.learning_context_id, T.name from temp1 as T
inner join learning_context as LC
on T.parent_learning_context_id = LC.id
where T.level = 4
order by LC.name, T.name
With a little twist, I can easily modify it to generate a list of all instructors teaching this Spring semester:
with temp1 (parent_learning_context_id, learning_context_id, name, level)
as
(
select parent_learning_context_id, learning_context_id,
name, 0 as level from rpt_learning_context
where parent_learning_context_id IS NULL
union all
select LC.parent_learning_context_id,
LC.learning_context_id, LC.name, level + 1
from rpt_learning_context as LC
inner join temp1 as T
on LC.parent_learning_context_id = T.learning_context_id
)
select LC.name, T.name, P.webct_id_lowercase,
P.name_n_given, P.name_n_family, P.email from temp1 as T
inner join learning_context as LC
on T.parent_learning_context_id = LC.id
inner join rpt_member as M
on M.learning_context_id = T.learning_context_id
inner join person as P
on M.person_id = p.id
where T.level = 4
and LC.name like '%2009_spring%'
and M.role='SINS'
and M.active = '1'
and M.denied_access = '0'
order by T.name
SQL queries - I'm loving it.