You are not logged in.

#1 2006-11-28 01:57:46

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Remote Administration?

I host a few different servers on a spare PC of mine, but sometimes they have a habbit to crash and I am not always home to bring them back online, I need a simple tool just to do that, but I want it to have restrictions so onyl certain commands can be ran, for example the starting of the servers command, ect. This is so another admin of one of my servers can bring it back up also.

Offline

#2 2006-11-28 03:30:27

slackhack
Member
Registered: 2004-06-30
Posts: 738

Re: Remote Administration?

what kind of services? it's probably not normal for them to be crashing like that.

Offline

#3 2006-11-28 14:14:24

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: Remote Administration?

Mainly a few game servers, during certain map changes, and other random things going on they do crash from time to time, and it's nice not to have to be called up early in the morning to start the servers tongue

Offline

#4 2006-11-28 14:17:18

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: Remote Administration?

You should try and find a script that checks if the server is running and if not starts it. Place that script as a cron job for automatical restart whenever the script is run and finds out that the server isn't running.

Using pgrep you could easily see if the process is running or not, I think it should be pretty easy to create a script that checks if pgrep returns nothing and then starts the server.

EDIT: Did some googleing (I'm not specially good at bash scripting) and this simple script should get the work done (using thunderbird for showing how it works):

#!/bin/bash
if ps ax | grep -v grep | grep thunderbird > /dev/null; then
  echo "Thunderbird is running, not starting it"
else
  echo "Thunderbird is not running, starting it up"
  thunderbird & 
fi

PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#5 2006-11-28 14:22:31

slackhack
Member
Registered: 2004-06-30
Posts: 738

Re: Remote Administration?

i guess you could write a script that checked to see if the programs are running, and then started them if they weren't. you could make it a cron job to run every minute or so, or however long you wanted between checks. i don't know advanced shell scripting, but it doesn't seem like it would be that hard. something that checked the output of ps ax and then started what wasn't running would probably be one way to do it.

Offline

#6 2006-11-28 14:23:19

slackhack
Member
Registered: 2004-06-30
Posts: 738

Re: Remote Administration?

[vEX] beat me. tongue

Offline

#7 2006-11-28 14:34:26

[vEX]
Member
From: Sweden
Registered: 2006-11-23
Posts: 450

Re: Remote Administration?

I'm not sure how could that script works, there is "if pgrep PROCESS" but it kept reporting that the process wasn't running for me even though it was.

slashhack smile


PC: Antec P182B | Asus P8Z77-V PRO | Intel i5 3570k | 16GB DDR3 | GeForce 450GTS | 4TB HDD | Pioneer BDR-207D | Asus Xonar DX | Altec Lansing CS21 | Eizo EV2736W-BK | Arch Linux x86_64
HTPC: Antec NSK2480 | ASUS M3A78-EM (AMD 780G) | AMD Athlon X3 425 | 8GB DDR2 | GeForce G210 | 2TB HDD | Arch Linux x86_64
Server: Raspberry Pi (model B) | 512MB RAM | 750GB HDD | Arch Linux ARM

Offline

#8 2006-11-28 14:38:15

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,718
Website

Re: Remote Administration?

Here, this should do it:

#!/bin/bash

function runOnce(){
INSTANCE=`ps -A | grep -c program_name`
if [ "$INSTANCE" == 0 ]; then 
program_name 
else 
:
fi
}

runOnce

This code just makes sure that an instance of program_name is running if it is not it starts it, otherwise, it does nothing.
You could use a cron job (say every 10 min') to "monitor" that the game server is running.

Hope this helps.

Offline

#9 2006-11-28 20:08:09

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: Remote Administration?

Thanks for the ideas everyone, problem solved. Thanks for the script ralvez, works like a charm smile.I still want to use some remote administation software of some sort, so I am also checking into Webmin so other admins can edit th servers config files ect, but as for the server crashing, this brings it back up automatically.:) On a side note, does anyone know of any good simple remote administation programs? Command line ones would be a plus for me, and access through telnet would be nice smile. But any remote administration applications are nice.

Offline

#10 2006-11-28 20:32:29

slackhack
Member
Registered: 2004-06-30
Posts: 738

Re: Remote Administration?

don't you have ssh? (openssh?) your cohorts could just log in at the command line and start whatever they needed to (with right permissions, etc.).

edit:
http://wiki.archlinux.org/index.php/Using_SSHD_and_SSH
http://wiki.archlinux.org/index.php/Using_SSH_Keys

Offline

#11 2006-11-28 22:45:53

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,718
Website

Re: Remote Administration?

You can use ssh and sudo.
The first to safely allow log in for your co-admins and the second to control what commands they are allowed to issue, that would take care of the problem.

R

Offline

#12 2007-01-06 07:46:55

huijar
Member
From: Finland
Registered: 2006-12-31
Posts: 6

Re: Remote Administration?

Yup, don't even think choosing telnet over ssh!

Offline

Board footer

Powered by FluxBB