plugin for download/upload routers switches configuration

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
User avatar
brononi
Cacti User
Posts: 123
Joined: Tue Aug 29, 2006 1:58 am
Location: Belgium
Contact:

Re: plugin for download/upload routers switches configuratio

Post by brononi »

When i use the telnetdownloadunix script on my linux cacti server, i got a small issue.

- For one device, it works. My first router is backupped normally.
- But when i've got several devices, it goes wrong. From the second one, the backup only shows 'building configuration'. And this is so for all following backups in that group. So only my first one is correct.

Any idea what's going on?
  • Cacti: 0.8.8f / Plugin Architecture Version: 3.1 / Linuxbased
  • Third Party: Apache 2.4.12 / PHP 5.6.11 / NET-SNMP version 5.3.2.2 / RRDTool 1.5.4
  • Plugins: Configmanager 0.826 / Aggregate 0.70B2 / Manage 0.6.2 / Weathermap 0.97a / Thold 0.4.9 / Quicktree 0.2 / Realtime 0.5 / Settings 0.7
  • Data:Host 1341 / Graphs 6752
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Re: plugin for download/upload routers switches configuratio

Post by pepj »

brononi wrote:When i use the telnetdownloadunix script on my linux cacti server, i got a small issue.
- For one device, it works. My first router is backupped normally.
- But when i've got several devices, it goes wrong. From the second one, the backup only shows 'building configuration'. And this is so for all following backups in that group. So only my first one is correct.
Any idea what's going on?
1/ first try from shell to start for one 'unlucky' device
./telnetdownloadunix host_or_ip user password file_to_create 4
and look at the created file
2/ perhaps temp file conflict. To correct it change all 'temp' into 'temp$1' in order to have different temp files per each device.

PS: in the new release I will offer new scripts' versions with more options and logfile and the integrations of new or own scripts will be very easy.
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
User avatar
brononi
Cacti User
Posts: 123
Joined: Tue Aug 29, 2006 1:58 am
Location: Belgium
Contact:

Re: plugin for download/upload routers switches configuratio

Post by brononi »

pepj wrote:2/ perhaps temp file conflict. To correct it change all 'temp' into 'temp$1' in order to have different temp files per each device.
Great, is working perfectly with this.

For the moment, my script (telnetdownloadunix.sh) is like:

Code: Select all

#!/bin/sh
(echo "$2"; echo "$3"; echo "term len 0"; echo "show run"; echo "exit"; sleep $5
) | telnet $1 > temp$1
csplit -k -f temp temp$1 '/show run/'
rm -f temp$1
if test -f temp00 ; then rm -f temp00; fi
if test ! -f temp01 ; then exit; fi
echo mv temp01 $4
mv temp01 $4
pepj wrote: PS: in the new release I will offer new scripts' versions with more options and logfile and the integrations of new or own scripts will be very easy.
Can't wait! We're battling with other backup programs (infovista, rma...), but seems like cacti is winning. So if i can prove now that cacti can handle every device we want... ;)
  • Cacti: 0.8.8f / Plugin Architecture Version: 3.1 / Linuxbased
  • Third Party: Apache 2.4.12 / PHP 5.6.11 / NET-SNMP version 5.3.2.2 / RRDTool 1.5.4
  • Plugins: Configmanager 0.826 / Aggregate 0.70B2 / Manage 0.6.2 / Weathermap 0.97a / Thold 0.4.9 / Quicktree 0.2 / Realtime 0.5 / Settings 0.7
  • Data:Host 1341 / Graphs 6752
ceyounger
Posts: 44
Joined: Fri Feb 10, 2006 2:59 pm
Location: Orange County, CA
Contact:

Re: plugin for download/upload routers switches configuratio

Post by ceyounger »

In addition to dos2unix, I had to modify the SQL statements to change "TYPE=MyISAM" to "ENGINE=MyISAM"

Just an FYI. :)
armstrongzhao
Posts: 28
Joined: Mon Feb 02, 2009 10:21 am
Location: CHINA

Re: plugin for download/upload routers switches configuratio

Post by armstrongzhao »

Hi, I want to download the configuration file of MOTO CMTS. Follow the telnetdownloadunix.sh, I made my script telnetdownloadmotocmtsunix.sh:
#!/bin/sh

( echo "$2"; echo "en"; echo "$3"; echo "copy running-conf tftp://10.2.7.104/${1}.cfg"; sleep 13; echo "exit"; sleep 2) | telnet $1

The template is telnet-download-moto-cmts-unix.

In the data parameters:
Command: %g%/configmanager/scripts/telnetdownloadmotocmtsunix.sh %n% %w% %o%

precommand: [ ! -d /var/lib/tftpboot/moto-cmts%y%%m%%d% ] && mkdir /var/lib/tftpboot/moto-cmts%y%%m%%d%

post command: mv /var/lib/tftpboot/%n%.%y%%m%%d%.cfg /var/lib/tftpboot/moto-cmts%y%%m%%d%

My script purpose is to download the configuration file to the tftpserver. The password and enable password should be right. I executed telnetdownloadmotocmtsunix.sh manually. It works fine, the cmts configuration file can be downloaded to the tftpserver. However the script does not work in the plugin. I even can not read any login event from the cmts log.

The log:
2011-11-08 17:10:02 CFG MANAGER: DEBUG: post command 'mv /var/lib/tftpboot/10.160.255.3.20111108.cfg /var/lib/tftpboot/moto-cmts20111108' return ->OK

2011-11-08 17:10:02 CFG MANAGER: DEBUG: exec_background(/var/www/html/cacti/plugins/configmanager/configmanager/scripts/telnetdownloadmotocmtsunix.sh 10.160.255.3 *** ***) for following hosts:10.160.255.3

2011-11-08 17:10:01 CFG MANAGER: DEBUG: pre command ' [ ! -d /var/lib/tftpboot/moto-cmts20111108 ] && mkdir /var/lib/tftpboot/moto-cmts20111108' return ->OK

2011-11-08 17:10:01 CFG MANAGER: DEBUG: createconfig for Moto_CMTS_configmanager(configid=3)!

2011-11-08 17:10:01 CFG MANAGER: INFO: execute Script method configuration 3 (Moto_CMTS_configmanager).

08/11/2011 17:10:01 CFG MANAGER: INFO: Database synchronisation. result=OK for UPDATE plugin_cfgmng_data SET hostip='10.160.255.3' WHERE (configmanagerid=3) AND (hostname='10.160.255.3');

08/11/2011 17:10:01 CFG MANAGER: INFO: Database synchronisation. result=OK for UPDATE plugin_cfgmng_data,host SET plugin_cfgmng_data.hostname=host.hostname WHERE ((plugin_cfgmng_data.hostid>0) AND (plugin_cfgmng_data.configmanagerid=3) AND (plugin_cfgmng_data.hostid=host.id));

08/11/2011 17:10:01 CFG MANAGER: INFO: Database synchronisation. result=OK for UPDATE plugin_cfgmng_data,host SET plugin_cfgmng_data.description=host.description WHERE ((plugin_cfgmng_data.hostid>0) AND (plugin_cfgmng_data.configmanagerid=3) AND (plugin_cfgmng_data.hostid=host.id));
thuanngo
Posts: 1
Joined: Mon Oct 26, 2009 8:37 am
Contact:

Re: I can't download config file of switch!

Post by thuanngo »

pepj wrote:
ddonohue wrote:#/cacti-0.8.6h/plugins/configmanager/scripts/telnetdownloadunix.sh ip address /var/depot/target.cfg
missing operand
You need more parameters to test this script.
all parameters are important, the sleep is very important, one of my secrets for this script.

/cacti-0.8.6h/plugins/configmanager/scripts/telnetdownloadunix.sh ipaddress_or_hostname user password /var/depot/target.cfg timeforsleep

I tried it under linux.

PS: But in the template.txt I put "(windows)" and "(unix)" one time on the wrong place. It should be behind "help=" like this -->

name=sftp-firewall-putty-windows
command=pscp -l %u% -pw %w% -sftp %n%:TMP/* %p%/%y%%m%%d%/
help=(windows) Here an example for secure FTP SFTP with pscp of putty.

name=telnet-cisco-unix
command=%g%/configmanager/scripts/telnetdownloadunix.sh %n% %u% %w% /var/depot/%n%.cfg 4
help=(unix) download with Telnet of the running-config of a Cisco router. The last parameter is for sending a sleep in order to wait for the logging. The parameters are: the router, user, password and destinationsfile.

Here attached is the right template.txt file

Hi pepj,

- I'm following guide u. Try it command

Code: Select all

[root@Log-10 scripts]#  sh telnetdownload-auto-unix.sh 10.0.0.46 admin 12345 10.0.0.46.conf 4
Connection closed by foreign host.
988
124
mv temp01 1.0.0.46.conf
- On switch is added command

Code: Select all

username admin autocommand show running-config
- This is my result of file 10.0.0.46.conf.

Code: Select all

2960-CAMERA-F8>show running-config
                     ^
% Invalid input detected at '^' marker.

2960-CAMERA-F8>exit
- I can't download config file of switch!
Please help me! :cry: :cry:
robertol1971
Posts: 6
Joined: Wed Jan 04, 2012 2:59 pm
Location: Rosario, Santa Fe, Argentina

Re: plugin for download/upload routers switches configuratio

Post by robertol1971 »

Hi pepj !
I have the next problem.

I need to backup the config of variuos mikrotik hosts at weekly periods, with the plugin Configmanager

The log of activity in the file cfgmng_logfile.txt is:
2012-04-12 18:10:08 CFG MANAGER: INFO: execute Script method configuration 2 (backupMikrotik).
2012-04-12 18:10:09 CFG MANAGER: DEBUG: exec_background(lftp -u admin,*** -e "get today.backup -o /var/backups/Mikrotik/192.168.175.1-12-04-2012.backup; bye" 192.168.175.1) for following hosts:192.168.175.1

The command works perfect from the cacti box command line.
I run the lftp sentence and the .backup file is created succesfully.
But i dont know why don´t work from inside the plugin interface.

The script in the file template.txt is:
name=lftp-mikrotik-linux
command=lftp -u %u%,%w% -e "get today.backup -o /var/backups/Mikrotik/%n%-%d%-%m%-%y%.backup; bye" %i%
help=(linux) XXXX XXXX XXXX XXX

I have chmoded to 777 the directory /var/backups/Mikrotik/ too.

Any ideas ?

Thanks in advance !
__________________________
Roberto Longo
Rosario - Santa Fe - Argentina
TikPov
Posts: 3
Joined: Fri Jul 22, 2011 6:31 am

Re: plugin for download/upload routers switches configuratio

Post by TikPov »

I'm using this plugin for testing upload speed of uplink from Cisco router to some server. The problem is that plugin timeout script after 20 seconds, even file upload has not finished jet.
If I start script manualy from shell, file upload ends succesfully.

Where is this 20 seconds value?
jimmy123
Posts: 5
Joined: Tue Aug 21, 2012 5:36 am

Re: plugin for download/upload routers switches configuratio

Post by jimmy123 »

All,

I have an issue with the compare funtion under linux.

All is fine when I use 2 plain text files, but
It doesn't work very well when you want to compare 2 .gz files.
the left pane is always empty, and the file that the pane refers to (f1_4.txt), does not exist anymore.

Can anyone help me.

jimmy
jimmy123
Posts: 5
Joined: Tue Aug 21, 2012 5:36 am

Re: plugin for download/upload routers switches configuratio

Post by jimmy123 »

All,

After I removed (commented out) lines 371 throu 374 in the compare.php files, it seems to work better.

lines:
//jim if (is_file($tempdir."/f1"."_".$_SESSION["sess_user_id"].".txt"))
// unlink($tempdir."/f1"."_".$_SESSION["sess_user_id"].".txt");
// if (is_file($tempdir."/f2"."_".$_SESSION["sess_user_id"].".txt"))
// unlink($tempdir."/f2"."_".$_SESSION["sess_user_id"].".txt");

I'm not a php wizzard, so can anyone tell me if this will break things?

Jim
User avatar
vesparossa
Posts: 6
Joined: Fri Apr 04, 2014 3:31 am

Re: plugin for download/upload routers switches configuratio

Post by vesparossa »

Hi guys,

since I got several problems to pass username and password to some devices I suggest to pass $2 and $3 arguments (username and password) using echo command with -e and force a carriage return with \r

Example:
echo -e "$2\r";

Final result is:

#!/bin/sh
(echo -e "$2\r"; echo -e "$3\r"; echo -e "term len 0\r"; echo -e "show run\r"; echo "exit"; sleep $5
) | telnet $1 > temp$1
echo temp$1
csplit -k -f temp temp$1 '/User login successful./'
rm -f temp$1
if test -f temp00 ; then rm -f temp00; fi
if test ! -f temp01 ; then exit; fi
echo mv temp01 $4
mv temp01 $4


Andre
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests