Koozali.org: home of the SME Server

Need to view active connections

Offline mikey777

  • 12
  • +0/-0
Need to view active connections
« on: August 02, 2013, 03:57:20 PM »
Hi I need to know if there is a way to view active connection to SME 8 server or is there a third party app i can use. I need this because sometimes i need to restart to server and not all user logoff server.

Offline larieu

  • ****
  • 214
  • +0/-0
Re: Need to view active connections
« Reply #1 on: August 03, 2013, 08:39:07 AM »
in console you can use netstat or lsof


Code: [Select]
netstat -n -A  inet

Code: [Select]
lsof -i
imaps or imap or pop 3 or ldap are not "so important"

most probably you need to parse them with grep for what are you interested in

to see what your server are listening to

Code: [Select]
netstat --listen -A inet

if everybody's life around you is better, probably yours will be better
just try to improve their life

Offline mmccarn

  • *
  • 2,628
  • +10/-0
Re: Need to view active connections
« Reply #2 on: August 03, 2013, 04:34:34 PM »
If your concern is mounted network shares and open files, you might want
Code: [Select]
smbstatus

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Need to view active connections
« Reply #3 on: August 06, 2013, 02:41:50 PM »
I need this because sometimes i need to restart to server and not all user logoff server.

You can restart the server whether they logoff or not.

Offline purvis

  • ****
  • 567
  • +0/-0
Re: Need to view active connections
« Reply #4 on: August 08, 2013, 12:18:17 AM »
I posted some php code to show any samba files open to be accessed by a web browsers.

you can look it up on the forum, search serverstatus or something like that  and also here is some php code

Code: [Select]
<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->

<html>

<head><title>Server Status</title></head>

<body>
<tt>
<b>
<div>
<?php
print "<pre>";
echo  
'<font size="4">';
print 
"Server Status Report\n";
print 
"\n";
print 
"Current date : ";
system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"    URL name : ";
print  (
$_SERVER['SERVER_NAME']);
print 
"\n";
print 
" Server name : ";
system("uname -n | col -b",$return);

print 
"************** UPTIME ***************\n";
system("uptime | col -b",$return);
print 
"\n";

print 
"\n";

print 
"************** SMB STATUS ****************\n";
system("smbstatus | col -b",$return);
print 
"\n";

print 
"\n---end of report---\n";
print 
"</pre>";
?>

</div>
</body>
</html>



Offline purvis

  • ****
  • 567
  • +0/-0
Re: Need to view active connections
« Reply #5 on: August 08, 2013, 12:22:41 AM »
here is php code for a  web page that loops back to itself

this report will only show files opened using samba file sharing


Code: [Select]

<!--DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"-->
<html>
<head>
<meta http-equiv="refresh" content="1">
<title>Server open smb files report</title>
</head>
<body>
<tt>
<b>
<div>
<font size="3">
To stop this webpage from automatic refreshing <a href="filesopen.php">click here</a>.
<?php
print "<pre>";
echo  
'<font size="2">';
print 
"Server open smb files report ";system("date +'%m-%d-%Y  %T %Z' | col -b",$return);
print 
"URL name : ";
print  (
$_SERVER['SERVER_NAME']);
system("smbstatus -b | col -b",$return);
echo  
'<font size="3">';
print 
"\n";
system("smbstatus -L | col -b",$return);
echo  
'<font size="2">';
print 
"---end of report---\n";
print 
"</pre>";
?>

</div>
</body>
</html>


Offline mikey777

  • 12
  • +0/-0
Re: Need to view active connections
« Reply #6 on: August 15, 2013, 01:53:54 PM »
thanks alot smbstatus works perfectly  :-o

Offline purvis

  • ****
  • 567
  • +0/-0
Re: Need to view active connections
« Reply #7 on: November 12, 2013, 02:56:52 AM »
SME 32-bit version of smbstatus discussed ONLY


There is an issue with smbstatus(/usr/bin/smbstatus) not returning text information in php coded webpages after an update in SME 8.
The issue seems to stem from the developers of samba. I am not sure.

Here is link to some discussion
https://bugzilla.samba.org/show_bug.cgi?id=9432
« Last Edit: November 13, 2013, 01:56:04 AM by purvis »

Offline purvis

  • ****
  • 567
  • +0/-0
Re: Need to view active connections
« Reply #8 on: November 12, 2013, 03:08:03 AM »
I am going to cross reference the previous post to an older post where I original posted the php code.
 
http://forums.contribs.org/index.php/topic,47424.msg

Offline purvis

  • ****
  • 567
  • +0/-0
Re: Need to view active connections
« Reply #9 on: November 13, 2013, 02:15:25 AM »
The problem that developed from running the smbstatus from a webpage is in permissions.

I do not have any experience using the sudoers file located in /etc directory.

But I added the below line in the /etc/sudoers file.
Code: [Select]
apache ALL=(root) NOPASSWD:/usr/bin/smbstatus


The unaltered /etc/sudoers has one line "root    ALL=(ALL) ALL"
I created a custom template in the sme server to allow /usr/bin/smbstatus to be run with the sudo command inside of a php webpage


What I did to allow smbstatus to run from the php webpage.

1ST.
---------------
If  the directory of /etc/e-smith/templates-custom/etc/sudoers/ does not exist and if there are no files in the directory.
I created the directory and copied the /etc/sudoers file into the directory and renamed it to 10sudoers
Be careful that you are not erasing any files that already exist inside the directory /etc/e-smith/templates-custom/etc/sudoers/

Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/sudoers
cp /etc/sudoers /etc/e-smith/templates-custom/etc/sudoers/10sudoers


2ND
---------------
I created a file named 20smbstatus inside the directory  /etc/e-smith/templates-custom/etc/sudoers and pasted the
text "apache ALL=(root) NOPASSWD:/usr/bin/smbstatus" inside of the file. Do not use the double quote marks if you are using a file editor and adding the text in the file.

The command to do this in a one line command without using an editor from the command line is.
Code: [Select]
echo "apache ALL=(root) NOPASSWD:/usr/bin/smbstatus" > /etc/e-smith/templates-custom/etc/sudoers/20smbstatus


3RD and final step
---------------
Finish the setup
Code: [Select]
expand-template /etc/sudoers


you should now see the added text in the /etc/sudoers file
Code: [Select]
cat /etc/sudoers


4TH
If reboot is required
Code: [Select]
signal-event post-upgrade;signal-event reboot

« Last Edit: November 13, 2013, 02:32:52 AM by purvis »

Offline purvis

  • ****
  • 567
  • +0/-0
Re: Need to view active connections
« Reply #10 on: November 13, 2013, 02:27:36 AM »
After the above steps.
I changed the lines in my php webpages that run the smbstatus program using the php command "system" to run under root privileges using the linux sudo command.
There are other lines where i use smbstatus but here is an example of a single line in php code that works now, as opposed to where it did work after updating SME 8.
from
Code: [Select]
system("smbstatus -b | col -b",$return);
to
Code: [Select]
system("sudo /usr/bin/smbstatus -b | col -b",$return);


This works for the smbstatus version 3.6.6-0.136.el5.
You can use the command "smbstatus -V" to retrieve the version number.
This is working on one 64 bit SME operating system and a 32 bit SME operating system version 8.
« Last Edit: November 13, 2013, 02:31:20 AM by purvis »