plugin for download/upload routers switches configuration

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
ddonohue
Cacti User
Posts: 77
Joined: Mon Jul 10, 2006 10:36 am
Contact:

Post by ddonohue »

I gave it a whirl, but still no soup for me. It feeds the MORE lines.

ie.

--MORE--

If there a way around this? The only way to feed in multipul automatic commands is on the 12.3 series IOS w/ TCL. But i'm not privileged enough to run that.

Also, after replacing the template.txt, it wasn't associating the script correctly, jsut a FYI.

Had to do this.

name=telnet-cisco-automatically-unix
command=%g%/configmanager/scripts/telnetdownload-auto-unix.sh %n% /var/depot/%n%.cfg 4
help=(unix) download with Telnet of the running-config automatically from a Cisco router. The user and password have to be insert in the script 'telnetdownload-auto-unix.sh' . The last parameter is for sending a sleep in order to wait for the logging. The other parameters are: the router and destinationsfile. On the device create a user with the two commands 'username cacticfgmgr password tobechanged'and 'username cacticfgmgr autocommand show run'


Donohue
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

ddonohue wrote: If there a way around this? The only way to feed in multipul automatic commands is on the 12.3 series IOS w/ TCL. But i'm not privileged enough to run that.
try putting

Code: Select all

(echo "cacticfgmgr"; echo "tobechanged"; for ((x=0;$x<5;x=x+1)); do echo ""; done; echo "exit"; sleep $3
instead the line 2


PS: echo "exit"; could be removed, but I would let it in case of ...

a other way could be using the command privilege

Code: Select all

username cacticfgmgr privilege 1 password tobechanged
privilege exec level 1 show run
on the router (and the script telnetdownloadunix.sh with or not [echo "cacticfgmgr"; echo "tobechanged"] in it)
ddonohue wrote:scripts/telnetdownload-auto-unix.sh
OK I changed it in the post before
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
ddonohue
Cacti User
Posts: 77
Joined: Mon Jul 10, 2006 10:36 am
Contact:

Post by ddonohue »

/cacti-0.8.6h/plugins/configmanager/scripts/telnetdownload-auto-unix.sh xx.xxx.201.2 /cacti-0.8.6h/plugins/configmanager/depot/xxx.xxx.201.2.cfg 4


telnet: /cacti-0.8.6h/plugins/configmanager/depot/xxx.xxx.201.2.cfg: Name or service not known
/cacti-0.8.6h/plugins/configmanager/depot/xxx.xxx.201.2.cfg: Unknown host

Then, when i feed in the IP addy again, i get this..

connection closed by host.

FYI, you don't have to EXIT outta the autorun, pretty much, just runs the command then exits. just have to feed the --MORE--
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

ddonohue wrote:/cacti-0.8.6h/plugins/configmanager/scripts/telnetdownload-auto-unix.sh xx.xxx.201.2 /cacti-0.8.6h/plugins/configmanager/depot/xxx.xxx.201.2.cfg 4
It was because in this script the produced file had to be copied
like

Code: Select all

#!/bin/sh
(echo "cacticfgmgr"; echo "tobechanged"; for ((x=0;$x<50;x=x+1)); do echo " "; d
one; echo "exit"; sleep $3
) | telnet $1 > temp
echo mv temp $2
mv temp $2
But we have to forget this way because Cisco autocommand don't read the input.

So the only way at this time (when not IOS 12.3) is to create an user with privilege like this

Code: Select all

username cacticfgmgr privilege 1 password tobechanged 
privilege exec level 1 show run
and
use the telnetdownloadunix.sh script giving the user and password in the configmanager config.

or
adapt the telnetdownloadunix.sh and template.txt like this
telnetdownload-auto-unix.sh:

Code: Select all

#!/bin/sh
(echo "cacticfgmgr"; echo "tobechanged"; echo "term len 0"; echo "show run"; echo "exit"; sleep $5
) | telnet $1 > temp
csplit -k -f temp temp '/show run/'
rm -f temp
if test -f temp00 ; then rm -f temp00; fi
if test ! -f temp01 ; then exit; fi
echo mv temp01 $4
mv temp01 $4
template.txt

Code: Select all

name=telnet-cisco-automatically-unix
command=%g%/configmanager/scripts/telnetdownload-auto-unix.sh %n% /var/depot/%n%.cfg 4
help=(unix) download with Telnet of the running-config automatically from a Cisco router. The user and password have to be inserted in the script 'telnetdownload-auto-unix.sh' . The last parameter is for sending a sleep in order to wait for the logging. The other parameters are: the router and destinationsfile. On the device create a user with the two commands 'username cacticfgmgr password tobechanged'and 'username cacticfgmgr autocommand show run'
Sorry for you autocommand idea. (I tried also with IOS 12.3(8) but it has not fonction; only one autocommand).
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
jduchesne
Posts: 30
Joined: Fri Jul 07, 2006 7:50 am

Post by jduchesne »

Sorry pepj,

But I want to download with the snmp3 but it don't work I explain to you:

First I had two access list in order to select the user and the server so this is my two access list for snmp v1

access-list 1 permit 172.21.2.45
access-list 2 deny 172.21.2.45
access-list 2 permit any
snmp-server communty priverserver RW 1
snmp-server communty public RO 2

and now i want snmpv3 so I delete the five instruction before and I make


snmp-server user julien conseil v3 auth md5 supergenial
snmp-server group conseil v3 auth read v1default write v1default
snmp-server community public RW

and so in cacti I put snmpuser julien
password supergenial
community public

but in my log I have this
Listing of the config /etc/cacti/conftestid13.conf.log
Aug 23 10:06:44 [CEST/+0200] pancho: (ERROR) lilfor0007 SNMP session failed to be created for lilfor0007!

and my config file is :

Listing of the config /etc/cacti/conftestid13.conf
[global]
TftpServer=172.21.2.45
TftpRoot=/usr/cacti/tftp/
TftpPath=sauvegardetest20060823
LogFile=/etc/cacti/conftestid13.conf.log
ForkLimit=10
StylePattern=::HOST::.::DATE::.running-config
StyleDate=%Y%m%d
SnmpVersion=3
SnmpRetries=1
SnmpWait=5.2
SnmpMtu=1500
SnmpDebug=0
Snmpusername=julien
SnmpAuthPassword=supergenial
SnmpAuthProtocol=md5
[lilfor0007]
IpAddress=172.16.5.17
pre=/home/jduchesne/cacti.sh 20060823 sauvegardetest
post=/home/jduchesne/cactieffacement.sh 2006 0823 sauvegardetest

So I think that my mistake is on the snmpv3 for the router and not in cacti.
Can you say me what I have forgotten?

Thanks
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

jduchesne wrote:i want snmpv3
(In my environement it functions. I checked it now)

1/ do you have installed the following perl modules ?
- Crypt::DES (Perl Module needed for SNMPv3)
- Digest::MD5 (Perl Module needed for SNMPv3)
- Digest::SHA1 (Perl Module needed for SNMPv3)
- Digest::HMAC (Perl Module needed for SNMPv3)

2/ Do you have active the encryption on the router? (ip domain + crypto key) ? (check it with ssh)
I have used also

Code: Select all

snmp-server group conseil v3 auth write v1default
snmp-server user julien conseil v3 auth md5 supergenial
(You can also add Access-list later)

PS: What I 've forgotten is the possibility to use the pancho feature to a SnmpAuthKey for v3. I will add this later.

PS: Why do you put "snmp-server community public RW ". Do you like risk?
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
jduchesne
Posts: 30
Joined: Fri Jul 07, 2006 7:50 am

Post by jduchesne »

ok pepj
No I don't have install the perl module that you say so I have to make it and after you think that it works or it is sure?

And for the risk I understand what you say but it was an exemple :D
thanks
jduchesne
Posts: 30
Joined: Fri Jul 07, 2006 7:50 am

Post by jduchesne »

I can not install Digest-MD5-2.36 when i make perl Makefile.PL I have this

Perl's config says that U32 access must be aligned.
Writing Makefile for Digest::MD5

So I try to make or make install but I have this error
Makefile:85: *** missing separator. Arrêt.
could you explain me please pepj?
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

jduchesne wrote:I can not install Digest-MD5-2.36
Try only with
Crypt::DES (Perl Module needed for SNMPv3)
Digest::SHA1 (Perl Module needed for SNMPv3)
Digest::HMAC (Perl Module needed for SNMPv3)

you should have already per default a MD5 package.

I don't know more about this problem (I try rewriting the perl part in native PHP, but need time), but on my system I have also not installed Digest::MD5, I think it uses my default MD5.
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
cfybyair
Posts: 27
Joined: Fri Sep 01, 2006 3:33 pm

Post by cfybyair »

my configmanage have some error!

i don't know which reson

Fatal error: Maximum execution time of 30 seconds exceeded in D:\apache2\Apache2\htdocs\cacti\plugins\configmanager\configmanager.php on line 300
Attachments
config-error.JPG
config-error.JPG (45.61 KiB) Viewed 5865 times
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

cfybyair wrote:my configmanage have some error!
i don't know which reson
Fatal error: Maximum execution time of 30 seconds exceeded in D:\apache2\Apache2\htdocs\cacti\plugins\configmanager\configmanager.php on line 300
I think it is when it try to read the file 'plugins/configmanager/template.txt' and search the '#' and blank line

Code: Select all

              	$pattern = '/(^#)|( $)/';
                if (!(preg_match($pattern, $linename, $matches))) {
- do you have this file
- if you have an unix can you try to convert it in pure unix without carriage return
- or try changing the line 299 of configmanager.php to

Code: Select all

              	$pattern = '/(^#)/';
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
cfybyair
Posts: 27
Joined: Fri Sep 01, 2006 3:33 pm

Post by cfybyair »

HI pepj!

i change the configmanager.php on line 299
but have error also!
like this!

Fatal error: Maximum execution time of 30 seconds exceeded in d:\apache2\apache2\htdocs\cacti\plugins\configmanager\configmanager.php on line 303

so depressed!
:oops:
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

replace again the line 299 like before

Code: Select all

              	$pattern = '/(^#)|( $)/';
and copy the template.txt file below (I converted it to unix format).

try again please
Attachments
template.txt
template in unix format
(3.36 KiB) Downloaded 1097 times
Jean-Michel
cacti 0.8.7e | cmd & cactid (cactid 0.8.x) | Linux | MySQL Ver 14.7 Distrib 4.1.12, for Win32 | PHP v5.2.6 | Apache v2.x | Thold | Plugin Architecture | plugin "configuration manager" http://cactiusers.org/forums/topic257.html | plugin "IP subnet calculator IPv4 / IPV6" http://forums.cacti.net/viewtopic.php?t=15428 | plugin banner http://docs.cacti.net/userplugin:banner | Net-SNMP 5.5.2 | cygwin 1.5.18 of 02.07.2005
cfybyair
Posts: 27
Joined: Fri Sep 01, 2006 3:33 pm

Post by cfybyair »

haha~~~

that's ok!

so great!
TheTick
Posts: 3
Joined: Tue Oct 31, 2006 4:41 pm
Location: Washington

Help with install

Post by TheTick »

Ok, I was able to get through the first three steps.
0/ You will need the plugin-architectur of Jimmy http://cactiusers.org
1/ Only If you want to use the "TFTP" method Install "pancho" www.pancho.org (with perl!!).
2/ copy the plugin under "your_cacti/plugins/configmanager"
3/ create the sql database
- "mysql --user=root --password cacti < your_cacti/plugins/configmanager/configmanager.sql"

But on the fourth step I got this error.

ERROR 1046 (3D000) at line 2: No database selected

Do I need to create a database first?

I
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest