plugin for download/upload routers switches configuration

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

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

Post by pepj »

1/
kos wrote:Adding a host to a config results in 2 entries (see attachment)
Removing a host of a config results in eliminating both hosts entries
please copy again the release 0.5e or 0.5f. Perhaps you inserted a command twice ... with all manually changes we had done before. (an indication is we can see the same host id)
I have installed a new test server without this problem ....

2/
kos wrote: Assume, you added a single device to several configs. If you remove such host in ONE dedicated config, the host gets removed in ALL configs
Yes you find a bug !!! .... I upload the new version 0.5f .... otherwise
please correct in configmanager_edit.php line 154 and 154

Code: Select all

			$t = db_fetch_assoc("select gorder from $cfgmngtable_data where configmanagerid=$configid and hostid = $id");
			$temp = db_fetch_assoc("delete from $cfgmngtable_data where configmanagerid=$configid and hostid ='$id'");
you should have

Code: Select all

function template_delete($configid,$configname) {
 global $cfgmngtable_basis,$cfgmngtable,$cfgmngtable_data;
	foreach($_POST as $t=>$v) {
		if (substr($t, 0,4) == "chk_") {
			$id = substr($t, 4);
			//if ($id<0) $id=-$id;
			$t = db_fetch_assoc("select gorder from $cfgmngtable_data where configmanagerid=$configid and hostid = $id");
			$temp = db_fetch_assoc("delete from $cfgmngtable_data where configmanagerid=$configid and hostid ='$id'");
			if (sizeof($t) > 0) {
			  order_remove ($t[0]['gorder'],$configid,$configname);
			}
		}
	}
	Header("Location: configmanager_edit.php?action=edit&configid=$configid&name=$configname");
	exit;
}

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
knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

Post by knobdy »

So for the comparison security configuration, it should be something like /tmp/depot ??


This plugin is doing very well now - I'm hoping I can dump my current system. Question is, is there a way to add to this plugin so that it downloads a config after a device sends it an snmp config trap? ;)
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

knobdy wrote:So for the comparison security configuration, it should be something like /tmp/depot ?
I don't understand your problem ? When you do not give a path in this file you/the user can browse the whole server . If you fix one path, you give only the permission to browse under this path ...
knobdy wrote:is there a way to add to this plugin so that it downloads a config after a device sends it an snmp config trap? ;)
I wanted to do that in combination with haloe/syslog. The problem is each vendor, sometimes hardware-type send other traps, but I cannot gather all traps ... perhaps can I let the possibility to the user to insert/add his list of the traps which can be allowed ...

PS: at this time I have created a network-class vendor and hardware independant for SNMP requests (like TFTP, VLAN, MACs, CPU, ...) in order to work without PERL or extern program and really vendor independant (I am fighting against the vendors which don't like to publish theirs mibs).
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
knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

Post by knobdy »

pepj wrote:I don't understand your problem ? When you do not give a path in this file you/the user can browse the whole server . If you fix one path, you give only the permission to browse under this path ...
I was asking where the downloaded configs go, since that's the most likely place I'd want to provide access to.
pepj wrote:I wanted to do that in combination with haloe/syslog. The problem is each vendor, sometimes hardware-type send other traps, but I cannot gather all traps ... perhaps can I let the possibility to the user to insert/add his list of the traps which can be allowed ...
For me, that would be quite excellent.

I've also seen mention of the use of a code repository (versioning and all of that) - is this built into the plugin or just implemented by the user based on where you choose to download the config files and then going outside of Cacti altogether to place those files into, for instance, subversion?
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Post by pepj »

knobdy wrote:I was asking where the downloaded configs go, since that's the most likely place I'd want to provide access to.
for the method TFTP: the path field in the config (but because TFTP can only place it on a subfolder, you have to use sometimes the POST command
for the method MULTI: in the path field in the config.
knobdy wrote:I've also seen mention of the use of a code repository (versioning and all of that) - is this built into the plugin or just implemented by the user based on where you choose to download the config files and then going outside of Cacti altogether to place those files into, for instance, subversion?
When you use the "multi" method you have the possibility to use either your scripts or the default scripts. I have prepared telnet with subversion, but you can optimize it or adapt the ssh/scp script.
PS: you can click on the help after you choosed a template(script) to show more information or tips.
I like the method "multi" because you need neither TFTP nor to configure SNMP nor need perl module for downloading and you can secure it with ssh/SCP.
I think I've solved all problems with telnet and SSH in these scripts (It was sometimes very tricky [like telnet on unix and window], but at the end I 've solved it).

PS: with TFTP method and subversion the problem is TFTP is asynchrone. Therefore when you insert your subversion commands/scripts in the POST command it could be that the file is not completly downloaded .... when subversion starts
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
torstentfk
Cacti User
Posts: 367
Joined: Tue Apr 05, 2005 9:52 am
Location: Munich, Germany

upgrade to cacti J with config manager fails

Post by torstentfk »

Hello developer,

Upgrading cacti from i to j fails if you have the plugin configmanager running:

Code: Select all


Warning: include_once(../lib/data_query.php) [function.include-once]: failed to open stream: No such file or directory in /cacti/install/index.php on line 309

Warning: include_once() [function.include]: Failed opening '../lib/data_query.php' for inclusion (include_path='.:/soft_php-5.1.4/lib/php') in /cacti/install/index.php on line 309

Warning: include_once(../lib/utility.php) [function.include-once]: failed to open stream: No such file or directory in /cacti/install/index.php on line 310

Warning: include_once() [function.include]: Failed opening '../lib/utility.php' for inclusion (include_path='.:/soft_php-5.1.4/lib/php') in /cacti/install/index.php on line 310

Warning: Cannot modify header information - headers already sent by (output started at /cacti/install/index.php:309) in /cacti/install/index.php on line 321

Fatal error: Call to undefined function repopulate_poller_cache() in /cacti/install/index.php on line 335
If I disable temporarly this plugin update procedure runs fine; after this I can reactivate the plugin and now error is there.

Could you please check the behavior?

Torsten
PS: I have folowing plugins in config.php

Code: Select all

$plugins = array();
$plugins[] = 'thold';
$plugins[] = 'manage';
$plugins[] = 'uptime';
$plugins[] = 'mactrack';
$plugins[] = 'haloe';
$plugins[] = 'aggregate';
/*$plugins[] = 'configmanager';*/
$plugins[] = 'ipsubnet';
$plugins[] = 'tools';
$plugins[] = 'pollperf';
$plugins[] = 'update';
$plugins[] = 'killspike';
$plugins[] = 'dataquery';
$plugins[] = 'hostinfo';
$plugins[] = 'cycle';
$plugins[] = 'passwd';
$plugins[] = 'rrdclean';
$plugins[] = 'reports';
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

Re: upgrade to cacti J with config manager fails

Post by pepj »

torstentfk wrote:Hello developer,

Upgrading cacti from i to j fails if you have the plugin configmanager running:

Code: Select all

Warning: include_once(../lib/data_query.php) [function.include-once]: failed to open stream: No such file or directory in /cacti/install/index.php on line 309
Warning: include_once() [function.include]: Failed opening '../lib/data_query.php' for inclusion (include_path='.:/soft_php-5.1.4/lib/php') in /cacti/install/index.php on line 309
.....
Fatal error: Call to undefined function repopulate_poller_cache() in /cacti/install/index.php on line 335
If I disable temporarly this plugin update procedure runs fine; after this I can reactivate the plugin and now error is there.
Could you please check the behavior?
1/ did you install cacti 0.8.j without architecture and only after that copied the new pluginarchitecture for 0.8.j ? In this way I'vnt got any error messages.

2/ which error message do you get now (after the install) and configmanager.
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
torstentfk
Cacti User
Posts: 367
Joined: Tue Apr 05, 2005 9:52 am
Location: Munich, Germany

Post by torstentfk »

Hi,

installation way:
- fresh download cacti-j, copied prepatched files from plugin arch over j files
- changed config.php to recognize the plugins I have installed
- normal upgrade procedure via web browser
The the error occurs.
Disabling this plugin removes the error so that cacti could write all changes to the db. Then I enabled all plugins an no error occurs at any time.

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

Post by pepj »

torstentfk wrote:Hi,
installation way:
- fresh download cacti-j, copied prepatched files from plugin arch over j files
- changed config.php to recognize the plugins I have installed
- normal upgrade procedure via web browser
The the error occurs.
Disabling this plugin removes the error so that cacti could write all changes to the db. Then I enabled all plugins an no error occurs at any time.
I am usually do the install before copying the pluginarchitecture files .... and do not get any errors ... .

(I don't know why the install shows these errors during the installation. My setup.php use only full path. It seems the $config["base_path"] and $config["library_path"] would not be ready or would be empty at this time or the installation do a directory change. )
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
pepj
Cacti User
Posts: 324
Joined: Thu Sep 29, 2005 5:03 am
Location: switzerland

new release 0.6 with traps & syslog

Post by pepj »

I post the new release 0.6

20.03.2007 add some template for cisco and Foundry scp download
11.02.2007 add of traps events starting the download of configuration
11.02.2007 change of format of dates in the logs to "Y-m-d H:i:s"



Next developpement (0.7):
- pure PHP TFTP upload/download (no need of pancho)
(the code exist already since a while but I had no time to test it).
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
zheka
Posts: 44
Joined: Tue May 23, 2006 11:52 am

Configmanager v6, what to do next, missing something

Post by zheka »

Hi folks, hi pepj!

I'm stuck with this plugin and don't know what to do and where to look at.
Pancho, plugin architecture and configmanager v6 are installed. Everythinkg looks all right. I use TFTP method to download configs.
Let's put it step by step so that it could be clearly seen where I'm wrong.

I click on manage configs and then press Add and then choose Pancho method. Then I fill out all the fields starting with the name of Config scheduler name as the name of the device

Let's say:
Config scheduler name Switch02
Date: 2007-04-10 12:50
TFTP server: localhost
direction: download
path for configurations files: /var/tftp
path for the data: /var/tftp
fileformat for the downloaded file: ::HOST::.::DATE::.cfg
pre command in pancho: blank
post command in pancho: blank
snmp version: Version 1
community: xxxxxxxx
when: Mon, Tue, Wen, Thu, Fri, Sat, Sun
Accept events: checked
active rule: active

Then I click Create and since I have a mactrack plugin I can check the IP address of the CISCO device in question. I check it and click "Go" next to the "Add to the config"

Having it done, I see the button and the line on top of the page: show final configuration file=/var/tftp/Switch02id6.conf
If I click on it I see the blank page with
Listing of the config /var/tftp/Switch02id6.conf header.

What's next? If I click again on the "manage configs" button I see that the config Switch02 was created and it is active, its "last run time" is 2007-04-10 13:06:11

How and when will it download the config file from my CISCO switch. Why I never see the Switch02id6.conf file

Please advise me where I am wrong and what I should do next?

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

Re: Configmanager v6, what to do next, missing something

Post by pepj »

zheka wrote: TFTP server: localhost
1/ + localhost is not possible because the switch/router will try to use localhost as tftp server ... it is itself and will do no download ... insert an IP which can be reached from switch.
+ because the plugin tried already to execute the config file, you have to reset it . Select (check) the configuration (in the view "config up/down-load-->manage configs") and choose the action "reset" instead "delete" and push "Go" button.

2/ if you active "Accept events" (download after traps enabled) you have to :
- install syslog
- active globally the trap events (in the setting Tabs)
- check the traps the plugin has to react: in menu "config up/down-load-->trap events"
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 »

Pepji,

Well, i've done a little bit of hacking, and it was fun!.

Anyways. Here's a hack on your telnetdownloadunix.sh designed for the old AAA system.


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



_____________________________________________________________

This was how i was running it.

<path_to_cacti>/plugins/configmanager/scripts/telnetdownloadunix-oldauth.sh <target> <login> <enable> /var/depot/<target>.cfg 15


______________________________________________________________

One thing I noticed is that in the .sh scripts for unix you simply use temp. I suggest that you do what i did above with your other unix scripts. Since unix will fire up all of the processes at a time it will try to write all of your parts to the same file. Which causes bad problems as it writes all of the sources to the same file and it wigs out. The fix i had to do to make the unix scp stuff work via the poller is what i did above on the other script.

This works great on routers and switches. I did however find 1 problem with this. Firewalls and ASA's don't support the term length 0 that we had talked about prior in regards to how to get this to work.

Other then that, i can make it work via command line without problem and the running the command line by hand did the trick as well. So i'll take this as a good sign.


Donohue
Last edited by ddonohue on Tue Apr 10, 2007 8:06 pm, edited 2 times in total.
zheka
Posts: 44
Joined: Tue May 23, 2006 11:52 am

Re: Configmanager v6, what to do next, missing something

Post by zheka »

Thanks Jean-Michel for a prompt reply!

1/ + localhost is not possible because the switch/router will try to use localhost as tftp server ... it is itself and will do no download ... insert an IP which can be reached from switch.

It's done, I mean changed to the public IP of the cacti host.

2/ if you active "Accept events" (download after traps enabled) you have to :

And I deactivated "Accept events" for now to have it as simple as possible.

Still nothing shows up at the tftp root directory (in my case it is /var/tftp).
Where can I check for errors or any poller problems regarding this plugin? The logfile (config up/down-load -> logfile) is empty, no switch02.conf files

And just noticed that the last run time stuck at the 2007-04-10 15:16:08 and doesn't change. Will it be changed the next day?

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

Re: Configmanager v6, what to do next, missing something

Post by pepj »

zheka wrote: And just noticed that the last run time stuck at the 2007-04-10 15:16:08 and doesn't change. Will it be changed the next day?

But you can reset the first time (explained post before) in order to start after 5 minutes and download the first time.
(if you don't want to wait : php yourdirectoryinlowercases/plugins/configmanager/configmanager_poller.php -d)
Yes, it will try each days because you 've select it
zheka wrote: no switch02.conf files
Do you really have no /var/tftp/switch02.conf?
- check the read/write rights
- In the "manage config view" when you click on the name of the config, you should see the hosts for this config and when you click on "show final configuration file"-ICON you should see the /var/tftp/switch02.conf that will be used by pancho.
- check the "configuration-->settings-->Up/Download TAB". Do you have insert "TFTP path" and "program" parameters (example windows program="pathperl/bin/perl.exe -Ipath/pancho/lib path/pancho/pancho.pl"

How to check pancho at the command line:
...perl\bin\perl.exe -I...\pancho\lib ...\pancho\modules\blib\lib\pancho.pl --download --config ....\tftp\data\yourconfig.conf

PS: have a look at the first posts http://forums.cacti.net/viewtopic.php?t ... c&start=15 and other pages
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
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests