ISPMan GUI performance
Wim Kerkhoff <[email protected]>
| Newsgroups | gmane.comp.isp.ispman.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi All, Attached is a small clients.cgi I've just put together. It entirely mimics the Client List in ISPMan. The major difference is that it *only* uses the OpenLDAP::Conn perl module. Run time of ldapsearch -x "(&(objectClass=ispmanClient))": 0.756 seconds Run time according to timed wget from https://ispman/ispman/admin/clients.cgi: 0.750 seconds. Run time (according to my system clock) of standard ISPMan showClients page: 12+ seconds. This indicates that OpenLDAP::Conn has essentially no overhead on top of the C LDAP libraries.... just a thin Perl layer providing an easy to use OO API via XS. Additionally, ISPMan somehow has a ton of extra modules and code/overhead running, even for simple forms and reports like the one above. Could these be conditionally loaded, or somehow optimized away? From looking through the code, I think it would take a lot of work to retrofit ISPMan to use OpenLDAP::Conn. But perhaps somebody has a quicker way of switching to it that doesn't require updating every single library and template? Wim
clients.cgi
(text/plain, 2 KB)
#!/usr/bin/perl -w
#
# Author: Wim Kerkhoff <wim AT nyetwork.org>
# Date: August 26, 2005
#
use strict;
$|++;
use OpenLDAP::Conn;
my $base = "o=ispman";
my $host = "ldap";
my $port = 389;
my $bind_dn = "cn=Directory Administrator, o=ispman";
my $pass = "supersecretpassword";
my $conn = new OpenLDAP::Conn($host, $port, $bind_dn, $pass)
|| die "Couldn't connect: $!";
my %resellers = &getResellerList();
&showClients;
$conn->close();
exit;
#########################3
sub showClients {
my $entry = $conn->search ($base, "subtree", "(&(objectclass=ispmanClient))");
print <<END_HEADER;
Content-Type: text/html
<html>
<head>
<title>ISP Manager - Client List</title>
<LINK HREF="/ispman/ispman.css" REL="stylesheet" TYPE="text/css">
</head>
<body>
<FONT FACE="Helvetica, Arial" size=2>
<font class=pageTitle>Summary of Clients</font>
<br>
<a href="/ispman/admin/index.cgi?mode=formAddClient">Add a new Client</a>
<body>
<table>
<tr>
<th>UID (Client id)</th>
<th>Reseller</th>
<th>Display Name</th>
<th># Domains</th>
</tr>
END_HEADER
while ($entry) {
my $ispmanClientId = $entry->{ispmanClientId}[0];
my $ispmanClientUID = $entry->{uid}[0];
my $ispmanClientName = $entry->{ispmanClientName}[0];
my $ispmanResellerId = $entry->{ispmanResellerId}[0];
my $ispmanClientMaxDomains = $entry->{ispmanClientMaxDomains}[0];
my $ResellerName = $resellers{$ispmanResellerId};
my $DN = $entry->getDN();
print <<END_ROW;
<tr>
<!-- $DN -->
<td>$ispmanClientUID ($ispmanClientId)</td>
<td>$ResellerName($ispmanResellerId)</td>
<td>$ispmanClientName</td>
<td>$ispmanClientMaxDomains</td>
</tr>
END_ROW
$entry = $conn->nextEntry();
}
print qq(</table>\n</body></html>\n);
}
sub getResellerList {
my %list;
my $entry = $conn->search($base, "subtree", "(&(objectClass=ispmanReseller))");
while ($entry) {
my $id = $entry->{ispmanResellerId}[0];
my $name = $entry->{cn}[0];
$list{$id} = $name;
$entry = $conn->nextEntry();
}
return %list;
}