Active FTP/SSH/Telnet/Samba Connections - Uses SNMP+BASH

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

wasca
Posts: 3
Joined: Fri Feb 22, 2008 1:36 am

Post by wasca »

Hi All

I'm also only getting -1 when I run this script.

I'm running it like this at a command line

./tcp_conns.sh 203.82.xxx.xxx 80 203.82.xxx.xxx public

I've also added the community in the tcp_conns.sh file as instructed.

Any clues?
cristyde
Posts: 1
Joined: Mon Sep 21, 2009 1:38 pm

Post by cristyde »

In case there's anyone still interested... I've figured out the logic of the script.
As an example, suppose we want to check the number of tcp connections to the port 143 in host 192.168.1.1:

We should query
/usr/bin/snmpwalk -On -c public -v1 192.168.1.1 .1.3.6.1.2.1.6.13.1.3.192.168.1.1.143

In the script there's an error:

Where it says

Code: Select all

CONNECTIONS=`$SNMPWALKBINARY -On -c $COMMUNITY -v1 $IPADDRESS .1.3.6.1.2.1.6.13.1.3.$SYSTEMNAME.$PORT | $WCBINARY -l`
It should be:

Code: Select all

CONNECTIONS=`$SNMPWALKBINARY -On -c $COMMUNITY -v1 $SYSTEMNAME .1.3.6.1.2.1.6.13.1.3.$IPADDRESS.$PORT | $WCBINARY -l`
Please note that $IPADDRESS and $SYSTEMNAME are exchanged.

Once corrected the script, one way to check it is:

./tcp_conns.sh hostname.test.com 143 192.168.1.1 public

good luck!
Cris.
pbroyce
Posts: 5
Joined: Wed Apr 04, 2007 10:31 am

Post by pbroyce »

If you use 'jgtm' original script tcp_conns.sh, and your cacti server is a Linux/UNIX box, you will need to do dos2unix format conversion for the shell script to run without error.
dos2unix -n tcp_conns.sh tcp_conns2.sh
pbroyce
Posts: 5
Joined: Wed Apr 04, 2007 10:31 am

Post by pbroyce »

If the above doesn't work for you, you can try the following thread which doesn't requires any scripts.

In this case, modify /etc/snmp/snmp.conf, and add:

proc smb

After that, follow this thread to get the 'ucd/net - Get Monitored Processes' data queries going you will be set.

http://forums.cacti.net/about9805.html
pbroyce
Posts: 5
Joined: Wed Apr 04, 2007 10:31 am

Post by pbroyce »

Correction:

proc smb (Wrong)

proc smbd (correct)
Tatoman
Posts: 4
Joined: Fri May 14, 2010 3:26 pm
Location: Montevideo, Uruguay

Post by Tatoman »

I have some trouble adding this template.
Running on localhost

RDD tool says:

/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-60 \
--title="MAGNETO - Active FTP Connections" \
--rigid \
--base=1000 \
--height=120 \
--width=600 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/var/lib/cacti/rra/magneto_ftp_conns_123.rrd":ftp_conns:LAST \
AREA:a#FF0000FF:"No. FTP Connections" \
GPRINT:a:LAST:"Current\:%8.2lf %s" \
GPRINT:a:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:a:MAX:"Maximum\:%8.2lf %s\n"
RRDTool Says:

ERROR: the RRD does not contain an RRA matching the chosen CF


Any suggestion?
Ubuntu Server 10.04
Cacti 0.8.7.e
Heiko
Cacti User
Posts: 77
Joined: Wed Apr 23, 2008 11:03 am

Re: Active FTP/SSH/Telnet/Samba Connections - Uses SNMP+BASH

Post by Heiko »

same here :(
doughairfield
Posts: 20
Joined: Wed Feb 20, 2008 1:57 pm

Re: Active FTP/SSH/Telnet/Samba Connections - Uses SNMP+BASH

Post by doughairfield »

I was never able to get the snmp walk to work either. It seems like the port is not what comes after the IP on my CentOS systems, it's some 5 digit number followed by the ip again and then the port.
ocoralan
Posts: 21
Joined: Mon Apr 25, 2011 7:38 pm

Re:

Post by ocoralan »

acacioas wrote:I made some modifications on the script and on the graph_template..

Now, you need only to choose what interface to check the connections and the port.

The graph title may be modified (this is important if you have more than one IP per host to check, like me..)

The community and the IP of the server (where the snmpwalk will query) are derived from the host configuration..
How can I use it in windows? I donn't know how to modify the tcp_conns.sh file. Would you please guide me? Thank you very much.
ocoralan
Posts: 21
Joined: Mon Apr 25, 2011 7:38 pm

Re: Active FTP/SSH/Telnet/Samba Connections - Uses SNMP+BASH

Post by ocoralan »

Hum, does anybody provide a windows version?
sebish
Posts: 7
Joined: Wed May 23, 2012 7:22 am

Re:

Post by sebish »

UKS-Gavin wrote:Change the script to be like this instead;

Code: Select all

#!/bin/bash
# Code updated by Gavin Conway
# Gavin@Essociate.co.uk

#------- User customisation area --------------#
SNMPWALKBINARY=/usr/bin/snmpwalk
ECHOBINARY=/bin/echo
WCBINARY=/usr/bin/wc
#-------- Do not edit below this line ----------#


SYSTEMNAME=$1
PORT=$2
IPADDRESS=$3
COMMUNITY=PUTYOURCOMMUNITYNAMEHEREIFYOUWANTTHISTOWORK!!!!!!!


if [[ -z $SYSTEMNAME || -z $PORT || -z $IPADDRESS || -z $COMMUNITY ]]
then
        echo "Usage: tcp_conns.sh hostname port ipaddress community"
fi

CONNECTIONS=`$SNMPWALKBINARY -On -c $COMMUNITY -v1 $IPADDRESS .1.3.6.1.2.1.6.13.1.3.$SYSTEMNAME.$PORT | $WCBINARY -l`

let "CONNECTIONS = $CONNECTIONS -1"
$ECHOBINARY $CONNECTIONS
[/quote][/quote]

What do i have to enter at "IP address of interface of the tcp connection"? Should this be the host ip or my ip in this network?

Aehm - Does this script still monitor a hosts ssh/tcp connections or does ist monitor MY connections what would make no sense..
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest