Sambastatus: my first module for nethserver

Tried this in the php:

$command = "smbstatus -b";
$admin_shell = shell_exec($command);
echo $admin_shell;

and got

1 Like

mmm
yes… i think it is the problem… (srvmgr is the user run webserver)

in 7.3

[root@segreteria tmp]# su srvmgr
bash-4.2$ smbstatus -b
smbstatus only works as root!
bash-4.2$

in 6.9

[root@server tmp]# su srvmgr
[srvmgr@server tmp]$ smbstatus -b

Samba version 3.6.23-45.el6_9
PID Username Group Machine

14913 admin admin (192.168.1.2)
9461 dimichele dimichele docenti3 (192.168.1.156)
14915 minucci minucci (192.168.1.2)
13254 giorgini giorgini docenti2 (192.168.1.155)

mmm… a big problem…

my sambastatus is not ready for nethserver 7 :frowning:

Did a very dirty trick, just writing smbstatus to a file as root:

[root@server SambaStatus]# su - srvmgr
Creating home directory for srvmgr.
[root@server SambaStatus]# smbstatus -b > home/svrmgr/smbstatb

Replaced the command string in Connection.php with:

$command = "cat ~/smbstatb | sed -e '1,4d' | awk '{print $2 \"\t\" $4 \"\t\" $5}' | sort -h";

Maybe let a cron job write the smbstatus to the file?

Somethings wrong with “Host name” which shows “users@cmb.local” but maybe I changed something when trying to find the error.

Hi Markus,
can you try $command = “sudo smbstatus -b”;

You can check that smbstatus is able to be run as sudo ?

i tried… but ask for password

try to add smbstatus in sudoers file and see then
I had a similar issue with my script and I had to add the script to the sudoers

3 Likes

thank you @mrmarkuz, @Ctek and @netbix

5 Likes

ok
i’m the king of the bugfix :smiley:

https://minucci.net/nethserver/nethserver-sambastatus-0.4-1.x86_64.rpm

now is “NethServer 7 ready” :slight_smile:

I put script in %post section of rpm package which add a file in /etc/sudoers.d/ if found nethserver version 7. The control check is into the php file too, if the version is 7 use “sudo smbstatus” instead of “smbstatus”

2 Likes

OK

I have upgrade package but …

Nome Utente -> OK
Nome Host -> NOT OK
Indirizzo IP -> OK

My Nethserver 7 DC

[root@sogomail ~]# smbstatus -p

Samba version 4.4.4
PID Username Group Machine Protocol Version Encryption Signing

15220 antonio@netbix.it domain users@netbix.it 192.168.0.223 (ipv4:192.168.0.223:64247) SMB3_11 - partial(AES-128-CMAC)
[root@sogomail ~]#

mmm… ok
i’ll try to fix in the next release :slight_smile:

Please, don’t create files in %post.
Revert https://github.com/carlominucci/SambaStatus/commit/2600d6b7c0a3e28ff96a9960718d54286f8ffa38 and add a file in the rpm package like in this example:
https://github.com/NethServer/nethserver-openvpn/blob/master/root/etc/sudoers.d/20_nethserver_openvpn

3 Likes

Ahaha :crown:
Amazing collaborative effort guys :smiley:

this is the hardware version of SambaStatus :slight_smile:

10 Likes

I wonder if is safe to install the module?

Regards

SambaStatus for NethServer 7 is ready!!!

You can download and install from here http://minucci.net/nethserver/nethserver-sambastatus-7.0-1.x86_64.rpm

For NethServer 6.x you must use the old version. Found all version here http://minucci.net/nethserver/

Source here https://github.com/carlominucci/SambaStatus

13 Likes

That’s a big news. I love the pic :smiley:

2 Likes

I definitely love the pic, but his badge choice is the top!!! :heart_eyes_cat:

@gecco thank you for the module and for being here!

1 Like

Thanks for the module.

To install I just need to do this?

rpm -i nethserver-sambastatus-7.0-1.x86_64.rpm

and nothing else? :thinking:

That should be enough, provided you have downloaded the rpm first and are in the directory you saved the rpm to.

[root@ns7 ~]# wget http://minucci.net/nethserver/nethserver-sambastatus-7.0-1.x86_64.rpm
–2018-10-03 21:18:28-- http://minucci.net/nethserver/nethserver-sambastatus-7.0-1.x86_64.rpm
Resolving minucci.net (minucci.net)… 46.28.5.100
Connecting to minucci.net (minucci.net)|46.28.5.100|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 6236 (6.1K)
Saving to: ‘nethserver-sambastatus-7.0-1.x86_64.rpm’
100%[======================================>] 6,236 --.-K/s in 0.001s
2018-10-03 21:18:28 (5.73 MB/s) - ‘nethserver-sambastatus-7.0-1.x86_64.rpm’ saved [6236/6236]
[root@ns7 ~]# rpm -i nethserver-sambastatus-7.0-1.x86_64.rpm
Counting installation…

3 Likes