Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 18th January 2008, 00:17
goldstift goldstift is offline
Junior Member
 
Join Date: Feb 2007
Location: Hilden, Germany
Posts: 16
Thanks: 3
Thanked 3 Times in 3 Posts
Default Show /var/log/messages in server_stats

Hi there,

I just wrote a little plugin that does a "sudo cat /var/log/messages" and display the result in a tab in server status dialog.

First I had to create the php script in "/home/admispconfig/ispconfig/lib/plugins/check_messagelog.plugin.php":
PHP Code:
<?php
/*
Copyright (c) 2008 Alexander Heusingfeld, http://www.goldstift.de
*/

 #############################################################
 #
 # ISPConfig Plugin
 # Version 1.0
 #
 # Plugin Name: check_messagelog
 # Version:     1.0
 # Datum:       17.01.2008
 #
 #############################################################

 
if(CONFIG_LOADED != 1) die('Direct access not permitted.');

class 
check_messagelog_plugin {

    function 
show ($doc_id$doctype_id$groupid 0)
    {
    global 
$go_info$go_api;


    if(
$go_info["server"]["os"] != "linux"$go_api->errorMessage("Dieses Plugin ist nur für Linux verfügbar.");

        
$buffer '';
// for this to work you need to add the following to "visudo" at [sudoers]
    
$fd popen ("sudo cat /var/log/messages""r");
    if(
$fd == false){ 
        
$buffer 'ERROR: For this to work you need to add the following line to "visudo" at the [sudoers] section 
                admispconfig ALL=(ALL) NOPASSWD: /bin/cat /var/log/messages

        For additional hints on visudo and ispconfig look here: http://www.howtoforge.com/forums/showpost.php?p=102225&postcount=6'
;
    } else {
        while (!
feof($fd)) {
            
$buffer .= fgets($fd4096);
        }
    }
    
pclose($fd);

    
$html_out .= '<div align="center"><table width="90%" border="0" cellspacing="1" cellpadding="4" bgcolor="#CCCCCC">
     <tr>
       <td width="100%" bgcolor="#FFFFFF"><h3>'
.$go_api->lng('var_log_messages').':</h3></td>
     </tr><tr>
       <td width="100%" bgcolor="#FFFFFF"><pre>'
.$buffer.'</pre></td>
     </tr></table></div>'
;

    return 
$html_out;
    }

    function 
insert($doc_id$doctype_id$groupid 0) { return true; }
    function 
update($doc_id$doctype_id$groupid 0) { return true; }
    function 
delete($doc_id$doctype_id$groupid 0) { return true; }
    function 
undelete($doc_id$doctype_id$groupid 0) { return true; }
}
?>

Then I added the new tab to the configuration in the ispconfig mysql database table:
Code:
UPDATE `doctype` SET `doctype_def` = 'O:3:"doc":28:{s:6:"userid";s:1:"1";s:7:"groupid";s:1:"1";s:14:"group_required";s:1:"0";s:5:"modul";s:3:"sys";s:4:"tree";s:1:"0";s:7:"buttons";s:1:"0";s:4:"name";s:12:"serverstatus";s:4:"type";s:9:"text/html";s:13:"template_type";s:4:"file";s:13:"template_path";N;s:12:"storage_type";s:2:"db";s:12:"storage_path";s:16:"isp_serverstatus";s:10:"form_width";s:3:"450";s:4:"deck";a:5:{i:0;O:4:"deck":5:{s:8:"elements";a:2:{i:0;O:11:"pluginField":13:{s:9:"css_class";N;s:7:"options";N;s:4:"name";s:12:"check_uptime";s:4:"type";s:11:"pluginField";s:5:"title";N;s:8:"language";s:2:"de";s:11:"description";N;s:6:"length";i:30;s:7:"visible";i:1;s:8:"required";i:1;s:14:"reg_expression";N;s:10:"reg_fehler";N;s:6:"search";N;}i:1;O:11:"pluginField":13:{s:9:"css_class";s:0:"";s:7:"options";N;s:4:"name";s:10:"check_disk";s:4:"type";s:11:"pluginField";s:5:"title";N;s:8:"language";s:2:"de";s:11:"description";N;s:6:"length";i:30;s:7:"visible";i:1;s:8:"required";i:1;s:14:"reg_expression";N;s:10:"reg_fehler";N;s:6:"search";N;}}s:5:"title";s:6:"Status";s:7:"visible";s:1:"1";s:9:"perm_read";s:1:"r";s:10:"perm_write";s:1:"r";}i:1;O:4:"deck":5:{s:8:"elements";a:1:{i:0;O:11:"pluginField":13:{s:9:"css_class";N;s:7:"options";N;s:4:"name";s:13:"check_meminfo";s:4:"type";s:11:"pluginField";s:5:"title";N;s:8:"language";s:2:"de";s:11:"description";N;s:6:"length";i:30;s:7:"visible";i:1;s:8:"required";i:1;s:14:"reg_expression";N;s:10:"reg_fehler";N;s:6:"search";N;}}s:5:"title";s:15:"Arbeitsspeicher";s:7:"visible";s:1:"1";s:9:"perm_read";s:1:"r";s:10:"perm_write";s:1:"r";}i:2;O:4:"deck":5:{s:8:"elements";a:1:{i:0;O:11:"pluginField":13:{s:9:"css_class";N;s:7:"options";N;s:4:"name";s:13:"check_cpuinfo";s:4:"type";s:11:"pluginField";s:5:"title";N;s:8:"language";s:2:"de";s:11:"description";N;s:6:"length";i:30;s:7:"visible";i:1;s:8:"required";i:1;s:14:"reg_expression";N;s:10:"reg_fehler";N;s:6:"search";N;}}s:5:"title";s:3:"CPU";s:7:"visible";s:1:"1";s:9:"perm_read";s:1:"r";s:10:"perm_write";s:1:"r";}i:3;O:4:"deck":5:{s:8:"elements";a:1:{i:0;O:11:"pluginField":13:{s:9:"css_class";s:0:"";s:7:"options";N;s:4:"name";s:14:"check_services";s:4:"type";s:11:"pluginField";s:5:"title";N;s:8:"language";s:2:"de";s:11:"description";N;s:6:"length";i:30;s:7:"visible";i:1;s:8:"required";i:1;s:14:"reg_expression";N;s:10:"reg_fehler";N;s:6:"search";N;}}s:5:"title";s:7:"Dienste";s:7:"visible";s:1:"1";s:9:"perm_read";s:1:"r";s:10:"perm_write";s:1:"r";}i:4;O:4:"deck":5:{s:8:"elements";a:1:{i:0;O:11:"pluginField":13:{s:9:"css_class";s:0:"";s:7:"options";N;s:4:"name";s:16:"check_messagelog";s:4:"type";s:11:"pluginField";s:5:"title";N;s:8:"language";s:2:"de";s:11:"description";N;s:6:"length";i:30;s:7:"visible";i:1;s:8:"required";i:1;s:14:"reg_expression";N;s:10:"reg_fehler";N;s:6:"search";N;}}s:5:"title";s:10:"MessageLog";s:7:"visible";s:1:"1";s:9:"perm_read";s:1:"r";s:10:"perm_write";s:1:"r";}}s:5:"title";s:17:"ISP Server Status";s:8:"keywords";N;s:11:"description";s:0:"";s:4:"path";N;s:4:"icon";s:10:"status.gif";s:5:"cache";s:1:"0";s:8:"permtype";N;s:7:"version";d:1.100000000000000088817841970012523233890533447265625;s:11:"event_class";s:0:"";s:12:"event_insert";s:0:"";s:12:"event_update";s:0:"";s:12:"event_delete";s:0:"";s:10:"event_show";N;s:11:"wysiwyg_lib";i:0;}' WHERE doctype_id=1021
For this to work I needed to modify the sudo-config. Type "visudo" and add the following at the sudoers section:
Code:
        admispconfig ALL=(ALL) NOPASSWD: /bin/cat /var/log/messages
For additional hints on visudo and ispconfig look here: http://www.howtoforge.com/forums/sho...25&postcount=6

That's it, a preformatted output of your /var/log/messages.
BTW: I afterwards also changed ISPConfig configuration to log to the SYSTEM.

@Falko and Till: is there any easy way to edit the serialized objects in the "doctype" table?? The way I added my new tab was really weird!!!

Greets,
Alex
Reply With Quote
The Following User Says Thank You to goldstift For This Useful Post:
falko (18th January 2008)
Sponsored Links
  #2  
Old 18th January 2008, 19:21
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,722 Times in 2,563 Posts
 
Default

Quote:
Originally Posted by goldstift
@Falko and Till: is there any easy way to edit the serialized objects in the "doctype" table?? The way I added my new tab was really weird!!!

Greets,
Alex
You can use the Form Editor under Management.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
goldstift (18th January 2008)
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto: Make Webalizer show full QueryString!! Zoon Tips/Tricks/Mods 1 5th November 2007 02:12
How to show error line number while using sh somefile.sh andipurwito Programming/Scripts 1 1st November 2007 18:46
Joomla images doesn't show off ! gabrix Server Operation 7 2nd November 2006 18:01
webmail not show emails euricojunior Installation/Configuration 2 11th August 2006 16:20
ISPConfig on OpenSuSE 10.0 Site doesn't show up Hendrikus Postma Installation/Configuration 5 6th February 2006 18:35


All times are GMT +2. The time now is 01:19.


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