And actually the SNMP command at the bottom is supposed to be on one
line .... the first OID to set the enable password is not needed to grab
a config, only the RW community. 
So in my actual script I only have what is necessary to grab the config:

<?
/* This file is part of JFFNMS
 * Copyright (C) <2002-2005> Javier Szyszlican <[EMAIL PROTECTED]>
 * This program is licensed under the GNU GPL, full terms in the LICENSE
file
 */

    // FOUNDRY-SN-AGENT-MIB Configuration Downloader Implementation
    //  successful (1), processing (18), timeout (6), bad access (11),
file-not-found (10)

    function config_fdry_cc_get ($ip, $rwcommunity, $server, $filename)
{

        if ($ip && $rwcommunity && $server && $filename) {
            $oid = ".1.3.6.1.4.1.1991.1.1.2.1";
            $result = snmp_set($ip,
$rwcommunity,"$oid.9.0","i","22"); //destroy

            if ($result==true) {
                snmp_set($ip,$rwcommunity,"$oid.5.0","a",
$server); //server 
                snmp_set($ip,$rwcommunity,"$oid.8.0","s",
$filename); //filename
                snmp_set($ip,
$rwcommunity,"$oid.9.0","i","22"); //activate the process
                            
                sleep (2);
            
                $result = snmp_get($ip,$rwcommunity,"$oid.9.0");
                if ($result != 1) return true;

            }
        }
        var_dump(debug_backtrace());
        return false;
    }

    function config_fdry_cc_wait ($ip, $rwcommunity, $server, $filename)
{
        $i = 1;
        $result = 1;
        $oid = ".1.3.6.1.4.1.1991.1.1.2.1";
        while (($result == 1) and ($i++ < 30)) { 
            $result = snmp_get($ip,$rwcommunity,"$oid.9.0");
            sleep(2); 
        }
        if (($result == 1) or (preg_match("/^successful/",$result)))
return true; 
        return false;
    }

?>





On Tue, 2007-07-03 at 15:30 -0400, Jeffrey Singleton wrote:

> Hello everyone,
> 
> I created a Host_Config get script using CISCO-CONFIG-COPY-MIB as a
> template.
> 
> I added a vardump after the first function in order to find out why it
> was not able to create the file?
> Are the snmp version and rw community name supposed to be a part of
> the same string?
> 
> Here is the vardump output:
> 
> 
> $ php tftp_get_host_config.php 
> 
> array(2) {
>   [0]=>
>   array(2) {
>     ["function"]=>
>     string(18) "config_fdry_cc_get"
>     ["args"]=>
>     array(4) {
>       [0]=>
>       &string(13) "192.168.19.19"
>       [1]=>
>       &string(9) "v2:ts_ops"
>       [2]=>
>       &string(13) "192.168.19.20"
>       [3]=>
>       &string(17) "468ada66070d0.dat"
>     }
>   }
>   [1]=>
>   array(4) {
>     ["file"]=>
>     string(55) "/usr/local/share/jffnms/engine/tftp_get_host_config.php"
>     ["line"]=>
>     int(49)
>     ["function"]=>
>     string(20) "call_user_func_array"
>     ["args"]=>
>     array(2) {
>       [0]=>
>       &string(18) "config_fdry_cc_get"
>       [1]=>
>       &array(4) {
>         [0]=>
>         string(13) "192.168.19.19"
>         [1]=>
>         string(9) "v2:ts_ops"
>         [2]=>
>         string(13) "192.168.19.20"
>         [3]=>
>         string(17) "468ada66070d0.dat"
>       }
>     }
>   }
> }
> 19:23:20  :  H   2 : 192.168.19.19 : fdry_cc : Error Getting File (2028.31 
> msec)
> 19:23:24  :  H   3 : 192.168.19.17 : cisco_cc : OK same config as last one 
> (2) (4231.06 msec)
> 19:23:24 TIMES  : Total Time 6269.8 msec.
> 
> As you can see the cisco switch has no problem downloading the config and 
> completing the task.
> 
> Anyway .. here is the working SNMP string that when run from command-line, 
> does download the config, as long as the path/file is already created and 
> writable:
> 
>       
> 
> snmpset -v2c -c private switch .1.3.6.1.4.1.1991.1.1.2.1.15.0 s
> enable .1.3.6.1.4.1.1991.1.1.2.1.5.0 a
> 127.0.0.1 .1.3.6.1.4.1.1991.1.1.2.1.8.0 s
> subdir/targetfile .1.3.6.1.4.1.1991.1.1.2.1.9.0 i 22 
> 
> 
> 
> -- 
> Jeffrey Singleton
> Network Systems Administrator (Trusted Source)
> Secure Computing Corporation
> 48000 North Point Parkway
> Alpharetta, GA 30022
> C: +1 770-820-2909
> O: +1 678-904-3694
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________ jffnms-users mailing list 
> jffnms-users@lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/jffnms-users

-- 
Jeffrey Singleton
Network Systems Administrator (Trusted Source)
Secure Computing Corporation
48000 North Point Parkway
Alpharetta, GA 30022
C: +1 770-820-2909
O: +1 678-904-3694
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
jffnms-users mailing list
jffnms-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jffnms-users

Reply via email to