Roxen.git / server / base_server / configuration.pike

version» Context lines:

Roxen.git/server/base_server/configuration.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //      // @appears Configuration   //! A site's main configuration    - constant cvs_version = "$Id: configuration.pike,v 1.640 2007/09/14 11:23:36 grubba Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.641 2007/11/05 15:16:35 grubba Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>   #include <request_trace.h>   #include <timers.h>      #define CATCH(P,X) do{mixed e;if(e=catch{X;})report_error("While "+P+"\n"+describe_backtrace(e));}while(0)      // --- Locale defines ---   //<locale-token project="roxen_start"> LOC_S </locale-token>
Roxen.git/server/base_server/configuration.pike:492:   /* A 'pri' is one of the ten priority objects. Each one holds a list    * of modules for that priority. They are all merged into one list for    * performance reasons later on.    */      array (Priority) allocate_pris()   {    return allocate(10, Priority)();   }    - // SNMP MIB for this configuration. - ADT.Trie mib = ADT.Trie(); - int mib_version; -  +    array(int) query_oid()   { -  return SNMP.RIS_OID_WEBSERVER + -  ({ 2 }); +  return SNMP.RIS_OID_WEBSERVER + ({ 2 });   }      //! @returns   //! Returns an array with two elements:   //! @array   //! @item array(int) oid   //! @item array(int) oid_suffix   //! @endarray   array(int) generate_module_oid_segment(RoxenModule me)   {
Roxen.git/server/base_server/configuration.pike:526:    array(int) oid_suffix,    RoxenModule me,    ModuleInfo moduleinfo,    ModuleCopies module)   {    array(int) segment = generate_module_oid_segment(me);    return SNMP.SimpleMIB(oid,    oid_suffix + segment,    ({    UNDEFINED, -  SNMP.Integer(segment[-1]), +  SNMP.Integer(segment[-1], "moduleCopy"),    SNMP.String(otomod[me],    "moduleIdentifier"),    SNMP.Integer(moduleinfo->type,    "moduleType"),    SNMP.String(me->cvs_version || "",    "moduleVersion"),    }));   }      // Cache some configuration variables.
Roxen.git/server/base_server/configuration.pike:3254:    1024, 65536 );    // and new connections does not even have to care.    throttler = 0;    }      #ifdef SNMP_AGENT    if(query("snmp_process") && objectp(roxen->snmpagent))    roxen->snmpagent->add_virtserv(get_config_id());   #endif    +  foreach(registered_urls, string url) { +  mapping(string:string|Configuration|Protocol) port_info = roxen.urls[url]; +  +  foreach((port_info && port_info->ports) || ({}), Protocol prot) { +  if ((prot->prot_name != "snmp") || (!prot->mib)) { +  continue;    }    -  +  string path = port_info->path || ""; +  if (has_prefix(path, "/")) { +  path = path[1..]; +  } +  if (has_suffix(path, "/")) { +  path = path[..sizeof(path)-2]; +  } +  +  array(int) oid_suffix = ({ sizeof(path), @((array(int))path) }); +  +  ADT.Trie mib = +  SNMP.SimpleMIB(query_oid(), oid_suffix, +  ({ +  UNDEFINED, +  UNDEFINED, +  SNMP.String(query_name, "siteName"), +  SNMP.String(comment, "siteComment"), +  SNMP.Counter64(lambda() { return sent; }, +  "sent"), +  SNMP.Counter64(lambda() { return received; }, +  "received"), +  SNMP.Counter64(lambda() { return hsent; }, +  "sentHeaders"), +  SNMP.Counter64(lambda() { return requests; }, +  "numRequests"), +  UNDEFINED, // NOTE: Reserved for modules! +  })); +  SNMP.set_owner(mib, this_object()); +  prot->mib->merge(mib); +  } +  } + } +    void save_me()   {    save_one( 0 );   }      void save(int|void all)   //! Save this configuration. If all is included, save all configuration   //! global variables as well, otherwise only all module variables.   {    if(all)
Roxen.git/server/base_server/configuration.pike:3774:       if(module_type & MODULE_LAST)    pri[pr]->last_modules += ({ me });       if(module_type & MODULE_FILTER)    pri[pr]->filter_modules += ({ me });       if(module_type & MODULE_FIRST)    pri[pr]->first_modules += ({ me });    -  array(int) oid_suffix = ({ query("snmp_site_id") }); -  mib->merge(generate_module_mib(query_oid() + ({ 8, 1 }), oid_suffix, -  me, moduleinfo, module)); +  foreach(registered_urls, string url) { +  mapping(string:string|Configuration|Protocol) port_info = roxen.urls[url]; +  +  foreach((port_info && port_info->ports) || ({}), Protocol prot) { +  if ((prot->prot_name != "snmp") || (!prot->mib)) { +  continue; +  } +  +  string path = port_info->path || ""; +  if (has_prefix(path, "/")) { +  path = path[1..]; +  } +  if (has_suffix(path, "/")) { +  path = path[..sizeof(path)-2]; +  } +  +  array(int) oid_suffix = ({ sizeof(path), @((array(int))path) }); +  +  ADT.Trie sub_mib = generate_module_mib(query_oid() + ({ 8, 1 }), +  oid_suffix, me, moduleinfo, module); +  SNMP.set_owner(sub_mib, this_object(), me); +  +  prot->mib->merge(sub_mib); +     if (me->query_snmp_mib) {    array(int) segment = generate_module_oid_segment(me); -  mib->merge(me->query_snmp_mib(query_oid() + ({ 8, 2 }) + +  sub_mib = me->query_snmp_mib(query_oid() + ({ 8, 2 }) +    segment[..sizeof(segment)-2], -  oid_suffix + ({ segment[-1] }))); +  oid_suffix + ({ segment[-1] })); +  SNMP.set_owner(sub_mib, this_object(), me); +  prot->mib->merge(sub_mib);    } -  mib_version++; +  } +  }       invalidate_cache();   }      void call_high_start_callbacks (RoxenModule me, ModuleInfo moduleinfo,    void|int newly_added)   {    // This is icky, but I don't know if it's safe to remove. /mast    if(!me) return;    if(!moduleinfo) return;
Roxen.git/server/base_server/configuration.pike:3916:    pri[pr]->filter_modules -= ({ me });       if( moduleinfo->type & MODULE_FIRST ) {    for(pr=0; pr<10; pr++)    pri[pr]->first_modules -= ({ me });    }       if( moduleinfo->type & MODULE_LOGGER )    for(pr=0; pr<10; pr++)    pri[pr]->logger_modules -= ({ me }); +  +  foreach(registered_urls, string url) { +  mapping(string:string|Configuration|Protocol) port_info = roxen.urls[url]; +  foreach((port_info && port_info->ports) || ({}), Protocol prot) { +  if ((prot->prot_name != "snmp") || (!prot->mib)) { +  continue;    }    -  +  SNMP.remove_owned(prot->mib, this_object(), me); +  } +  } + } +    int disable_module( string modname, int|void nodest )   {    MODULE_LOCK (2);    RoxenModule me;    int id, pr;    sscanf(modname, "%s#%d", modname, id );       if( datacache ) datacache->flush();       ModuleInfo moduleinfo = roxen.find_module( modname );
Roxen.git/server/base_server/configuration.pike:5000:   // report_debug("[defvar: %.1fms] ", (gethrtime()-st)/1000.0 );   // st = gethrtime();       mapping(string:mixed) retrieved_vars = retrieve("spider#0", this_object());    if (sizeof (retrieved_vars) && !retrieved_vars->compat_level)    // Upgrading an older configuration; default to 2.1 compatibility level.    set ("compat_level", "2.1");    setvars( retrieved_vars );      // report_debug("[restore: %.1fms] ", (gethrtime()-st)/1000.0 ); -  -  // FIXME: The default value ought to be stable. -  defvar("snmp_site_id", sizeof(roxen->configurations)+1, -  DLOCALE(0, "SNMP: Site id"), TYPE_INT, -  DLOCALE(0, "OID suffix to 1.3.6.1.4.1.8614.1.1.2 " -  "identifying this site.")); -  -  // FIXME: The following should move to a stage where -  // the config variables have been loaded. -  mib->merge(SNMP.SimpleMIB(query_oid(), ({ query("snmp_site_id") }), -  ({ -  UNDEFINED, -  UNDEFINED, -  query_name, -  comment, -  SNMP.Counter64(lambda() { return sent; }), -  SNMP.Counter64(lambda() { return received; }), -  SNMP.Counter64(lambda() { return hsent; }), -  SNMP.Counter64(lambda() { return requests; }), -  UNDEFINED, // NOTE: Reserved for modules! -  }))); -  mib_version++; +    }      static int arent_we_throttling_server () {    return !query("throttle");   }   static int arent_we_throttling_request() {    return !query("req_throttle");   }      #ifdef SNMP_AGENT   private static int(0..1) snmp_disabled() {    return (!snmp_global_disabled() && !query("snmp_process"));   }   private static int(0..1) snmp_global_disabled() {    return (!objectp(roxen->snmpagent));   }   #endif