Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Tue Aug 21, 2018 6:38 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Show locked Machines, Shares and Files from a Samba Server
PostPosted: Sun May 08, 2005 2:51 pm 
Offline

Joined: Mon May 02, 2005 7:18 pm
Posts: 6
I have written a little perl script for linux which graphs the locked machines, shares and files from a samba server in gauge mode.

the attachment includes a little install howto.


dirk


Attachments:
File comment: samba.pl
Graph Template
Install Howto

samba.zip [3.28 KiB]
Downloaded 2286 times
File comment: Graph
samba.png
samba.png [ 4.87 KiB | Viewed 32463 times ]
Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 5:09 pm 
Offline
Cacti User
User avatar

Joined: Mon Apr 26, 2004 7:18 am
Posts: 68
Location: Switzerland
thanx for sharing your script

can't import the .XML file.
errormessage : Error: XML: Hash version does not exist.

what does that mean ?
which cacti version do you use for running that script ?

_________________
http://www.lounge-radio.com/


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 08, 2005 6:57 pm 
Offline

Joined: Mon May 02, 2005 7:18 pm
Posts: 6
i use the latest stable version (0.8.6d)

http://forums.cacti.net/post-28880.html
it seems to be a version conflict


Top
 Profile  
 
 Post subject: grep: The -P option is not supported
PostPosted: Thu Jun 02, 2005 10:45 am 
Offline

Joined: Thu Jun 02, 2005 10:42 am
Posts: 9
Hi,

when I run that script, I get 3 errors:
grep: The -P option is not supported
grep: The -P option is not supported
grep: The -P option is not supported

something seems to be wrong with
grep -c -P '(\\d+)'`;

my grep version is 2.5.1.ds1-4

can you help me with this?

regards,

jeroen


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 02, 2005 1:31 pm 
Offline

Joined: Mon May 02, 2005 7:18 pm
Posts: 6
the -P opion is for the perl regex >'(\\d+)'<, i think you have to install perl.

dirk


Top
 Profile  
 
 Post subject: grep: The -P option is not supported
PostPosted: Fri Jun 03, 2005 2:23 am 
Offline

Joined: Thu Jun 02, 2005 10:42 am
Posts: 9
hi,

I have perl installed:
>This is perl, v5.8.4 built for i386-linux-thread-multi

it was already installed.

any other ideas?

regards,

jeroen


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 6:22 am 
Offline

Joined: Mon May 02, 2005 7:18 pm
Posts: 6
for this solution: no

but you can count all lines with grep (-c option) an than subtract the number of lines which are program outputs like version number, descriptions ...

dirk


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 11:11 am 
Offline

Joined: Fri Jul 08, 2005 11:01 am
Posts: 2
Tanks a lot for this script, it works fine with cacti 0.8.6f on SME Server 6.0.1-01.

Stephane


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 6:57 pm 
Offline

Joined: Mon Aug 22, 2005 6:47 pm
Posts: 2
I modified the template to work with SNMP query. I Hope It helps somebody...

no problem with "grep: The -P option is not supported"

PS: I dont checked the results values.


Attachments:
samba.tar.gz [3.38 KiB]
Downloaded 1568 times
Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 2:27 pm 
Offline

Joined: Tue May 24, 2005 2:08 pm
Posts: 8
rayel wrote:
I modified the template to work with SNMP query. I Hope It helps somebody...

no problem with "grep: The -P option is not supported"

PS: I dont checked the results values.



Here snmpwalk works extremaly slow and my graphics continues empty.

time snmpwalk -v 1 -c public 10.100.0.252 .1.3.6.1.4.1.2021.55.1.101.1 -t 120
UCD-SNMP-MIB::ucdavis.55.1.101.1 = STRING: "340"

real 5m9.265s
user 0m0.041s
sys 0m0.010s



time snmpwalk -v 1 -c public 10.100.0.252 .1.3.6.1.4.1.2021.55.2.101.1 -t 120
UCD-SNMP-MIB::ucdavis.55.2.101.1 = STRING: "1689"

real 7m30.465s
user 0m0.046s
sys 0m0.003s


time snmpwalk -v 1 -c public 10.100.0.252 .1.3.6.1.4.1.2021.55.3.101.1 -t 120
UCD-SNMP-MIB::ucdavis.55.3.101.1 = STRING: "612"

real 0m0.132s
user 0m0.040s
sys 0m0.009s


why is smbstatus too slow here?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 9:16 pm 
Offline

Joined: Mon Aug 22, 2005 6:47 pm
Posts: 2
if you run smbstatus manually, it returns the values imediatelly?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 12:51 am 
Offline

Joined: Wed Dec 14, 2005 9:37 pm
Posts: 8
rayel wrote:
I modified the template to work with SNMP query. I Hope It helps somebody...

no problem with "grep: The -P option is not supported"

PS: I dont checked the results values.


Hi, I think it's really very useful for me, but when I ran the script I got this messages:
# ./sambanew.pl
Use of uninitialized value in string eq at ./sambanew.pl line 9.
Use of uninitialized value in string eq at ./sambanew.pl line 9.
Use of uninitialized value in string eq at ./sambanew.pl line 9.
Use of uninitialized value in scalar chomp at ./sambanew.pl line 18.
Use of uninitialized value in string at ./sambanew.pl line 20.

Is there something wrong with my machine?
I can also get the output when run snmpwork from a remote server:
# snmpwalk -v 1 -c public 192.168.32.60 .1.3.6.1.4.1.2021.55.3.101.1
UCD-SNMP-MIB::ucdavis.55.3.101.1 = STRING: "Processes:11 Shares:12 Files:0"

but got no graph :(

My question: How can I get the samba status from a remote cacti server?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 10:58 am 
Offline
Cacti User

Joined: Tue Feb 21, 2006 9:40 am
Posts: 68
I was thinking somebody could be interested in a script not using grep at all :

Of course, adapt the paths to smbstatus.

Code:
/usr/local/bin/perl -w
###############################################################################
##
## local-samba-stats.pl
##
## Authors : Gael Jean
##
## Arguments : See help
##
################################################################################

use strict ;

################################################################################

my ( $status ) = eval { Main ( @ARGV ) || 0 } ;

if ( [email protected] ) {
        print STDERR [email protected] ;
        $status = 1 ;
}

exit $status ;

################################################################################

sub Main {

        my ( $files, $processes, $shares ) = 0 ;

        my $command = "/exploit/samba/bin/smbstatus -p" ;
        open ( OUTPUT, "$command |" ) || die "$!\n" ;

        # Parsing output
        foreach ( <OUTPUT> )
        {
                $processes++ if /^\d+/ ;
        }
        close ( OUTPUT ) ;

        my $command = "/exploit/samba/bin/smbstatus -S" ;
        open ( OUTPUT, "$command |" ) || die "$!\n" ;

        # Parsing output
        foreach ( <OUTPUT> )
        {
                $shares++ if /^[^\s]+\s+\d+/ ;
        }
        close ( OUTPUT ) ;

        my $command = "/exploit/samba/bin/smbstatus -L" ;
        open ( OUTPUT, "$command |" ) || die "$!\n" ;

        # Parsing output
        foreach ( <OUTPUT> )
        {
                $files++ if /^\d+/ ;
        }
        close ( OUTPUT ) ;

        # Print output
        print "processes:$processes shares:$shares files:$files" ;
        print "\n" ;

}



Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 5:04 pm 
Offline

Joined: Sun Jul 09, 2006 1:51 am
Posts: 42
Location: detroit'ish
if you replace "grep -c -P" with "grep -c -e" the first perl script works.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2008 8:12 am 
Offline

Joined: Fri Sep 05, 2008 9:14 am
Posts: 12
Location: Bosnia
I try on gentoo 2008.0 to install !

But no graph ...

i use second modified template and folow instruction !

Need help


Attachments:
samba1.png
samba1.png [ 29.04 KiB | Viewed 21628 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group