Script for monitoring

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Script for monitoring

Post by Ptitzizi » 09 Jul 2008 13:41

Hi every one,

I'm working on a monitoring script based on differents scripts but I'd like something I didn't find yet.
I'd like display is Xaseco is running or not like :
Xaseco : ON
or
Xaseco : OFF
The thing is I don't really know how to do, are there a function for detect that ?

Thanks in advance :)

I hope my English is enough good for your understanding :D

Cya !

expressman
happy cruiser
happy cruiser
Posts: 152
Joined: 26 Aug 2006 07:51

Re: Script for monitoring

Post by expressman » 10 Jul 2008 01:26

in php there is the fsockopen function

http://www.php.net/manual/en/function.fsockopen.php

Code: Select all

<?php
$port = "5000"; //your aseco port
$ip = "127.0.0.1"; //your ip or domain
if ($socket = @fsockopen($ip, $port, $nm, $err, 10))
{
// aseco up
fclose($socket);
}
else
{
// aseco down
}
?>

User avatar
Phhere
sunday driver
sunday driver
Posts: 65
Joined: 16 Oct 2006 21:01
Owned TM-games: TMS, TMU
Contact:

Re: Script for monitoring

Post by Phhere » 10 Jul 2008 08:54

The script by expressman only shows whether the server is online and allows remote control or is offline.
*Sorry for my english*
webSPELL Development
Image

Xymph
Pit Crew
Pit Crew
Posts: 5705
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: Script for monitoring

Post by Xymph » 10 Jul 2008 10:06

With that code you're testing whether the dedicated server is running, not XAseco.

I was going to point you to my init.d scripts but discovered they didn't actually allow obtaining the XAseco (nor dedicated server) status, so I had to fix them first. Check out the new versions now, the status results are:

Code: Select all

$ /etc/init.d/asecof status
aseco.php TMF (pid 977) is running...
or when the system isn't running:

Code: Select all

$ /etc/init.d/asecof status
asecof is stopped
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: Script for monitoring

Post by Ptitzizi » 10 Jul 2008 12:29

Thanks for you answers but, sorry, I'm not very good, so I don't understand if your script is for a web monitoring like tmos viewer or for a monitoring server.
I have to use your start scripts for display on a web page if Xaseco is running or not ?

Xymph
Pit Crew
Pit Crew
Posts: 5705
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: Script for monitoring

Post by Xymph » 10 Jul 2008 14:48

Ptitzizi wrote:Thanks for you answers but, sorry, I'm not very good, so I don't understand if your script is for a web monitoring like tmos viewer or for a monitoring server.
I have to use your start scripts for display on a web page if Xaseco is running or not ?
It would have been helpful if you mentioned that in the initial post. :wink: Anyway, the above scripts are for starting/stopping and checking the status of XAseco on Linux. For anything else, especially on Windows, I can't help.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

User avatar
Phhere
sunday driver
sunday driver
Posts: 65
Joined: 16 Oct 2006 21:01
Owned TM-games: TMS, TMU
Contact:

Re: Script for monitoring

Post by Phhere » 12 Jul 2008 12:01

Some days before i wrote a php function to get the current pid of a program

Code: Select all

$param1 = "program name";
        $param2 = "possible argument";
        exec("ps aux | grep '".$param1."' | grep '".$param2."' | grep -v grep | grep -v su | awk {'print $2'}",$PIDs);
		return $PIDs;
It returns the Pid of the program if it is running. So you can check the status of aseco
*Sorry for my english*
webSPELL Development
Image

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: Script for monitoring

Post by Ptitzizi » 12 Jul 2008 15:39

Thanks, I will test that :)

Edit :
I have 4 server running with Xaseco so how it can detect whitch aseco is ? Because when I write this command on Putty :
ps -ef | grep aseco
It returns "/usr/local/bin/php5 aseco.php TMN" for every xaseco running...
I hope you understand me :D

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: Script for monitoring

Post by Ptitzizi » 24 Aug 2008 17:21

Mini up :D
Thanks in advance !

nouseforname
swift roadking
swift roadking
Posts: 840
Joined: 20 Apr 2008 08:58
Owned TM-games: TMUF,TMNF, TMN
Manialink(s): therookies
Location: Germany
Contact:

Re: Script for monitoring

Post by nouseforname » 24 Aug 2008 17:28

Ptitzizi wrote:Mini up :D
Thanks in advance !

to have seperate entrys in putty (ps -ef) just rename the aseco.php file.
eg.
server 1 = aseco01.php
server 2 = aseco02.php
....

than u will see the different name in putty. ;)
Owner of the Rookie servers and some more. :)
Rookies HP
My Project
Rookies Manialinkcolor>

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: Script for monitoring

Post by Ptitzizi » 24 Aug 2008 19:45

It's done...
So now when I ps -ef | grep aseco :

Code: Select all

serveur  15861     1  2 21:32 pts/2    00:00:18 /usr/local/bin/php5 aseco3.php TMN
serveur  16094     1  2 21:34 pts/2    00:00:20 /usr/local/bin/php5 aseco0.php TMN
serveur  16104     1  2 21:34 pts/2    00:00:15 /usr/local/bin/php5 aseco1.php TMN
serveur  16121     1  2 21:35 pts/2    00:00:15 /usr/local/bin/php5 aseco2.php TMN
So with the code of Phhere :

Code: Select all

$param1 = "aseco";
        $param2 = "possible argument";
        exec("ps aux | grep '".$param1."' | grep '".$param2."' | grep -v grep | grep -v su | awk {'print $2'}",$PIDs);
      return $PIDs;
What I have to put in "possible argument" ?
And after, if I find a PID, the program is running, so it's Online...

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: Script for monitoring

Post by Ptitzizi » 26 Aug 2008 17:42

Erf, nobody can help me ? :'(

User avatar
akira2x
pedestrian
pedestrian
Posts: 10
Joined: 23 May 2008 13:07
Owned TM-games: TMO, TMS, TMN, TMUF
Contact:

Re: Script for monitoring

Post by akira2x » 27 Aug 2008 09:24

That monitoring php script should work, if you don't have more than 40 chat lines between 2 polls.

Code: Select all

<?
include("/path/to/GbxRemote.inc.php");

# should be a xaseco specific chat output like the INFO message prefix
$stringtofind = 'INFO';

$Client = new IXR_ClientMulticall_Gbx();
$Client->Init(5001);
$Client->query("Authenticate","SuperAdmin","password");
$Client->query("GetChatLines",40);
$chat = $Client->getResponse();

foreach ($chat as $line) {
        if (ereg($stringtofind,$line)) {
          echo "xaseco is running";
          exit;
        }
}
echo "xaseco stopped";
?>

Ptitzizi
road tourist
road tourist
Posts: 104
Joined: 03 May 2008 15:13
Owned TM-games: TMF

Re: Script for monitoring

Post by Ptitzizi » 27 Aug 2008 10:40

Thanks, it's not really working, because when Xaseco stop, it search in the log files the line 40 and it's here... so it shows "Xaseco is Running". The idea was good :D
We need to find a function that is open when Xaseco works... I think ? lol
Thanks for your help !

User avatar
akira2x
pedestrian
pedestrian
Posts: 10
Joined: 23 May 2008 13:07
Owned TM-games: TMO, TMS, TMN, TMUF
Contact:

Re: Script for monitoring

Post by akira2x » 27 Aug 2008 11:33

i am not a windows nerd, but try the next...
using a windows bat file, you could do something like:

Code: Select all

@echo off

set asecotask=aseco.php

tasklist | find /I "%asecotask%"
if "%errorlevel%" NEQ "0" echo %asecotask% is not running

kind regards
aki

Post Reply