Show whether a process is either running or not

I'd like to know of a way to output to a webpage whether specific processes are running or not. I host a few eggdrops, bncs and would like to be able to show if they're up or down.

I use Debian Squeeze and Nginx.

Help would be greatly appreciated. :)

4 Replies

ps -C <process_name></process_name>
This will show a list of currently running processes. For example, if you want to know if the SSH server is running, you do "ps -C sshd".

Write a PHP script (or a script in any other language that you prefer) to execute this command and count the number of entries.

I appreciate the reply. TBH I wouldn't know where to start in writing a PHP script for this.

What I was thinking was being able to show if a process is running or not on a webpage by the words "Online" and "Offline".

I'd like some more replies if possible. Any help would be awesome.

What programming languages do you know?

Here's a PHP script that I just whipped up.

PHP is probably the easiest language to set up with nginx, because nginx doesn't support plain old CGI, Python/Ruby frameworks are overkill for your purpose, and there are tons of tutorials for setting up Debian+nginx with PHP/FastCGI. (Don't bother with compiling FPM, just use php5-cgi and spawn-fcgi packages from the repository.)

Save it as "ps.php" someplace where nginx can serve it. Set up nginx to use PHP if you already haven't done so.

Now, visit http://your-domain-or-ip-address/ps.php … ocess_name">http://your-domain-or-ip-address/ps.php?process=processname. If everything is set up properly, the page will display the number of running processes. (Replace processname with the name of the server process that you'd like to monitor. If you're unsure, use the "top" command to see the names of running processes.)

Caution: You probably don't want this script to be accessible to everyone in the world. Although I think I've built in adequate protections from injection attacks, it would be a good idea to hide it where other people won't know.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct