Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

model.h

Go to the documentation of this file.
00001 
00002 /*
00003 ** Copyright (C) 2005 Russell Leighton
00004 **
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 **
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 **
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00020 
00021 #ifndef __AWMODEL__
00022 #define __AWMODEL__
00023 
00024 #include "awsqlite.h"
00025 
00026 #include "monitor.h"
00027 
00029 /*\@{*/
00030 
00031 
00046 typedef struct {
00047 
00048   /* key into aw_user table */
00049   u_int32_t
00050    userid;
00051 
00052   /* read only? */
00053   u_int32_t
00054    ro;
00055 
00056 } aw_model_userhandle_t;
00057 
00058 #define AW_MODEL_NETMESSAGE_DEFAULT_PORT 9999
00059 
00061 typedef enum {
00062   AW_MODEL_INTERFACE_HANDLER = 1,
00063   AW_MODEL_SERVICE_HANDLER,
00064 } aw_model_netmon_class_t;
00065 
00066 
00068 typedef struct aw_model_netmon_s {
00069 
00070   /* linked list */
00071   struct aw_model_netmon_s
00072    *next;
00073 
00074   /* type of handler */
00075   aw_model_netmon_class_t
00076    handler_class;
00077 
00078   /* id in database */
00079   u_int32_t
00080    id;
00081 
00082   /* ptr to handler */
00083   aw_wire_obj_t
00084    *h;
00085 
00086 } aw_model_netmon_t;
00087 
00089 typedef struct {
00090 
00092   byte_t *sql;
00093   
00095   sqlite3_stmt *compiled;
00096 
00097 } aw_model_stmt_t ;
00098 
00100 typedef struct {
00101 
00102   /* options for monitoring */
00103   struct {
00104 
00105     /* network monitoring */
00106     struct {
00107 
00108       /* info for listening for network events */
00109       struct {
00110 
00111         u_int32_t
00112         port;
00113 
00114         aw_ip_addr_t
00115         bind;
00116 
00117       } message;
00118 
00119     } net;
00120 
00121     /* alert processing */
00122     struct {
00123  
00124       /* time limit in minutes before an alert needs escalation (default to 30) */
00125       u_int32_t
00126        timelimit;
00127 
00128     } alert_escalator;
00129 
00130   } sysmon;
00131 
00132 } aw_model_options_t;
00133 
00139 typedef struct {
00140 
00142   aw_monitor_t 
00143    *mon;
00144 
00146   aw_model_userhandle_t 
00147    superuser;
00148 
00149   /* directory structure for persistence */
00150    struct { 
00151 
00152     const byte_t *root; 
00154     const byte_t *log;  
00156     const byte_t *rrd;  
00158   } dirs;
00159 
00160   /* monitoring */
00161   struct {
00162 
00163     /* network monitoring */
00164     struct {
00165 
00166       /* non-zero if network monitoring has been disabled */
00167       u_int32_t disabled; 
00168 
00169       /* info for listening for network events */
00170       struct {
00171 
00172         u_int32_t
00173         port;
00174 
00175         aw_ip_addr_t
00176         bind;
00177 
00178       } message;
00179 
00180       /* masks for all interface and service events */
00181       struct {
00182 
00183         aw_address_t
00184           interface_event,
00185           service_event,
00186           connect_event,
00187           noconnect_event,
00188           upservice_event,
00189           downservice_event,
00190           triptime_event;
00191 
00192       } event_masks;
00193 
00194       /* addresses for other events */
00195       struct {
00196 
00197         aw_address_t
00198           discover_event,
00199           message_event,
00200           mdns_event;
00201 
00202       } event_addr;
00203 
00204       /* process id of discovery process */
00205       int32_t 
00206        discovery_pid;  
00207 
00208       /* run network disovery on a clock */
00209       aw_handler_t
00210        discovery;
00211 
00212       /* takes interface events and updates model */
00213       aw_handler_t
00214        interface_event_rx;
00215 
00216       /* takes service events and updates model */
00217       aw_handlerid_t
00218        mdns_probeid;
00219       aw_handler_t
00220        service_event_rx;
00221 
00222       /* takes mdns events and updates model */
00223       aw_handler_t
00224        mdns_event_rx;
00225 
00226       /* takes message events and updates model */
00227       aw_handler_t
00228        message_event_rx;
00229 
00230       /* list of active handlers */
00231       aw_model_netmon_t
00232        *probes;
00233 
00234     } net;
00235 
00236     /* alert processing */
00237     struct {
00238 
00239       /* time limit in minutes before an alert needs escalation */
00240       u_int32_t
00241        timelimit;
00242  
00243       aw_handler_t
00244        poller;
00245 
00246     } alert_escalator;
00247 
00248   } sysmon;
00249 
00250   /* database info */
00251   struct {
00252 
00253     aw_sqlite_cinfo_t  
00254      cinfo;
00255 
00256     aw_sqlite_state_t  
00257      state;
00258 
00259     /* holds prepared statements */
00260     struct {
00261 #include "model_pstmt.h"
00262     } stmts;
00263 
00264   } db;
00265 
00266 } aw_model_t;
00267 
00271 typedef struct {
00272 
00273   /* handle */
00274   aw_model_userhandle_t handle;
00275 
00276   byte_t loginid[16];
00277   byte_t password[33];
00278   byte_t lastname[16];
00279   byte_t firstname[16];
00280   byte_t notifymode[16];
00281   u_int32_t notify;
00282   u_int32_t active;
00283   u_int32_t deleted;
00284 
00285 } aw_model_user_t;
00286 
00287 
00291 typedef struct aw_model_user_listing_s {
00292 
00293   struct {
00294 
00295     /* iterator: return non-zero on data, 0 on done and -1 on error */
00296     int32_t (*next)(struct aw_model_user_listing_s *);
00297 
00298     /* private */
00299     struct {
00300 
00301       aw_model_t *model;
00302 
00303       u_int32_t deleted; /* if non-zero then return records marked deleted */
00304 
00305     } state;
00306 
00307     /* NOTE: if we want more than 1
00308        of these in flight at a time, 
00309        then the pstmt needs to move
00310        here from the model */
00311 
00312   } iter ;
00313 
00314   struct {
00315     u_int32_t userid;
00316     byte_t loginid[16];
00317     byte_t lastname[16];
00318     byte_t firstname[16];
00319     u_int32_t active;
00320     u_int32_t deleted;
00321   } listing;
00322 
00323 } aw_model_user_listing_t;
00324 
00325 
00329 typedef struct {
00330 
00331   u_int32_t userid; 
00332 
00333   byte_t
00334     street1[51],
00335     street2[51],
00336     city[31],
00337     state[3],
00338     zip[11],
00339     country[16],
00340     homephone[16],
00341     workphone[16],
00342     fax[16],
00343     email[51],
00344     mobile[16],
00345     pager[16],
00346     notes[256];
00347 
00348   u_int32_t id;
00349 
00350 } aw_model_userinfo_t;
00351 
00355 typedef struct {
00356 
00357     u_int32_t groupid;
00358     byte_t name[26];
00359     byte_t desc[256];
00360     u_int32_t deleted;
00361 
00362 } aw_model_group_t;
00363 
00367 typedef struct  aw_model_group_listing_s {
00368 
00369   struct {
00370 
00371     /* iterator: return non-zero on data, 0 on done and -1 on error */
00372     int32_t (*next)(struct aw_model_group_listing_s *);
00373 
00374     /* private */
00375     struct {
00376 
00377       aw_model_t *model;
00378 
00379       u_int32_t deleted; /* if non-zero then return records marked deleted */
00380 
00381     } state;
00382 
00383     /* NOTE: if we want more than 1
00384        of these in flight at a time, 
00385        then the pstmt needs to move
00386        here from the model */
00387 
00388   } iter ;
00389 
00390   aw_model_group_t
00391    listing;
00392 
00393 } aw_model_group_listing_t;
00394 
00395 
00399 typedef struct aw_model_group_slisting_s {
00400 
00401   struct {
00402 
00403     /* iterator: return non-zero on data, 0 on done and -1 on error */
00404     int32_t (*next)(struct aw_model_group_slisting_s *);
00405 
00406     /* private */
00407     struct {
00408 
00409       aw_model_stmt_t *stmt;
00410 
00411       aw_model_t *model;
00412 
00413     } state;
00414 
00415     /* NOTE: if we want more than 1
00416        of these in flight at a time, 
00417        then the pstmt needs to move
00418        here from the model */
00419 
00420   } iter ;
00421 
00422   u_int32_t groupid;
00423   byte_t name[26];
00424 
00425 } aw_model_group_slisting_t;
00426 
00430 typedef struct aw_model_user_slisting_s {
00431 
00432   struct {
00433 
00434     /* iterator: return non-zero on data, 0 on done and -1 on error */
00435     int32_t (*next)(struct aw_model_user_slisting_s *);
00436 
00437     /* private */
00438     struct {
00439 
00440       aw_model_t *model;
00441 
00442     } state;
00443 
00444     /* NOTE: if we want more than 1
00445        of these in flight at a time, 
00446        then the pstmt needs to move
00447        here from the model */
00448 
00449   } iter ;
00450 
00451   u_int32_t userid;
00452   byte_t loginid[16];
00453 
00454 } aw_model_user_slisting_t;
00455 
00456 
00460 typedef struct aw_model_user2group_s {
00461 
00462   struct {
00463 
00464     /* iterator: return non-zero on success, 0 on done and -1 on error */
00465     int32_t (*associate)(struct aw_model_user2group_s *, u_int32_t groupid);
00466 
00467     /* call this when done to commit */
00468     void (*commit)(struct aw_model_user2group_s *);
00469 
00470     /* call this when done to rollback */
00471     void (*rollback)(struct aw_model_user2group_s *);
00472 
00473     /* private */
00474     struct {
00475 
00476       aw_model_t *model;
00477 
00478       u_int32_t userid;
00479 
00480     } state;
00481 
00482     /* NOTE: if we want more than 1
00483        of these in flight at a time, 
00484        then the pstmt needs to move
00485        here from the model */
00486 
00487   } iter ;
00488 
00489 } aw_model_user2group_t;
00490 
00491 
00495 typedef struct aw_model_group2user_s {
00496 
00497   struct {
00498 
00499     /* iterator: return non-zero on success, 0 on done and -1 on error */
00500     int32_t (*associate)(struct aw_model_group2user_s *, u_int32_t groupid);
00501 
00502     /* call this when done to commit */
00503     void (*commit)(struct aw_model_group2user_s *);
00504 
00505     /* call this when done to rollback */
00506     void (*rollback)(struct aw_model_group2user_s *);
00507 
00508     /* private */
00509     struct {
00510 
00511       aw_model_t *model;
00512 
00513       u_int32_t groupid;
00514 
00515     } state;
00516 
00517     /* NOTE: if we want more than 1
00518        of these in flight at a time, 
00519        then the pstmt needs to move
00520        here from the model */
00521 
00522   } iter ;
00523 
00524 } aw_model_group2user_t;
00525 
00526 
00530 typedef struct {
00531 
00532     u_int32_t nodegrpid;
00533     byte_t name[26];
00534     byte_t desc[256];
00535     u_int32_t deleted;
00536 
00537 } aw_model_nodegrp_t;
00538 
00542 typedef struct aw_model_nodegrp_listing_s {
00543 
00544   struct {
00545 
00546     /* iterator: return non-zero on data, 0 on done and -1 on error */
00547     int32_t (*next)(struct aw_model_nodegrp_listing_s *);
00548 
00549     /* private */
00550     struct {
00551 
00552       aw_model_t *model;
00553 
00554       u_int32_t deleted; /* if non-zero then return records marked deleted */
00555 
00556     } state;
00557 
00558     /* NOTE: if we want more than 1
00559        of these in flight at a time, 
00560        then the pstmt needs to move
00561        here from the model */
00562 
00563   } iter ;
00564 
00565   u_int32_t nodegrpid;
00566   byte_t name[65];
00567   u_int32_t outage;
00568   u_int32_t deleted;
00569 
00570 } aw_model_nodegrp_listing_t;
00571 
00575 typedef struct aw_model_node2nodegrp_s {
00576 
00577   struct {
00578 
00579     /* iterator: return non-zero on success, 0 on done and -1 on error */
00580     int32_t (*associate)(struct aw_model_node2nodegrp_s *, u_int32_t nodegrpid);
00581 
00582     /* call this when done to commit */
00583     void (*commit)(struct aw_model_node2nodegrp_s *);
00584 
00585     /* call this when done to rollback */
00586     void (*rollback)(struct aw_model_node2nodegrp_s *);
00587 
00588     /* private */
00589     struct {
00590 
00591       aw_model_t *model;
00592 
00593       u_int32_t nodeid;
00594 
00595     } state;
00596 
00597     /* NOTE: if we want more than 1
00598        of these in flight at a time, 
00599        then the pstmt needs to move
00600        here from the model */
00601 
00602   } iter ;
00603 
00604 } aw_model_node2nodegrp_t;
00605 
00606 
00610 typedef struct aw_model_nodegrp2node_s {
00611 
00612   struct {
00613 
00614     /* iterator: return non-zero on success, 0 on done and -1 on error */
00615     int32_t (*associate)(struct aw_model_nodegrp2node_s *, u_int32_t nodeid);
00616 
00617     /* call this when done to commit */
00618     void (*commit)(struct aw_model_nodegrp2node_s *);
00619 
00620     /* call this when done to rollback */
00621     void (*rollback)(struct aw_model_nodegrp2node_s *);
00622 
00623     /* private */
00624     struct {
00625 
00626       aw_model_t *model;
00627 
00628       u_int32_t nodegrpid;
00629 
00630     } state;
00631 
00632     /* NOTE: if we want more than 1
00633        of these in flight at a time, 
00634        then the pstmt needs to move
00635        here from the model */
00636 
00637   } iter ;
00638 
00639 } aw_model_nodegrp2node_t;
00640 
00644 typedef struct aw_model_node2group_s {
00645 
00646   struct {
00647 
00648     /* iterator: return non-zero on success, 0 on done and -1 on error */
00649     int32_t (*associate)(struct aw_model_node2group_s *, u_int32_t nodeid);
00650 
00651     /* call this when done to commit */
00652     void (*commit)(struct aw_model_node2group_s *);
00653 
00654     /* call this when done to rollback */
00655     void (*rollback)(struct aw_model_node2group_s *);
00656 
00657     /* private */
00658     struct {
00659 
00660       aw_model_t *model;
00661 
00662       u_int32_t nodeid;
00663 
00664     } state;
00665 
00666     /* NOTE: if we want more than 1
00667        of these in flight at a time, 
00668        then the pstmt needs to move
00669        here from the model */
00670 
00671   } iter ;
00672 
00673 } aw_model_node2group_t;
00674 
00675 
00679 typedef struct {
00680   u_int32_t nodeid;
00681   byte_t name[65];
00682   u_int32_t outage;
00683   u_int32_t active;
00684   u_int32_t deleted;
00685 } aw_model_node_t;
00686 
00690 typedef struct {
00691   u_int32_t nodeid;
00692   byte_t username[65];
00693   byte_t nmbname[65];
00694   byte_t snmpname[65];
00695   byte_t mdnsname[65];
00696   byte_t ipname[65];
00697   byte_t desc[256];
00698   u_int32_t active;
00699   u_int32_t deleted;
00700 } aw_model_node_detail_t;
00701 
00705 typedef struct aw_model_node_listing_s {
00706 
00707   struct {
00708 
00709     /* iterator: return non-zero on data, 0 on done and -1 on error */
00710     int32_t (*next)(struct aw_model_node_listing_s *);
00711 
00712     /* private */
00713     struct {
00714 
00715       aw_model_t *model;
00716 
00717       aw_model_stmt_t *query;
00718 
00719       u_int32_t deleted; /* if non-zero then return records marked deleted */
00720 
00721     } state;
00722 
00723     /* NOTE: if we want more than 1
00724        of these in flight at a time, 
00725        then the pstmt needs to move
00726        here from the model */
00727 
00728   } iter ;
00729 
00730   aw_model_node_t
00731    listing;
00732 
00733 } aw_model_node_listing_t;
00734 
00738 typedef struct aw_model_node_slisting_s {
00739 
00740   struct {
00741 
00742     /* iterator: return non-zero on data, 0 on done and -1 on error */
00743     int32_t (*next)(struct aw_model_node_slisting_s *);
00744 
00745     /* private */
00746     struct {
00747 
00748       aw_model_t *model;
00749 
00750     } state;
00751 
00752     /* NOTE: if we want more than 1
00753        of these in flight at a time, 
00754        then the pstmt needs to move
00755        here from the model */
00756 
00757   } iter ;
00758 
00759   u_int32_t nodeid;
00760   byte_t name[65];
00761 
00762 } aw_model_node_slisting_t;
00763 
00767 typedef struct {
00768 
00769     u_int32_t 
00770       nodeid;
00771     byte_t
00772       manufacturer[65],
00773       vendor[65],
00774       modelnumber[65],
00775       serialnumber[65],
00776       circuitid[65],
00777       assetnumber[65],
00778       os[65],
00779       rack[65],
00780       slot[65],
00781       port[65],
00782       region[65],
00783       division[65],
00784       department[65],
00785       address1[256],
00786       address2[256],
00787       city[65],
00788       state[65],
00789       country[65],
00790       zip[65],
00791       building[65],
00792       floor[65],
00793       room[65],
00794       vendorphone[65],
00795       vendorfax[65],
00796       vendoremail[65],
00797       vendorim[65],
00798       vendorurl[65],
00799       vendorassetnumber[65],
00800       dateinstalled[65],
00801       lease[65],
00802       leaseexpires[65],
00803       supportphone[65],
00804       maintcontract[65],
00805       maintcontractexpires[65],
00806       comment[256];  
00807 
00808 } aw_model_nodeasset_t;
00809 
00810 
00811 typedef struct { 
00812 
00813   byte_t prettyname[131];
00814 
00815 } aw_model_interface_name_t;
00816 
00817 /* Calc cron size (worst case):
00818 
00819 min = ( 10 + 50*2 )*2 - 1  + 1 = 220
00820 hr = ( 10 + 14*2 )*2 - 1  + 1 = 76
00821 dom = ( 9 + 22*2 )*2 - 1  + 1 = 106
00822 mon = ( 9 + 3*2 )*2 - 1  + 1 = 30
00823 dow = ( 7 )*2 - 1 = 13
00824 
00825 total = 445 + 1
00826 */
00827 
00828 typedef struct { 
00829 
00830   u_int32_t interfaceid;
00831   aw_model_interface_name_t name;
00832   u_int32_t up;
00833   u_int32_t outage;
00834   u_int32_t snmp;
00835   u_int32_t active;
00836   u_int32_t deleted;
00837 
00838   byte_t ip[65];
00839   byte_t snmp_community[65];
00840   u_int32_t timeout;
00841   u_int32_t cycle;
00842   byte_t handlercron[446]; 
00843   byte_t maintcron[446];
00844   u_int32_t perf;
00845   u_int32_t traffic;
00846 
00847 } aw_model_interface_detail_t;
00848 
00852 typedef struct aw_model_interface_listing_s {
00853 
00854   struct {
00855 
00856     /* iterator: return non-zero on data, 0 on done and -1 on error */
00857     int32_t (*next)(struct aw_model_interface_listing_s *);
00858 
00859     /* private */
00860     struct {
00861 
00862       aw_model_t *model;
00863 
00864       u_int32_t deleted; /* if non-zero then return records marked deleted */
00865 
00866     } state;
00867 
00868     /* NOTE: if we want more than 1
00869        of these in flight at a time, 
00870        then the pstmt needs to move
00871        here from the model */
00872 
00873   } iter ;
00874 
00875   /*
00876   struct {
00877     u_int32_t interfaceid;
00878     aw_model_interface_name_t name;
00879     u_int32_t up;
00880     u_int32_t outage;
00881     u_int32_t snmp;
00882     u_int32_t active;
00883     u_int32_t deleted;
00884     } */
00885 
00886   aw_model_interface_detail_t listing;
00887 
00888 } aw_model_interface_listing_t;
00889 
00893 typedef struct aw_model_interface_netmon_listing_s {
00894 
00895   struct {
00896 
00897     /* iterator: return non-zero on data, 0 on done and -1 on error */
00898     int32_t (*next)(struct aw_model_interface_netmon_listing_s *);
00899 
00900     /* private */
00901     struct {
00902 
00903       aw_model_t *model;
00904 
00905     } state;
00906 
00907     /* NOTE: if we want more than 1
00908        of these in flight at a time, 
00909        then the pstmt needs to move
00910        here from the model */
00911 
00912   } iter ;
00913 
00914   aw_model_interface_detail_t listing;
00915 
00916 } aw_model_interface_netmon_listing_t;
00917 
00918 
00919 typedef struct { 
00920   byte_t prettyname[131];
00921 } aw_model_service_name_t;
00922 
00923 typedef struct {
00924 
00925     u_int32_t serviceid;
00926     aw_model_service_name_t name;
00927     u_int32_t up;
00928     u_int32_t active;
00929     u_int32_t deleted;
00930 
00931     byte_t service[33];
00932     byte_t ip[65];
00933     u_int32_t port;
00934     byte_t proto[33];
00935     byte_t handler[33];
00936     u_int32_t timeout;
00937     u_int32_t cycle;
00938     byte_t handlercron[446];
00939     byte_t maintcron[446];
00940     u_int32_t perf;
00941 
00942 } aw_model_service_detail_t;
00943 
00947 typedef struct aw_model_service_listing_s {
00948 
00949   struct {
00950 
00951     /* iterator: return non-zero on data, 0 on done and -1 on error */
00952     int32_t (*next)(struct aw_model_service_listing_s *);
00953 
00954     /* private */
00955     struct {
00956 
00957       aw_model_t *model;
00958 
00959       u_int32_t deleted; /* if non-zero then return records marked deleted */
00960 
00961     } state;
00962 
00963     /* NOTE: if we want more than 1
00964        of these in flight at a time, 
00965        then the pstmt needs to move
00966        here from the model */
00967 
00968   } iter ;
00969 
00970   aw_model_service_detail_t listing;
00971 
00972 } aw_model_service_listing_t;
00973 
00977 typedef struct aw_model_service_netmon_listing_s {
00978 
00979   struct {
00980 
00981     /* iterator: return non-zero on data, 0 on done and -1 on error */
00982     int32_t (*next)(struct aw_model_service_netmon_listing_s *);
00983 
00984     /* private */
00985     struct {
00986 
00987       aw_model_t *model;
00988 
00989     } state;
00990 
00991     /* NOTE: if we want more than 1
00992        of these in flight at a time, 
00993        then the pstmt needs to move
00994        here from the model */
00995 
00996   } iter ;
00997 
00998   aw_model_service_detail_t listing;
00999 
01000 } aw_model_service_netmon_listing_t;
01001 
01005 typedef struct aw_model_service2port_listing_s {
01006 
01007   struct {
01008 
01009     /* iterator: return non-zero on data, 0 on done and -1 on error */
01010     int32_t (*next)(struct aw_model_service2port_listing_s *);
01011 
01012     /* private */
01013     struct {
01014 
01015       aw_model_t *model;
01016 
01017       u_int32_t deleted; /* if non-zero then return records marked deleted */
01018 
01019     } state;
01020 
01021     /* NOTE: if we want more than 1
01022        of these in flight at a time, 
01023        then the pstmt needs to move
01024        here from the model */
01025 
01026   } iter ;
01027 
01028   struct {
01029     u_int32_t port;
01030     byte_t proto[33];
01031     byte_t service[33];
01032   } listing;
01033 
01034 } aw_model_service2port_listing_t;
01035 
01036 typedef struct {
01037 
01038   byte_t kw[65];
01039   byte_t val[65];
01040   byte_t note[129];
01041 
01042 } aw_model_setting_t;
01043 
01047 typedef struct aw_model_subnet_listing_s {
01048 
01049   struct {
01050 
01051     /* iterator: return non-zero on data, 0 on done and -1 on error */
01052     int32_t (*next)(struct aw_model_subnet_listing_s *);
01053 
01054     /* private */
01055     struct {
01056 
01057       aw_model_t *model;
01058 
01059       u_int32_t deleted; /* if non-zero then return records marked deleted */
01060 
01061     } state;
01062 
01063     /* NOTE: if we want more than 1
01064        of these in flight at a time, 
01065        then the pstmt needs to move
01066        here from the model */
01067 
01068   } iter ;
01069 
01070   struct {
01071     u_int32_t subnetid;
01072     byte_t netmask[65];
01073     u_int32_t active;
01074     u_int32_t deleted;
01075   } listing;
01076 
01077 } aw_model_subnet_listing_t;
01078 
01082 typedef struct aw_model_event_slisting_s {
01083 
01084   struct {
01085 
01086     /* iterator: return non-zero on data, 0 on done and -1 on error */
01087     int32_t (*next)(struct aw_model_event_slisting_s *);
01088 
01089     /* private */
01090     struct {
01091 
01092       aw_model_t *model;
01093 
01094     } state;
01095 
01096     /* NOTE: if we want more than 1
01097        of these in flight at a time, 
01098        then the pstmt needs to move
01099        here from the model */
01100 
01101   } iter ;
01102 
01103   byte_t dt[20];
01104   int32_t type;      // 0 => Down , 1 => Up , -1 => message
01105   byte_t msg[513];
01106 
01107 } aw_model_event_slisting_t;
01108 
01109 
01113 typedef struct aw_model_alert_slisting_s {
01114 
01115   struct {
01116 
01117     /* iterator: return non-zero on data, 0 on done and -1 on error */
01118     int32_t (*next)(struct aw_model_alert_slisting_s *);
01119 
01120     /* private */
01121     struct {
01122 
01123       aw_model_t *model;
01124 
01125     } state;
01126 
01127     /* NOTE: if we want more than 1
01128        of these in flight at a time, 
01129        then the pstmt needs to move
01130        here from the model */
01131 
01132   } iter ;
01133 
01134   byte_t msg[513];
01135 
01136 } aw_model_alert_slisting_t;
01137 
01138 /* --- core.c --- */
01139 
01147 int32_t aw_model_execute_stmt(aw_model_t *model, aw_model_stmt_t *stmt);
01148 
01155 void aw_model_reset_stmt(aw_model_t *model, aw_model_stmt_t *stmt);
01156 
01163 void aw_model_finalize_stmt(aw_model_t *model, aw_model_stmt_t *stmt);
01164 
01174 int32_t aw_model_open(const byte_t *db, aw_monitor_t *mon, const aw_model_options_t *options, aw_model_t *model);
01175 
01181 void aw_model_close(aw_model_t *model);
01182 
01183 /* --- discover.c --- */
01184 
01192 int32_t aw_model_discover(aw_model_t *model, const aw_model_userhandle_t *handle);
01193 
01201 int32_t aw_model_run_discover(aw_model_t *model, const aw_model_userhandle_t *handle);
01202 
01203 
01211 int32_t aw_model_discover_running(aw_model_t *model, const aw_model_userhandle_t *handle);
01212 
01219 void aw_model_schedule_discovery(aw_model_t *model, const aw_model_userhandle_t *handle, const byte_t *mode);
01220 
01221 /* --- auth.c --- */
01222 
01231 const aw_model_userhandle_t * aw_model_authenticate(aw_model_t *model, const byte_t *userid, 
01232                                                     const byte_t *password);
01233 
01243 const aw_model_userhandle_t *aw_model_CHAP(aw_model_t *model, const byte_t *userid, 
01244                                            u_int32_t prefix, const byte_t *response);
01245 
01246 /* --- user.c --- */
01247 
01255 const aw_model_userhandle_t *aw_model_make_handle(u_int32_t userid, u_int32_t ro);
01256 
01262 void aw_model_free_handle(const aw_model_userhandle_t *handle);
01263 
01272 int32_t aw_model_user_create(aw_model_t *model, const aw_model_userhandle_t *handle, const byte_t *loginid);
01273 
01283 int32_t aw_model_user_query(aw_model_t *model, const aw_model_userhandle_t *handle,
01284                             u_int32_t userid, aw_model_user_t *user);
01285 
01295 int32_t aw_model_user_list(aw_model_t *model, const aw_model_userhandle_t *handle,
01296                            u_int32_t deleted, aw_model_user_listing_t *user_listing);
01297 
01306 int32_t aw_model_user_update(aw_model_t *model, const aw_model_userhandle_t *handle,
01307                              const aw_model_user_t *updated_user);
01308 
01318 int32_t aw_model_userinfo_query(aw_model_t *model, const aw_model_userhandle_t *handle,
01319                                 u_int32_t userid, aw_model_userinfo_t *userinfo);
01320 
01329 int32_t aw_model_userinfo_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01330                                  const aw_model_userinfo_t *updated_userinfo);
01331 
01332 /* --- group.c --- */
01333 
01342 int32_t aw_model_group_create(aw_model_t *model, const aw_model_userhandle_t *handle, 
01343                               const byte_t *groupname);
01344 
01354 int32_t aw_model_group_query(aw_model_t *model, const aw_model_userhandle_t *handle,
01355                              u_int32_t groupid, aw_model_group_t *group);
01356 
01366 int32_t aw_model_group_list(aw_model_t *model, const aw_model_userhandle_t *handle,
01367                             u_int32_t deleted, aw_model_group_listing_t *group_listing);
01368 
01378 int32_t aw_model_group_user_slist(aw_model_t *model, const aw_model_userhandle_t *handle,
01379                                   u_int32_t userid, aw_model_group_slisting_t *group_slisting);
01380 
01390 int32_t aw_model_group_notuser_slist(aw_model_t *model, const aw_model_userhandle_t *handle,
01391                                      u_int32_t userid, aw_model_group_slisting_t *group_slisting);
01392 
01402 int32_t aw_model_group_node_slist(aw_model_t *model, const aw_model_userhandle_t *handle,
01403                                   u_int32_t nodeid, aw_model_group_slisting_t *group_slisting);
01404 
01414 int32_t aw_model_group_notnode_slist(aw_model_t *model, const aw_model_userhandle_t *handle,
01415                                      u_int32_t nodeid, aw_model_group_slisting_t *group_slisting);
01416 
01426 int32_t aw_model_user_group_slist(aw_model_t *model, const aw_model_userhandle_t *handle,
01427                                   u_int32_t groupid, aw_model_user_slisting_t *user_slisting);
01428 
01438 int32_t aw_model_user_notgroup_slist(aw_model_t *model, const aw_model_userhandle_t *handle,
01439                                      u_int32_t groupid, aw_model_user_slisting_t *user_slisting);
01440 
01449 int32_t aw_model_group_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01450                               const aw_model_group_t *updated_group);
01451 
01461 int32_t aw_model_user2groups(aw_model_t *model, const aw_model_userhandle_t *handle, 
01462                              u_int32_t userid, aw_model_user2group_t *user2group);
01463 
01464 
01474 int32_t aw_model_group2users(aw_model_t *model, const aw_model_userhandle_t *handle, 
01475                              u_int32_t groupid, aw_model_group2user_t *group2user);
01476 
01477 /* --- node.c --- */
01478 
01487 int32_t aw_model_node_create(aw_model_t *model, const aw_model_userhandle_t *handle, 
01488                              const byte_t *name);
01489 
01499 int32_t aw_model_node_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01500                             u_int32_t nodeid, aw_model_node_detail_t *nodedetail);
01501 
01510 int32_t aw_model_node_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01511                              const aw_model_node_detail_t *updated_nodedetail);
01512 
01521 int32_t aw_model_nodegrp_create(aw_model_t *model, const aw_model_userhandle_t *handle, 
01522                                 const byte_t *name);
01523 
01532 int32_t aw_model_nodegrp_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01533                                 const aw_model_nodegrp_t *updated_nodegrp);
01534 
01544 int32_t aw_model_nodegrp_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01545                                u_int32_t nodegrpid, aw_model_nodegrp_t *nodegrp);
01546 
01556 int32_t aw_model_nodegrp_list(aw_model_t *model, const aw_model_userhandle_t *handle, 
01557                               u_int32_t deleted, aw_model_nodegrp_listing_t *nodegrp_listing);
01558 
01568 int32_t aw_model_node_list(aw_model_t *model, const aw_model_userhandle_t *handle, 
01569                            u_int32_t deleted, aw_model_node_listing_t *node_listing);
01570 
01580 int32_t aw_model_node_outages(aw_model_t *model, const aw_model_userhandle_t *handle, 
01581                               u_int32_t limit, aw_model_node_listing_t *node_listing);
01582 
01593 int32_t aw_model_node_list_by_nodegrp(aw_model_t *model, const aw_model_userhandle_t *handle, 
01594                                       u_int32_t nodegrpid,
01595                                       u_int32_t deleted, aw_model_node_listing_t *node_listing);
01596 
01607 int32_t aw_model_nodegrp2nodes(aw_model_t *model, const aw_model_userhandle_t *handle, 
01608                                u_int32_t append, u_int32_t nodegrpid, 
01609                                aw_model_nodegrp2node_t *nodegrp2node);
01610 
01620 int32_t aw_model_node_nodegrp_slist(aw_model_t *model, const aw_model_userhandle_t *handle, 
01621                                     u_int32_t nodegrpid, aw_model_node_slisting_t *node_slisting);
01622 
01632 int32_t aw_model_node_notnodegrp_slist(aw_model_t *model, const aw_model_userhandle_t *handle, 
01633                                        u_int32_t nodegrpid, aw_model_node_slisting_t *node_slisting);
01634 
01644 int32_t aw_model_nodegrp_apply_active(aw_model_t *model, const aw_model_userhandle_t *handle, 
01645                                       u_int32_t nodegrpid, u_int32_t val);
01646 
01656 int32_t aw_model_nodegrp_apply_deleted(aw_model_t *model, const aw_model_userhandle_t *handle, 
01657                                        u_int32_t nodegrpid, u_int32_t val);
01658 
01668 int32_t aw_model_node2groups(aw_model_t *model, const aw_model_userhandle_t *handle, 
01669                              u_int32_t nodeid, aw_model_node2group_t *node2group);
01670 
01671 
01672 /* --- nodeasset.c --- */
01673 
01683 int32_t aw_model_nodeasset_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01684                                  u_int32_t nodeid, aw_model_nodeasset_t *nodeasset);
01685 
01695 int32_t aw_model_nodeasset_update(aw_model_t *model, const aw_model_userhandle_t *handle,
01696                                   u_int32_t nodeid, const aw_model_nodeasset_t *nodeasset);
01697 
01698 /* --- interface.c --- */
01699 
01709 int32_t aw_model_interface_create(aw_model_t *model, const aw_model_userhandle_t *handle, 
01710                                   u_int32_t nodeid, const byte_t *ip);
01711 
01720 int32_t aw_model_interface_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01721                                   const aw_model_interface_detail_t *updated_interfacedetail);
01722 
01732 int32_t aw_model_interface_name_query(aw_model_t *model, const aw_model_userhandle_t *handle,
01733                                       u_int32_t interfaceid, 
01734                                       aw_model_interface_name_t *interface_name);
01735 
01745 int32_t aw_model_interface_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01746                                  u_int32_t interfaceid, aw_model_interface_detail_t *interfacedetail);
01747 
01758 int32_t aw_model_interface_list_by_node(aw_model_t *model, const aw_model_userhandle_t *handle, 
01759                                         u_int32_t nodeid,
01760                                         u_int32_t deleted, 
01761                                         aw_model_interface_listing_t *interface_listing);
01762 
01771 int32_t aw_model_interface_netmon_list(aw_model_t *model, const aw_model_userhandle_t *handle, 
01772                                        aw_model_interface_netmon_listing_t *interface_netmon_listing);
01773 
01774 /* --- service.c --- */
01775 
01785 int32_t aw_model_service_create(aw_model_t *model, const aw_model_userhandle_t *handle, 
01786                                 u_int32_t interfaceid, const byte_t *service);
01787 
01799 int32_t aw_model_service_unique(aw_model_t *model, const aw_model_userhandle_t *handle, 
01800                                u_int32_t serviceid,  byte_t *ip, u_int32_t port, byte_t *proto);
01801 
01810 int32_t aw_model_service_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01811                                   const aw_model_service_detail_t *updated_servicedetail);
01812 
01822 int32_t aw_model_service_name_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01823                                     u_int32_t serviceid, 
01824                                     aw_model_service_name_t *service_name);
01825 
01835 int32_t aw_model_service_id_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01836                                   const byte_t *ip, u_int32_t port);
01837 
01847 int32_t aw_model_service_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01848                                u_int32_t serviceid, aw_model_service_detail_t *servicedetail);
01849 
01860 int32_t aw_model_service_list_by_interface(aw_model_t *model, const aw_model_userhandle_t *handle, 
01861                                            u_int32_t interfaceid,
01862                                            u_int32_t deleted, aw_model_service_listing_t *service_listing);
01863 
01872 int32_t aw_model_service_netmon_list(aw_model_t *model, const aw_model_userhandle_t *handle, 
01873                                      aw_model_service_netmon_listing_t *service_netmon_listing);
01882 int32_t aw_model_service2port_list(aw_model_t *model, const aw_model_userhandle_t *handle, 
01883                                    aw_model_service2port_listing_t *service2port_listing);
01884 
01885 /* --- settings.c --- */
01886 
01896 int32_t aw_model_settings_query(aw_model_t *model, const aw_model_userhandle_t *handle, 
01897                                 const byte_t *kw, aw_model_setting_t *setting);
01898 
01908 int32_t aw_model_settings_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01909                                  const byte_t *kw, const byte_t *val);
01910 
01911 /* --- subnet.c --- */
01912 
01921 int32_t aw_model_subnet_create(aw_model_t *model, const aw_model_userhandle_t *handle, const byte_t *netmask);
01922 
01932 int32_t aw_model_subnet_list(aw_model_t *model, const aw_model_userhandle_t *handle, 
01933                              u_int32_t deleted, aw_model_subnet_listing_t *subnet_listing);
01934 
01945 int32_t aw_model_subnet_update(aw_model_t *model, const aw_model_userhandle_t *handle, 
01946                                u_int32_t subnetid, u_int32_t active, u_int32_t deleted);
01947 
01948 /* --- event.c --- */
01949 
01961 int32_t aw_model_ia_event_insert(aw_model_t *model, const aw_model_userhandle_t *handle,
01962                                  u_int32_t interface_id, u_int32_t up, 
01963                                  u_int32_t priority, aw_timestamp_t tstamp);
01964 
01977 int32_t aw_model_sa_event_insert(aw_model_t *model, const aw_model_userhandle_t *handle,
01978                                  u_int32_t service_id, u_int32_t up, 
01979                                  const byte_t *type, u_int32_t priority,aw_timestamp_t tstamp);
01980 
01981 
01996 int32_t aw_model_mdns_event_insert(aw_model_t *model, const aw_model_userhandle_t *handle,
01997                                      const byte_t *ip, u_int32_t port, const byte_t *service,
01998                                      const byte_t *protocol, const byte_t *name, u_int32_t up, 
01999                                      u_int32_t priority, aw_timestamp_t tstamp);
02000 
02001 
02013 int32_t aw_model_nm_event_insert(aw_model_t *model, const aw_model_userhandle_t *handle,
02014                                  const byte_t *nodename, const byte_t *msg, 
02015                                  u_int32_t priority,aw_timestamp_t tstamp);
02016 
02026 int32_t aw_model_event_today_slist(aw_model_t *model, const aw_model_userhandle_t *handle, 
02027                                    u_int32_t limit,
02028                                    aw_model_event_slisting_t *event_slisting);
02029 
02030 /* --- alert.c --- */
02031 
02042 int32_t aw_model_interface_alert(aw_model_t *model, const aw_model_userhandle_t *handle,
02043                                  u_int32_t interface_id, u_int32_t up,aw_timestamp_t tstamp);
02044 
02055 int32_t aw_model_service_alert(aw_model_t *model, const aw_model_userhandle_t *handle,
02056                                u_int32_t service_id, u_int32_t up, aw_timestamp_t tstamp);
02057 
02068 int32_t aw_model_message_alert(aw_model_t *model, const aw_model_userhandle_t *handle,
02069                                const byte_t *nodename, const byte_t *msg, aw_timestamp_t tstamp);
02070 
02078 int32_t aw_model_escalate_alert(aw_model_t *model, const aw_model_userhandle_t *handle);
02079 
02090 int32_t aw_model_alert_user_slist(aw_model_t *model, const aw_model_userhandle_t *handle, 
02091                                   u_int32_t user_id, u_int32_t limit,
02092                                   aw_model_alert_slisting_t *alert_slisting);
02093 
02094 /* --- netmon.c --- */
02095 
02103 void aw_model_netmon_remove_probe(aw_model_t *model, 
02104                                   aw_model_netmon_class_t handler_class,
02105                                   u_int32_t id);
02106 
02125 int32_t aw_model_netmon_add_probe_by_name(aw_model_t *model, 
02126                                           aw_model_netmon_class_t handler_class,
02127                                           u_int32_t id,
02128                                           const byte_t *name,
02129                                           const byte_t *ip,
02130                                           u_int32_t port,
02131                                           const byte_t *proto,
02132                                           const byte_t *handler,
02133                                           u_int32_t timeout,
02134                                           u_int32_t cycle,
02135                                           const byte_t *handlercron, 
02136                                           const byte_t *maintcron,
02137                                           u_int32_t perf
02138                                           );
02139 
02145 void aw_model_netmon_init(aw_model_t *model);
02146 
02153 u_int32_t aw_model_netmon_is_disabled(aw_model_t *model);
02154 
02160 void aw_model_netmon_start(aw_model_t *model);
02161 
02167 void aw_model_netmon_stop(aw_model_t *model);
02168 
02174 void aw_model_netmon_restart(aw_model_t *model);
02175 
02181 void aw_model_netmon_clear(aw_model_t *model);
02182 
02183 
02184 /*\@}*/
02185 
02186 #endif
Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)