Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 22nd April 2006, 15:07
ColdDoT ColdDoT is offline
Senior Member
 
Join Date: Jan 2006
Location: Netherland
Posts: 178
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ColdDoT
Smile Extension for the monit and munin programs(tut from falko)

hello
http://www.howtoforge.com/server_monitoring_monit_munin

i like the programs it is easy to set up and nicly to see but i don't liked it to have 2 diffrent pages and even 1 with a other port. So i tought maybe i can do something cool with it.

here a SS from my output now
login:


Overview


requirements
webserver with php
followed the tut form falko you can find it here http://www.howtoforge.com/server_monitoring_monit_munin
monit with ssl installed


here is the thing i have done (maybe you can call it tut but i don't know)
first follow the nice tut from falko
----------------------------------------------------------
if you have virtual host you can do this(is not skip this section)
----------------------------------------------------------
edit munin config file
vi /etc/munin/munin.conf
set the htmldir to
htmldir /var/www/stats/monitoring
then if you have apache with virutal host set this in the httpd.conf file
if you don't know where it is locate httpd.conf
vi httpd.conf
add this below NameVirtualHost *:80
Code:
<VirtualHost *:80>
  ServerName stats.example.com:80
  ServerAdmin webmaster@example.com
  ServerAlias stats.example.com *.stats.example.com
  DocumentRoot "/var/www/stats"
</VirtualHost>
vi /var/www/stats/.htaccess
Code:
AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/stats/.htpasswd
<limit GET PUT POST>
require valid-user
</limit>
htpasswd -c /var/www/stats.htpasswd admin
if you have compiled apache from source first locate htpasswd
----------------------------------------------------------
other wise you can do this
----------------------------------------------------------
example your site is
www.example.com
make a map called stats.
edit munin config file
vi /etc/munin/munin.conf
set the htmldir to
htmldir /var/www/www.example.com/stats/monitoring

vi /var/www/www.example.com/stats/.htaccess
Code:
AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/www.example.com/stats/.htpasswd
<limit GET PUT POST>
require valid-user
</limit>
htpasswd -c /var/www/www.example.com/stats/.htpasswd admin
if you have compiled apache from source first locate htpasswd
----------------------------------------------------------

now you can add my custom build php script in the stats map.
index.php
Code:
<?
error_reporting(NULL);
$monit_port = "2812";
$monit_user = "admin";
$monit_pass = "test";
$server_addres = "www.example.com";
$full_site = "stats.example.com"; //or if no virtual host "www.example.com/stats/"
$site_name = "Example";
$site = file_get_contents("monitoring/index.html");
$site = str_replace("href=\"","href=\"monitoring/",$site);
$site = str_replace("src=\"","src=\"monitoring",$site);
//Copy right remover
//$site = preg_replace('#<i class="small">(.*?)</i>#',"",$site);
//$site = preg_replace('#<table cellpadding="2" cellspacing="4" border="0">(.*?)</table>#',"",$site);
$site = str_replace("server1.example.com</a>",$full_site."</a>",$site);
$site = str_replace("example.com</a>",$site_name."</a>",$site);
$site = str_replace('<td><div class="logo">&nbsp;</div></td>',"",$site);
$site = str_replace('<h1>Overview</h1>',"<span style=\"font-size: 32px;\">Overview</span><br><br>",$site);
$site = str_replace("<title>Munin :: overview</title>","<title>ColdDoT 1u Server Monitor</title>",$site);

echo $site;
$fp = fsockopen("ssl://".$full_site, $monit_port, $errno, $errstr);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {
   $out = "GET / HTTP/1.1\r\n";
   $out .= "Host: ".$full_site."\r\n";
   $out .= "Authorization: Basic ".base64_encode($monit_user.":".$monit_pass)."\r\n";
   $out .= "Connection: Close\r\n\r\n";

   fwrite($fp, $out);
   while (!feof($fp)) {
       $site2 .= fgets($fp, 128);
   }
   fclose($fp);
}
$site2 = preg_replace("#href='(.*?)'#","href='https://".$server_addres.":".$monit_port."$1'",$site2);
$site2 = preg_replace("#src=\"(.*?)\"#","src=\"https://".$server_addres.":".$monit_port."$1\"",$site2);
$site2 = preg_replace("#HTTP(.*?)<p>&nbsp;</p>#se","",$site2);
//Copy right remover
//$site2 = preg_replace('#<p>&nbsp;</p><p>&nbsp;</p><p><br></p><div align="center">(.*?)</div>#',"<small><center><br><br>Copyright 2000-2006 by ".$site_name."</center></small>",$site2);
echo $site2;
?>
Attached Images
  
__________________
2B or not 2B (a pro)

Last edited by ColdDoT; 22nd April 2006 at 19:22.
Reply With Quote
Sponsored Links
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:44.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.