Roxen.git / server / base_server / snmpagent.pike

version» Context lines:

Roxen.git/server/base_server/snmpagent.pike:1:   /* -  * $Id: snmpagent.pike,v 1.5 2001/07/18 21:10:04 hop Exp $ +  * $Id: snmpagent.pike,v 1.6 2001/07/19 20:23:02 hop Exp $    *    * The Roxen SNMP agent    * Copyright © 2001, Roxen IS.    *    * Author: Honza Petrous    * January 2001         RFC 1213 base MIB    system.* (all done)
Roxen.git/server/base_server/snmpagent.pike:20:   RFC 2576 Coexistence between v1, v2 and v3 of SNMP protocol   RFC 2594 Definitions of managed objects for WWW services      Developer notes:       Known issues:    - every reload spawne a new thread, I guess that old ones are never    used then. [threads leak] // FIXME: solved by switching to the async i/o    - the OID must be minimally 5 elements long, otherwise GETNEXT return    "no such name" error -  - the tree walking returns the 'end of MIB' instead of some object -  from next subtree +     Todos:    v1.0 todo:    - cold/warm start trap generation    - 'basic' Roxen working variables       v1.1 todo:    - trap handling       v2.0 todo:    - Roxen.module API for registering MIB subtree
Roxen.git/server/base_server/snmpagent.pike:117:       void create() {    vsdb = ([]);    //disable();    }       //! Enable SNMPagent processing.    int enable() {       mib = SubMIBsystem(); // system.* table -  if(objectp(mib)) // snmp.* table -  //mib->register(MIBTREE_BASE+"."+"2.1.11", SubMIBsnmp(this_object())); - { object mib2 = SubMIBsnmp(this_object()); +  if(objectp(mib)) { +  // snmp.*    mib->register(MIBTREE_BASE+"."+"2.1.11", SubMIBsnmp(this_object())); -  +  // enterprises.roxenis.* +  mib->register(MIBTREE_BASE+"."+"4.1.8614", SubMIBroxenis(this_object()));   }    if (!status())    start();    enabled = 1;    return (enabled);    }       //! Disable SNMPagent processing.    int disable() {   
Roxen.git/server/base_server/snmpagent.pike:318:       //! Cold start notificator. Sends trap for all virtual servers in the vsarr.    void coldstart_trap(array(int) vsarr) {       object uri;       if(intp(vsarr))    return;    foreach(vsarr, int vsid)    if(vsdb[vsid] && vsdb[vsid]->variables["snmp_traphosts"]) { -  SNMPAGENT_MSG(sprintf("virt.serv[%d/%s]'s traphosts:%O", vsid, vsdb[vsid]->name, vsdb[vsid]->variables["snmp_traphosts"])); +  SNMPAGENT_MSG(sprintf("virt.serv[%d/%s]'s traphosts:%O", vsid, +  vsdb[vsid]->name, vsdb[vsid]->variables["snmp_traphosts"]));    foreach(vsdb[vsid]->variables["snmp_traphosts"], string thost) {    uri = Standards.URI(thost);    SNMPAGENT_MSG(sprintf("Trap sent: %s.", thost));    fd->trap(RISMIB_BASE_WEBSERVER, -  Standards.URI(vsdb[vsid]->varibles["MyWorldLocation"])->host, 0, 0, +  Standards.URI(vsdb[vsid]->varibles["MyWorldLocation"])->host, +  0, 0,    get_uptime(), 0, uri->host, uri->port);    }    } else -  SNMPAGENT_MSG(sprintf("virt.serv[%d/%s] hasn't any traphosts.", vsid, vsdb[vsid]->name)); +  if(vsdb[vsid]) +  SNMPAGENT_MSG(sprintf("virt.serv[%d/%O] hasn't any traphosts.", +  vsid, vsdb[vsid] && vsdb[vsid]->name));       }       //! Warm start notificator    void warmstart_trap() {       }       //! Authentication failure notificator    void authfailure_trap() {
Roxen.git/server/base_server/snmpagent.pike:538:       //! External function for MIB object returning nothing    array get_null() { return OBJ_COUNT(0); }      } // SubMIBManager      // base external feeders      //! External function for MIB object 'system.sysDescr'   array get_description() { -  return OBJ_STR("Roxen Webserver SNMP agent v"+("$Revision: 1.5 $"/" ")[1]+" (devel. rel.)"); +  return OBJ_STR("Roxen Webserver SNMP agent v"+("$Revision: 1.6 $"/" ")[1]+" (devel. rel.)");   }      //! External function for MIB object 'system.sysOID'   array get_sysoid() {    return OBJ_OID(RISMIB_BASE_WEBSERVER);   }      //! External function for MIB object 'system.sysUpTime'   array get_uptime() {    return OBJ_TICK((time(1) - roxen->start_time)*100);
Roxen.git/server/base_server/snmpagent.pike:684:    // snmp.snmpOutTraps    "2.1.11.29.0": get_null,    // snmp.snmpEnableAuthenTraps    "2.1.11.30.0": agent->get_snmpenaauth,       ]);       }   }    - /* -  // enterprises -  "4.1": ({ 0, get_null, "4.1.8614.1.1.999.1.0" }), -  // enterprises.roxenIS -  "4.1.8614": ({ 0, get_null, "4.1.8614.1.1.999.1.0" }), -  // enterprises.roxenIS.app -  "4.1.8614.1.1": ({ 0, get_null, "4.1.8614.1.1.999.1.0" }), -  // enterprises.roxenIS.app.webserver -  "4.1.8614.1.1": ({ 0, get_null, "4.1.8614.1.1.999.1.0" }), -  // HACK!! -  "4.1.8614.1.1.999.1.0": ({ 0, get_null, 0 }), + //! roxenis enterprise subtree manager + //! Manages the enterprise.roxenis.* submib tree. + class SubMIBroxenis {    -  // hack2 :) -  "4.1.8614.1.1.999.2.1.0": ({ "int", get_virtserv, "4.1.8614.1.1.999.2.2.0" }) +  inherit SubMIBManager;    - */ +  constant name = "roxenis"; +  constant tree = "4.1.8614";    -  +  void create(object agent) { +  +  submibtab = ([ +  // enterprises +  // hack2 :) +  "4.1.8614.1.1.999.2.1.0": agent->get_virtserv +  ]); +  } + } +    /*    switch (attrname) {    case RISMIB_BASE_WEBSERVER+".1.0":    // HACK! For testing purpose only!    // Server restart = 1; server shutdown = 2    if(chk_access("rw", pdata[msgid])) {    setflg = 1;    rdata[attrname] += ({ "int", attrval });    rdata["1.3.6.1.2.1.1.3.0"] += ({"tick", get_uptime() });    if(attrval == 1 || attrval == 2) {