m d3velopment a technical, development and security blog

15Nov/110

How to Clear the Linux Memory Cache

Clearning the Linux Memory cache can be a quick way to regain system resources. Writing to the drop_cache process will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

  • To free pagecache:# echo 1 > /proc/sys/vm/drop_caches
  • To free dentries and inodes:# echo 2 > /proc/sys/vm/drop_caches
  • To free pagecache, dentries and inodes:# echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.

Example - Memory before:

[root@server ~]# free -m
total       used       free     shared    buffers     cached
Mem:          7860       7040        820          0        343       5076
-/+ buffers/cache:       1620       6240
Swap:         3999          0       3999

[root@server ~]# sync
[root@server ~]# echo 3 > /proc/sys/vm/drop_caches

Memory after:

[root@server ~]# free -m
total       used       free     shared    buffers     cached
Mem:          7860       1279       6581          0          0         33
-/+ buffers/cache:       1245       6615
Swap:         3999          0       3999

Filed under: Development, Linux No Comments
9Nov/110

Active Directory Health Check

Weekly or bi-weekly Active Directory Health Checks are an important part of a Microsoft SysAdmin's responsibility. Busy or inexperienced SysAdmin's often overlook some of the important Health Check steps or don't do them at all. Taking the time to routinely review and assess your Microsoft Active Directory is the difference between a proactive SysAdmin and a reactive SysAdmin.

First of all, monitoring the Windows Event Viewer is a must. Take the time to check through all of the Event Log queues including the Application, Security and System log. On Domain Controllers the DFS Replication, Directory Service and DNS Server logs should also be reviewed. Leverage the sort and error fields to filter out the information you don't need to see.

Next, run command line diagnostics and pipe the results to a text document for in-depth review. This allows you to analyze the results in detail and compare results after you've fixed any issues you identify. Its also much easier to read the logs in a NotePad++ window and search for events then trying to dig through command line output.

The following reports can be ran from the Windows command prompt:

DC Diag

This report will identify issues with domain controllers and any services associated with them:

C:\>dcdiag.exe /v >> c:\pre_dcdiag.txt

7Nov/110

Import an OpenSSL CSR into Windows CA server

To import a Certificate Signing Request (CSR) into a Windows Certificate Authority Server, you must define a certificate template.  OpenSSL does not do this because this is a Microsoft only concept.  With the use of the Windows 'certreq' command, you can apply a template type during the request import process.  This command should be available on your Microsoft CA server.

C:\>certreq -submit -attrib "CertificateTemplate:WebServer" request.csr

An alternative method for importing CSR's to Microsoft CA can be found here.

7Nov/110

Plesk Qmail Error 5.4.6

I recently ran into a strange problem with Plesk 9.3 and Qmail. After completing the install of a new Plesk server I initiated migrations of production sites to it. Post migration the sites and email functioned normally for around 22 hours until suddenly all inbound email to the server bounced with the following error:

Nov 6 05:50:29 vh1 qmail-[27612]: Handlers Filter before-remote for qmail started ...
Nov 6 05:50:29 vh1 qmail-[27612]: from=m@me.com
Nov 6 05:50:29 vh1 qmail-[27612]: to=add2@domain.com
Nov 6 05:50:29 vh1 qmail-[27612]: hook_dir = '/usr/local/psa/handlers/before-remote'
Nov 6 05:50:29 vh1 qmail-[27612]: recipient[3] = 'add2@domain.com'
Nov 6 05:50:29 vh1 qmail-[27612]: handlers dir = '/usr/local/psa/handlers/before-remote/recipient/paul@tap10.com'
Nov 6 05:50:29 vh1 qmail: 1320533429.707838 delivery 233: failure: Sorry._Although_I'm_listed_as_a_best preference_MX_or_A_for_that_host,/it_isn't_in_my_control/locals_file,_so_I_don't_treat_it_as_local._(#5.4.6)/

The problem could be resolved by simply restarting Qmail but then the issue re-occured 22 hours later, immediately after nightly backups.

Parallels notes a fix for the problem at: http://kb.parallels.com/en/1380 but after running /usr/local/psa/admin/sbin/mchk then waiting 22 hours, the problem re-occurred.

21Oct/110

Cisco IOS Diagnostic Tools

There are certain a number of diagnostic tools that can be used to troubleshoot and monitor the different elements of a network. This article takes a look at a number of the built-in tools/command that exists within Cisco IOS. Any experienced IOS engineer knows that many issues can be diagnosed using only the tools that exist within the IOS itself; the target audience of this article includes engineers with less experience looking to become more familiar with the available tools and those preparing for the CCNP TSHOOT exam.

Show Processes CPU

One of the most basic commands to run on a Cisco device is show processes cpu. In its full view the command will show all of the active processes on a device and how much of the processor time the process is taking both currently and historically. Figure 1 below shows a shortened version of the command:

Cisco IOS Show Processes CPU

This command would typically be used when troubleshooting a problem with a device that is having trouble performing basic functions; for example if a router is having trouble forwarding and routing pa