Roxen.git / server / base_server / snmpagent.pike

version» Context lines:

Roxen.git/server/base_server/snmpagent.pike:1:   /* -  * $Id: snmpagent.pike,v 1.15 2001/08/31 13:07:54 hop Exp $ +  * $Id: snmpagent.pike,v 1.16 2001/09/04 13:26:48 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:23:   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    - default value for snmpagent host/port variable in the config. int.    hasn't set correctly hostname part // FIXME: how reach config.int.'s URL    from define_global_variables ? -  - cold_start trap code isn't completed -  - tabular walking throught roxenis.app.webserver.* doesn't working +     Todos: -  v1.0 todo: -  - cold/warm start trap generation -  - restart/stop -  - 'basic' Roxen working variables +     -  v1.1 todo: -  - trap handling +     - module reloading -  -  v2.0 todo: +     - Roxen.module API for registering MIB subtree    -  v3.0 todo: +     - SNMP v3 -  - security +  - security (DES?)          */      inherit "global_variables";   inherit Roxen;   #define roxen roxenp()         
Roxen.git/server/base_server/snmpagent.pike:90:   // The starting part of OID of every object will have, so we stripp it out   // before making index from OID to the MIB DB   #define MIBTREE_BASE "1.3.6.1"      #define RISMIB_BASE_ADD "4.1.8614"   // enterprises.roxenis   #define RISMIB_BASE MIBTREE_BASE+"."+RISMIB_BASE_ADD   #define RISMIB_BASE_WEBSERVER_ADD "1.1"   // enterprises.roxenis.app.roxen   #define RISMIB_BASE_WEBSERVER RISMIB_BASE+"."+RISMIB_BASE_WEBSERVER_ADD + //   // enterprises.roxenis.app.webserver.global   #define RISMIB_BASE_WEBSERVER_GLOBAL RISMIB_BASE_WEBSERVER+".1"   // enterprises.roxenis.app.webserver.global.restart   #define RISMIB_BASE_WEBSERVER_GLOBAL_BOOT RISMIB_BASE_WEBSERVER_GLOBAL+".1"   // enterprises.roxenis.app.webserver.global.vsCount   #define RISMIB_BASE_WEBSERVER_GLOBAL_VS RISMIB_BASE_WEBSERVER_GLOBAL+".2" -  + //   // enterprises.roxenis.app.webserver.vsTable   #define RISMIB_BASE_WEBSERVER_VS RISMIB_BASE_WEBSERVER+".2"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsIndex   #define RISMIB_BASE_WEBSERVER_VS_INDEX RISMIB_BASE_WEBSERVER_VS+".1.1"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsName   #define RISMIB_BASE_WEBSERVER_VS_NAME RISMIB_BASE_WEBSERVER_VS+".1.2"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsDescription   #define RISMIB_BASE_WEBSERVER_VS_DESC RISMIB_BASE_WEBSERVER_VS+".1.3"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsSent   #define RISMIB_BASE_WEBSERVER_VS_SDATA RISMIB_BASE_WEBSERVER_VS+".1.4"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsReceived   #define RISMIB_BASE_WEBSERVER_VS_RDATA RISMIB_BASE_WEBSERVER_VS+".1.5"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsHeaders   #define RISMIB_BASE_WEBSERVER_VS_SHDRS RISMIB_BASE_WEBSERVER_VS+".1.6"   // enterprises.roxenis.app.webserver.vsTable.vsEntry.vsRequests   #define RISMIB_BASE_WEBSERVER_VS_REQS RISMIB_BASE_WEBSERVER_VS+".1.7" -  + // + // enterprises.roxenis.app.webserver.trap + #define RISMIB_BASE_WEBSERVER_TRAP RISMIB_BASE_WEBSERVER+".3" + // enterprises.roxenis.app.webserver.trap.vsColdTrap + #define RISMIB_BASE_WEBSERVER_TRAP_VSCOLD RISMIB_BASE_WEBSERVER_TRAP+".1"      #define LOG_EVENT(txt, pkt) log_event(txt, pkt)      #if !efunc(Array.oid_sort_func)   int oid_sort_func(string a0,string b0) {    string a2="",b2="";    int a1, b1;    sscanf(a0,"%d.%s",a1,a2);    sscanf(b0,"%d.%s",b1,b2);    if (a1>b1) return 1;
Roxen.git/server/base_server/snmpagent.pike:383:    }       //! 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"] && sizeof(vsdb[vsid]->variables["snmp_traphosts"]->query())) { +  if(vsdb[vsid] && vsdb[vsid]->variables["snmp_traphosts"] && +  sizeof(vsdb[vsid]->variables["snmp_traphosts"]->query())) {    SNMPAGENT_MSG(sprintf("server %O(#%d): traphosts:%O",    vsdb[vsid]->name, vsid,    vsdb[vsid]->variables["snmp_traphosts"]->query()));    foreach(vsdb[vsid]->variables["snmp_traphosts"]->query(), mixed thost) { -  uri = Standards.URI(thost); +  if(catch(uri = Standards.URI(thost))) { +  SNMPAGENT_MSG(sprintf("Traphost is invalid: %s !", thost)); +  continue; // FIXME: what about possibility to add some warnings? +  }    SNMPAGENT_MSG(sprintf("Trap sent: %s", thost)); - /* + #if 1    fd->trap( -  ([RISMIB_BASE_WEBSERVER+".999.1.1": -  ({ "str", Standards.URI(vsdb[vsid]->variables["MyWorldLocation"]->query())->host}) ]), +  ([RISMIB_BASE_WEBSERVER_TRAP_VSCOLD: +  ({ "count", vsid }) ]), +  //({ "str", Standards.URI(vsdb[vsid]->variables["MyWorldLocation"]->query())->host}) ]),    uri->host, uri->port); - */ + #endif    }    } else    if(vsdb[vsid])    SNMPAGENT_MSG(sprintf("server %O(#%d) hasn't any traphosts.",    vsdb[vsid] && vsdb[vsid]->name, vsid));       }       //! Warm start notificator    void warmstart_trap() {
Roxen.git/server/base_server/snmpagent.pike:693:       //! 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.15 $"/" ")[1]+" (devel. rel.)"); +  return OBJ_STR("Roxen Webserver SNMP agent v"+("$Revision: 1.16 $"/" ")[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);