postnuke block
jgking at packetstorm.org
jgking at packetstorm.org
Tue Jan 21 14:04:45 CET 2003
Here is one of the blocks. I havent opened up the monitor site cause i
keep trying tofind better ways to implement it. Im currently thinking of
ways to install Perl, NetSNMP, rrdtool, NMIS, snort and other things all
under a single user directory so that everything (perl mods and all) are
seperate from the core linux rpm distros.
-Greg
<?php
// $Id: text.php,v 1.1.1.1 2002/09/15 22:26:15 root Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Greg King
// Purpose of file: Display a Nagios Block for HOst Status
// See www.nagios.org for more information on Nagios
// ----------------------------------------------------------------------
//
/* Installation
The file must be placed in : ../html/includes/blocks/nghs.php
The filename must be named nghs.php or the block will not register in
the admin area properly
Set the permissions accordingly to the uid and gid of the web
owner/group
Set the nagios_url, nagios_user and nagios_password variables
Go to the admin/block section and add the block
Overview
This is a down-and-dirty method to yank the html data produced by
nagios. I would prefer
to read the status log files and generate the data without using the
current mechanism and
that is planned.
I chose this method for the following reasons:
1. It got a sample block up pretty quick so i could see how it would
look
2. Websites do not have to worry about safe mode and opendirectory php
restrictions. All that has to be allowed
is the fopenurl function.
3. I wanted something very lightweight codewise, this block is not
that many lines
Problem I need help with
1. With this block and the other variants the biggest issue is the CSS
stuff from the postnuke data and the Nagios data messing
with each other. If someone finds a way to combine them that would
be great.
*/
$blocks_modules['nghs'] = array(
'func_display' => 'blocks_nghs_block',
'func_update' => 'blocks_nghs_update',
'text_type' => 'nghs',
'text_type_long' => 'NGHS Menu',
'allow_multiple' => false,
'form_content' => false,
'form_refresh' => false,
'show_preview' => true
);
pnSecAddSchema('nghsblock::', 'Block title::');
function blocks_nghs_block($row)
{
$nagios_url =
"yourdom.ain/nagios/cgi-bin/status.cgi?hostgroup=all&style=grid";
$is_htaccess = 'true'; // eventually have a check for this
$nagios_user = "******";
$nagios_password = '*****';
$retval = '';
if(!($nagios_page =
fopen("http://$nagios_user:$nagios_password@$nagios_url/","r")))
{ print("Unable to open $nagios_url"); }
while(!feof($nagios_page))
{
$current_line = (fgets($nagios_page,255));
if(preg_match("/Host Status Totals/",$current_line))
{
$current_line = (fgets($nagios_page,255));$current_line =
(fgets($nagios_page,255));
for($i = 0; $i <= 12; $i++)
{ $retval .= $current_line = (fgets($nagios_page,255)); }
}
}
fclose($nagios_page);
$retval .= "</TABLE>";
$temp = ereg_replace("HREF='","HREF='nagios/cgi-bin/",$retval);
$row['content'] = ereg_replace("ing|able",'',$temp);
return themesideblock($row);
}
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
More information about the Users
mailing list