Monthly Archives: November 2013

intel turbo boost

Intel® Turbo Boost Technology1 provides more performance when needed on 4th generation Intel® Core™ processor-based systems. Intel® Turbo Boost Technology 2.0 automatically allows processor cores to run faster than the base operating frequency if they’re operating below power, current, and temperature specification limits.

Dynamically increasing performance
Intel Turbo Boost Technology 2.0 is activated when the Operating System (OS) requests the highest processor performance state (P0).

The maximum frequency of Intel Turbo Boost Technology 2.0 is dependent on the number of active cores. The amount of time the processor spends in the Intel Turbo Boost Technology 2.0 state depends on the workload and operating environment.

Any of the following can set the upper limit of Intel Turbo Boost Technology 2.0 on a given workload:

Number of active cores
Estimated current consumption
Estimated power consumption
Processor temperature

nginx status plugin for munin

nginx -V 2>&1 | grep -o with-http_stub_status_module
vi /etc/nginx/nginx.conf
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
allow your_IP;
deny all;
}
service nginx reload

vi /etc/munin/plugin-conf.d/nginx_
[nginx*]
env.url http://localhost/nginx_status

cd /etc/munin/plugins/
sudo ln -sf /usr/share/munin/plugins/nginx_* .
service munin-node restart

apache calculate MaxClients count

To get a rough idea of how to set the MaxClients directive, it is best to find out how much memory the largest apache thread is using. Then stop apache, check the free memory and divide that amount by the size of the apache thread found earlier. It usually work only for mod_php mode:

#!/bin/bash
echo “This is intended as a guideline only!”
if [ -e /etc/debian_version ]; then
APACHE=”apache2″
elif [ -e /etc/redhat-release ]; then
APACHE=”httpd”
fi
RSS=$(ps -aylC $APACHE |grep “$APACHE” |awk ‘{print $8’} |sort -n |tail -n 1)
RSS=$(expr $RSS / 1024)
echo “Stopping $APACHE to calculate free memory”
/etc/init.d/$APACHE stop &> /dev/null
MEM=$(free -m |head -n 2 |tail -n 1 |awk ‘{free=($4); print free}’)
echo “Starting $APACHE again”
/etc/init.d/$APACHE start &> /dev/null
echo “MaxClients should be around” $(expr $MEM / $RSS)

limit java memory jboss, tomcat

Java processes can often consume more memory than any other application running on a server.

Java processes can be passed a -Xmx option. This controls the maximum Java memory heap size. It is important to set a limit on the heap size, otherwise the heap will keep increasing until you get out of memory errors on your VPS (resulting in the Java process – or even some other, random, process – dying.

Usually the setting can be found in your /usr/local/jboss/bin/run.conf or /usr/local/tomcat/bin/setenv.sh config files. And your RimuHosting default install should have a reasonable value in there already.

If you are running a custom Java application, check there is a -XmxNNm (where NN is a number of megabytes) option on the Java command line.

The optimal -Xmx setting value will depend on what you are running. And how much memory is available on your server.

From experience we have found that Tomcat often runs well with an -Xmx between 48m and 64m. JBoss will need a -Xmx of at least 96m to 128m. You can set the value higher. However, you should ensure that there is memory available on your server.

To determine how much memory you can spare for Java, try this: stop your Java process; run free -m; subtract the ‘used’ value from the “-/+ cache” row from the total memory allocated to your server and then subtract another ‘just in case’ margin of about 10% of your total server memory. The number you come up with is a rough indicator of the largest -Xmx setting you can use on your ser

vnstat monitor network traffic usage

vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s). It uses the network interface statistics provided by the kernel as information source. This means that vnStat won’t actually be sniffing any traffic and also ensures light use of system resources.

vnstat -m

linux – finding memory leaks

Memory leaks are among the most difficult bugs to detect because they don’t cause any outward problems until you’ve run out of memory and your call to malloc suddenly fails. In fact, when working with a language like C or C++ that doesn’t have garbage collection, almost half your time might be spent handling correctly freeing memory. And even one mistake can be costly if your program runs for long enough and follows that branch of code.

When you run your code, you’ll need to specify the tool you want to use; simply running valgrind will give you the current list. We’ll focus mainly on the memcheck tool for this tutorial as running valgrind with the memcheck tool will allow us to check correct memory usage. With no other arguments, Valgrind presents a summary of calls to free and malloc: (Note that 18490 is the process id on my system; it will differ between runs.)

valgrind –tool=memcheck program_name

If you have a memory leak, then the number of allocs and the number of frees will differ (you can’t use one free to release the memory belonging to more than one alloc). We’ll come back to the error summary later, but for now, notice that some errors might be suppressed — this is because some errors will be from standard library routines rather than your own code.

If the number of allocs differs from the number of frees, you’ll want to rerun your program again with the leak-check option. This will show you all of the calls to malloc/new/etc that don’t have a matching free.

Memcheck provides command line options that can be used to focus the checking process. Some of the options available are:
–leak-check
When enabled, Memcheck searches for memory leaks when the client program finishes. The default value is summary, which outputs the number of leaks found. Other possible values are yes and full, both of which give details of each individual leak, and no, which disables memory leak checking.
–undef-value-errors
When enabled (set to yes), Memcheck reports errors when undefined values are used. When disabled (set to no), undefined value errors are not reported. This is enabled by default. Disabling it speeds up Memcheck slightly.
–ignore-ranges
Allows the user to specify one or more ranges that Memcheck should ignore when checking for addressability. Multiple ranges are delimited by commas, for example, –ignore-ranges=0xPP-0xQQ,0xRR-0xSS.

Server Error in ‘/’ Application. – http://www.lsi.com

The farm is unavailable.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The farm is unavailable.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: The farm is unavailable.]
Microsoft.SharePoint.Administration.Claims.SPSecurityTokenServiceManager.get_Local() +24621004
Microsoft.SharePoint.IdentityModel.SPTokenCache..ctor() +34

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +146
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +298
System.Activator.CreateInstance(Type type, Boolean nonPublic) +79
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +10362891
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
Microsoft.IdentityModel.Configuration.CustomTypeElement.Resolve(CustomTypeElement customTypeElement, Object[] arguments) +908

[ConfigurationErrorsException: ID0012: Failed to create an instance of ‘Microsoft.SharePoint.IdentityModel.SPTokenCache, Microsoft.SharePoint.IdentityModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ from configuration.]
Microsoft.IdentityModel.Configuration.CustomTypeElement.Resolve(CustomTypeElement customTypeElement, Object[] arguments) +1368677
Microsoft.IdentityModel.Configuration.ServiceConfiguration.LoadHandlers(ServiceElement serviceElement) +1160
Microsoft.IdentityModel.Configuration.ServiceConfiguration.LoadConfiguration(ServiceElement element) +843
Microsoft.IdentityModel.Configuration.ServiceConfiguration..ctor() +317
Microsoft.IdentityModel.Web.FederatedAuthentication.get_ServiceConfiguration() +120
Microsoft.IdentityModel.Web.HttpModuleBase.Init(HttpApplication context) +17
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +480
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +336
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +350
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +382

[HttpException (0x80004005): ID0012: Failed to create an instance of ‘Microsoft.SharePoint.IdentityModel.SPTokenCache, Microsoft.SharePoint.IdentityModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ from configuration.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11305670
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4342340

Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

You shouldn’t use Microsoft. 😀

LSI MegaRAID

megactl is the first one is an opensource tool named megactl which can be used to report controller and disks status

megactl
a0 PERC 4/Di chan:2 ldrv:1 batt:good
a0d0 273GiB RAID 5 1×3 optimal
a0c0t0 136GiB a0d0 online
a0c0t1 136GiB a0d0 online
a0c0t2 136GiB a0d0 online

megaraid-status

— Arrays informations —
— ID | Type | Size | Status
a0d0 | RAID 5 | 273GiB | optimal

— Disks informations
— ID | Model | Status | Warnings
a0c0t0 | SEAGATE ST3146807LC 136GiB | online
a0c0t1 | SEAGATE ST3146807LC 136GiB | online
a0c0t2 | SEAGATE ST3146807LC 136GiB | online