#!/usr/bin/perl -w ############################################################################### # HCCServerinfo.pm - A custom API module for CPanel # Version 0.1.2 beta - 11/MAY/2005 # (c) 2003, 2005 Juan R. Pozo # http://html.conclase.net/cp/scripts/ # mailto:jrpozo@conclase.net # Mailing-list: http://www.conclase.net/mailman/listinfo/cpanel_conclase.net ############################################################################### # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### # For INSTALLATION and DOCUMENTATION please see: # http://html.conclase.net/cp/scripts/HCCServerinfo.txt (plain text), or # http://html.conclase.net/cp/scripts/HCCServerinfo.pdf (Acrobat) ############################################################################### # Please consider making a donation today. Visit my amazon.com wishlist at: # http://html.conclase.net/link/wishlist # Thank you :) ############################################################################### package Cpanel::HCCServerinfo; use strict; use vars qw(@ISA @EXPORT $VERSION $prefix); require Exporter; @ISA = qw(Exporter); @EXPORT = qw( HCCServerinfo_init HCCServerinfo_status ); $VERSION = '0.1.2'; $prefix = "HCCServerinfo"; Cpanel::Lang::loadlang($Cpanel::CPDATA{LANG}); require 5.004; sub HCCServerinfo_init { return(1); } sub HCCServerinfo_status { # Available options are: services, memory, swap, load, partitions my @options = @_; my $up; foreach (@options) { if (/^\s*['"]?\s*services\s*['"]?\s*$/i) { my ($message, $icon, $status); opendir(SRV, "/var/run/chkservd") or die($!); my @srvs = grep { -f "/var/run/chkservd/$_" } readdir(SRV); closedir(DIR); foreach my $srv (sort @srvs) { open(SRV, "; close(SRV); if (defined($up) && $up) { $message = "ServiceUp"; $icon = "ServiceUpIcon"; $status = "StatusOK"; } else { $message = "ServiceDown"; $icon = "ServiceDownIcon"; $status = "StatusAlert"; } print "