Operating System - Linux
1821638 Members
3127 Online
109633 Solutions
New Discussion юеВ

need the script to show via browser if the vpn client is running

 
SOLVED
Go to solution
'chris'
Super Advisor

need the script to show via browser if the vpn client is running

hi

I have cisco vpnclient-linux-3.7.3.A-k9
installed on linux server SuSE 8.2.
This server is also the proxy server
for 300 clients.
So all our users have vpn connection
via proxy and I don't need install
any vpn clients at the workstations.

But sometimes the vpn client is going down,
so I wrote the php script to start it
via browser.
The problem is, that sometimes the remote server goes down and the vpn client cannot establish connection and user don't know
where the problem is.

I need the second PHP or Perl script to show
in browser if the VPN client is running or not.
So if I am not in the office, users can check it.
I thought, to check the proces:

# ps ax | grep vpnclient | grep -v grep
11153 ? S 0:00 /usr/local/bin/vpnclient

and show via browser:

"VPN Client is up and running"

any idea ?

kind regards
chris
6 REPLIES 6
Vijaya Kumar_3
Respected Contributor
Solution

Re: need the script to show via browser if the vpn client is running

Hi chris,

It is relatively easy to setup i hope.
Go through this perl CGI module page and you can easily set up what you want:

http://stein.cshl.org/WWW/software/CGI/

Hope this helps
vijay
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Toni Niemi
Occasional Advisor

Re: need the script to show via browser if the vpn client is running

Would this php script be useful in your case?
There you can write a script that includes ps command with arguments and pipes or just hardcode it in php like this sample shows. there grep -c counts how many lines has hitted so if vpnclient line is found then output has value 1.
$output=shell_exec("ps ax | grep -v grep | grep -c vpnclient");
if ($output != 0) {
echo "VPN client is up and running!
;
} else {
echo "Here what to do then!
"
}
?>

Regards Toni
There is unlimited amount of information but very limited amount of time
'chris'
Super Advisor

Re: need the script to show via browser if the vpn client is running

hi toni

I tried your script, but I get this error:

parse error, unexpected T_STRING, expecting ',' or ';' in /srv/www/htdocs/coda1.php on line 31

kind regards
chris
'chris'
Super Advisor

Re: need the script to show via browser if the vpn client is running

anyway I corrected it

$output=shell_exec("ps ax | grep -v grep | grep -c vpnclient");
if ($output != 0) {
echo "VPN client is up and running!";
} else {
echo "Here what to do then!";
}
?>

now it works well !

regards
chris
'chris'
Super Advisor

Re: need the script to show via browser if the vpn client is running

thanks toni and have a nice day !
Toni Niemi
Occasional Advisor

Re: need the script to show via browser if the vpn client is running

Hello Chris

Ah, sorry, every command needs to end with semicolon, since coding is not my main work it seems to be forgotten pretty easely;-) And I have to admit that I didnt test the code before suggesting it. Well it didnt seem to be a problem to you after all so problem solved.

Have a nice day too, Chris!!

Regards,
Toni
There is unlimited amount of information but very limited amount of time