User Monitors Can Cause NetScaler ADC Sluggishness and Performance Degradation
book
Article ID: CTX239816
calendar_today
Updated On:
Description
The NetScaler GUI and CLI are sluggish, unresponsive, and virtually unusable on the Primary node. Further in ns.log, you will see logs similar to below:
Nov 30 01:02:00 <kern.crit> ns1 kernel: maxproc limit exceeded by uid 65532 (perl), please see tuning(7) and login.conf(5).
Nov 30 01:02:01 <kern.crit> ns1 kernel: maxproc limit exceeded by uid 65532 (nsumond), please see tuning(7) and login.conf(5).
Environment
The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.
Resolution
Do not use CURL or spawn any process from within the Perl script. Instead use Perl's built-in capabilities to query a server or accomplish what you need. Here is an example for a Server SOAP Request:
#!/usr/local/bin/perl
use strict;
use Netscaler::KAS;
use LWP::UserAgent;
use HTTP::Request;
sub myprobe
{
my $responsestring = "Windows";
my $host = $_[0];
my $port = $_[1];
my $message = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://YoursoapURL\">
<soapenv:Header/> <soapenv:Body/>
</soapenv:Envelope>";
my $userAgent = LWP::UserAgent->new();
my $request = HTTP::Request->new(POST => "http://$host:$port/");
$request->header(SOAPAction => "http://YourSOAPActionURL/and/path");
$request->content($message);
$request->content_type("text/xml; charset=utf-8");
my $response = $userAgent->request($request);
if($response->code == 200)
{
if(index($response->as_string, $responsestring) != -1)
{
return 0;
}
}
return 1;
}
probe(\&myprobe);
Problem Cause
This issue is caused by a Fork Bomb. In this example, it's due to the use of CURL in a User Monitor Perl script. The NetScaler nsumond process executes the Perl script, which executes CURL, and this repeats every time the monitor is triggered, hitting the system's MaxProc limit.
Here is an example of code that can cause this Fork Bomb to occur:
#!/usr/local/bin/perl
use strict;
use Netscaler::KAS;
sub myprobe
{
my $host = $_[0];
my $port = $_[1];
my $curl = `curl http://$host:$port/`;
if ($curl =~ "Windows")
{
return 0;
}
return 1;
}
probe(\&myprobe);
Was this article helpful?
thumb_up
Yes
thumb_down
No