Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Feature Requests

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 8th May 2009, 17:19
glohmann glohmann is offline
Junior Member
 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default Todo: ISPConfig - Checking of services

The ISPConfig checks the status of the services only on localhost. This way all services running on specific IPs or even running without any IP at all could not be monitored. One example is for shoutcast which uses a connection less datagram protocol. Also some daemons may behave badly on portscans.

Todo:
- call for configured daemons '/etc/init.d/mydeamon status' (and if it really not return a status number as it should parse the output via a RegEx)
or maybe
- use a check for the daemon lock file (/var/lock/subsys/mydaemon.lock)
or use
- or maybe check the pid file (/var/run/mydaemon.pid) with checkproc

[checkproc can be found in killproc.rpm (PLD) or sysvinit.rpm (Suse)]

Remark: maybe it is a Feature Request but one can even think about it as a Bug ... so feel free to move it to the good forum if needed

Last edited by glohmann; 8th May 2009 at 17:23. Reason: (add Remark)
Reply With Quote
Sponsored Links
  #2  
Old 8th May 2009, 17:58
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 34,572
Thanks: 792
Thanked 4,980 Times in 3,901 Posts
Default

The monitor works as intended, so thats definately not a bug. if you configure your system differently so that it does not comply with a default installation of ispconfig and you then need a different monitoring, feel free to post a feture request or write your own monitoring plugin.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 8th May 2009, 19:17
glohmann glohmann is offline
Junior Member
 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

There are already several core functions in monitor_core_module.inc.php to check if a service is up and running ... following I will try to provide additional methods:

--- monitor_core_module.inc.php 2009-05-08 18:21:22.000000000 +0200
+++ monitor_core_module.inc.php 2009-05-08 19:09:10.000000000 +0200
@@ -1290,6 +1290,21 @@ class monitor_core_module {
}
}

+ /**
+ * check if the named daemon is up and running
+ * daemon: name of daemon
+ */
+ function _checkDaemon ($daemon) {
+
+ $out = @exec("/etc/init.d/$daemon status", $outarr, $retval);
+ if ($retval == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
function _checkFtp ($host,$port){

$conn_id = @ftp_connect($host, $port);


badly I not found a good integrated functionality in PHP itself to look for running services (well there is only a 'win32_query_service_status') ... I guess I have to provide some PECL package here to fill that gap ... as I would prefer to not use functions like 'exec' if I can avoid them in any way ...
Reply With Quote
  #4  
Old 8th May 2009, 21:53
glohmann glohmann is offline
Junior Member
 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok here is another approach looking for the lock and pid file:

<?php

$ret = _checkDaemon2("/var/lock/subsys/httpd", "/var/run/httpd.pid");
printf("\n check on daemon returned '%s' \n\n", (($ret==true)?"true":"false") );

/**
* check if the named daemon is up and running
* daemon_lock: path of daemon lock file (see /var/lock/subsys/)
* daemon_pid : path of daemon pid file (see /var/run/)
*/
function _checkDaemon2 ($daemon_lock, $daemon_pid) {
$retval = file_exists($daemon_lock);
if ($retval == true) {
// subsystem is locked, but maybe daemon crashed, check pid is alive
$pid = file_get_contents($daemon_pid, 0, null, -1, 20); // it is unlikely a pid is longer then 20 characters
if($pid != false) {
$pid = intval($pid); // as we call 'exec' we want to be sure this is an integer!
// we found a pid file, now chek if process is alive
exec("ps -p $pid", $retarr, $retval);
if(count($retarr)>1) {
// we have at least two lines looking like so daemon is alive
// [0] => PID TTY TIME CMD
// [1] => 15375 ? 00:00:01 httpd
return true;
}
}
}
return false;
}

?>


We again use exec but this time the only modifiable parameter is the pid which we check before is an integer so no chance to exploit that. All other methods only doing reading attempts to the file system.
Reply With Quote
  #5  
Old 8th May 2009, 23:21
glohmann glohmann is offline
Junior Member
 
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
 
Default

pros:
- you not flood you log file with million of lines like:
May 8 22:55:01 neptun imapd: Connection, ip=[::ffff:127.0.0.1]
May 8 22:55:01 neptun imapd: Disconnected, ip=[::ffff:127.0.0.1], time=0
May 8 23:00:02 neptun pop3d: Connection, ip=[::ffff:127.0.0.1]
May 8 23:00:02 neptun pop3d: Disconnected, ip=[::ffff:127.0.0.1]
- You can be sure your daemon is running even if he serve a different port
- it is fast (e.g. no need to wait for timeouts)
- you can use it even for daemons not serving on a ip/port (e.g. amavisd)

cons:
- you may see a specific daemon running but still not know if one can connect
- some daemons serve several protocols (pop3, po3-ssl, ...) but you only know if the daemon itself is up

well ... maybe we could add both ... having the default 5 min polling just if the daemon itself is running ... and in the monitor GUI an additional button to check if specific services could be connected or not ... and if it fails then directly return a meaningfull error message if possible.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Installation -- pcre_exec.c:403: internal compiler error: Segmentation fault zerman Installation/Configuration 2 23rd September 2008 23:58
ERROR: Could not configure PHP -- Ubuntu 6.06 djoseph74 Installation/Configuration 11 10th February 2008 05:48
ERROR: The PHP binary coming with ISPConfig does not work properly on your system! micko_escalade Installation/Configuration 35 30th March 2007 11:31
Network questions regarding Ubuntu Server lubod Installation/Configuration 7 3rd January 2007 18:53
ISP-Server Setup - Ubuntu 5.10 "Breezy Badger" Problem with ISPConfig chipw Installation/Configuration 6 30th October 2006 09:38


All times are GMT +2. The time now is 16:42.


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