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.
Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 22nd April 2006, 15:13
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
Default

It can be that i have done something wrong don't be mad. It was late you know . If there is something wrong post here and i wil solve it.

greets
__________________
2B or not 2B (a pro)
Reply With Quote
  #3  
Old 2nd May 2006, 00:58
chrno chrno is offline
Member
 
Join Date: Apr 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi ColdDoT,

I used your index.php (adopting it to my server settings). But it didn't display the monit at all. Any idea how to debug this?

Thanks

chrno
Reply With Quote
  #4  
Old 2nd May 2006, 10:46
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
Default

Pleaz set to top rule
error_reporting(NULL);
to
error_reporting(E_ALL);

wat error do you get then ?
__________________
2B or not 2B (a pro)
Reply With Quote
  #5  
Old 3rd May 2006, 22:44
chrno chrno is offline
Member
 
Join Date: Apr 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
Warning: fgets(): SSL: fatal protocol error in /var/www/web9/web/index.php on line 37
Reply With Quote
  #6  
Old 3rd May 2006, 23:43
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
Default

Does the monit programma works well if you see it just trough the normal pages?

set
$full_site to your normal addres so you get.
$full_site = www.yoursite.ext;
or if you use it as a other virtual host with a subdomain you must set
$full_site = yoursub.yoursite.ext;

if this still not works then i must rewrite the whole tut and i can do it tommorow
__________________
2B or not 2B (a pro)
Reply With Quote
  #7  
Old 4th May 2006, 11:17
chrno chrno is offline
Member
 
Join Date: Apr 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Emmm ... monit is displaying now but it's still showing that error ...

I've send you a pm for my website URL. Please have a quick peek ... thanks!
Reply With Quote
  #8  
Old 4th May 2006, 11:37
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
 
Default

set back
error_reporting(NULL);


The error can't do any harm
__________________
2B or not 2B (a pro)
Reply With Quote
Reply

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 19:15.


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