Branch: Tag:

2001-06-26

2001-06-26 23:18:14 by Honza Petrous <hop@unibase.cz>

Core of a SNMP agent.
It's working only with -DSNMP_AGENT.

The same MIB 'core' as before:

- system group
- snmp group (only snmp.snmpInPkts and snmp.snmpOutPkts)
- roxenis.app.webserver group [enterprises.8614.1.1]
(only demonstartion of reboot/restart by SNMP_SET in the enterprises.8614.1.1.1.0 with value 1/2)

Rev: server/base_server/global_variables.pike:1.72
Rev: server/base_server/roxen.pike:1.678
Rev: server/base_server/snmpagent.pike:1.2

6:   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.677 2001/06/26 09:41:40 per Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.678 2001/06/26 23:18:14 hop Exp $";      // The argument cache. Used by the image cache.   ArgCache argcache;
22:      // Inherits   inherit "global_variables"; + #ifdef SNMP_AGENT + inherit "snmpagent"; + #endif   inherit "hosts";   inherit "disk_cache";   // inherit "language";
426:    exit(-1); // Restart.    }    + #ifdef SNMP_AGENT +  if(objectp(snmpagent)) +  snmpagent->disable(); + #endif +     catch(stop_all_configurations());    destruct(cache);   
3793:    name_thread( backend_thread, "Backend" );   #endif /* THREADS */    + #ifdef SNMP_AGENT +  //SNMPagent start +  report_notice("SNMPagent configuration checking ... "); +  if(query("snmp_agent")) { +  // enabling SNMP agent +  snmpagent = SNMPagent(); +  snmpagent->enable(); +  report_notice("enabled.\n"); +  +  } else +  report_notice("disabled.\n"); + #endif // SNMP_AGENT +     // Signals which cause a restart (exitcode != 0)    foreach( ({ "SIGINT", "SIGTERM" }), string sig)    catch( signal(signum(sig), async_sig_start(exit_when_done,0)) );
3837:    else    remove_call_out(restart);    break; +  + #ifdef SNMP_AGENT +  case "snmp_agent": +  if (value && !snmpagent) { +  report_notice("SNMPagent enabling ...\n"); +  snmpagent = SNMPagent(); +  snmpagent->enable();    } -  +  if (!value && objectp(snmpagent)) { +  report_notice("SNMPagent disabling ...\n"); +  snmpagent->disable(); +  snmpagent = 0;    } -  +  break; + #endif // SNMP_AGENT    -  +  } + } +    int is_ip(string s)   {    return (sscanf(s,"%*d.%*d.%*d.%*d")==4 && s[-1]>47 && s[-1]<58);