From fe9d8f21bbdfb442b8233b4627a0c67dc458a8bd Mon Sep 17 00:00:00 2001 From: Joshua Tolley Date: Fri, 26 Nov 2010 10:22:01 -0700 Subject: [PATCH 1/1] Import from CVS --- APPLICATION-MIB | 441 ++ COPYRIGHT | 22 + KNOWNBUG.txt | 1 + Makefile | 50 + .../pgsnmpdTables/pgsnmpdConnectionsTable.c | 129 + .../pgsnmpdTables/pgsnmpdConnectionsTable.h | 198 + .../pgsnmpdConnectionsTable_data_access.h | 56 + .../pgsnmpdConnectionsTable_data_get.c | 279 + .../pgsnmpdConnectionsTable_data_get.h | 65 + .../pgsnmpdConnectionsTable_data_set.c | 24 + .../pgsnmpdConnectionsTable_data_set.h | 27 + .../pgsnmpdConnectionsTable_enums.h | 40 + .../pgsnmpdConnectionsTable_interface.c | 707 +++ .../pgsnmpdConnectionsTable_interface.h | 72 + .../pgsnmpdConnectionsTable_oids.h | 30 + .../pgsqlPgAggregateTable.c | 129 + .../pgsqlPgAggregateTable.h | 221 + .../pgsqlPgAggregateTable_data_access.c | 297 ++ .../pgsqlPgAggregateTable_data_access.h | 70 + .../pgsqlPgAggregateTable_data_get.c | 839 +++ .../pgsqlPgAggregateTable_data_get.h | 72 + .../pgsqlPgAggregateTable_data_set.c | 24 + .../pgsqlPgAggregateTable_data_set.h | 27 + .../pgsqlPgAggregateTable_enums.h | 40 + .../pgsqlPgAggregateTable_interface.c | 784 +++ .../pgsqlPgAggregateTable_interface.h | 72 + .../pgsqlPgAggregateTable_oids.h | 33 + .../pgsqlPgAmTable/pgsqlPgAmTable.c | 129 + .../pgsqlPgAmTable/pgsqlPgAmTable.h | 306 ++ .../pgsqlPgAmTable_data_access.c | 312 ++ .../pgsqlPgAmTable_data_access.h | 70 + .../pgsqlPgAmTable/pgsqlPgAmTable_data_get.c | 2289 +++++++++ .../pgsqlPgAmTable/pgsqlPgAmTable_data_get.h | 107 + .../pgsqlPgAmTable/pgsqlPgAmTable_data_set.c | 24 + .../pgsqlPgAmTable/pgsqlPgAmTable_data_set.h | 27 + .../pgsqlPgAmTable/pgsqlPgAmTable_enums.h | 178 + .../pgsqlPgAmTable/pgsqlPgAmTable_interface.c | 903 ++++ .../pgsqlPgAmTable/pgsqlPgAmTable_interface.h | 72 + .../pgsqlPgAmTable/pgsqlPgAmTable_oids.h | 50 + .../pgsqlPgAmopTable/old/pgsqlPgAmopTable.c | 316 ++ .../pgsqlPgAmopTable/old/pgsqlPgAmopTable.h | 24 + .../pgsqlPgAmopTable/pgsqlPgAmopTable.c | 329 ++ .../pgsqlPgAmopTable/pgsqlPgAmopTable.h | 24 + .../tmp/pgsqlPgAggregateTable.c | 254 + .../tmp/pgsqlPgAggregateTable.h | 23 + RDBMS-MIB | 1420 ++++++ RDBMS-MIB_src/rdbmsDbInfoTable/README | 1 + .../rdbmsDbInfoTable/rdbmsDbInfoTable.c | 123 + .../rdbmsDbInfoTable/rdbmsDbInfoTable.h | 223 + .../rdbmsDbInfoTable_data_access.c | 418 ++ .../rdbmsDbInfoTable_data_access.h | 77 + .../rdbmsDbInfoTable_data_get.c | 847 ++++ .../rdbmsDbInfoTable_data_get.h | 70 + .../rdbmsDbInfoTable/rdbmsDbInfoTable_enums.h | 76 + .../rdbmsDbInfoTable_interface.c | 716 +++ .../rdbmsDbInfoTable_interface.h | 50 + .../rdbmsDbInfoTable/rdbmsDbInfoTable_oids.h | 39 + .../rdbmsDbLimitedResourceTable.c | 130 + .../rdbmsDbLimitedResourceTable.h | 224 + .../rdbmsDbLimitedResourceTable_data_access.c | 307 ++ .../rdbmsDbLimitedResourceTable_data_access.h | 64 + .../rdbmsDbLimitedResourceTable_data_get.c | 868 ++++ .../rdbmsDbLimitedResourceTable_data_get.h | 71 + .../rdbmsDbLimitedResourceTable_data_set.c | 30 + .../rdbmsDbLimitedResourceTable_data_set.h | 34 + .../rdbmsDbLimitedResourceTable_enums.h | 47 + .../rdbmsDbLimitedResourceTable_interface.c | 747 +++ .../rdbmsDbLimitedResourceTable_interface.h | 50 + .../rdbmsDbLimitedResourceTable_oids.h | 40 + .../rdbmsDbParamTable/rdbmsDbParamTable.c | 130 + .../rdbmsDbParamTable/rdbmsDbParamTable.h | 214 + .../rdbmsDbParamTable_data_access.c | 394 ++ .../rdbmsDbParamTable_data_access.h | 77 + .../rdbmsDbParamTable_data_get.c | 732 +++ .../rdbmsDbParamTable_data_get.h | 65 + .../rdbmsDbParamTable_data_set.c | 30 + .../rdbmsDbParamTable_data_set.h | 34 + .../rdbmsDbParamTable_enums.h | 47 + .../rdbmsDbParamTable_interface.c | 739 +++ .../rdbmsDbParamTable_interface.h | 50 + .../rdbmsDbParamTable_oids.h | 38 + RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.c | 124 + RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.h | 220 + .../rdbmsDbTable/rdbmsDbTable_data_access.c | 377 ++ .../rdbmsDbTable/rdbmsDbTable_data_access.h | 64 + .../rdbmsDbTable/rdbmsDbTable_data_get.c | 763 +++ .../rdbmsDbTable/rdbmsDbTable_data_get.h | 66 + .../rdbmsDbTable/rdbmsDbTable_data_set.c | 517 ++ .../rdbmsDbTable/rdbmsDbTable_data_set.h | 77 + .../rdbmsDbTable/rdbmsDbTable_enums.h | 47 + .../rdbmsDbTable/rdbmsDbTable_interface.c | 1238 +++++ .../rdbmsDbTable/rdbmsDbTable_interface.h | 50 + .../rdbmsDbTable/rdbmsDbTable_oids.h | 46 + RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.c | 130 + RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.h | 205 + .../rdbmsRelTable/rdbmsRelTable_data_access.c | 322 ++ .../rdbmsRelTable/rdbmsRelTable_data_access.h | 77 + .../rdbmsRelTable/rdbmsRelTable_data_get.c | 378 ++ .../rdbmsRelTable/rdbmsRelTable_data_get.h | 63 + .../rdbmsRelTable/rdbmsRelTable_data_set.c | 30 + .../rdbmsRelTable/rdbmsRelTable_data_set.h | 34 + .../rdbmsRelTable/rdbmsRelTable_enums.h | 76 + .../rdbmsRelTable/rdbmsRelTable_interface.c | 712 +++ .../rdbmsRelTable/rdbmsRelTable_interface.h | 50 + .../rdbmsRelTable/rdbmsRelTable_oids.h | 35 + RDBMS-MIB_src/rdbmsSrvInfoTable/README | 1 + .../rdbmsSrvInfoTable/rdbmsSrvInfoTable.c | 127 + .../rdbmsSrvInfoTable/rdbmsSrvInfoTable.h | 262 + .../rdbmsSrvInfoTable_data_access.c | 340 ++ .../rdbmsSrvInfoTable_data_access.h | 77 + .../rdbmsSrvInfoTable_data_get.c | 1429 ++++++ .../rdbmsSrvInfoTable_data_get.h | 86 + .../rdbmsSrvInfoTable_data_set.c | 30 + .../rdbmsSrvInfoTable_data_set.h | 34 + .../rdbmsSrvInfoTable_enums.h | 47 + .../rdbmsSrvInfoTable_interface.c | 777 +++ .../rdbmsSrvInfoTable_interface.h | 50 + .../rdbmsSrvInfoTable_oids.h | 47 + RDBMS-MIB_src/rdbmsSrvLimitedResource/README | 11 + .../rdbmsSrvLimitedResource.h | 14 + .../rdbmsSrvParamTable/rdbmsSrvParamTable.c | 130 + .../rdbmsSrvParamTable/rdbmsSrvParamTable.h | 214 + .../rdbmsSrvParamTable_data_access.c | 308 ++ .../rdbmsSrvParamTable_data_access.h | 64 + .../rdbmsSrvParamTable_data_get.c | 726 +++ .../rdbmsSrvParamTable_data_get.h | 66 + .../rdbmsSrvParamTable_data_set.c | 30 + .../rdbmsSrvParamTable_data_set.h | 34 + .../rdbmsSrvParamTable_enums.h | 47 + .../rdbmsSrvParamTable_interface.c | 743 +++ .../rdbmsSrvParamTable_interface.h | 50 + .../rdbmsSrvParamTable_oids.h | 38 + RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable.c | 130 + RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable.h | 205 + .../rdbmsSrvTable/rdbmsSrvTable_data_access.c | 306 ++ .../rdbmsSrvTable/rdbmsSrvTable_data_access.h | 64 + .../rdbmsSrvTable/rdbmsSrvTable_data_get.c | 758 +++ .../rdbmsSrvTable/rdbmsSrvTable_data_get.h | 66 + .../rdbmsSrvTable/rdbmsSrvTable_data_set.c | 30 + .../rdbmsSrvTable/rdbmsSrvTable_data_set.h | 34 + .../rdbmsSrvTable/rdbmsSrvTable_enums.h | 47 + .../rdbmsSrvTable/rdbmsSrvTable_interface.c | 701 +++ .../rdbmsSrvTable/rdbmsSrvTable_interface.h | 50 + .../rdbmsSrvTable/rdbmsSrvTable_oids.h | 37 + README.pgsnmpd | 87 + TODO.txt | 27 + customquery.c | 490 ++ customquery.h | 47 + doc/pgsnmpd.htm | 337 ++ doc/pgsnmpd_faq.html | 29 + pg_array.c | 151 + pg_array.h | 24 + pgsnmpd.c | 371 ++ pgsnmpd.conf | 5 + pgsnmpd.h | 57 + pgsnmpd.sql | 11 + pgsnmpd.yaml | 148 + pgsnmpd_regress.pl | 276 + pgsqlMibWriter.pl | 154 + pgsql_mib_pieces/PGSQL-MIB | 4481 +++++++++++++++++ pgsql_mib_pieces/a_PGSQL_MIB_header.mib | 100 + pgsql_mib_pieces/pg_aggregate.mib | 86 + pgsql_mib_pieces/pg_aggregate.tbldef | 7 + pgsql_mib_pieces/pg_am.mib | 239 + pgsql_mib_pieces/pg_am.tbldef | 25 + pgsql_mib_pieces/pg_amop.mib | 95 + pgsql_mib_pieces/pg_amop.tbldef | 9 + pgsql_mib_pieces/pg_amproc.mib | 68 + pgsql_mib_pieces/pg_amproc.tbldef | 5 + pgsql_mib_pieces/pg_attrdef.mib | 68 + pgsql_mib_pieces/pg_attrdef.tbldef | 6 + pgsql_mib_pieces/pg_attribute.mib | 185 + pgsql_mib_pieces/pg_attribute.tbldef | 18 + pgsql_mib_pieces/pg_auth_members.mib | 69 + pgsql_mib_pieces/pg_auth_members.tbldef | 6 + pgsql_mib_pieces/pg_authid.mib | 132 + pgsql_mib_pieces/pg_authid.tbldef | 14 + pgsql_mib_pieces/pg_autovacuum.mib | 122 + pgsql_mib_pieces/pg_autovacuum.tbldef | 11 + pgsql_mib_pieces/pg_cast.mib | 68 + pgsql_mib_pieces/pg_cast.tbldef | 6 + pgsql_mib_pieces/pg_class.mib | 275 + pgsql_mib_pieces/pg_class.tbldef | 29 + pgsql_mib_pieces/pg_constraint.mib | 167 + pgsql_mib_pieces/pg_constraint.tbldef | 17 + pgsql_mib_pieces/pg_conversion.mib | 95 + pgsql_mib_pieces/pg_conversion.tbldef | 9 + pgsql_mib_pieces/pg_database.mib | 132 + pgsql_mib_pieces/pg_database.tbldef | 14 + pgsql_mib_pieces/pg_depend.mib | 95 + pgsql_mib_pieces/pg_depend.tbldef | 8 + pgsql_mib_pieces/pg_description.mib | 68 + pgsql_mib_pieces/pg_description.tbldef | 5 + pgsql_mib_pieces/pg_enum.mib | 50 + pgsql_mib_pieces/pg_enum.tbldef | 4 + pgsql_mib_pieces/pg_index.mib | 131 + pgsql_mib_pieces/pg_index.tbldef | 12 + pgsql_mib_pieces/pg_inherits.mib | 59 + pgsql_mib_pieces/pg_inherits.tbldef | 4 + pgsql_mib_pieces/pg_language.mib | 86 + pgsql_mib_pieces/pg_language.tbldef | 8 + pgsql_mib_pieces/pg_largeobject.mib | 51 + pgsql_mib_pieces/pg_largeobject.tbldef | 4 + pgsql_mib_pieces/pg_listener.mib | 59 + pgsql_mib_pieces/pg_listener.tbldef | 4 + pgsql_mib_pieces/pg_namespace.mib | 59 + pgsql_mib_pieces/pg_namespace.tbldef | 5 + pgsql_mib_pieces/pg_opclass.mib | 95 + pgsql_mib_pieces/pg_opclass.tbldef | 9 + pgsql_mib_pieces/pg_operator.mib | 185 + pgsql_mib_pieces/pg_operator.tbldef | 19 + pgsql_mib_pieces/pg_opfamily.mib | 68 + pgsql_mib_pieces/pg_opfamily.tbldef | 6 + pgsql_mib_pieces/pg_pltemplate.mib | 86 + pgsql_mib_pieces/pg_pltemplate.tbldef | 7 + pgsql_mib_pieces/pg_proc.mib | 194 + pgsql_mib_pieces/pg_proc.tbldef | 20 + pgsql_mib_pieces/pg_rewrite.mib | 95 + pgsql_mib_pieces/pg_rewrite.tbldef | 9 + pgsql_mib_pieces/pg_shdepend.mib | 86 + pgsql_mib_pieces/pg_shdepend.tbldef | 7 + pgsql_mib_pieces/pg_shdescription.mib | 59 + pgsql_mib_pieces/pg_shdescription.tbldef | 4 + pgsql_mib_pieces/pg_statistic.mib | 221 + pgsql_mib_pieces/pg_statistic.tbldef | 22 + pgsql_mib_pieces/pg_tablespace.mib | 68 + pgsql_mib_pieces/pg_tablespace.tbldef | 6 + pgsql_mib_pieces/pg_trigger.mib | 149 + pgsql_mib_pieces/pg_trigger.tbldef | 15 + pgsql_mib_pieces/pg_ts_config.mib | 68 + pgsql_mib_pieces/pg_ts_config.tbldef | 6 + pgsql_mib_pieces/pg_ts_config_map.mib | 68 + pgsql_mib_pieces/pg_ts_config_map.tbldef | 5 + pgsql_mib_pieces/pg_ts_dict.mib | 77 + pgsql_mib_pieces/pg_ts_dict.tbldef | 7 + pgsql_mib_pieces/pg_ts_parser.mib | 95 + pgsql_mib_pieces/pg_ts_parser.tbldef | 9 + pgsql_mib_pieces/pg_ts_template.mib | 68 + pgsql_mib_pieces/pg_ts_template.tbldef | 6 + pgsql_mib_pieces/pg_type.mib | 239 + pgsql_mib_pieces/pg_type.tbldef | 25 + pgsql_mib_pieces/reprocess.sh | 14 + pgsql_mib_pieces/z_FOOTER.mib | 1 + query_reader.c | 333 ++ query_reader.h | 9 + test_pgsnmpd.sh | 16 + yaml_interp.c | 135 + 247 files changed, 45414 insertions(+) create mode 100644 APPLICATION-MIB create mode 100644 COPYRIGHT create mode 100644 KNOWNBUG.txt create mode 100644 Makefile create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.c create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.h create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_access.h create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.c create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.h create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.c create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.h create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_enums.h create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.c create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.h create mode 100644 PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_oids.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_enums.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_oids.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.h create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.c create mode 100644 PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.h create mode 100644 RDBMS-MIB create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/README create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.c create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.h create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.c create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.c create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.c create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.c create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/README create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.c create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsSrvLimitedResource/README create mode 100644 RDBMS-MIB_src/rdbmsSrvLimitedResource/rdbmsSrvLimitedResource.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable.c create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_oids.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable.c create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_access.c create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_access.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_get.c create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_get.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_set.c create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_set.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_enums.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_interface.c create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_interface.h create mode 100644 RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_oids.h create mode 100644 README.pgsnmpd create mode 100644 TODO.txt create mode 100644 customquery.c create mode 100644 customquery.h create mode 100644 doc/pgsnmpd.htm create mode 100644 doc/pgsnmpd_faq.html create mode 100644 pg_array.c create mode 100644 pg_array.h create mode 100644 pgsnmpd.c create mode 100644 pgsnmpd.conf create mode 100644 pgsnmpd.h create mode 100644 pgsnmpd.sql create mode 100644 pgsnmpd.yaml create mode 100644 pgsnmpd_regress.pl create mode 100644 pgsqlMibWriter.pl create mode 100644 pgsql_mib_pieces/PGSQL-MIB create mode 100644 pgsql_mib_pieces/a_PGSQL_MIB_header.mib create mode 100644 pgsql_mib_pieces/pg_aggregate.mib create mode 100644 pgsql_mib_pieces/pg_aggregate.tbldef create mode 100644 pgsql_mib_pieces/pg_am.mib create mode 100644 pgsql_mib_pieces/pg_am.tbldef create mode 100644 pgsql_mib_pieces/pg_amop.mib create mode 100644 pgsql_mib_pieces/pg_amop.tbldef create mode 100644 pgsql_mib_pieces/pg_amproc.mib create mode 100644 pgsql_mib_pieces/pg_amproc.tbldef create mode 100644 pgsql_mib_pieces/pg_attrdef.mib create mode 100644 pgsql_mib_pieces/pg_attrdef.tbldef create mode 100644 pgsql_mib_pieces/pg_attribute.mib create mode 100644 pgsql_mib_pieces/pg_attribute.tbldef create mode 100644 pgsql_mib_pieces/pg_auth_members.mib create mode 100644 pgsql_mib_pieces/pg_auth_members.tbldef create mode 100644 pgsql_mib_pieces/pg_authid.mib create mode 100644 pgsql_mib_pieces/pg_authid.tbldef create mode 100644 pgsql_mib_pieces/pg_autovacuum.mib create mode 100644 pgsql_mib_pieces/pg_autovacuum.tbldef create mode 100644 pgsql_mib_pieces/pg_cast.mib create mode 100644 pgsql_mib_pieces/pg_cast.tbldef create mode 100644 pgsql_mib_pieces/pg_class.mib create mode 100644 pgsql_mib_pieces/pg_class.tbldef create mode 100644 pgsql_mib_pieces/pg_constraint.mib create mode 100644 pgsql_mib_pieces/pg_constraint.tbldef create mode 100644 pgsql_mib_pieces/pg_conversion.mib create mode 100644 pgsql_mib_pieces/pg_conversion.tbldef create mode 100644 pgsql_mib_pieces/pg_database.mib create mode 100644 pgsql_mib_pieces/pg_database.tbldef create mode 100644 pgsql_mib_pieces/pg_depend.mib create mode 100644 pgsql_mib_pieces/pg_depend.tbldef create mode 100644 pgsql_mib_pieces/pg_description.mib create mode 100644 pgsql_mib_pieces/pg_description.tbldef create mode 100644 pgsql_mib_pieces/pg_enum.mib create mode 100644 pgsql_mib_pieces/pg_enum.tbldef create mode 100644 pgsql_mib_pieces/pg_index.mib create mode 100644 pgsql_mib_pieces/pg_index.tbldef create mode 100644 pgsql_mib_pieces/pg_inherits.mib create mode 100644 pgsql_mib_pieces/pg_inherits.tbldef create mode 100644 pgsql_mib_pieces/pg_language.mib create mode 100644 pgsql_mib_pieces/pg_language.tbldef create mode 100644 pgsql_mib_pieces/pg_largeobject.mib create mode 100644 pgsql_mib_pieces/pg_largeobject.tbldef create mode 100644 pgsql_mib_pieces/pg_listener.mib create mode 100644 pgsql_mib_pieces/pg_listener.tbldef create mode 100644 pgsql_mib_pieces/pg_namespace.mib create mode 100644 pgsql_mib_pieces/pg_namespace.tbldef create mode 100644 pgsql_mib_pieces/pg_opclass.mib create mode 100644 pgsql_mib_pieces/pg_opclass.tbldef create mode 100644 pgsql_mib_pieces/pg_operator.mib create mode 100644 pgsql_mib_pieces/pg_operator.tbldef create mode 100644 pgsql_mib_pieces/pg_opfamily.mib create mode 100644 pgsql_mib_pieces/pg_opfamily.tbldef create mode 100644 pgsql_mib_pieces/pg_pltemplate.mib create mode 100644 pgsql_mib_pieces/pg_pltemplate.tbldef create mode 100644 pgsql_mib_pieces/pg_proc.mib create mode 100644 pgsql_mib_pieces/pg_proc.tbldef create mode 100644 pgsql_mib_pieces/pg_rewrite.mib create mode 100644 pgsql_mib_pieces/pg_rewrite.tbldef create mode 100644 pgsql_mib_pieces/pg_shdepend.mib create mode 100644 pgsql_mib_pieces/pg_shdepend.tbldef create mode 100644 pgsql_mib_pieces/pg_shdescription.mib create mode 100644 pgsql_mib_pieces/pg_shdescription.tbldef create mode 100644 pgsql_mib_pieces/pg_statistic.mib create mode 100644 pgsql_mib_pieces/pg_statistic.tbldef create mode 100644 pgsql_mib_pieces/pg_tablespace.mib create mode 100644 pgsql_mib_pieces/pg_tablespace.tbldef create mode 100644 pgsql_mib_pieces/pg_trigger.mib create mode 100644 pgsql_mib_pieces/pg_trigger.tbldef create mode 100644 pgsql_mib_pieces/pg_ts_config.mib create mode 100644 pgsql_mib_pieces/pg_ts_config.tbldef create mode 100644 pgsql_mib_pieces/pg_ts_config_map.mib create mode 100644 pgsql_mib_pieces/pg_ts_config_map.tbldef create mode 100644 pgsql_mib_pieces/pg_ts_dict.mib create mode 100644 pgsql_mib_pieces/pg_ts_dict.tbldef create mode 100644 pgsql_mib_pieces/pg_ts_parser.mib create mode 100644 pgsql_mib_pieces/pg_ts_parser.tbldef create mode 100644 pgsql_mib_pieces/pg_ts_template.mib create mode 100644 pgsql_mib_pieces/pg_ts_template.tbldef create mode 100644 pgsql_mib_pieces/pg_type.mib create mode 100644 pgsql_mib_pieces/pg_type.tbldef create mode 100644 pgsql_mib_pieces/reprocess.sh create mode 100644 pgsql_mib_pieces/z_FOOTER.mib create mode 100644 query_reader.c create mode 100644 query_reader.h create mode 100755 test_pgsnmpd.sh create mode 100644 yaml_interp.c diff --git a/APPLICATION-MIB b/APPLICATION-MIB new file mode 100644 index 0000000..021cf41 --- /dev/null +++ b/APPLICATION-MIB @@ -0,0 +1,441 @@ + APPLICATION-MIB DEFINITIONS ::= BEGIN + + IMPORTS + OBJECT-TYPE, Counter32, Gauge32 + FROM SNMPv2-SMI + mib-2 + FROM RFC1213-MIB + DisplayString, TimeStamp + FROM SNMPv2-TC; + + + -- Textual conventions + + -- DistinguishedName [5] is used to refer to objects in the + -- directory. + + DistinguishedName ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "A Distinguished Name represented in accordance with + RFC1485." + SYNTAX DisplayString + + application MODULE-IDENTITY + LAST-UPDATED "9311280000Z" + ORGANIZATION "IETF Mail and Directory Management Working Group" + CONTACT-INFO + " Ned Freed + + Postal: Innosoft International, Inc. + 250 West First Street, Suite 240 + Claremont, CA 91711 + US + + Tel: +1 909 624 7907 + Fax: +1 909 621 5319 + + E-Mail: ned@innosoft.com" + DESCRIPTION + "The MIB module describing network service applications" + ::= { mib-2 27 } + + -- The basic applTable contains a list of the application + -- entities. + applTable OBJECT-TYPE + SYNTAX SEQUENCE OF ApplEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table holding objects which apply to all different + kinds of applications providing network services." + ::= {application 1} + + applEntry OBJECT-TYPE + SYNTAX ApplEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry associated with a network service application." + INDEX {applIndex} + ::= {applTable 1} + + ApplEntry ::= SEQUENCE { + applIndex + INTEGER, + applName + DisplayString, + applDirectoryName + DistinguishedName, + applVersion + DisplayString, + applUptime + TimeStamp, + applOperStatus + INTEGER, + applLastChange + TimeStamp, + applInboundAssociations + Gauge32, + applOutboundAssociations + Gauge32, + applAccumulatedInboundAssociations + Counter32, + applAccumulatedOutboundAssociations + Counter32, + applLastInboundActivity + TimeStamp, + applLastOutboundActivity + TimeStamp, + applRejectedInboundAssociations + Counter32, + applFailedOutboundAssociations + Counter32 + } + + applIndex OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An index to uniquely identify the network service + application." + ::= {applEntry 1} + + applName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The name the network service application chooses to be + known by." + ::= {applEntry 2} + + applDirectoryName OBJECT-TYPE + SYNTAX DistinguishedName + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The Distinguished Name of the directory entry where + static information about this application is stored. + An empty string indicates that no information about + the application is available in the directory." + ::= {applEntry 3} + + applVersion OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The version of network service application software." + ::= {applEntry 4} + + applUptime OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time the network service + application was last initialized. If the application was + last initialized prior to the last initialization of the + network management subsystem, then this object contains + a zero value." + ::= {applEntry 5} + + applOperStatus OBJECT-TYPE + SYNTAX INTEGER { + up(1), + down(2), + halted(3), + congested(4), + restarting(5) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Indicates the operational status of the network service + application. 'down' indicates that the network service is + not available. 'running' indicates that the network service + is operational and available. 'halted' indicates that the + service is operational but not available. 'congested' + indicates that the service is operational but no additional + inbound associations can be accomodated. 'restarting' + indicates that the service is currently unavailable but is + in the process of restarting and will be available soon." + ::= {applEntry 6} + + applLastChange OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time the network service + application entered its current operational state. If + the current state was entered prior to the last + initialization of the local network management subsystem, + then this object contains a zero value." + ::= {applEntry 7} + + applInboundAssociations OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of current associations to the network service + application, where it is the responder. For dynamic single + threaded processes, this will be the number of application + instances." + ::= {applEntry 8} + + applOutboundAssociations OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of current associations to the network service + application, where it is the initiator. For dynamic single + threaded processes, this will be the number of application + instances." + ::= {applEntry 9} + + applAccumulatedInboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of associations to the application entity + since application initialization, where it was the responder. + For dynamic single threaded processes, this will be the + number of application instances." + ::= {applEntry 10} + + applAccumulatedOutboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of associations to the application entity + since application initialization, where it was the initiator. + For dynamic single threaded processes, this will be the + number of application instances." + ::= {applEntry 11} + + applLastInboundActivity OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time this application last + had an inbound association. If the last association + occurred prior to the last initialization of the network + subsystem, then this object contains a zero value." + ::= {applEntry 12} + + applLastOutboundActivity OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time this application last + had an outbound association. If the last association + occurred prior to the last initialization of the network + subsystem, then this object contains a zero value." + ::= {applEntry 13} + + applRejectedInboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of inbound associations the application + entity has rejected, since application initialization." + ::= {applEntry 14} + + applFailedOutboundAssociations OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number associations where the application entity + is initiator and association establishment has failed, + since application initialization." + ::= {applEntry 15} + + + -- The assocTable augments the information in the applTable + -- with information about associations. Note that two levels + -- of compliance are specified below, depending on whether + -- association monitoring is mandated. + + assocTable OBJECT-TYPE + SYNTAX SEQUENCE OF AssocEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table holding a set of all active application + associations." + ::= {application 2} + + assocEntry OBJECT-TYPE + SYNTAX AssocEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry associated with an association for a network + service application." + INDEX {applIndex, assocIndex} + ::= {assocTable 1} + + AssocEntry ::= SEQUENCE { + assocIndex + INTEGER, + assocRemoteApplication + DisplayString, + assocApplicationProtocol + OBJECT IDENTIFIER, + assocApplicationType + INTEGER, + assocDuration + TimeStamp + } + + assocIndex OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An index to uniquely identify each association for a network + service application." + ::= {assocEntry 1} + + assocRemoteApplication OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The name of the system running remote network service + application. For an IP-based application this should be + either a domain name or IP address. For an OSI application + it should be the string encoded distinguished name of the + managed object. For X.400(84) MTAs which do not have a + Distinguished Name, the RFC1327 [6] syntax + 'mta in globalid' should be used." + ::= {assocEntry 2} + + assocApplicationProtocol OBJECT-TYPE + SYNTAX OBJECT IDENTIFIER + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "An identification of the protocol being used for the + application. For an OSI Application, this will be the + Application Context. For Internet applications, the IANA + maintains a registry of the OIDs which correspond to + well-known applications. If the application protocol is + not listed in the registry, an OID value of the form + {applTCPProtoID port} or {applUDProtoID port} are used for + TCP-based and UDP-based protocols, respectively. In either + case 'port' corresponds to the primary port number being + used by the protocol." + ::= {assocEntry 3} + + assocApplicationType OBJECT-TYPE + SYNTAX INTEGER { + ua-initiator(1), + ua-responder(2), + peer-initiator(3), + peer-responder(4)} + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This indicates whether the remote application is some type of + client making use of this network service (e.g. a User Agent) + or a server acting as a peer. Also indicated is whether the + remote end initiated an incoming connection to the network + service or responded to an outgoing connection made by the + local application." + ::= {assocEntry 4} + + assocDuration OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of sysUpTime at the time this association was + started. If this association started prior to the last + initialization of the network subsystem, then this + object contains a zero value." + ::= {assocEntry 5} + + + -- Conformance information + + applConformance OBJECT IDENTIFIER ::= {application 3} + + applGroups OBJECT IDENTIFIER ::= {applConformance 1} + applCompliances OBJECT IDENTIFIER ::= {applConformance 2} + + + -- Compliance statements + + applCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for SNMPv2 entities + which implement the Network Services Monitoring MIB + for basic monitoring of network service applications." + MODULE -- this module + MANDATORY-GROUPS {applGroup} + ::= {applCompliances 1} + + assocCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for SNMPv2 entities which + implement the Network Services Monitoring MIB for basic + monitoring of network service applications and their + associations." + MODULE -- this module + MANDATORY-GROUPS {applGroup, assocGroup} + ::= {applCompliances 2} + + -- Units of conformance + + applGroup OBJECT-GROUP + OBJECTS { + applName, applVersion, applUptime, applOperStatus, + applLastChange, applInboundAssociations, + applOutboundAssociations, applAccumulatedInboundAssociations, + applAccumulatedOutboundAssociations, applLastInboundActivity, + applLastOutboundActivity, applRejectedInboundAssociations, + applFailedOutboundAssociations} + STATUS current + DESCRIPTION + "A collection of objects providing basic monitoring of + network service applications." + ::= {applGroups 1} + + assocGroup OBJECT-GROUP + OBJECTS { + assocRemoteApplication, assocApplicationProtocol, + assocApplicationType, assocDuration} + STATUS current + DESCRIPTION + "A collection of objects providing basic monitoring of + network service applications' associations." + ::= {applGroups 2} + + + -- OIDs of the form {applTCPProtoID port} are intended to be used + -- for TCP-based protocols that don't have OIDs assigned by other + -- means. {applUDPProtoID port} serves the same purpose for + -- UDP-based protocols. In either case 'port' corresponds to + -- the primary port number being used by the protocol. For example, + -- assuming no other OID is assigned for SMTP, an OID of + -- {applTCPProtoID 25} could be used, since SMTP is a TCP-based + -- protocol that uses port 25 as its primary port. + + applTCPProtoID OBJECT IDENTIFIER ::= {application 4} + applUDPProtoID OBJECT IDENTIFIER ::= {application 5} + + END diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..e4782a3 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,22 @@ +pgsnmpd - snmpd for the PostgreSQL Database Management System + +This is under the following license. + +Copyright (c) 2003-2007, PostgreSQL Global Development Group + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement +is hereby granted, provided that the above copyright notice and this +paragraph and the following two paragraphs appear in all copies. + +IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING +LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS +DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS +ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO +PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/KNOWNBUG.txt b/KNOWNBUG.txt new file mode 100644 index 0000000..3152c75 --- /dev/null +++ b/KNOWNBUG.txt @@ -0,0 +1 @@ +== Ver 1.0 Release. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7864b4a --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +# $PostgreSQL: pgsql/contrib/pgsnmp/Makefile,v 1.05 2005/11/10 11:03:07 saito Exp $ + +PROGRAM = pgsnmpd + +OBJS = pgsnmpd.o \ + RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.o RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.o RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.o \ + RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.o RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.o \ + RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.o RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.o \ + RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.o RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.o \ + RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.o RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.o \ + RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.o RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.o \ + RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.o \ + RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_interface.o \ + RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable.o RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_access.o \ + RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_get.o RDBMS-MIB_src/rdbmsSrvTable/rdbmsSrvTable_data_set.o \ + RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable.o RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_access.o \ + RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_get.o RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_data_set.o \ + RDBMS-MIB_src/rdbmsSrvParamTable/rdbmsSrvParamTable_interface.o \ + RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.o RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.o \ + RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get.o RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_set.o \ + RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_interface.o \ + RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.o RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.o \ + RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.o RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.o \ + RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.o \ + RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.o RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.o \ + RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.o RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.o \ + RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.o \ + customquery.o \ + query_reader.o \ + pg_array.o + +SNMPFLAGS=-I. -I./RDBMS-MIB_src $(shell net-snmp-config --cflags) +AGENTLIBS=$(shell net-snmp-config --agent-libs) + +PG_CPPFLAGS = -O0 -g -I$(libpq_srcdir) $(SNMPFLAGS) +PG_LIBS = $(libpq_pgport) $(AGENTLIBS) -lyaml + +DOCS = README.pgsnmpd + +DATA = pgsnmpd.conf pgsnmpd.sql + +ifndef DONT_USE_PGXS +PGXS := $(shell pg_config --pgxs) +include $(PGXS) +else +subdir = contrib/pgsnmpd +top_builddir = ../.. +include $(top_builddir)/src/Makefile.global +include $(top_srcdir)/contrib/contrib-global.mk +endif diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.c b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.c new file mode 100644 index 0000000..5ab5792 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.c @@ -0,0 +1,129 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable.c,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +/** \mainpage MFD helper for pgsnmpdConnectionsTable + * + * \section intro Introduction + * Introductory text. + * + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsnmpdConnectionsTable.h" + +#include + +#include "pgsnmpdConnectionsTable_interface.h" + +oid pgsnmpdConnectionsTable_oid[] = { PGSNMPDCONNECTIONSTABLE_OID }; +int pgsnmpdConnectionsTable_oid_size = OID_LENGTH(pgsnmpdConnectionsTable_oid); + +void initialize_table_pgsnmpdConnectionsTable(void); + + +/** + * Initializes the pgsnmpdConnectionsTable module + */ +void +init_pgsnmpdConnectionsTable(void) +{ + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:init_pgsnmpdConnectionsTable","called\n")); + + /* + * TODO:300:o: Perform pgsnmpdConnectionsTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("pgsnmpdConnectionsTable")) + initialize_table_pgsnmpdConnectionsTable(); + +} /* init_pgsnmpdConnectionsTable */ + +/** + * Initialize the table pgsnmpdConnectionsTable + * (Define its contents and how it's structured) + */ +void +initialize_table_pgsnmpdConnectionsTable(void) +{ + pgsnmpdConnectionsTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:initialize_table_pgsnmpdConnectionsTable","called\n")); + + /* + * TODO:301:o: Perform pgsnmpdConnectionsTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize pgsnmpdConnectionsTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("pgsnmpdConnectionsTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _pgsnmpdConnectionsTable_initialize_interface(user_context, flags); +} /* initialize_table_pgsnmpdConnectionsTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +pgsnmpdConnectionsTable_pre_request(pgsnmpdConnectionsTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform pgsnmpdConnectionsTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* pgsnmpdConnectionsTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +pgsnmpdConnectionsTable_post_request(pgsnmpdConnectionsTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_post_request","called\n")); + + /* + * TODO:511:o: Perform pgsnmpdConnectionsTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* pgsnmpdConnectionsTable_post_request */ + + +/** @{ */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.h new file mode 100644 index 0000000..7191830 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable.h @@ -0,0 +1,198 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +#ifndef PGSNMPDCONNECTIONSTABLE_H +#define PGSNMPDCONNECTIONSTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(PGSQL-MIB/pgsnmpdConnectionsTable/pgsnmpdConnectionsTable_interface); +config_require(PGSQL-MIB/pgsnmpdConnectionsTable/pgsnmpdConnectionsTable_data_access); +config_require(PGSQL-MIB/pgsnmpdConnectionsTable/pgsnmpdConnectionsTable_data_get); +config_require(PGSQL-MIB/pgsnmpdConnectionsTable/pgsnmpdConnectionsTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "pgsnmpdConnectionsTable_oids.h" + +/* enum definions */ +#include "pgsnmpdConnectionsTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_pgsnmpdConnectionsTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsnmpdConnectionsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsnmpdConnectionsTable is subid 1 of pgsnmpdTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.1.1, length: 10 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review pgsnmpdConnectionsTable registration context. + */ +typedef netsnmp_data_list * pgsnmpdConnectionsTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review pgsnmpdConnectionsTable data context structure. + * This structure is used to represent the data for pgsnmpdConnectionsTable. + */ +/* + * This structure contains storage for all the columns defined in the + * pgsnmpdConnectionsTable. + */ +typedef struct pgsnmpdConnectionsTable_data_s { + + /* + * pgsnmpdConnHost(2)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + char pgsnmpdConnHost[255]; +size_t pgsnmpdConnHost_len; /* # of char elements, not bytes */ + + /* + * pgsnmpdConnPort(3)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + char pgsnmpdConnPort[255]; +size_t pgsnmpdConnPort_len; /* # of char elements, not bytes */ + + /* + * pgsnmpdConnDbName(4)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + char pgsnmpdConnDbName[255]; +size_t pgsnmpdConnDbName_len; /* # of char elements, not bytes */ + +} pgsnmpdConnectionsTable_data; + + +/* + * TODO:120:r: |-> Review pgsnmpdConnectionsTable mib index. + * This structure is used to represent the index for pgsnmpdConnectionsTable. + */ +typedef struct pgsnmpdConnectionsTable_mib_index_s { + + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + /** 128 - 0(other indexes) - oid length(12) = 115 */ + char pgsnmpdConnID[115]; + size_t pgsnmpdConnID_len; + + +} pgsnmpdConnectionsTable_mib_index; + + /* + * TODO:121:r: | |-> Review pgsnmpdConnectionsTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + * Guessing 128 - col/entry(2) - oid len(10) +*/ +#define MAX_pgsnmpdConnectionsTable_IDX_LEN 116 + + +/* ********************************************************************* + * TODO:130:o: |-> Review pgsnmpdConnectionsTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * pgsnmpdConnectionsTable_rowreq_ctx pointer. + */ +typedef struct pgsnmpdConnectionsTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_pgsnmpdConnectionsTable_IDX_LEN]; + + pgsnmpdConnectionsTable_mib_index tbl_idx; + + pgsnmpdConnectionsTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + pgsnmpdConnectionsTable_registration_ptr pgsnmpdConnectionsTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to pgsnmpdConnectionsTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *pgsnmpdConnectionsTable_data_list; + +} pgsnmpdConnectionsTable_rowreq_ctx; + +typedef struct pgsnmpdConnectionsTable_ref_rowreq_ctx_s { + pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx; +} pgsnmpdConnectionsTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int pgsnmpdConnectionsTable_pre_request(pgsnmpdConnectionsTable_registration_ptr user_context); + int pgsnmpdConnectionsTable_post_request(pgsnmpdConnectionsTable_registration_ptr user_context); + + +extern oid pgsnmpdConnectionsTable_oid[]; +extern int pgsnmpdConnectionsTable_oid_size; + + +#include "pgsnmpdConnectionsTable_interface.h" +#include "pgsnmpdConnectionsTable_data_access.h" +#include "pgsnmpdConnectionsTable_data_get.h" +#include "pgsnmpdConnectionsTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* PGSNMPDCONNECTIONSTABLE_H */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_access.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_access.h new file mode 100644 index 0000000..d378541 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_access.h @@ -0,0 +1,56 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_data_access.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +#ifndef PGSNMPDCONNECTIONSTABLE_DATA_ACCESS_H +#define PGSNMPDCONNECTIONSTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsnmpdConnectionsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsnmpdConnectionsTable is subid 1 of pgsnmpdTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.1.1, length: 10 +*/ + + + int pgsnmpdConnectionsTable_init_data(pgsnmpdConnectionsTable_registration_ptr pgsnmpdConnectionsTable_reg); + + +/* + * TODO:180:o: Review pgsnmpdConnectionsTable cache timeout. + * The number of seconds before the cache times out + */ +#define PGSNMPDCONNECTIONSTABLE_CACHE_TIMEOUT 60 + +void pgsnmpdConnectionsTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int pgsnmpdConnectionsTable_cache_load(netsnmp_container *container); +void pgsnmpdConnectionsTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.c b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.c new file mode 100644 index 0000000..c2e7677 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.c @@ -0,0 +1,279 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_data_get.c,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsnmpdConnectionsTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement pgsnmpdConnectionsTable get routines. + * TODO:240:M: Implement pgsnmpdConnectionsTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsnmpdConnectionsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsnmpdConnectionsTable is subid 1 of pgsnmpdTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.1.1, length: 10 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement pgsnmpdConnectionsTable data context functions. + */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsnmpdConnectionEntry.pgsnmpdConnID + * pgsnmpdConnID is subid 1 of pgsnmpdConnectionEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.1.1.1.1 + * Description: +Identifying string for this connection. Default is host:port:database. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE pgsnmpdConnID IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsnmpdConnID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_pgsnmpdConnID_val_ptr); + netsnmp_assert((NULL != mib_pgsnmpdConnID_val_ptr_ptr) && (NULL != mib_pgsnmpdConnID_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnID_map","called\n")); + + /* + * TODO:241:r: |-> Implement pgsnmpdConnID non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_pgsnmpdConnID_val_ptr_len; /* assume equal */ + if((NULL == *mib_pgsnmpdConnID_val_ptr_ptr) || (*mib_pgsnmpdConnID_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_pgsnmpdConnID_val_ptr_ptr = realloc( *mib_pgsnmpdConnID_val_ptr_ptr, converted_len * sizeof(**mib_pgsnmpdConnID_val_ptr_ptr)); + if(NULL == *mib_pgsnmpdConnID_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_pgsnmpdConnID_val_ptr_len_ptr = converted_len; + memcpy( *mib_pgsnmpdConnID_val_ptr_ptr, raw_pgsnmpdConnID_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* pgsnmpdConnID_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +pgsnmpdConnectionsTable_indexes_set_tbl_idx(pgsnmpdConnectionsTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len) +{ + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_indexes_set_tbl_idx","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + tbl_idx->pgsnmpdConnID_len = sizeof(tbl_idx->pgsnmpdConnID); + /* + * make sure there is enough space for pgsnmpdConnID data + */ + if ((NULL == tbl_idx->pgsnmpdConnID) || + (tbl_idx->pgsnmpdConnID_len < (pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->pgsnmpdConnID_len = pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0]); + memcpy( tbl_idx->pgsnmpdConnID, pgsnmpdConnID_val_ptr, tbl_idx->pgsnmpdConnID_len ); + + + return MFD_SUCCESS; +} /* pgsnmpdConnectionsTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +pgsnmpdConnectionsTable_indexes_set(pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len) +{ + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_indexes_set","called\n")); + + if(MFD_SUCCESS != pgsnmpdConnectionsTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , pgsnmpdConnID_val_ptr, pgsnmpdConnID_val_ptr_len + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != pgsnmpdConnectionsTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsnmpdConnectionsTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsnmpdConnectionEntry.pgsnmpdConnHost + * pgsnmpdConnHost is subid 2 of pgsnmpdConnectionEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.1.1.1.2 + * Description: +Host name, IP address, or other identifier of the host PostgreSQL server for this connection + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE pgsnmpdConnHost IS NOT ACCESSIBLE + * + * + */ +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsnmpdConnectionEntry.pgsnmpdConnPort + * pgsnmpdConnPort is subid 3 of pgsnmpdConnectionEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.1.1.1.3 + * Description: +PostgreSQL server port number for this connection + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE pgsnmpdConnPort IS NOT ACCESSIBLE + * + * + */ +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsnmpdConnectionEntry.pgsnmpdConnDbName + * pgsnmpdConnDbName is subid 4 of pgsnmpdConnectionEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.1.1.1.4 + * Description: +Name of the database this connection is connected to + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE pgsnmpdConnDbName IS NOT ACCESSIBLE + * + * + */ + + +/** @} */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.h new file mode 100644 index 0000000..2e12dae --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_get.h @@ -0,0 +1,65 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_data_get.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + * + * @file pgsnmpdConnectionsTable_data_get.h + * + * @addtogroup get + * + * Prototypes for get functions + * + * @{ + */ +#ifndef PGSNMPDCONNECTIONSTABLE_DATA_GET_H +#define PGSNMPDCONNECTIONSTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsnmpdConnectionsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsnmpdConnectionsTable is subid 1 of pgsnmpdTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.1.1, length: 10 +*/ + /* + * indexes + */ + int pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc); + + int pgsnmpdConnHost_map(char **mib_pgsnmpdConnHost_val_ptr_ptr, size_t *mib_pgsnmpdConnHost_val_ptr_len_ptr, char *raw_pgsnmpdConnHost_val_ptr, size_t raw_pgsnmpdConnHost_val_ptr_len, int allow_realloc); + int pgsnmpdConnHost_get( pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, char **pgsnmpdConnHost_val_ptr_ptr, size_t *pgsnmpdConnHost_val_ptr_len_ptr ); + int pgsnmpdConnPort_map(char **mib_pgsnmpdConnPort_val_ptr_ptr, size_t *mib_pgsnmpdConnPort_val_ptr_len_ptr, char *raw_pgsnmpdConnPort_val_ptr, size_t raw_pgsnmpdConnPort_val_ptr_len, int allow_realloc); + int pgsnmpdConnPort_get( pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, char **pgsnmpdConnPort_val_ptr_ptr, size_t *pgsnmpdConnPort_val_ptr_len_ptr ); + int pgsnmpdConnDbName_map(char **mib_pgsnmpdConnDbName_val_ptr_ptr, size_t *mib_pgsnmpdConnDbName_val_ptr_len_ptr, char *raw_pgsnmpdConnDbName_val_ptr, size_t raw_pgsnmpdConnDbName_val_ptr_len, int allow_realloc); + int pgsnmpdConnDbName_get( pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, char **pgsnmpdConnDbName_val_ptr_ptr, size_t *pgsnmpdConnDbName_val_ptr_len_ptr ); + + +int pgsnmpdConnectionsTable_indexes_set_tbl_idx(pgsnmpdConnectionsTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len); +int pgsnmpdConnectionsTable_indexes_set(pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSNMPDCONNECTIONSTABLE_DATA_GET_H */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.c b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.c new file mode 100644 index 0000000..44af8ae --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.c @@ -0,0 +1,24 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_data_set.c,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + * + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsnmpdConnectionsTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.h new file mode 100644 index 0000000..d077ee0 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_data_set.h @@ -0,0 +1,27 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_data_set.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +#ifndef PGSNMPDCONNECTIONSTABLE_DATA_SET_H +#define PGSNMPDCONNECTIONSTABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSNMPDCONNECTIONSTABLE_DATA_SET_H */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_enums.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_enums.h new file mode 100644 index 0000000..5fcc4cd --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_enums.h @@ -0,0 +1,40 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c,v 1.3 2004/05/18 17:44:32 rstory Exp $ + * + * $Id: pgsnmpdConnectionsTable_enums.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +#ifndef PGSNMPDCONNECTIONSTABLE_ENUMS_H +#define PGSNMPDCONNECTIONSTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table pgsnmpdConnectionsTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSNMPDCONNECTIONSTABLE_ENUMS_H */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.c b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.c new file mode 100644 index 0000000..2b42a61 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.c @@ -0,0 +1,707 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_interface.c,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsnmpdConnectionsTable.h" + + +#include + +#include "pgsnmpdConnectionsTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table pgsnmpdConnectionsTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsnmpdConnectionsTable is subid 1 of pgsnmpdTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.1.1, length: 10 +*/ +typedef struct pgsnmpdConnectionsTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + pgsnmpdConnectionsTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} pgsnmpdConnectionsTable_interface_ctx; + +static pgsnmpdConnectionsTable_interface_ctx pgsnmpdConnectionsTable_if_ctx; + +static void _pgsnmpdConnectionsTable_container_init( + pgsnmpdConnectionsTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_pgsnmpdConnectionsTable_pre_request; +static Netsnmp_Node_Handler _mfd_pgsnmpdConnectionsTable_post_request; +static Netsnmp_Node_Handler _mfd_pgsnmpdConnectionsTable_object_lookup; +static Netsnmp_Node_Handler _mfd_pgsnmpdConnectionsTable_get_values; +/** + * @internal + * Initialize the table pgsnmpdConnectionsTable + * (Define its contents and how it's structured) + */ +void +_pgsnmpdConnectionsTable_initialize_interface(pgsnmpdConnectionsTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &pgsnmpdConnectionsTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &pgsnmpdConnectionsTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_pgsnmpdConnectionsTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for pgsnmpdConnectionsTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_OCTET_STR, /** index: pgsnmpdConnID */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = PGSNMPDCONNECTIONSTABLE_MIN_COL; + tbl_info->max_column = PGSNMPDCONNECTIONSTABLE_MAX_COL; + + /* + * save users context + */ + pgsnmpdConnectionsTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + pgsnmpdConnectionsTable_init_data(reg_ptr); + + /* + * set up the container + */ + _pgsnmpdConnectionsTable_container_init(&pgsnmpdConnectionsTable_if_ctx); + if (NULL == pgsnmpdConnectionsTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for pgsnmpdConnectionsTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_pgsnmpdConnectionsTable_object_lookup; + access_multiplexer->get_values = _mfd_pgsnmpdConnectionsTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_pgsnmpdConnectionsTable_pre_request; + access_multiplexer->post_request = _mfd_pgsnmpdConnectionsTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("pgsnmpdConnectionsTable:init_pgsnmpdConnectionsTable", + "Registering pgsnmpdConnectionsTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("pgsnmpdConnectionsTable", handler, + pgsnmpdConnectionsTable_oid, + pgsnmpdConnectionsTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table pgsnmpdConnectionsTable\n"); + return; + } + reginfo->my_reg_void = &pgsnmpdConnectionsTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + pgsnmpdConnectionsTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != pgsnmpdConnectionsTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(pgsnmpdConnectionsTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _pgsnmpdConnectionsTable_initialize_interface */ + +void +pgsnmpdConnectionsTable_valid_columns_set(netsnmp_column_info *vc) +{ + pgsnmpdConnectionsTable_if_ctx.tbl_info.valid_columns = vc; +} /* pgsnmpdConnectionsTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +pgsnmpdConnectionsTable_index_to_oid(netsnmp_index *oid_idx, + pgsnmpdConnectionsTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_index_to_oid","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + snmp_set_var_value(&var_pgsnmpdConnID, (u_char*)&mib_idx->pgsnmpdConnID, + mib_idx->pgsnmpdConnID_len * sizeof(mib_idx->pgsnmpdConnID[0])); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_pgsnmpdConnID); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsnmpdConnectionsTable_index_to_oid */ + +/** + * extract pgsnmpdConnectionsTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +pgsnmpdConnectionsTable_index_from_oid(netsnmp_index *oid_idx, + pgsnmpdConnectionsTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_pgsnmpdConnID ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + /* + * NOTE: val_len is in bytes, pgsnmpdConnID_len might not be + */ + if(var_pgsnmpdConnID.val_len > sizeof(mib_idx->pgsnmpdConnID)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->pgsnmpdConnID, var_pgsnmpdConnID.val.string, var_pgsnmpdConnID.val_len); + mib_idx->pgsnmpdConnID_len = var_pgsnmpdConnID.val_len / sizeof(mib_idx->pgsnmpdConnID[0]); + } + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsnmpdConnectionsTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a pgsnmpdConnectionsTable_rowreq_ctx + */ +pgsnmpdConnectionsTable_rowreq_ctx * +pgsnmpdConnectionsTable_allocate_rowreq_ctx(void) +{ + pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(pgsnmpdConnectionsTable_rowreq_ctx); + + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "pgsnmpdConnectionsTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->pgsnmpdConnectionsTable_data_list = NULL; + rowreq_ctx->pgsnmpdConnectionsTable_reg = pgsnmpdConnectionsTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* pgsnmpdConnectionsTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a pgsnmpdConnectionsTable_rowreq_ctx + */ +void +pgsnmpdConnectionsTable_release_rowreq_ctx(pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:pgsnmpdConnectionsTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* pgsnmpdConnectionsTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsnmpdConnectionsTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = pgsnmpdConnectionsTable_pre_request(pgsnmpdConnectionsTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable","error %d from " + "pgsnmpdConnectionsTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsnmpdConnectionsTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsnmpdConnectionsTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx; + int rc = pgsnmpdConnectionsTable_post_request(pgsnmpdConnectionsTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable","error %d from " + "pgsnmpdConnectionsTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(pgsnmpdConnectionsTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(pgsnmpdConnectionsTable_if_ctx.container, rowreq_ctx); + pgsnmpdConnectionsTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsnmpdConnectionsTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsnmpdConnectionsTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_mfd_pgsnmpdConnectionsTable_object_lookup","called\n")); + + /* + * get our context from mfd + * pgsnmpdConnectionsTable_interface_ctx *if_ctx = + * (pgsnmpdConnectionsTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + pgsnmpdConnectionsTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsnmpdConnectionsTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_pgsnmpdConnectionsTable_get_column( pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_mfd_pgsnmpdConnectionsTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + default: + snmp_log(LOG_ERR,"unknown column %d in _pgsnmpdConnectionsTable_get_column\n", column); + break; + } + + return rc; +} /* _pgsnmpdConnectionsTable_get_column */ + +int +_mfd_pgsnmpdConnectionsTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_mfd_pgsnmpdConnectionsTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _pgsnmpdConnectionsTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsnmpdConnectionsTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for pgsnmpdConnectionsTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return pgsnmpdConnectionsTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + pgsnmpdConnectionsTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in pgsnmpdConnectionsTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + pgsnmpdConnectionsTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_pgsnmpdConnectionsTable_container_init(pgsnmpdConnectionsTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:pgsnmpdConnectionsTable:_pgsnmpdConnectionsTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + pgsnmpdConnectionsTable_oid, + pgsnmpdConnectionsTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for pgsnmpdConnectionsTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + pgsnmpdConnectionsTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("pgsnmpdConnectionsTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "pgsnmpdConnectionsTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _pgsnmpdConnectionsTable_container_init */ + diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.h new file mode 100644 index 0000000..872beea --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_interface.h @@ -0,0 +1,72 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsnmpdConnectionsTable_interface.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +/** @defgroup interface: Routines to interface to Net-SNMP + * + * \warning This code should not be modified, called directly, + * or used to interpret functionality. It is subject to + * change at any time. + * + * @{ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ +#ifndef PGSNMPDCONNECTIONSTABLE_INTERFACE_H +#define PGSNMPDCONNECTIONSTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "pgsnmpdConnectionsTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _pgsnmpdConnectionsTable_initialize_interface(pgsnmpdConnectionsTable_registration_ptr user_ctx, + u_long flags); + + pgsnmpdConnectionsTable_rowreq_ctx * pgsnmpdConnectionsTable_allocate_rowreq_ctx(void); +void pgsnmpdConnectionsTable_release_rowreq_ctx(pgsnmpdConnectionsTable_rowreq_ctx *rowreq_ctx); + +int pgsnmpdConnectionsTable_index_to_oid(netsnmp_index *oid_idx, + pgsnmpdConnectionsTable_mib_index *mib_idx); +int pgsnmpdConnectionsTable_index_from_oid(netsnmp_index *oid_idx, + pgsnmpdConnectionsTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void pgsnmpdConnectionsTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSNMPDCONNECTIONSTABLE_INTERFACE_H */ diff --git a/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_oids.h b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_oids.h new file mode 100644 index 0000000..9f8d9c6 --- /dev/null +++ b/PGSQL-MIB_src/pgsnmpdTables/pgsnmpdConnectionsTable_oids.h @@ -0,0 +1,30 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c,v 1.10 2004/10/08 23:39:17 rstory Exp $ + * + * $Id: pgsnmpdConnectionsTable_oids.h,v 1.1 2007/10/30 11:44:41 eggyknap Exp $ + */ +#ifndef PGSNMPDCONNECTIONSTABLE_OIDS_H +#define PGSNMPDCONNECTIONSTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table pgsnmpdConnectionsTable */ +#define PGSNMPDCONNECTIONSTABLE_OID 1,3,6,1,4,1,27645,1,1,1 +#define COLUMN_PGSNMPDCONNID 1 +#define COLUMN_PGSNMPDCONNHOST 2 +#define COLUMN_PGSNMPDCONNPORT 3 +#define COLUMN_PGSNMPDCONNDBNAME 4 + +#define PGSNMPDCONNECTIONSTABLE_MIN_COL +#define PGSNMPDCONNECTIONSTABLE_MAX_COL + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSNMPDCONNECTIONSTABLE_OIDS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c new file mode 100644 index 0000000..5d427c0 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c @@ -0,0 +1,129 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsqlPgAggregateTable.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/** \mainpage MFD helper for pgsqlPgAggregateTable + * + * \section intro Introduction + * Introductory text. + * + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + +#include + +#include "pgsqlPgAggregateTable_interface.h" + +oid pgsqlPgAggregateTable_oid[] = { PGSQLPGAGGREGATETABLE_OID }; +int pgsqlPgAggregateTable_oid_size = OID_LENGTH(pgsqlPgAggregateTable_oid); + +void initialize_table_pgsqlPgAggregateTable(void); + + +/** + * Initializes the pgsqlPgAggregateTable module + */ +void +init_pgsqlPgAggregateTable(void) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:init_pgsqlPgAggregateTable","called\n")); + + /* + * TODO:300:o: Perform pgsqlPgAggregateTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("pgsqlPgAggregateTable")) + initialize_table_pgsqlPgAggregateTable(); + +} /* init_pgsqlPgAggregateTable */ + +/** + * Initialize the table pgsqlPgAggregateTable + * (Define its contents and how it's structured) + */ +void +initialize_table_pgsqlPgAggregateTable(void) +{ + pgsqlPgAggregateTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:initialize_table_pgsqlPgAggregateTable","called\n")); + + /* + * TODO:301:o: Perform pgsqlPgAggregateTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize pgsqlPgAggregateTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("pgsqlPgAggregateTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _pgsqlPgAggregateTable_initialize_interface(user_context, flags); +} /* initialize_table_pgsqlPgAggregateTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +pgsqlPgAggregateTable_pre_request(pgsqlPgAggregateTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform pgsqlPgAggregateTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +pgsqlPgAggregateTable_post_request(pgsqlPgAggregateTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_post_request","called\n")); + + /* + * TODO:511:o: Perform pgsqlPgAggregateTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_post_request */ + + +/** @{ */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h new file mode 100644 index 0000000..18c7e4d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h @@ -0,0 +1,221 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsqlPgAggregateTable.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_H +#define PGSQLPGAGGREGATETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface); +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access); +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get); +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "pgsqlPgAggregateTable_oids.h" + +/* enum definions */ +#include "pgsqlPgAggregateTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_pgsqlPgAggregateTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review pgsqlPgAggregateTable registration context. + */ +typedef netsnmp_data_list * pgsqlPgAggregateTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review pgsqlPgAggregateTable data context structure. + * This structure is used to represent the data for pgsqlPgAggregateTable. + */ +/* + * This structure contains storage for all the columns defined in the + * pgsqlPgAggregateTable. + */ +typedef struct pgsqlPgAggregateTable_data_s { + + /* + * pgsqlPgAggregateAggfnoid(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggfnoid; + + /* + * pgsqlPgAggregateAggtransfn(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggtransfn; + + /* + * pgsqlPgAggregateAggfinalfn(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggfinalfn; + + /* + * pgsqlPgAggregateAggsortop(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggsortop; + + /* + * pgsqlPgAggregateAggtranstype(6)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggtranstype; + + /* + * pgsqlPgAggregateAgginitval(7)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char pgsqlPgAggregateAgginitval[255]; +size_t pgsqlPgAggregateAgginitval_len; /* # of char elements, not bytes */ + +} pgsqlPgAggregateTable_data; + + +/* + * TODO:120:r: |-> Review pgsqlPgAggregateTable mib index. + * This structure is used to represent the index for pgsqlPgAggregateTable. + */ +typedef struct pgsqlPgAggregateTable_mib_index_s { + + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + /** 128 - 2(other indexes) - oid length(12) = 113 */ + char pgsnmpdConnID[113]; + size_t pgsnmpdConnID_len; + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + /* + * pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + long pgsqlPgAggregateEntryOID; + + +} pgsqlPgAggregateTable_mib_index; + + /* + * TODO:121:r: | |-> Review pgsqlPgAggregateTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + * Guessing 128 - col/entry(2) - oid len(10) +*/ +#define MAX_pgsqlPgAggregateTable_IDX_LEN 116 + + +/* ********************************************************************* + * TODO:130:o: |-> Review pgsqlPgAggregateTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * pgsqlPgAggregateTable_rowreq_ctx pointer. + */ +typedef struct pgsqlPgAggregateTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_pgsqlPgAggregateTable_IDX_LEN]; + + pgsqlPgAggregateTable_mib_index tbl_idx; + + pgsqlPgAggregateTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + pgsqlPgAggregateTable_registration_ptr pgsqlPgAggregateTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to pgsqlPgAggregateTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *pgsqlPgAggregateTable_data_list; + +} pgsqlPgAggregateTable_rowreq_ctx; + +typedef struct pgsqlPgAggregateTable_ref_rowreq_ctx_s { + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx; +} pgsqlPgAggregateTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int pgsqlPgAggregateTable_pre_request(pgsqlPgAggregateTable_registration_ptr user_context); + int pgsqlPgAggregateTable_post_request(pgsqlPgAggregateTable_registration_ptr user_context); + + +extern oid pgsqlPgAggregateTable_oid[]; +extern int pgsqlPgAggregateTable_oid_size; + + +#include "pgsqlPgAggregateTable_interface.h" +#include "pgsqlPgAggregateTable_data_access.h" +#include "pgsqlPgAggregateTable_data_get.h" +#include "pgsqlPgAggregateTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c new file mode 100644 index 0000000..2f55780 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c @@ -0,0 +1,297 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_access.c,v 1.2 2008/01/17 12:29:36 eggyknap Exp $ + */ +#include "pgsnmpd.h" + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" +#include "pgsqlPgAggregateTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + +/** + * initialization for pgsqlPgAggregateTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param pgsqlPgAggregateTable_reg + * Pointer to pgsqlPgAggregateTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +pgsqlPgAggregateTable_init_data(pgsqlPgAggregateTable_registration_ptr pgsqlPgAggregateTable_reg) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_init_data","called\n")); + + /* + * TODO:303:o: Initialize pgsqlPgAggregateTable data. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +pgsqlPgAggregateTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to pgsqlPgAggregateTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up pgsqlPgAggregateTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = PGSQLPGAGGREGATETABLE_CACHE_TIMEOUT; /* seconds */ +} /* pgsqlPgAggregateTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement pgsqlPgAggregateTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * pgsqlPgAggregateTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +pgsqlPgAggregateTable_cache_load(netsnmp_container *container) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + + char pgsnmpdConnID[112] = "Default conn ID"; + size_t pgsnmpdConnID_len = strlen(pgsnmpdConnID); + long rdbmsDbIndex = 1; + int i, resultCount, tmpInt; + char *tmpString; + PGresult *pg_db_qry; + +snmp_log(LOG_INFO, "Running pgsqlPgAggregateTable\n"); + if (PQstatus(dbconn) == CONNECTION_OK) + pg_db_qry = PQexec(dbconn, "SELECT aggfnoid::INTEGER, aggfnoid, aggtransfn, aggfinalfn, aggsortop, aggtranstype, agginitval FROM pg_aggregate ORDER BY 1 ASC"); + else { + snmp_log(LOG_ERR, "Can't get connected to database\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_cache_load","called\n")); + + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database\n"); + PQclear(pg_db_qry); + return MFD_RESOURCE_UNAVAILABLE; + } + resultCount = PQntuples(pg_db_qry); + + /* + * TODO:351:M: |-> Load/update data in the pgsqlPgAggregateTable container. + * loop over your pgsqlPgAggregateTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new pgsqlPgAggregateTable rowreq context. + */ + rowreq_ctx = pgsqlPgAggregateTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + if(MFD_SUCCESS != pgsqlPgAggregateTable_indexes_set(rowreq_ctx + , pgsnmpdConnID, pgsnmpdConnID_len + , rdbmsDbIndex + , atol(PQgetvalue(pg_db_qry, i, 0)) + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "pgsqlPgAggregateTable cache.\n"); + pgsqlPgAggregateTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + rowreq_ctx->data.pgsqlPgAggregateAgginitval_len = 255; + + rowreq_ctx->data.pgsqlPgAggregateAggfnoid = strtoul(PQgetvalue(pg_db_qry, i, 1), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggtransfn = strtoul(PQgetvalue(pg_db_qry, i, 2), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggfinalfn = strtoul(PQgetvalue(pg_db_qry, i, 3), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggsortop = strtoul(PQgetvalue(pg_db_qry, i, 4), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggtranstype = strtoul(PQgetvalue(pg_db_qry, i, 5), NULL, 10); + + tmpString = PQgetvalue(pg_db_qry, i, 6); + tmpInt = strlen(tmpString); + if ((NULL == rowreq_ctx->data.pgsqlPgAggregateAgginitval) || + (rowreq_ctx->data.pgsqlPgAggregateAgginitval_len < (tmpInt * sizeof(rowreq_ctx->data.pgsqlPgAggregateAgginitval[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + rowreq_ctx->data.pgsqlPgAggregateAgginitval_len = tmpInt * sizeof(rowreq_ctx->data.pgsqlPgAggregateAgginitval[0]); + memcpy( rowreq_ctx->data.pgsqlPgAggregateAgginitval, tmpString, rowreq_ctx->data.pgsqlPgAggregateAgginitval_len ); + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + + DEBUGMSGT(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_cache_load", + "inserted %d records\n", count)); + PQclear(pg_db_qry); + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +pgsqlPgAggregateTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_cache_free","called\n")); + + /* + * TODO:380:M: Free pgsqlPgAggregateTable cache. + */ +} /* pgsqlPgAggregateTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +pgsqlPgAggregateTable_row_prep( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_row_prep */ + +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h new file mode 100644 index 0000000..6831083 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h @@ -0,0 +1,70 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_access.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_DATA_ACCESS_H +#define PGSQLPGAGGREGATETABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + + + int pgsqlPgAggregateTable_init_data(pgsqlPgAggregateTable_registration_ptr pgsqlPgAggregateTable_reg); + + +/* + * TODO:180:o: Review pgsqlPgAggregateTable cache timeout. + * The number of seconds before the cache times out + */ +#define PGSQLPGAGGREGATETABLE_CACHE_TIMEOUT 60 + +void pgsqlPgAggregateTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int pgsqlPgAggregateTable_cache_load(netsnmp_container *container); +void pgsqlPgAggregateTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int pgsqlPgAggregateTable_row_prep( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_DATA_ACCESS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c new file mode 100644 index 0000000..c156328 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c @@ -0,0 +1,839 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_get.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement pgsqlPgAggregateTable get routines. + * TODO:240:M: Implement pgsqlPgAggregateTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement pgsqlPgAggregateTable data context functions. + */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsnmpdConnectionEntry.pgsnmpdConnID + * pgsnmpdConnID is subid 1 of pgsnmpdConnectionEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.1.1.1.1 + * Description: +Identifying string for this connection. Default is host:port:database. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE pgsnmpdConnID IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsnmpdConnID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_pgsnmpdConnID_val_ptr); + netsnmp_assert((NULL != mib_pgsnmpdConnID_val_ptr_ptr) && (NULL != mib_pgsnmpdConnID_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsnmpdConnID_map","called\n")); + + /* + * TODO:241:r: |-> Implement pgsnmpdConnID non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_pgsnmpdConnID_val_ptr_len; /* assume equal */ + if((NULL == *mib_pgsnmpdConnID_val_ptr_ptr) || (*mib_pgsnmpdConnID_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_pgsnmpdConnID_val_ptr_ptr = realloc( *mib_pgsnmpdConnID_val_ptr_ptr, converted_len * sizeof(**mib_pgsnmpdConnID_val_ptr_ptr)); + if(NULL == *mib_pgsnmpdConnID_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_pgsnmpdConnID_val_ptr_len_ptr = converted_len; + memcpy( *mib_pgsnmpdConnID_val_ptr_ptr, raw_pgsnmpdConnID_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* pgsnmpdConnID_map */ + + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateEntryOID + * pgsqlPgAggregateEntryOID is subid 1 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.1 + * Description: +OID of this entry + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + * + * + * + * NOTE: NODE pgsqlPgAggregateEntryOID IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateEntryOID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateEntryOID_map(long *mib_pgsqlPgAggregateEntryOID_val_ptr, long raw_pgsqlPgAggregateEntryOID_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateEntryOID_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateEntryOID_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateEntryOID mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateEntryOID_val_ptr) = raw_pgsqlPgAggregateEntryOID_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateEntryOID_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +pgsqlPgAggregateTable_indexes_set_tbl_idx(pgsqlPgAggregateTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_indexes_set_tbl_idx","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + tbl_idx->pgsnmpdConnID_len = sizeof(tbl_idx->pgsnmpdConnID); + /* + * make sure there is enough space for pgsnmpdConnID data + */ + if ((NULL == tbl_idx->pgsnmpdConnID) || + (tbl_idx->pgsnmpdConnID_len < (pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->pgsnmpdConnID_len = pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0]); + memcpy( tbl_idx->pgsnmpdConnID, pgsnmpdConnID_val_ptr, tbl_idx->pgsnmpdConnID_len ); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + /* pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ + tbl_idx->pgsqlPgAggregateEntryOID = pgsqlPgAggregateEntryOID_val; + + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +pgsqlPgAggregateTable_indexes_set(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_indexes_set","called\n")); + + if(MFD_SUCCESS != pgsqlPgAggregateTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , pgsnmpdConnID_val_ptr, pgsnmpdConnID_val_ptr_len + , rdbmsDbIndex_val + , pgsqlPgAggregateEntryOID_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != pgsqlPgAggregateTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggfnoid + * pgsqlPgAggregateAggfnoid is subid 2 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.2 + * Description: +pg_proc OID of the aggregate function + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggfnoid.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggfnoid_map(long *mib_pgsqlPgAggregateAggfnoid_val_ptr, long raw_pgsqlPgAggregateAggfnoid_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggfnoid_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfnoid_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggfnoid mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggfnoid_val_ptr) = raw_pgsqlPgAggregateAggfnoid_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfnoid_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggfnoid data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggfnoid_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggfnoid_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfnoid_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggfnoid_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfnoid_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggfnoid data. + * set (* pgsqlPgAggregateAggfnoid_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggfnoid_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggfnoid; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfnoid_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggtransfn + * pgsqlPgAggregateAggtransfn is subid 3 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.3 + * Description: +Transition function + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggtransfn.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggtransfn_map(long *mib_pgsqlPgAggregateAggtransfn_val_ptr, long raw_pgsqlPgAggregateAggtransfn_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggtransfn_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtransfn_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggtransfn mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggtransfn_val_ptr) = raw_pgsqlPgAggregateAggtransfn_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtransfn_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggtransfn data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggtransfn_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggtransfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtransfn_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggtransfn_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtransfn_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggtransfn data. + * set (* pgsqlPgAggregateAggtransfn_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggtransfn_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggtransfn; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtransfn_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggfinalfn + * pgsqlPgAggregateAggfinalfn is subid 4 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.4 + * Description: +Final function (zero if none) + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggfinalfn.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggfinalfn_map(long *mib_pgsqlPgAggregateAggfinalfn_val_ptr, long raw_pgsqlPgAggregateAggfinalfn_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggfinalfn_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfinalfn_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggfinalfn mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggfinalfn_val_ptr) = raw_pgsqlPgAggregateAggfinalfn_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfinalfn_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggfinalfn data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggfinalfn_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggfinalfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfinalfn_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggfinalfn_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfinalfn_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggfinalfn data. + * set (* pgsqlPgAggregateAggfinalfn_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggfinalfn_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggfinalfn; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfinalfn_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggsortop + * pgsqlPgAggregateAggsortop is subid 5 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.5 + * Description: +Associated sort operator (zero if none) + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggsortop.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggsortop_map(long *mib_pgsqlPgAggregateAggsortop_val_ptr, long raw_pgsqlPgAggregateAggsortop_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggsortop_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggsortop_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggsortop mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggsortop_val_ptr) = raw_pgsqlPgAggregateAggsortop_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggsortop_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggsortop data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggsortop_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggsortop_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggsortop_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggsortop_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggsortop_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggsortop data. + * set (* pgsqlPgAggregateAggsortop_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggsortop_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggsortop; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggsortop_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggtranstype + * pgsqlPgAggregateAggtranstype is subid 6 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.6 + * Description: +Data type of the aggregate function's internal transition (state) data + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggtranstype.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggtranstype_map(long *mib_pgsqlPgAggregateAggtranstype_val_ptr, long raw_pgsqlPgAggregateAggtranstype_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggtranstype_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtranstype_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggtranstype mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggtranstype_val_ptr) = raw_pgsqlPgAggregateAggtranstype_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtranstype_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggtranstype data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggtranstype_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggtranstype_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtranstype_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggtranstype_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtranstype_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggtranstype data. + * set (* pgsqlPgAggregateAggtranstype_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggtranstype_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggtranstype; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtranstype_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAgginitval + * pgsqlPgAggregateAgginitval is subid 7 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.7 + * Description: +The initial value of the transition state. This is a text field containing the initial value in its external string representation. If this field is NULL, the transition state value starts out NULL + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAgginitval.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAgginitval_map(char **mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr, char *raw_pgsqlPgAggregateAgginitval_val_ptr, size_t raw_pgsqlPgAggregateAgginitval_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_pgsqlPgAggregateAgginitval_val_ptr); + netsnmp_assert((NULL != mib_pgsqlPgAggregateAgginitval_val_ptr_ptr) && (NULL != mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAgginitval_map","called\n")); + + /* + * TODO:241:r: |-> Implement pgsqlPgAggregateAgginitval non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_pgsqlPgAggregateAgginitval_val_ptr_len; /* assume equal */ + if((NULL == *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr) || (*mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr = realloc( *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, converted_len * sizeof(**mib_pgsqlPgAggregateAgginitval_val_ptr_ptr)); + if(NULL == *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr = converted_len; + memcpy( *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, raw_pgsqlPgAggregateAgginitval_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAgginitval_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAgginitval data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAgginitval_val_ptr_ptr + * Pointer to storage for a char variable + * @param pgsqlPgAggregateAgginitval_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by pgsqlPgAggregateAgginitval. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*pgsqlPgAggregateAgginitval_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update pgsqlPgAggregateAgginitval_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +pgsqlPgAggregateAgginitval_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char **pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != pgsqlPgAggregateAgginitval_val_ptr_ptr) && (NULL != *pgsqlPgAggregateAgginitval_val_ptr_ptr)); + netsnmp_assert( NULL != pgsqlPgAggregateAgginitval_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAgginitval_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAgginitval data. + * set (* pgsqlPgAggregateAgginitval_val_ptr_ptr ) and (* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for pgsqlPgAggregateAgginitval data + */ + if ((NULL == (* pgsqlPgAggregateAgginitval_val_ptr_ptr )) || + ((* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) < (rowreq_ctx->data.pgsqlPgAggregateAgginitval_len * sizeof((* pgsqlPgAggregateAgginitval_val_ptr_ptr )[0])))) { + /* + * allocate space for pgsqlPgAggregateAgginitval data + */ + (* pgsqlPgAggregateAgginitval_val_ptr_ptr ) = malloc(rowreq_ctx->data.pgsqlPgAggregateAgginitval_len * sizeof((* pgsqlPgAggregateAgginitval_val_ptr_ptr )[0])); + if(NULL == (* pgsqlPgAggregateAgginitval_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAgginitval_len * sizeof((* pgsqlPgAggregateAgginitval_val_ptr_ptr )[0]); + memcpy( (* pgsqlPgAggregateAgginitval_val_ptr_ptr ), rowreq_ctx->data.pgsqlPgAggregateAgginitval, (* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAgginitval_get */ + + + +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h new file mode 100644 index 0000000..c5c1e73 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h @@ -0,0 +1,72 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_get.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + * + * @file pgsqlPgAggregateTable_data_get.h + * + * @addtogroup get + * + * Prototypes for get functions + * + * @{ + */ +#ifndef PGSQLPGAGGREGATETABLE_DATA_GET_H +#define PGSQLPGAGGREGATETABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + /* + * indexes + */ + int pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc); + int pgsqlPgAggregateEntryOID_map(long *mib_pgsqlPgAggregateEntryOID_val_ptr, long raw_pgsqlPgAggregateEntryOID_val); + + int pgsqlPgAggregateAggfnoid_map(long *mib_pgsqlPgAggregateAggfnoid_val_ptr, long raw_pgsqlPgAggregateAggfnoid_val); + int pgsqlPgAggregateAggfnoid_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfnoid_val_ptr ); + int pgsqlPgAggregateAggtransfn_map(long *mib_pgsqlPgAggregateAggtransfn_val_ptr, long raw_pgsqlPgAggregateAggtransfn_val); + int pgsqlPgAggregateAggtransfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtransfn_val_ptr ); + int pgsqlPgAggregateAggfinalfn_map(long *mib_pgsqlPgAggregateAggfinalfn_val_ptr, long raw_pgsqlPgAggregateAggfinalfn_val); + int pgsqlPgAggregateAggfinalfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfinalfn_val_ptr ); + int pgsqlPgAggregateAggsortop_map(long *mib_pgsqlPgAggregateAggsortop_val_ptr, long raw_pgsqlPgAggregateAggsortop_val); + int pgsqlPgAggregateAggsortop_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggsortop_val_ptr ); + int pgsqlPgAggregateAggtranstype_map(long *mib_pgsqlPgAggregateAggtranstype_val_ptr, long raw_pgsqlPgAggregateAggtranstype_val); + int pgsqlPgAggregateAggtranstype_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtranstype_val_ptr ); + int pgsqlPgAggregateAgginitval_map(char **mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr, char *raw_pgsqlPgAggregateAgginitval_val_ptr, size_t raw_pgsqlPgAggregateAgginitval_val_ptr_len, int allow_realloc); + int pgsqlPgAggregateAgginitval_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char **pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *pgsqlPgAggregateAgginitval_val_ptr_len_ptr ); + + +int pgsqlPgAggregateTable_indexes_set_tbl_idx(pgsqlPgAggregateTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val); +int pgsqlPgAggregateTable_indexes_set(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_DATA_GET_H */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c new file mode 100644 index 0000000..b266046 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c @@ -0,0 +1,24 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_set.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + * + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h new file mode 100644 index 0000000..52061bc --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h @@ -0,0 +1,27 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_set.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_DATA_SET_H +#define PGSQLPGAGGREGATETABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_DATA_SET_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h new file mode 100644 index 0000000..161cc07 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h @@ -0,0 +1,40 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c,v 1.3 2004/05/18 17:44:32 rstory Exp $ + * + * $Id: pgsqlPgAggregateTable_enums.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_ENUMS_H +#define PGSQLPGAGGREGATETABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table pgsqlPgAggregateTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_ENUMS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c new file mode 100644 index 0000000..8215a2d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c @@ -0,0 +1,784 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_interface.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + + +#include + +#include "pgsqlPgAggregateTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ +typedef struct pgsqlPgAggregateTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + pgsqlPgAggregateTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} pgsqlPgAggregateTable_interface_ctx; + +static pgsqlPgAggregateTable_interface_ctx pgsqlPgAggregateTable_if_ctx; + +static void _pgsqlPgAggregateTable_container_init( + pgsqlPgAggregateTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_pre_request; +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_post_request; +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_object_lookup; +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_get_values; +/** + * @internal + * Initialize the table pgsqlPgAggregateTable + * (Define its contents and how it's structured) + */ +void +_pgsqlPgAggregateTable_initialize_interface(pgsqlPgAggregateTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &pgsqlPgAggregateTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &pgsqlPgAggregateTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_pgsqlPgAggregateTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for pgsqlPgAggregateTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_OCTET_STR, /** index: pgsnmpdConnID */ + ASN_INTEGER, /** index: rdbmsDbIndex */ + ASN_INTEGER, /** index: pgsqlPgAggregateEntryOID */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = PGSQLPGAGGREGATETABLE_MIN_COL; + tbl_info->max_column = PGSQLPGAGGREGATETABLE_MAX_COL; + + /* + * save users context + */ + pgsqlPgAggregateTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + pgsqlPgAggregateTable_init_data(reg_ptr); + + /* + * set up the container + */ + _pgsqlPgAggregateTable_container_init(&pgsqlPgAggregateTable_if_ctx); + if (NULL == pgsqlPgAggregateTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for pgsqlPgAggregateTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_pgsqlPgAggregateTable_object_lookup; + access_multiplexer->get_values = _mfd_pgsqlPgAggregateTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_pgsqlPgAggregateTable_pre_request; + access_multiplexer->post_request = _mfd_pgsqlPgAggregateTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("pgsqlPgAggregateTable:init_pgsqlPgAggregateTable", + "Registering pgsqlPgAggregateTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("pgsqlPgAggregateTable", handler, + pgsqlPgAggregateTable_oid, + pgsqlPgAggregateTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table pgsqlPgAggregateTable\n"); + return; + } + reginfo->my_reg_void = &pgsqlPgAggregateTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + pgsqlPgAggregateTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != pgsqlPgAggregateTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(pgsqlPgAggregateTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _pgsqlPgAggregateTable_initialize_interface */ + +void +pgsqlPgAggregateTable_valid_columns_set(netsnmp_column_info *vc) +{ + pgsqlPgAggregateTable_if_ctx.tbl_info.valid_columns = vc; +} /* pgsqlPgAggregateTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +pgsqlPgAggregateTable_index_to_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + netsnmp_variable_list var_pgsqlPgAggregateEntryOID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_pgsqlPgAggregateEntryOID, 0x00, sizeof(var_pgsqlPgAggregateEntryOID) ); + var_pgsqlPgAggregateEntryOID.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAggregateEntryOID; var_pgsqlPgAggregateEntryOID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_index_to_oid","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + snmp_set_var_value(&var_pgsnmpdConnID, (u_char*)&mib_idx->pgsnmpdConnID, + mib_idx->pgsnmpdConnID_len * sizeof(mib_idx->pgsnmpdConnID[0])); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + /* pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ + snmp_set_var_value(&var_pgsqlPgAggregateEntryOID, (u_char*)&mib_idx->pgsqlPgAggregateEntryOID, + sizeof(mib_idx->pgsqlPgAggregateEntryOID)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_pgsnmpdConnID); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsqlPgAggregateTable_index_to_oid */ + +/** + * extract pgsqlPgAggregateTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +pgsqlPgAggregateTable_index_from_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + netsnmp_variable_list var_pgsqlPgAggregateEntryOID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_pgsqlPgAggregateEntryOID, 0x00, sizeof(var_pgsqlPgAggregateEntryOID) ); + var_pgsqlPgAggregateEntryOID.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAggregateEntryOID; var_pgsqlPgAggregateEntryOID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_pgsnmpdConnID ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + /* + * NOTE: val_len is in bytes, pgsnmpdConnID_len might not be + */ + if(var_pgsnmpdConnID.val_len > sizeof(mib_idx->pgsnmpdConnID)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->pgsnmpdConnID, var_pgsnmpdConnID.val.string, var_pgsnmpdConnID.val_len); + mib_idx->pgsnmpdConnID_len = var_pgsnmpdConnID.val_len / sizeof(mib_idx->pgsnmpdConnID[0]); + } + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + mib_idx->pgsqlPgAggregateEntryOID = *((long *)var_pgsqlPgAggregateEntryOID.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsqlPgAggregateTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a pgsqlPgAggregateTable_rowreq_ctx + */ +pgsqlPgAggregateTable_rowreq_ctx * +pgsqlPgAggregateTable_allocate_rowreq_ctx(void) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(pgsqlPgAggregateTable_rowreq_ctx); + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:pgsqlPgAggregateTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "pgsqlPgAggregateTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->pgsqlPgAggregateTable_data_list = NULL; + rowreq_ctx->pgsqlPgAggregateTable_reg = pgsqlPgAggregateTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* pgsqlPgAggregateTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a pgsqlPgAggregateTable_rowreq_ctx + */ +void +pgsqlPgAggregateTable_release_rowreq_ctx(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:pgsqlPgAggregateTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* pgsqlPgAggregateTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAggregateTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = pgsqlPgAggregateTable_pre_request(pgsqlPgAggregateTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable","error %d from " + "pgsqlPgAggregateTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAggregateTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx; + int rc = pgsqlPgAggregateTable_post_request(pgsqlPgAggregateTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable","error %d from " + "pgsqlPgAggregateTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(pgsqlPgAggregateTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(pgsqlPgAggregateTable_if_ctx.container, rowreq_ctx); + pgsqlPgAggregateTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAggregateTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_mfd_pgsqlPgAggregateTable_object_lookup","called\n")); + + /* + * get our context from mfd + * pgsqlPgAggregateTable_interface_ctx *if_ctx = + * (pgsqlPgAggregateTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + pgsqlPgAggregateTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_pgsqlPgAggregateTable_get_column( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_mfd_pgsqlPgAggregateTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* pgsqlPgAggregateAggfnoid(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGFNOID: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggfnoid_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggtransfn(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGTRANSFN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggtransfn_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggfinalfn(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGFINALFN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggfinalfn_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggsortop(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGSORTOP: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggsortop_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggtranstype(6)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGTRANSTYPE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggtranstype_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAgginitval(7)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_PGSQLPGAGGREGATEAGGINITVAL: + var->type = ASN_OCTET_STR; +rc = pgsqlPgAggregateAgginitval_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _pgsqlPgAggregateTable_get_column\n", column); + break; + } + + return rc; +} /* _pgsqlPgAggregateTable_get_column */ + +int +_mfd_pgsqlPgAggregateTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_mfd_pgsqlPgAggregateTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _pgsqlPgAggregateTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for pgsqlPgAggregateTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return pgsqlPgAggregateTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + pgsqlPgAggregateTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in pgsqlPgAggregateTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + pgsqlPgAggregateTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_pgsqlPgAggregateTable_container_init(pgsqlPgAggregateTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_pgsqlPgAggregateTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + pgsqlPgAggregateTable_oid, + pgsqlPgAggregateTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for pgsqlPgAggregateTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + pgsqlPgAggregateTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("pgsqlPgAggregateTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "pgsqlPgAggregateTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _pgsqlPgAggregateTable_container_init */ + diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h new file mode 100644 index 0000000..94a4e9a --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h @@ -0,0 +1,72 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_interface.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/** @defgroup interface: Routines to interface to Net-SNMP + * + * \warning This code should not be modified, called directly, + * or used to interpret functionality. It is subject to + * change at any time. + * + * @{ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ +#ifndef PGSQLPGAGGREGATETABLE_INTERFACE_H +#define PGSQLPGAGGREGATETABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "pgsqlPgAggregateTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _pgsqlPgAggregateTable_initialize_interface(pgsqlPgAggregateTable_registration_ptr user_ctx, + u_long flags); + + pgsqlPgAggregateTable_rowreq_ctx * pgsqlPgAggregateTable_allocate_rowreq_ctx(void); +void pgsqlPgAggregateTable_release_rowreq_ctx(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx); + +int pgsqlPgAggregateTable_index_to_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx); +int pgsqlPgAggregateTable_index_from_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void pgsqlPgAggregateTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_INTERFACE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h new file mode 100644 index 0000000..bb5a69d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h @@ -0,0 +1,33 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c,v 1.10 2004/10/08 23:39:17 rstory Exp $ + * + * $Id: pgsqlPgAggregateTable_oids.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_OIDS_H +#define PGSQLPGAGGREGATETABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table pgsqlPgAggregateTable */ +#define PGSQLPGAGGREGATETABLE_OID 1,3,6,1,4,1,27645,1,2,1 +#define COLUMN_PGSQLPGAGGREGATEENTRYOID 1 +#define COLUMN_PGSQLPGAGGREGATEAGGFNOID 2 +#define COLUMN_PGSQLPGAGGREGATEAGGTRANSFN 3 +#define COLUMN_PGSQLPGAGGREGATEAGGFINALFN 4 +#define COLUMN_PGSQLPGAGGREGATEAGGSORTOP 5 +#define COLUMN_PGSQLPGAGGREGATEAGGTRANSTYPE 6 +#define COLUMN_PGSQLPGAGGREGATEAGGINITVAL 7 + +#define PGSQLPGAGGREGATETABLE_MIN_COL COLUMN_PGSQLPGAGGREGATEAGGFNOID +#define PGSQLPGAGGREGATETABLE_MAX_COL COLUMN_PGSQLPGAGGREGATEAGGINITVAL + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_OIDS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.c new file mode 100644 index 0000000..d8d6304 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.c @@ -0,0 +1,129 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsqlPgAmTable.c,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +/** \mainpage MFD helper for pgsqlPgAmTable + * + * \section intro Introduction + * Introductory text. + * + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAmTable.h" + +#include + +#include "pgsqlPgAmTable_interface.h" + +oid pgsqlPgAmTable_oid[] = { PGSQLPGAMTABLE_OID }; +int pgsqlPgAmTable_oid_size = OID_LENGTH(pgsqlPgAmTable_oid); + +void initialize_table_pgsqlPgAmTable(void); + + +/** + * Initializes the pgsqlPgAmTable module + */ +void +init_pgsqlPgAmTable(void) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:init_pgsqlPgAmTable","called\n")); + + /* + * TODO:300:o: Perform pgsqlPgAmTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("pgsqlPgAmTable")) + initialize_table_pgsqlPgAmTable(); + +} /* init_pgsqlPgAmTable */ + +/** + * Initialize the table pgsqlPgAmTable + * (Define its contents and how it's structured) + */ +void +initialize_table_pgsqlPgAmTable(void) +{ + pgsqlPgAmTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:initialize_table_pgsqlPgAmTable","called\n")); + + /* + * TODO:301:o: Perform pgsqlPgAmTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize pgsqlPgAmTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("pgsqlPgAmTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _pgsqlPgAmTable_initialize_interface(user_context, flags); +} /* initialize_table_pgsqlPgAmTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +pgsqlPgAmTable_pre_request(pgsqlPgAmTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform pgsqlPgAmTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +pgsqlPgAmTable_post_request(pgsqlPgAmTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_post_request","called\n")); + + /* + * TODO:511:o: Perform pgsqlPgAmTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_post_request */ + + +/** @{ */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.h new file mode 100644 index 0000000..a6e5f01 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable.h @@ -0,0 +1,306 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsqlPgAmTable.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +#ifndef PGSQLPGAMTABLE_H +#define PGSQLPGAMTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(PGSQL-MIB/pgsqlPgAmTable/pgsqlPgAmTable_interface); +config_require(PGSQL-MIB/pgsqlPgAmTable/pgsqlPgAmTable_data_access); +config_require(PGSQL-MIB/pgsqlPgAmTable/pgsqlPgAmTable_data_get); +config_require(PGSQL-MIB/pgsqlPgAmTable/pgsqlPgAmTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "pgsqlPgAmTable_oids.h" + +/* enum definions */ +#include "pgsqlPgAmTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_pgsqlPgAmTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAmTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAmTable is subid 2 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.2, length: 10 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review pgsqlPgAmTable registration context. + */ +typedef netsnmp_data_list * pgsqlPgAmTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review pgsqlPgAmTable data context structure. + * This structure is used to represent the data for pgsqlPgAmTable. + */ +/* + * This structure contains storage for all the columns defined in the + * pgsqlPgAmTable. + */ +typedef struct pgsqlPgAmTable_data_s { + + /* + * pgsqlPgAmAmname(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char pgsqlPgAmAmname[255]; +size_t pgsqlPgAmAmname_len; /* # of char elements, not bytes */ + + /* + * pgsqlPgAmAmstrategies(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmstrategies; + + /* + * pgsqlPgAmAmsupport(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmsupport; + + /* + * pgsqlPgAmAmorderstrategy(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmorderstrategy; + + /* + * pgsqlPgAmAmcanunique(6)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long pgsqlPgAmAmcanunique; + + /* + * pgsqlPgAmAmcanmulticol(7)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long pgsqlPgAmAmcanmulticol; + + /* + * pgsqlPgAmAmoptionalkey(8)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long pgsqlPgAmAmoptionalkey; + + /* + * pgsqlPgAmAmindexnulls(9)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long pgsqlPgAmAmindexnulls; + + /* + * pgsqlPgAmAmstorage(10)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long pgsqlPgAmAmstorage; + + /* + * pgsqlPgAmAmclusterable(11)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long pgsqlPgAmAmclusterable; + + /* + * pgsqlPgAmAminsert(12)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAminsert; + + /* + * pgsqlPgAmAmbeginscan(13)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmbeginscan; + + /* + * pgsqlPgAmAmgettuple(14)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmgettuple; + + /* + * pgsqlPgAmAmgetmulti(15)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmgetmulti; + + /* + * pgsqlPgAmAmrescan(16)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmrescan; + + /* + * pgsqlPgAmAmendscan(17)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmendscan; + + /* + * pgsqlPgAmAmmarkpos(18)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmmarkpos; + + /* + * pgsqlPgAmAmrestrpos(19)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmrestrpos; + + /* + * pgsqlPgAmAmbuild(20)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmbuild; + + /* + * pgsqlPgAmAmbulkdelete(21)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmbulkdelete; + + /* + * pgsqlPgAmAmvacuumcleanup(22)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmvacuumcleanup; + + /* + * pgsqlPgAmAmcostestimate(23)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmcostestimate; + + /* + * pgsqlPgAmAmoptions(24)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAmAmoptions; + +} pgsqlPgAmTable_data; + + +/* + * TODO:120:r: |-> Review pgsqlPgAmTable mib index. + * This structure is used to represent the index for pgsqlPgAmTable. + */ +typedef struct pgsqlPgAmTable_mib_index_s { + + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + /** 128 - 2(other indexes) - oid length(12) = 113 */ + char pgsnmpdConnID[113]; + size_t pgsnmpdConnID_len; + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + /* + * pgsqlPgAmEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + long pgsqlPgAmEntryOID; + + +} pgsqlPgAmTable_mib_index; + + /* + * TODO:121:r: | |-> Review pgsqlPgAmTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + * Guessing 128 - col/entry(2) - oid len(10) +*/ +#define MAX_pgsqlPgAmTable_IDX_LEN 116 + + +/* ********************************************************************* + * TODO:130:o: |-> Review pgsqlPgAmTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * pgsqlPgAmTable_rowreq_ctx pointer. + */ +typedef struct pgsqlPgAmTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_pgsqlPgAmTable_IDX_LEN]; + + pgsqlPgAmTable_mib_index tbl_idx; + + pgsqlPgAmTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + pgsqlPgAmTable_registration_ptr pgsqlPgAmTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to pgsqlPgAmTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *pgsqlPgAmTable_data_list; + +} pgsqlPgAmTable_rowreq_ctx; + +typedef struct pgsqlPgAmTable_ref_rowreq_ctx_s { + pgsqlPgAmTable_rowreq_ctx *rowreq_ctx; +} pgsqlPgAmTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int pgsqlPgAmTable_pre_request(pgsqlPgAmTable_registration_ptr user_context); + int pgsqlPgAmTable_post_request(pgsqlPgAmTable_registration_ptr user_context); + + +extern oid pgsqlPgAmTable_oid[]; +extern int pgsqlPgAmTable_oid_size; + + +#include "pgsqlPgAmTable_interface.h" +#include "pgsqlPgAmTable_data_access.h" +#include "pgsqlPgAmTable_data_get.h" +#include "pgsqlPgAmTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.c new file mode 100644 index 0000000..0d910c4 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.c @@ -0,0 +1,312 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsqlPgAmTable_data_access.c,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +#include "pgsnmpd.h" + +/* include our parent header */ +#include "pgsqlPgAmTable.h" +#include "pgsqlPgAmTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAmTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAmTable is subid 2 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.2, length: 10 +*/ + +/** + * initialization for pgsqlPgAmTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param pgsqlPgAmTable_reg + * Pointer to pgsqlPgAmTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +pgsqlPgAmTable_init_data(pgsqlPgAmTable_registration_ptr pgsqlPgAmTable_reg) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_init_data","called\n")); + + /* + * TODO:303:o: Initialize pgsqlPgAmTable data. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +pgsqlPgAmTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to pgsqlPgAmTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up pgsqlPgAmTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = PGSQLPGAMTABLE_CACHE_TIMEOUT; /* seconds */ +} /* pgsqlPgAmTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement pgsqlPgAmTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * pgsqlPgAmTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +pgsqlPgAmTable_cache_load(netsnmp_container *container) +{ + pgsqlPgAmTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + + int i, resultCount, tmpInt; + char *tmpString; + PGresult *pg_db_qry; + + char pgsnmpdConnID[112] = "Default conn ID"; + size_t pgsnmpdConnID_len = strlen(pgsnmpdConnID); + long rdbmsDbIndex = 1; + long pgsqlPgAmEntryOID; + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_cache_load","called\n")); + snmp_log(LOG_INFO, "Running pgsqlPgAmTable\n"); + + if (PQstatus(dbconn) == CONNECTION_OK) + pg_db_qry = PQexec(dbconn, "SELECT oid, amname, amstrategies, amsupport, amorderstrategy, CASE WHEN amcanunique THEN 1 ELSE 2 END, CASE WHEN amcanmulticol THEN 1 ELSE 2 END, CASE WHEN amoptionalkey THEN 1 ELSE 2 END, CASE WHEN amindexnulls THEN 1 ELSE 2 END, CASE WHEN amstorage THEN 1 ELSE 2 END, CASE WHEN amclusterable THEN 1 ELSE 2 END, aminsert, ambeginscan, amgettuple, amgetmulti, amrescan, amendscan, ammarkpos, amrestrpos, ambuild, ambulkdelete, amvacuumcleanup, amcostestimate, amoptions FROM pg_am"); + else { + snmp_log(LOG_ERR, "Can't get connected to database\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database\n"); + PQclear(pg_db_qry); + return MFD_RESOURCE_UNAVAILABLE; + } + resultCount = PQntuples(pg_db_qry); + + /* + * TODO:351:M: |-> Load/update data in the pgsqlPgAmTable container. + * loop over your pgsqlPgAmTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (i = 0; i < resultCount; i++) { + /* + * TODO:352:M: | |-> set indexes in new pgsqlPgAmTable rowreq context. + */ + rowreq_ctx = pgsqlPgAmTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + if(MFD_SUCCESS != pgsqlPgAmTable_indexes_set(rowreq_ctx + , pgsnmpdConnID, pgsnmpdConnID_len + , rdbmsDbIndex + , atol(PQgetvalue(pg_db_qry, i, 0)) + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "pgsqlPgAmTable cache.\n"); + pgsqlPgAmTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + rowreq_ctx->data.pgsqlPgAmAmname_len = 255; + + tmpString = PQgetvalue(pg_db_qry, i, 1); + tmpInt = strlen(tmpString); + if ((NULL == rowreq_ctx->data.pgsqlPgAmAmname) || + (rowreq_ctx->data.pgsqlPgAmAmname_len < (tmpInt * sizeof(rowreq_ctx->data.pgsqlPgAmAmname[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + rowreq_ctx->data.pgsqlPgAmAmname_len = tmpInt * sizeof(rowreq_ctx->data.pgsqlPgAmAmname[0]); + memcpy( rowreq_ctx->data.pgsqlPgAmAmname, tmpString, rowreq_ctx->data.pgsqlPgAmAmname_len ); + + rowreq_ctx->data.pgsqlPgAmAmstrategies = strtoul(PQgetvalue(pg_db_qry, i, 2), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmsupport = strtoul(PQgetvalue(pg_db_qry, i, 3), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmorderstrategy = strtoul(PQgetvalue(pg_db_qry, i, 4), NULL, 10); + + /* These are TruthValue columns. 1 = true, 2 = false */ + rowreq_ctx->data.pgsqlPgAmAmcanunique, strtoul(PQgetvalue(pg_db_qry, i, 5), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmcanmulticol, strtoul(PQgetvalue(pg_db_qry, i, 6), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmoptionalkey, strtoul(PQgetvalue(pg_db_qry, i, 7), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmindexnulls, strtoul(PQgetvalue(pg_db_qry, i, 8), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmstorage, strtoul(PQgetvalue(pg_db_qry, i, 9), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmclusterable, strtoul(PQgetvalue(pg_db_qry, i, 10), NULL, 10); + + rowreq_ctx->data.pgsqlPgAmAminsert = strtoul(PQgetvalue(pg_db_qry, i, 11), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmbeginscan = strtoul(PQgetvalue(pg_db_qry, i, 12), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmgettuple = strtoul(PQgetvalue(pg_db_qry, i, 13), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmgetmulti = strtoul(PQgetvalue(pg_db_qry, i, 14), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmrescan = strtoul(PQgetvalue(pg_db_qry, i, 15), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmendscan = strtoul(PQgetvalue(pg_db_qry, i, 16), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmmarkpos = strtoul(PQgetvalue(pg_db_qry, i, 17), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmrestrpos = strtoul(PQgetvalue(pg_db_qry, i, 18), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmbuild = strtoul(PQgetvalue(pg_db_qry, i, 19), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmbulkdelete = strtoul(PQgetvalue(pg_db_qry, i, 20), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmvacuumcleanup = strtoul(PQgetvalue(pg_db_qry, i, 21), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmcostestimate = strtoul(PQgetvalue(pg_db_qry, i, 22), NULL, 10); + rowreq_ctx->data.pgsqlPgAmAmoptions = strtoul(PQgetvalue(pg_db_qry, i, 23), NULL, 10); + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + + DEBUGMSGT(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_cache_load", + "inserted %d records\n", count)); + PQclear(pg_db_qry); + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +pgsqlPgAmTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_cache_free","called\n")); + + /* + * TODO:380:M: Free pgsqlPgAmTable cache. + */ +} /* pgsqlPgAmTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +pgsqlPgAmTable_row_prep( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_row_prep */ + +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.h new file mode 100644 index 0000000..29987d0 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_access.h @@ -0,0 +1,70 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsqlPgAmTable_data_access.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +#ifndef PGSQLPGAMTABLE_DATA_ACCESS_H +#define PGSQLPGAMTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAmTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAmTable is subid 2 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.2, length: 10 +*/ + + + int pgsqlPgAmTable_init_data(pgsqlPgAmTable_registration_ptr pgsqlPgAmTable_reg); + + +/* + * TODO:180:o: Review pgsqlPgAmTable cache timeout. + * The number of seconds before the cache times out + */ +#define PGSQLPGAMTABLE_CACHE_TIMEOUT 60 + +void pgsqlPgAmTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int pgsqlPgAmTable_cache_load(netsnmp_container *container); +void pgsqlPgAmTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int pgsqlPgAmTable_row_prep( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_DATA_ACCESS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.c new file mode 100644 index 0000000..84d66fb --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.c @@ -0,0 +1,2289 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsqlPgAmTable_data_get.c,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAmTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement pgsqlPgAmTable get routines. + * TODO:240:M: Implement pgsqlPgAmTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAmTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAmTable is subid 2 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.2, length: 10 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement pgsqlPgAmTable data context functions. + */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmEntryOID + * pgsqlPgAmEntryOID is subid 1 of pgsqlPgAmEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.1 + * Description: +OID of this entry + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + * + * + * + * NOTE: NODE pgsqlPgAmEntryOID IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmEntryOID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmEntryOID_map(long *mib_pgsqlPgAmEntryOID_val_ptr, long raw_pgsqlPgAmEntryOID_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmEntryOID_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmEntryOID_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmEntryOID mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmEntryOID_val_ptr) = raw_pgsqlPgAmEntryOID_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmEntryOID_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +pgsqlPgAmTable_indexes_set_tbl_idx(pgsqlPgAmTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAmEntryOID_val) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_indexes_set_tbl_idx","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + tbl_idx->pgsnmpdConnID_len = sizeof(tbl_idx->pgsnmpdConnID); + /* + * make sure there is enough space for pgsnmpdConnID data + */ + if ((NULL == tbl_idx->pgsnmpdConnID) || + (tbl_idx->pgsnmpdConnID_len < (pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->pgsnmpdConnID_len = pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0]); + memcpy( tbl_idx->pgsnmpdConnID, pgsnmpdConnID_val_ptr, tbl_idx->pgsnmpdConnID_len ); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + /* pgsqlPgAmEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ + tbl_idx->pgsqlPgAmEntryOID = pgsqlPgAmEntryOID_val; + + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +pgsqlPgAmTable_indexes_set(pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAmEntryOID_val) +{ + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_indexes_set","called\n")); + + if(MFD_SUCCESS != pgsqlPgAmTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , pgsnmpdConnID_val_ptr, pgsnmpdConnID_val_ptr_len + , rdbmsDbIndex_val + , pgsqlPgAmEntryOID_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != pgsqlPgAmTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmname + * pgsqlPgAmAmname is subid 2 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.2 + * Description: +Name of the access method + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmname.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmname_map(char **mib_pgsqlPgAmAmname_val_ptr_ptr, size_t *mib_pgsqlPgAmAmname_val_ptr_len_ptr, char *raw_pgsqlPgAmAmname_val_ptr, size_t raw_pgsqlPgAmAmname_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_pgsqlPgAmAmname_val_ptr); + netsnmp_assert((NULL != mib_pgsqlPgAmAmname_val_ptr_ptr) && (NULL != mib_pgsqlPgAmAmname_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmname_map","called\n")); + + /* + * TODO:241:r: |-> Implement pgsqlPgAmAmname non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_pgsqlPgAmAmname_val_ptr_len; /* assume equal */ + if((NULL == *mib_pgsqlPgAmAmname_val_ptr_ptr) || (*mib_pgsqlPgAmAmname_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_pgsqlPgAmAmname_val_ptr_ptr = realloc( *mib_pgsqlPgAmAmname_val_ptr_ptr, converted_len * sizeof(**mib_pgsqlPgAmAmname_val_ptr_ptr)); + if(NULL == *mib_pgsqlPgAmAmname_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_pgsqlPgAmAmname_val_ptr_len_ptr = converted_len; + memcpy( *mib_pgsqlPgAmAmname_val_ptr_ptr, raw_pgsqlPgAmAmname_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* pgsqlPgAmAmname_map */ + +/** + * Extract the current value of the pgsqlPgAmAmname data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmname_val_ptr_ptr + * Pointer to storage for a char variable + * @param pgsqlPgAmAmname_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by pgsqlPgAmAmname. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*pgsqlPgAmAmname_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update pgsqlPgAmAmname_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +pgsqlPgAmAmname_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, char **pgsqlPgAmAmname_val_ptr_ptr, size_t *pgsqlPgAmAmname_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != pgsqlPgAmAmname_val_ptr_ptr) && (NULL != *pgsqlPgAmAmname_val_ptr_ptr)); + netsnmp_assert( NULL != pgsqlPgAmAmname_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmname_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmname data. + * set (* pgsqlPgAmAmname_val_ptr_ptr ) and (* pgsqlPgAmAmname_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for pgsqlPgAmAmname data + */ + if ((NULL == (* pgsqlPgAmAmname_val_ptr_ptr )) || + ((* pgsqlPgAmAmname_val_ptr_len_ptr ) < (rowreq_ctx->data.pgsqlPgAmAmname_len * sizeof((* pgsqlPgAmAmname_val_ptr_ptr )[0])))) { + /* + * allocate space for pgsqlPgAmAmname data + */ + (* pgsqlPgAmAmname_val_ptr_ptr ) = malloc(rowreq_ctx->data.pgsqlPgAmAmname_len * sizeof((* pgsqlPgAmAmname_val_ptr_ptr )[0])); + if(NULL == (* pgsqlPgAmAmname_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* pgsqlPgAmAmname_val_ptr_len_ptr ) = rowreq_ctx->data.pgsqlPgAmAmname_len * sizeof((* pgsqlPgAmAmname_val_ptr_ptr )[0]); + memcpy( (* pgsqlPgAmAmname_val_ptr_ptr ), rowreq_ctx->data.pgsqlPgAmAmname, (* pgsqlPgAmAmname_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* pgsqlPgAmAmname_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmstrategies + * pgsqlPgAmAmstrategies is subid 3 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.3 + * Description: +Number of operator strategies for this access method + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmstrategies.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmstrategies_map(long *mib_pgsqlPgAmAmstrategies_val_ptr, long raw_pgsqlPgAmAmstrategies_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmstrategies_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmstrategies_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmstrategies mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmstrategies_val_ptr) = raw_pgsqlPgAmAmstrategies_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmstrategies_map */ + +/** + * Extract the current value of the pgsqlPgAmAmstrategies data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmstrategies_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmstrategies_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmstrategies_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmstrategies_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmstrategies_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmstrategies data. + * set (* pgsqlPgAmAmstrategies_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmstrategies_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmstrategies; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmstrategies_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmsupport + * pgsqlPgAmAmsupport is subid 4 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.4 + * Description: +Number of support routines for this access method + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmsupport.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmsupport_map(long *mib_pgsqlPgAmAmsupport_val_ptr, long raw_pgsqlPgAmAmsupport_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmsupport_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmsupport_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmsupport mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmsupport_val_ptr) = raw_pgsqlPgAmAmsupport_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmsupport_map */ + +/** + * Extract the current value of the pgsqlPgAmAmsupport data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmsupport_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmsupport_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmsupport_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmsupport_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmsupport_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmsupport data. + * set (* pgsqlPgAmAmsupport_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmsupport_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmsupport; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmsupport_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmorderstrategy + * pgsqlPgAmAmorderstrategy is subid 5 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.5 + * Description: +Zero if the index offers no sort order, otherwise the strategy number of the strategy operator that describes the sort order + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmorderstrategy.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmorderstrategy_map(long *mib_pgsqlPgAmAmorderstrategy_val_ptr, long raw_pgsqlPgAmAmorderstrategy_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmorderstrategy_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmorderstrategy_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmorderstrategy mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmorderstrategy_val_ptr) = raw_pgsqlPgAmAmorderstrategy_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmorderstrategy_map */ + +/** + * Extract the current value of the pgsqlPgAmAmorderstrategy data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmorderstrategy_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmorderstrategy_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmorderstrategy_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmorderstrategy_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmorderstrategy_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmorderstrategy data. + * set (* pgsqlPgAmAmorderstrategy_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmorderstrategy_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmorderstrategy; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmorderstrategy_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmcanunique + * pgsqlPgAmAmcanunique is subid 6 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.6 + * Description: +Does the access method support unique indexes? + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmcanunique.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmcanunique_map(u_long *mib_pgsqlPgAmAmcanunique_val_ptr, u_long raw_pgsqlPgAmAmcanunique_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmcanunique_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmcanunique_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmcanunique enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_pgsqlPgAmAmcanunique_val) { + case INTERNAL_PGSQLPGAMAMCANUNIQUE_TRUE: + *mib_pgsqlPgAmAmcanunique_val_ptr = TRUTHVALUE_TRUE; + break; + + case INTERNAL_PGSQLPGAMAMCANUNIQUE_FALSE: + *mib_pgsqlPgAmAmcanunique_val_ptr = TRUTHVALUE_FALSE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for pgsqlPgAmAmcanunique\n", raw_pgsqlPgAmAmcanunique_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmAmcanunique_map */ + +/** + * Extract the current value of the pgsqlPgAmAmcanunique data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmcanunique_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmcanunique_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmcanunique_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmcanunique_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmcanunique_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmcanunique data. + * set (* pgsqlPgAmAmcanunique_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmcanunique_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmcanunique; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmcanunique_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmcanmulticol + * pgsqlPgAmAmcanmulticol is subid 7 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.7 + * Description: +Does the access method support multicolumn indexes? + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmcanmulticol.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmcanmulticol_map(u_long *mib_pgsqlPgAmAmcanmulticol_val_ptr, u_long raw_pgsqlPgAmAmcanmulticol_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmcanmulticol_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmcanmulticol_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmcanmulticol enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_pgsqlPgAmAmcanmulticol_val) { + case INTERNAL_PGSQLPGAMAMCANMULTICOL_TRUE: + *mib_pgsqlPgAmAmcanmulticol_val_ptr = TRUTHVALUE_TRUE; + break; + + case INTERNAL_PGSQLPGAMAMCANMULTICOL_FALSE: + *mib_pgsqlPgAmAmcanmulticol_val_ptr = TRUTHVALUE_FALSE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for pgsqlPgAmAmcanmulticol\n", raw_pgsqlPgAmAmcanmulticol_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmAmcanmulticol_map */ + +/** + * Extract the current value of the pgsqlPgAmAmcanmulticol data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmcanmulticol_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmcanmulticol_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmcanmulticol_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmcanmulticol_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmcanmulticol_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmcanmulticol data. + * set (* pgsqlPgAmAmcanmulticol_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmcanmulticol_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmcanmulticol; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmcanmulticol_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmoptionalkey + * pgsqlPgAmAmoptionalkey is subid 8 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.8 + * Description: +Does the access method support a scan without any constraint for the first index column? + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmoptionalkey.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmoptionalkey_map(u_long *mib_pgsqlPgAmAmoptionalkey_val_ptr, u_long raw_pgsqlPgAmAmoptionalkey_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmoptionalkey_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmoptionalkey_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmoptionalkey enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_pgsqlPgAmAmoptionalkey_val) { + case INTERNAL_PGSQLPGAMAMOPTIONALKEY_TRUE: + *mib_pgsqlPgAmAmoptionalkey_val_ptr = TRUTHVALUE_TRUE; + break; + + case INTERNAL_PGSQLPGAMAMOPTIONALKEY_FALSE: + *mib_pgsqlPgAmAmoptionalkey_val_ptr = TRUTHVALUE_FALSE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for pgsqlPgAmAmoptionalkey\n", raw_pgsqlPgAmAmoptionalkey_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmAmoptionalkey_map */ + +/** + * Extract the current value of the pgsqlPgAmAmoptionalkey data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmoptionalkey_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmoptionalkey_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmoptionalkey_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmoptionalkey_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmoptionalkey_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmoptionalkey data. + * set (* pgsqlPgAmAmoptionalkey_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmoptionalkey_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmoptionalkey; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmoptionalkey_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmindexnulls + * pgsqlPgAmAmindexnulls is subid 9 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.9 + * Description: +Does the access method support null index entries? + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmindexnulls.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmindexnulls_map(u_long *mib_pgsqlPgAmAmindexnulls_val_ptr, u_long raw_pgsqlPgAmAmindexnulls_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmindexnulls_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmindexnulls_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmindexnulls enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_pgsqlPgAmAmindexnulls_val) { + case INTERNAL_PGSQLPGAMAMINDEXNULLS_TRUE: + *mib_pgsqlPgAmAmindexnulls_val_ptr = TRUTHVALUE_TRUE; + break; + + case INTERNAL_PGSQLPGAMAMINDEXNULLS_FALSE: + *mib_pgsqlPgAmAmindexnulls_val_ptr = TRUTHVALUE_FALSE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for pgsqlPgAmAmindexnulls\n", raw_pgsqlPgAmAmindexnulls_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmAmindexnulls_map */ + +/** + * Extract the current value of the pgsqlPgAmAmindexnulls data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmindexnulls_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmindexnulls_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmindexnulls_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmindexnulls_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmindexnulls_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmindexnulls data. + * set (* pgsqlPgAmAmindexnulls_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmindexnulls_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmindexnulls; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmindexnulls_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmstorage + * pgsqlPgAmAmstorage is subid 10 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.10 + * Description: +Can index storage data type differ from column data type? + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmstorage.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmstorage_map(u_long *mib_pgsqlPgAmAmstorage_val_ptr, u_long raw_pgsqlPgAmAmstorage_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmstorage_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmstorage_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmstorage enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_pgsqlPgAmAmstorage_val) { + case INTERNAL_PGSQLPGAMAMSTORAGE_TRUE: + *mib_pgsqlPgAmAmstorage_val_ptr = TRUTHVALUE_TRUE; + break; + + case INTERNAL_PGSQLPGAMAMSTORAGE_FALSE: + *mib_pgsqlPgAmAmstorage_val_ptr = TRUTHVALUE_FALSE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for pgsqlPgAmAmstorage\n", raw_pgsqlPgAmAmstorage_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmAmstorage_map */ + +/** + * Extract the current value of the pgsqlPgAmAmstorage data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmstorage_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmstorage_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmstorage_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmstorage_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmstorage_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmstorage data. + * set (* pgsqlPgAmAmstorage_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmstorage_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmstorage; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmstorage_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmclusterable + * pgsqlPgAmAmclusterable is subid 11 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.11 + * Description: +Can an index of this type be clustered on? + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 2/8. Values: true(1), false(2) + * + * Its syntax is TruthValue (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmclusterable.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmclusterable_map(u_long *mib_pgsqlPgAmAmclusterable_val_ptr, u_long raw_pgsqlPgAmAmclusterable_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmclusterable_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmclusterable_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmclusterable enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_pgsqlPgAmAmclusterable_val) { + case INTERNAL_PGSQLPGAMAMCLUSTERABLE_TRUE: + *mib_pgsqlPgAmAmclusterable_val_ptr = TRUTHVALUE_TRUE; + break; + + case INTERNAL_PGSQLPGAMAMCLUSTERABLE_FALSE: + *mib_pgsqlPgAmAmclusterable_val_ptr = TRUTHVALUE_FALSE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for pgsqlPgAmAmclusterable\n", raw_pgsqlPgAmAmclusterable_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAmAmclusterable_map */ + +/** + * Extract the current value of the pgsqlPgAmAmclusterable data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmclusterable_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmclusterable_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmclusterable_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmclusterable_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmclusterable_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmclusterable data. + * set (* pgsqlPgAmAmclusterable_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmclusterable_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmclusterable; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmclusterable_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAminsert + * pgsqlPgAmAminsert is subid 12 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.12 + * Description: +Insert this tuple + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAminsert.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAminsert_map(long *mib_pgsqlPgAmAminsert_val_ptr, long raw_pgsqlPgAmAminsert_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAminsert_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAminsert_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAminsert mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAminsert_val_ptr) = raw_pgsqlPgAmAminsert_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAminsert_map */ + +/** + * Extract the current value of the pgsqlPgAmAminsert data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAminsert_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAminsert_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAminsert_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAminsert_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAminsert_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAminsert data. + * set (* pgsqlPgAmAminsert_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAminsert_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAminsert; + + return MFD_SUCCESS; +} /* pgsqlPgAmAminsert_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmbeginscan + * pgsqlPgAmAmbeginscan is subid 13 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.13 + * Description: +Start new scan + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmbeginscan.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmbeginscan_map(long *mib_pgsqlPgAmAmbeginscan_val_ptr, long raw_pgsqlPgAmAmbeginscan_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmbeginscan_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmbeginscan_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmbeginscan mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmbeginscan_val_ptr) = raw_pgsqlPgAmAmbeginscan_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmbeginscan_map */ + +/** + * Extract the current value of the pgsqlPgAmAmbeginscan data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmbeginscan_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmbeginscan_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmbeginscan_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmbeginscan_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmbeginscan_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmbeginscan data. + * set (* pgsqlPgAmAmbeginscan_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmbeginscan_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmbeginscan; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmbeginscan_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmgettuple + * pgsqlPgAmAmgettuple is subid 14 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.14 + * Description: +Next valid tuple + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmgettuple.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmgettuple_map(long *mib_pgsqlPgAmAmgettuple_val_ptr, long raw_pgsqlPgAmAmgettuple_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmgettuple_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmgettuple_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmgettuple mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmgettuple_val_ptr) = raw_pgsqlPgAmAmgettuple_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmgettuple_map */ + +/** + * Extract the current value of the pgsqlPgAmAmgettuple data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmgettuple_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmgettuple_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmgettuple_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmgettuple_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmgettuple_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmgettuple data. + * set (* pgsqlPgAmAmgettuple_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmgettuple_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmgettuple; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmgettuple_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmgetmulti + * pgsqlPgAmAmgetmulti is subid 15 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.15 + * Description: +Fetch multiple tuples + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmgetmulti.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmgetmulti_map(long *mib_pgsqlPgAmAmgetmulti_val_ptr, long raw_pgsqlPgAmAmgetmulti_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmgetmulti_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmgetmulti_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmgetmulti mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmgetmulti_val_ptr) = raw_pgsqlPgAmAmgetmulti_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmgetmulti_map */ + +/** + * Extract the current value of the pgsqlPgAmAmgetmulti data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmgetmulti_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmgetmulti_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmgetmulti_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmgetmulti_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmgetmulti_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmgetmulti data. + * set (* pgsqlPgAmAmgetmulti_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmgetmulti_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmgetmulti; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmgetmulti_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmrescan + * pgsqlPgAmAmrescan is subid 16 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.16 + * Description: +Restart this scan + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmrescan.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmrescan_map(long *mib_pgsqlPgAmAmrescan_val_ptr, long raw_pgsqlPgAmAmrescan_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmrescan_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmrescan_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmrescan mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmrescan_val_ptr) = raw_pgsqlPgAmAmrescan_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmrescan_map */ + +/** + * Extract the current value of the pgsqlPgAmAmrescan data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmrescan_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmrescan_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmrescan_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmrescan_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmrescan_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmrescan data. + * set (* pgsqlPgAmAmrescan_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmrescan_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmrescan; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmrescan_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmendscan + * pgsqlPgAmAmendscan is subid 17 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.17 + * Description: +End this scan + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmendscan.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmendscan_map(long *mib_pgsqlPgAmAmendscan_val_ptr, long raw_pgsqlPgAmAmendscan_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmendscan_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmendscan_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmendscan mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmendscan_val_ptr) = raw_pgsqlPgAmAmendscan_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmendscan_map */ + +/** + * Extract the current value of the pgsqlPgAmAmendscan data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmendscan_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmendscan_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmendscan_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmendscan_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmendscan_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmendscan data. + * set (* pgsqlPgAmAmendscan_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmendscan_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmendscan; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmendscan_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmmarkpos + * pgsqlPgAmAmmarkpos is subid 18 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.18 + * Description: +Mark current scan position + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmmarkpos.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmmarkpos_map(long *mib_pgsqlPgAmAmmarkpos_val_ptr, long raw_pgsqlPgAmAmmarkpos_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmmarkpos_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmmarkpos_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmmarkpos mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmmarkpos_val_ptr) = raw_pgsqlPgAmAmmarkpos_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmmarkpos_map */ + +/** + * Extract the current value of the pgsqlPgAmAmmarkpos data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmmarkpos_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmmarkpos_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmmarkpos_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmmarkpos_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmmarkpos_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmmarkpos data. + * set (* pgsqlPgAmAmmarkpos_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmmarkpos_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmmarkpos; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmmarkpos_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmrestrpos + * pgsqlPgAmAmrestrpos is subid 19 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.19 + * Description: +Restore marked scan position + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmrestrpos.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmrestrpos_map(long *mib_pgsqlPgAmAmrestrpos_val_ptr, long raw_pgsqlPgAmAmrestrpos_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmrestrpos_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmrestrpos_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmrestrpos mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmrestrpos_val_ptr) = raw_pgsqlPgAmAmrestrpos_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmrestrpos_map */ + +/** + * Extract the current value of the pgsqlPgAmAmrestrpos data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmrestrpos_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmrestrpos_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmrestrpos_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmrestrpos_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmrestrpos_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmrestrpos data. + * set (* pgsqlPgAmAmrestrpos_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmrestrpos_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmrestrpos; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmrestrpos_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmbuild + * pgsqlPgAmAmbuild is subid 20 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.20 + * Description: +Build new index + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmbuild.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmbuild_map(long *mib_pgsqlPgAmAmbuild_val_ptr, long raw_pgsqlPgAmAmbuild_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmbuild_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmbuild_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmbuild mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmbuild_val_ptr) = raw_pgsqlPgAmAmbuild_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmbuild_map */ + +/** + * Extract the current value of the pgsqlPgAmAmbuild data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmbuild_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmbuild_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmbuild_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmbuild_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmbuild_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmbuild data. + * set (* pgsqlPgAmAmbuild_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmbuild_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmbuild; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmbuild_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmbulkdelete + * pgsqlPgAmAmbulkdelete is subid 21 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.21 + * Description: +Bulk-delete function + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmbulkdelete.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmbulkdelete_map(long *mib_pgsqlPgAmAmbulkdelete_val_ptr, long raw_pgsqlPgAmAmbulkdelete_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmbulkdelete_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmbulkdelete_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmbulkdelete mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmbulkdelete_val_ptr) = raw_pgsqlPgAmAmbulkdelete_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmbulkdelete_map */ + +/** + * Extract the current value of the pgsqlPgAmAmbulkdelete data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmbulkdelete_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmbulkdelete_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmbulkdelete_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmbulkdelete_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmbulkdelete_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmbulkdelete data. + * set (* pgsqlPgAmAmbulkdelete_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmbulkdelete_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmbulkdelete; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmbulkdelete_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmvacuumcleanup + * pgsqlPgAmAmvacuumcleanup is subid 22 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.22 + * Description: +Post- VACUUM cleanup function + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmvacuumcleanup.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmvacuumcleanup_map(long *mib_pgsqlPgAmAmvacuumcleanup_val_ptr, long raw_pgsqlPgAmAmvacuumcleanup_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmvacuumcleanup_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmvacuumcleanup_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmvacuumcleanup mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmvacuumcleanup_val_ptr) = raw_pgsqlPgAmAmvacuumcleanup_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmvacuumcleanup_map */ + +/** + * Extract the current value of the pgsqlPgAmAmvacuumcleanup data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmvacuumcleanup_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmvacuumcleanup_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmvacuumcleanup_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmvacuumcleanup_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmvacuumcleanup_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmvacuumcleanup data. + * set (* pgsqlPgAmAmvacuumcleanup_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmvacuumcleanup_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmvacuumcleanup; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmvacuumcleanup_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmcostestimate + * pgsqlPgAmAmcostestimate is subid 23 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.23 + * Description: +Function to estimate cost of an index scan + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmcostestimate.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmcostestimate_map(long *mib_pgsqlPgAmAmcostestimate_val_ptr, long raw_pgsqlPgAmAmcostestimate_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmcostestimate_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmcostestimate_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmcostestimate mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmcostestimate_val_ptr) = raw_pgsqlPgAmAmcostestimate_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmcostestimate_map */ + +/** + * Extract the current value of the pgsqlPgAmAmcostestimate data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmcostestimate_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmcostestimate_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmcostestimate_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmcostestimate_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmcostestimate_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmcostestimate data. + * set (* pgsqlPgAmAmcostestimate_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmcostestimate_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmcostestimate; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmcostestimate_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAmEntry.pgsqlPgAmAmoptions + * pgsqlPgAmAmoptions is subid 24 of pgsqlPgAmEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.2.1.24 + * Description: +Function to parse and validate reloptions for an index + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAmAmoptions.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAmAmoptions_map(long *mib_pgsqlPgAmAmoptions_val_ptr, long raw_pgsqlPgAmAmoptions_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAmAmoptions_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmoptions_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAmAmoptions mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAmAmoptions_val_ptr) = raw_pgsqlPgAmAmoptions_val; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmoptions_map */ + +/** + * Extract the current value of the pgsqlPgAmAmoptions data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAmAmoptions_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAmAmoptions_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmoptions_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAmAmoptions_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmAmoptions_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAmAmoptions data. + * set (* pgsqlPgAmAmoptions_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAmAmoptions_val_ptr ) = rowreq_ctx->data.pgsqlPgAmAmoptions; + + return MFD_SUCCESS; +} /* pgsqlPgAmAmoptions_get */ + + + +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.h new file mode 100644 index 0000000..19852b7 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_get.h @@ -0,0 +1,107 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsqlPgAmTable_data_get.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + * + * @file pgsqlPgAmTable_data_get.h + * + * @addtogroup get + * + * Prototypes for get functions + * + * @{ + */ +#ifndef PGSQLPGAMTABLE_DATA_GET_H +#define PGSQLPGAMTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAmTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAmTable is subid 2 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.2, length: 10 +*/ + /* + * indexes + */ + int pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc); + int rdbmsDbIndex_map(long *mib_rdbmsDbIndex_val_ptr, long raw_rdbmsDbIndex_val); + int pgsqlPgAmEntryOID_map(long *mib_pgsqlPgAmEntryOID_val_ptr, long raw_pgsqlPgAmEntryOID_val); + + int pgsqlPgAmAmname_map(char **mib_pgsqlPgAmAmname_val_ptr_ptr, size_t *mib_pgsqlPgAmAmname_val_ptr_len_ptr, char *raw_pgsqlPgAmAmname_val_ptr, size_t raw_pgsqlPgAmAmname_val_ptr_len, int allow_realloc); + int pgsqlPgAmAmname_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, char **pgsqlPgAmAmname_val_ptr_ptr, size_t *pgsqlPgAmAmname_val_ptr_len_ptr ); + int pgsqlPgAmAmstrategies_map(long *mib_pgsqlPgAmAmstrategies_val_ptr, long raw_pgsqlPgAmAmstrategies_val); + int pgsqlPgAmAmstrategies_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmstrategies_val_ptr ); + int pgsqlPgAmAmsupport_map(long *mib_pgsqlPgAmAmsupport_val_ptr, long raw_pgsqlPgAmAmsupport_val); + int pgsqlPgAmAmsupport_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmsupport_val_ptr ); + int pgsqlPgAmAmorderstrategy_map(long *mib_pgsqlPgAmAmorderstrategy_val_ptr, long raw_pgsqlPgAmAmorderstrategy_val); + int pgsqlPgAmAmorderstrategy_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmorderstrategy_val_ptr ); + int pgsqlPgAmAmcanunique_map(u_long *mib_pgsqlPgAmAmcanunique_val_ptr, u_long raw_pgsqlPgAmAmcanunique_val); + int pgsqlPgAmAmcanunique_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmcanunique_val_ptr ); + int pgsqlPgAmAmcanmulticol_map(u_long *mib_pgsqlPgAmAmcanmulticol_val_ptr, u_long raw_pgsqlPgAmAmcanmulticol_val); + int pgsqlPgAmAmcanmulticol_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmcanmulticol_val_ptr ); + int pgsqlPgAmAmoptionalkey_map(u_long *mib_pgsqlPgAmAmoptionalkey_val_ptr, u_long raw_pgsqlPgAmAmoptionalkey_val); + int pgsqlPgAmAmoptionalkey_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmoptionalkey_val_ptr ); + int pgsqlPgAmAmindexnulls_map(u_long *mib_pgsqlPgAmAmindexnulls_val_ptr, u_long raw_pgsqlPgAmAmindexnulls_val); + int pgsqlPgAmAmindexnulls_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmindexnulls_val_ptr ); + int pgsqlPgAmAmstorage_map(u_long *mib_pgsqlPgAmAmstorage_val_ptr, u_long raw_pgsqlPgAmAmstorage_val); + int pgsqlPgAmAmstorage_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmstorage_val_ptr ); + int pgsqlPgAmAmclusterable_map(u_long *mib_pgsqlPgAmAmclusterable_val_ptr, u_long raw_pgsqlPgAmAmclusterable_val); + int pgsqlPgAmAmclusterable_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, u_long * pgsqlPgAmAmclusterable_val_ptr ); + int pgsqlPgAmAminsert_map(long *mib_pgsqlPgAmAminsert_val_ptr, long raw_pgsqlPgAmAminsert_val); + int pgsqlPgAmAminsert_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAminsert_val_ptr ); + int pgsqlPgAmAmbeginscan_map(long *mib_pgsqlPgAmAmbeginscan_val_ptr, long raw_pgsqlPgAmAmbeginscan_val); + int pgsqlPgAmAmbeginscan_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmbeginscan_val_ptr ); + int pgsqlPgAmAmgettuple_map(long *mib_pgsqlPgAmAmgettuple_val_ptr, long raw_pgsqlPgAmAmgettuple_val); + int pgsqlPgAmAmgettuple_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmgettuple_val_ptr ); + int pgsqlPgAmAmgetmulti_map(long *mib_pgsqlPgAmAmgetmulti_val_ptr, long raw_pgsqlPgAmAmgetmulti_val); + int pgsqlPgAmAmgetmulti_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmgetmulti_val_ptr ); + int pgsqlPgAmAmrescan_map(long *mib_pgsqlPgAmAmrescan_val_ptr, long raw_pgsqlPgAmAmrescan_val); + int pgsqlPgAmAmrescan_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmrescan_val_ptr ); + int pgsqlPgAmAmendscan_map(long *mib_pgsqlPgAmAmendscan_val_ptr, long raw_pgsqlPgAmAmendscan_val); + int pgsqlPgAmAmendscan_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmendscan_val_ptr ); + int pgsqlPgAmAmmarkpos_map(long *mib_pgsqlPgAmAmmarkpos_val_ptr, long raw_pgsqlPgAmAmmarkpos_val); + int pgsqlPgAmAmmarkpos_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmmarkpos_val_ptr ); + int pgsqlPgAmAmrestrpos_map(long *mib_pgsqlPgAmAmrestrpos_val_ptr, long raw_pgsqlPgAmAmrestrpos_val); + int pgsqlPgAmAmrestrpos_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmrestrpos_val_ptr ); + int pgsqlPgAmAmbuild_map(long *mib_pgsqlPgAmAmbuild_val_ptr, long raw_pgsqlPgAmAmbuild_val); + int pgsqlPgAmAmbuild_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmbuild_val_ptr ); + int pgsqlPgAmAmbulkdelete_map(long *mib_pgsqlPgAmAmbulkdelete_val_ptr, long raw_pgsqlPgAmAmbulkdelete_val); + int pgsqlPgAmAmbulkdelete_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmbulkdelete_val_ptr ); + int pgsqlPgAmAmvacuumcleanup_map(long *mib_pgsqlPgAmAmvacuumcleanup_val_ptr, long raw_pgsqlPgAmAmvacuumcleanup_val); + int pgsqlPgAmAmvacuumcleanup_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmvacuumcleanup_val_ptr ); + int pgsqlPgAmAmcostestimate_map(long *mib_pgsqlPgAmAmcostestimate_val_ptr, long raw_pgsqlPgAmAmcostestimate_val); + int pgsqlPgAmAmcostestimate_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmcostestimate_val_ptr ); + int pgsqlPgAmAmoptions_map(long *mib_pgsqlPgAmAmoptions_val_ptr, long raw_pgsqlPgAmAmoptions_val); + int pgsqlPgAmAmoptions_get( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAmAmoptions_val_ptr ); + + +int pgsqlPgAmTable_indexes_set_tbl_idx(pgsqlPgAmTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAmEntryOID_val); +int pgsqlPgAmTable_indexes_set(pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAmEntryOID_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_DATA_GET_H */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.c new file mode 100644 index 0000000..59971e9 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.c @@ -0,0 +1,24 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsqlPgAmTable_data_set.c,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + * + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAmTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.h new file mode 100644 index 0000000..b5ff1d8 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_data_set.h @@ -0,0 +1,27 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsqlPgAmTable_data_set.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +#ifndef PGSQLPGAMTABLE_DATA_SET_H +#define PGSQLPGAMTABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_DATA_SET_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_enums.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_enums.h new file mode 100644 index 0000000..051af4e --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_enums.h @@ -0,0 +1,178 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c,v 1.3 2004/05/18 17:44:32 rstory Exp $ + * + * $Id: pgsqlPgAmTable_enums.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +#ifndef PGSQLPGAMTABLE_ENUMS_H +#define PGSQLPGAMTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table pgsqlPgAmTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * pgsqlPgAmAmcanunique (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + + +#endif /* TRUTHVALUE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of pgsqlPgAmAmcanunique enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_PGSQLPGAMAMCANUNIQUE_TRUE 1 +#define INTERNAL_PGSQLPGAMAMCANUNIQUE_FALSE 2 + +/************************************************************* + * constants for enums for the MIB node + * pgsqlPgAmAmcanmulticol (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + + +#endif /* TRUTHVALUE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of pgsqlPgAmAmcanmulticol enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_PGSQLPGAMAMCANMULTICOL_TRUE 1 +#define INTERNAL_PGSQLPGAMAMCANMULTICOL_FALSE 2 + +/************************************************************* + * constants for enums for the MIB node + * pgsqlPgAmAmoptionalkey (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + + +#endif /* TRUTHVALUE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of pgsqlPgAmAmoptionalkey enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_PGSQLPGAMAMOPTIONALKEY_TRUE 1 +#define INTERNAL_PGSQLPGAMAMOPTIONALKEY_FALSE 2 + +/************************************************************* + * constants for enums for the MIB node + * pgsqlPgAmAmindexnulls (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + + +#endif /* TRUTHVALUE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of pgsqlPgAmAmindexnulls enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_PGSQLPGAMAMINDEXNULLS_TRUE 1 +#define INTERNAL_PGSQLPGAMAMINDEXNULLS_FALSE 2 + +/************************************************************* + * constants for enums for the MIB node + * pgsqlPgAmAmstorage (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + + +#endif /* TRUTHVALUE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of pgsqlPgAmAmstorage enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_PGSQLPGAMAMSTORAGE_TRUE 1 +#define INTERNAL_PGSQLPGAMAMSTORAGE_FALSE 2 + +/************************************************************* + * constants for enums for the MIB node + * pgsqlPgAmAmclusterable (TruthValue / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef TRUTHVALUE_ENUMS +#define TRUTHVALUE_ENUMS + +#define TRUTHVALUE_TRUE 1 +#define TRUTHVALUE_FALSE 2 + + +#endif /* TRUTHVALUE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of pgsqlPgAmAmclusterable enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_PGSQLPGAMAMCLUSTERABLE_TRUE 1 +#define INTERNAL_PGSQLPGAMAMCLUSTERABLE_FALSE 2 + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_ENUMS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.c new file mode 100644 index 0000000..3259307 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.c @@ -0,0 +1,903 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsqlPgAmTable_interface.c,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "pgsqlPgAmTable.h" + + +#include + +#include "pgsqlPgAmTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAmTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAmTable is subid 2 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.2, length: 10 +*/ +typedef struct pgsqlPgAmTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + pgsqlPgAmTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} pgsqlPgAmTable_interface_ctx; + +static pgsqlPgAmTable_interface_ctx pgsqlPgAmTable_if_ctx; + +static void _pgsqlPgAmTable_container_init( + pgsqlPgAmTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_pgsqlPgAmTable_pre_request; +static Netsnmp_Node_Handler _mfd_pgsqlPgAmTable_post_request; +static Netsnmp_Node_Handler _mfd_pgsqlPgAmTable_object_lookup; +static Netsnmp_Node_Handler _mfd_pgsqlPgAmTable_get_values; +/** + * @internal + * Initialize the table pgsqlPgAmTable + * (Define its contents and how it's structured) + */ +void +_pgsqlPgAmTable_initialize_interface(pgsqlPgAmTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &pgsqlPgAmTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &pgsqlPgAmTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:pgsqlPgAmTable:_pgsqlPgAmTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for pgsqlPgAmTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_OCTET_STR, /** index: pgsnmpdConnID */ + ASN_INTEGER, /** index: rdbmsDbIndex */ + ASN_INTEGER, /** index: pgsqlPgAmEntryOID */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = PGSQLPGAMTABLE_MIN_COL; + tbl_info->max_column = PGSQLPGAMTABLE_MAX_COL; + + /* + * save users context + */ + pgsqlPgAmTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + pgsqlPgAmTable_init_data(reg_ptr); + + /* + * set up the container + */ + _pgsqlPgAmTable_container_init(&pgsqlPgAmTable_if_ctx); + if (NULL == pgsqlPgAmTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for pgsqlPgAmTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_pgsqlPgAmTable_object_lookup; + access_multiplexer->get_values = _mfd_pgsqlPgAmTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_pgsqlPgAmTable_pre_request; + access_multiplexer->post_request = _mfd_pgsqlPgAmTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("pgsqlPgAmTable:init_pgsqlPgAmTable", + "Registering pgsqlPgAmTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("pgsqlPgAmTable", handler, + pgsqlPgAmTable_oid, + pgsqlPgAmTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table pgsqlPgAmTable\n"); + return; + } + reginfo->my_reg_void = &pgsqlPgAmTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + pgsqlPgAmTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != pgsqlPgAmTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(pgsqlPgAmTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _pgsqlPgAmTable_initialize_interface */ + +void +pgsqlPgAmTable_valid_columns_set(netsnmp_column_info *vc) +{ + pgsqlPgAmTable_if_ctx.tbl_info.valid_columns = vc; +} /* pgsqlPgAmTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +pgsqlPgAmTable_index_to_oid(netsnmp_index *oid_idx, + pgsqlPgAmTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * pgsqlPgAmEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + netsnmp_variable_list var_pgsqlPgAmEntryOID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_pgsqlPgAmEntryOID, 0x00, sizeof(var_pgsqlPgAmEntryOID) ); + var_pgsqlPgAmEntryOID.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAmEntryOID; var_pgsqlPgAmEntryOID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_index_to_oid","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + snmp_set_var_value(&var_pgsnmpdConnID, (u_char*)&mib_idx->pgsnmpdConnID, + mib_idx->pgsnmpdConnID_len * sizeof(mib_idx->pgsnmpdConnID[0])); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + /* pgsqlPgAmEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ + snmp_set_var_value(&var_pgsqlPgAmEntryOID, (u_char*)&mib_idx->pgsqlPgAmEntryOID, + sizeof(mib_idx->pgsqlPgAmEntryOID)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, + NULL, 0, &var_pgsnmpdConnID); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsqlPgAmTable_index_to_oid */ + +/** + * extract pgsqlPgAmTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +pgsqlPgAmTable_index_from_oid(netsnmp_index *oid_idx, + pgsqlPgAmTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * pgsqlPgAmEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + netsnmp_variable_list var_pgsqlPgAmEntryOID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_pgsqlPgAmEntryOID, 0x00, sizeof(var_pgsqlPgAmEntryOID) ); + var_pgsqlPgAmEntryOID.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAmEntryOID; var_pgsqlPgAmEntryOID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_pgsnmpdConnID ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + /* + * NOTE: val_len is in bytes, pgsnmpdConnID_len might not be + */ + if(var_pgsnmpdConnID.val_len > sizeof(mib_idx->pgsnmpdConnID)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->pgsnmpdConnID, var_pgsnmpdConnID.val.string, var_pgsnmpdConnID.val_len); + mib_idx->pgsnmpdConnID_len = var_pgsnmpdConnID.val_len / sizeof(mib_idx->pgsnmpdConnID[0]); + } + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + mib_idx->pgsqlPgAmEntryOID = *((long *)var_pgsqlPgAmEntryOID.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsqlPgAmTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a pgsqlPgAmTable_rowreq_ctx + */ +pgsqlPgAmTable_rowreq_ctx * +pgsqlPgAmTable_allocate_rowreq_ctx(void) +{ + pgsqlPgAmTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(pgsqlPgAmTable_rowreq_ctx); + + DEBUGMSGTL(("internal:pgsqlPgAmTable:pgsqlPgAmTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "pgsqlPgAmTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->pgsqlPgAmTable_data_list = NULL; + rowreq_ctx->pgsqlPgAmTable_reg = pgsqlPgAmTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* pgsqlPgAmTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a pgsqlPgAmTable_rowreq_ctx + */ +void +pgsqlPgAmTable_release_rowreq_ctx(pgsqlPgAmTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:pgsqlPgAmTable:pgsqlPgAmTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* pgsqlPgAmTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAmTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = pgsqlPgAmTable_pre_request(pgsqlPgAmTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsqlPgAmTable","error %d from " + "pgsqlPgAmTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAmTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAmTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAmTable_rowreq_ctx *rowreq_ctx; + int rc = pgsqlPgAmTable_post_request(pgsqlPgAmTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsqlPgAmTable","error %d from " + "pgsqlPgAmTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(pgsqlPgAmTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(pgsqlPgAmTable_if_ctx.container, rowreq_ctx); + pgsqlPgAmTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAmTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAmTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAmTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:pgsqlPgAmTable:_mfd_pgsqlPgAmTable_object_lookup","called\n")); + + /* + * get our context from mfd + * pgsqlPgAmTable_interface_ctx *if_ctx = + * (pgsqlPgAmTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + pgsqlPgAmTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAmTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_pgsqlPgAmTable_get_column( pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:pgsqlPgAmTable:_mfd_pgsqlPgAmTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* pgsqlPgAmAmname(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_PGSQLPGAMAMNAME: + var->type = ASN_OCTET_STR; +rc = pgsqlPgAmAmname_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + /* pgsqlPgAmAmstrategies(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMSTRATEGIES: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmstrategies_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmsupport(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMSUPPORT: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmsupport_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmorderstrategy(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMORDERSTRATEGY: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmorderstrategy_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmcanunique(6)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_PGSQLPGAMAMCANUNIQUE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmcanunique_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* pgsqlPgAmAmcanmulticol(7)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_PGSQLPGAMAMCANMULTICOL: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmcanmulticol_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* pgsqlPgAmAmoptionalkey(8)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_PGSQLPGAMAMOPTIONALKEY: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmoptionalkey_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* pgsqlPgAmAmindexnulls(9)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_PGSQLPGAMAMINDEXNULLS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmindexnulls_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* pgsqlPgAmAmstorage(10)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_PGSQLPGAMAMSTORAGE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmstorage_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* pgsqlPgAmAmclusterable(11)/TruthValue/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_PGSQLPGAMAMCLUSTERABLE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmclusterable_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* pgsqlPgAmAminsert(12)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMINSERT: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAminsert_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmbeginscan(13)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMBEGINSCAN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmbeginscan_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmgettuple(14)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMGETTUPLE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmgettuple_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmgetmulti(15)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMGETMULTI: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmgetmulti_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmrescan(16)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMRESCAN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmrescan_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmendscan(17)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMENDSCAN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmendscan_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmmarkpos(18)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMMARKPOS: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmmarkpos_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmrestrpos(19)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMRESTRPOS: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmrestrpos_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmbuild(20)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMBUILD: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmbuild_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmbulkdelete(21)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMBULKDELETE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmbulkdelete_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmvacuumcleanup(22)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMVACUUMCLEANUP: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmvacuumcleanup_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmcostestimate(23)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMCOSTESTIMATE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmcostestimate_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAmAmoptions(24)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAMAMOPTIONS: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAmAmoptions_get(rowreq_ctx, (long *)var->val.string ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _pgsqlPgAmTable_get_column\n", column); + break; + } + + return rc; +} /* _pgsqlPgAmTable_get_column */ + +int +_mfd_pgsqlPgAmTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAmTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:pgsqlPgAmTable:_mfd_pgsqlPgAmTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _pgsqlPgAmTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAmTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:pgsqlPgAmTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for pgsqlPgAmTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return pgsqlPgAmTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(pgsqlPgAmTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:pgsqlPgAmTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + pgsqlPgAmTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:pgsqlPgAmTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in pgsqlPgAmTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + pgsqlPgAmTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_pgsqlPgAmTable_container_init(pgsqlPgAmTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:pgsqlPgAmTable:_pgsqlPgAmTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + pgsqlPgAmTable_oid, + pgsqlPgAmTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for pgsqlPgAmTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + pgsqlPgAmTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("pgsqlPgAmTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "pgsqlPgAmTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _pgsqlPgAmTable_container_init */ + diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.h new file mode 100644 index 0000000..86903e1 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_interface.h @@ -0,0 +1,72 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsqlPgAmTable_interface.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +/** @defgroup interface: Routines to interface to Net-SNMP + * + * \warning This code should not be modified, called directly, + * or used to interpret functionality. It is subject to + * change at any time. + * + * @{ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ +#ifndef PGSQLPGAMTABLE_INTERFACE_H +#define PGSQLPGAMTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "pgsqlPgAmTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _pgsqlPgAmTable_initialize_interface(pgsqlPgAmTable_registration_ptr user_ctx, + u_long flags); + + pgsqlPgAmTable_rowreq_ctx * pgsqlPgAmTable_allocate_rowreq_ctx(void); +void pgsqlPgAmTable_release_rowreq_ctx(pgsqlPgAmTable_rowreq_ctx *rowreq_ctx); + +int pgsqlPgAmTable_index_to_oid(netsnmp_index *oid_idx, + pgsqlPgAmTable_mib_index *mib_idx); +int pgsqlPgAmTable_index_from_oid(netsnmp_index *oid_idx, + pgsqlPgAmTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void pgsqlPgAmTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_INTERFACE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_oids.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_oids.h new file mode 100644 index 0000000..85bb01d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmTable/pgsqlPgAmTable_oids.h @@ -0,0 +1,50 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c,v 1.10 2004/10/08 23:39:17 rstory Exp $ + * + * $Id: pgsqlPgAmTable_oids.h,v 1.1 2008/01/17 12:29:36 eggyknap Exp $ + */ +#ifndef PGSQLPGAMTABLE_OIDS_H +#define PGSQLPGAMTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table pgsqlPgAmTable */ +#define PGSQLPGAMTABLE_OID 1,3,6,1,4,1,27645,1,2,2 +#define COLUMN_PGSQLPGAMENTRYOID 1 +#define COLUMN_PGSQLPGAMAMNAME 2 +#define COLUMN_PGSQLPGAMAMSTRATEGIES 3 +#define COLUMN_PGSQLPGAMAMSUPPORT 4 +#define COLUMN_PGSQLPGAMAMORDERSTRATEGY 5 +#define COLUMN_PGSQLPGAMAMCANUNIQUE 6 +#define COLUMN_PGSQLPGAMAMCANMULTICOL 7 +#define COLUMN_PGSQLPGAMAMOPTIONALKEY 8 +#define COLUMN_PGSQLPGAMAMINDEXNULLS 9 +#define COLUMN_PGSQLPGAMAMSTORAGE 10 +#define COLUMN_PGSQLPGAMAMCLUSTERABLE 11 +#define COLUMN_PGSQLPGAMAMINSERT 12 +#define COLUMN_PGSQLPGAMAMBEGINSCAN 13 +#define COLUMN_PGSQLPGAMAMGETTUPLE 14 +#define COLUMN_PGSQLPGAMAMGETMULTI 15 +#define COLUMN_PGSQLPGAMAMRESCAN 16 +#define COLUMN_PGSQLPGAMAMENDSCAN 17 +#define COLUMN_PGSQLPGAMAMMARKPOS 18 +#define COLUMN_PGSQLPGAMAMRESTRPOS 19 +#define COLUMN_PGSQLPGAMAMBUILD 20 +#define COLUMN_PGSQLPGAMAMBULKDELETE 21 +#define COLUMN_PGSQLPGAMAMVACUUMCLEANUP 22 +#define COLUMN_PGSQLPGAMAMCOSTESTIMATE 23 +#define COLUMN_PGSQLPGAMAMOPTIONS 24 + +#define PGSQLPGAMTABLE_MIN_COL COLUMN_PGSQLPGAMAMNAME +#define PGSQLPGAMTABLE_MAX_COL COLUMN_PGSQLPGAMAMOPTIONS + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAMTABLE_OIDS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.c new file mode 100644 index 0000000..66de62f --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.c @@ -0,0 +1,316 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $ + */ + +#include "pgsnmpd.h" +#include "pgsqlPgAmopTable.h" + +void fill_pgsqlPgAmopTable(void); + +/** Initializes the pgsqlPgAmopTable module */ +void +init_pgsqlPgAmopTable(void) +{ + /* here we initialize all the tables we're planning on supporting */ + initialize_table_pgsqlPgAmopTable(); +} + + /* TODO: "Determine the first/last column names" */ + +/** Initialize the pgsqlPgAmopTable table by defining its contents and how it's structured */ +void +initialize_table_pgsqlPgAmopTable(void) +{ + static oid pgsqlPgAmopTable_oid[] = {1,3,6,1,4,1,27645,1,2,3}; + size_t pgsqlPgAmopTable_oid_len = OID_LENGTH(pgsqlPgAmopTable_oid); + netsnmp_handler_registration *reg; + netsnmp_iterator_info *iinfo; + netsnmp_table_registration_info *table_info; + + reg = netsnmp_create_handler_registration( + "pgsqlPgAmopTable", pgsqlPgAmopTable_handler, + pgsqlPgAmopTable_oid, pgsqlPgAmopTable_oid_len, + HANDLER_CAN_RONLY + ); + + table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info ); + netsnmp_table_helper_add_indexes(table_info, + ASN_OCTET_STR, /* index: pgsnmpdConnID */ + ASN_INTEGER, /* index: rdbmsDbIndex */ + ASN_INTEGER, /* index: pgsqlPgAmopEntryOID */ + 0); + table_info->min_column = COLUMN_PGSQLPGAMOPAMOPFAMILY; + table_info->max_column = COLUMN_PGSQLPGAMOPAMOPMETHOD; + + iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info ); + iinfo->get_first_data_point = pgsqlPgAmopTable_get_first_data_point; + iinfo->get_next_data_point = pgsqlPgAmopTable_get_next_data_point; + iinfo->table_reginfo = table_info; + + netsnmp_register_table_iterator( reg, iinfo ); + + /* Initialise the contents of the table here */ + fill_pgsqlPgAmopTable(); +} + +#define CONNID_LEN 255 + + /* Typical data structure for a row entry */ +struct pgsqlPgAmopTable_entry { + /* Index values */ + u_char pgsnmpdConnID[CONNID_LEN]; + size_t pgsnmpdConnID_len; + long rdbmsDbIndex; + long pgsqlPgAmopEntryOID; + + /* Column values */ + long pgsqlPgAmopAmopfamily; + long pgsqlPgAmopAmoplefttype; + long pgsqlPgAmopAmoprighttype; + int pgsqlPgAmopAmopstrategy; + int pgsqlPgAmopAmopreqcheck; + long pgsqlPgAmopAmopopr; + long pgsqlPgAmopAmopmethod; + + /* Illustrate using a simple linked list */ + int valid; + struct pgsqlPgAmopTable_entry *next; +}; + +struct pgsqlPgAmopTable_entry *pgsqlPgAmopTable_head = NULL; + +/* Quiet compiler */ +struct pgsqlPgAmopTable_entry * +pgsqlPgAmopTable_createEntry( + char* pgsnmpdConnID, + size_t pgsnmpdConnID_len, + long rdbmsDbIndex, + long pgsqlPgAmopEntryOID + ); +void +pgsqlPgAmopTable_removeEntry( struct pgsqlPgAmopTable_entry *entry ); + +/* create a new row in the (unsorted) table */ +struct pgsqlPgAmopTable_entry * +pgsqlPgAmopTable_createEntry( + char* pgsnmpdConnID, + size_t pgsnmpdConnID_len, + long rdbmsDbIndex, + long pgsqlPgAmopEntryOID + ) { + struct pgsqlPgAmopTable_entry *entry; + + entry = SNMP_MALLOC_TYPEDEF(struct pgsqlPgAmopTable_entry); + if (!entry) + return NULL; + + /*memset(entry->pgsnmpdConnID, 0, CONNID_LEN); */ + memcpy(entry->pgsnmpdConnID, pgsnmpdConnID, pgsnmpdConnID_len); + entry->pgsnmpdConnID_len = pgsnmpdConnID_len; + entry->rdbmsDbIndex = rdbmsDbIndex; + entry->pgsqlPgAmopEntryOID = pgsqlPgAmopEntryOID; + + entry->next = pgsqlPgAmopTable_head; + pgsqlPgAmopTable_head = entry; + return entry; +} + +/* remove a row from the table */ +void +pgsqlPgAmopTable_removeEntry( struct pgsqlPgAmopTable_entry *entry ) { + struct pgsqlPgAmopTable_entry *ptr, *prev; + + if (!entry) + return; /* Nothing to remove */ + + for ( ptr = pgsqlPgAmopTable_head, prev = NULL; + ptr != NULL; + prev = ptr, ptr = ptr->next ) { + if ( ptr == entry ) + break; + } + if ( !ptr ) + return; /* Can't find it */ + + if ( prev == NULL ) + pgsqlPgAmopTable_head = ptr->next; + else + prev->next = ptr->next; + + SNMP_FREE( entry ); /* XXX - release any other internal resources */ +} + +void fill_pgsqlPgAmopTable(void) { + PGresult *pg_db_query; + int resultCount, i; + struct pgsqlPgAmopTable_entry *entry; + char pgsnmpdConnID[112] = "Default conn ID"; + size_t pgsnmpdConnID_len = strlen(pgsnmpdConnID) + 1; + long rdbmsDbIndex = 1; + + snmp_log(LOG_INFO, "Initializing pgsqlPgAmopTable\n"); + if (PQstatus(dbconn) == CONNECTION_OK) { + pg_db_query = PQexec(dbconn, "SELECT oid::INTEGER, amopfamily::INTEGER, amoplefttype::INTEGER, amoprighttype::INTEGER, amopstrategy, amopreqcheck, amopopr::INTEGER , amopmethod::INTEGER FROM pg_amop ORDER BY 1 ASC"); + } + else { + snmp_log(LOG_ERR, "Can't get connected to database\n"); + return; + /* TODO: I should signal MFD_RESOURCE_UNAVAILABLE somehow, here */ + } + + if (PQresultStatus(pg_db_query) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database\n"); + PQclear(pg_db_query); + return; + /* TODO: I should signal MFD_RESOURCE_UNAVAILABLE somehow, here */ + } + resultCount = PQntuples(pg_db_query); + for (i = 0; i < resultCount; i++) { + entry = pgsqlPgAmopTable_createEntry(pgsnmpdConnID, pgsnmpdConnID_len, + rdbmsDbIndex, atol(PQgetvalue(pg_db_query, i, 0))); + entry->pgsqlPgAmopAmopfamily = atol(PQgetvalue(pg_db_query, i, 1)); + entry->pgsqlPgAmopAmoplefttype = atol(PQgetvalue(pg_db_query, i, 2)); + entry->pgsqlPgAmopAmoprighttype = atol(PQgetvalue(pg_db_query, i, 3)); + entry->pgsqlPgAmopAmopstrategy = atoi(PQgetvalue(pg_db_query, i, 4)); + entry->pgsqlPgAmopAmopreqcheck = atoi(PQgetvalue(pg_db_query, i, 5)); + entry->pgsqlPgAmopAmopopr = atol(PQgetvalue(pg_db_query, i, 6)); + entry->pgsqlPgAmopAmopmethod = atol(PQgetvalue(pg_db_query, i, 7)); + } + snmp_log(LOG_INFO, "Finished initializing pgsqlPgAmopTable with %d entries\n", resultCount); +} + +/* Example iterator hook routines - using 'get_next' to do most of the work */ +netsnmp_variable_list * +pgsqlPgAmopTable_get_first_data_point(void **my_loop_context, + void **my_data_context, + netsnmp_variable_list *put_index_data, + netsnmp_iterator_info *mydata) +{ + *my_loop_context = pgsqlPgAmopTable_head; + return pgsqlPgAmopTable_get_next_data_point(my_loop_context, my_data_context, + put_index_data, mydata ); +} + +netsnmp_variable_list * +pgsqlPgAmopTable_get_next_data_point(void **my_loop_context, + void **my_data_context, + netsnmp_variable_list *put_index_data, + netsnmp_iterator_info *mydata) +{ + struct pgsqlPgAmopTable_entry *entry = (struct pgsqlPgAmopTable_entry *)*my_loop_context; + netsnmp_variable_list *idx = put_index_data; + + if ( entry ) { + snmp_set_var_value( idx, entry->pgsnmpdConnID, sizeof(entry->pgsnmpdConnID) ); + idx = idx->next_variable; + snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->rdbmsDbIndex ); + idx = idx->next_variable; + snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->pgsqlPgAmopEntryOID ); + idx = idx->next_variable; + *my_data_context = (void *)entry; + *my_loop_context = (void *)entry->next; + return put_index_data; + } else { + return NULL; + } +} + + +/** handles requests for the pgsqlPgAmopTable table */ +int +pgsqlPgAmopTable_handler( + netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) { + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + struct pgsqlPgAmopTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request=requests; request; request=request->next) { + table_entry = (struct pgsqlPgAmopTable_entry *) + netsnmp_extract_iterator_context(request); + table_info = netsnmp_extract_table_info( request); + + switch (table_info->colnum) { + case COLUMN_PGSQLPGAMOPAMOPFAMILY: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopfamily); + break; + case COLUMN_PGSQLPGAMOPAMOPLEFTTYPE: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmoplefttype); + break; + case COLUMN_PGSQLPGAMOPAMOPRIGHTTYPE: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmoprighttype); + break; + case COLUMN_PGSQLPGAMOPAMOPSTRATEGY: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopstrategy); + break; + case COLUMN_PGSQLPGAMOPAMOPREQCHECK: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopreqcheck); + break; + case COLUMN_PGSQLPGAMOPAMOPOPR: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopopr); + break; + case COLUMN_PGSQLPGAMOPAMOPMETHOD: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopmethod); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.h new file mode 100644 index 0000000..2d7ee0c --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/old/pgsqlPgAmopTable.h @@ -0,0 +1,24 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $ + */ +#ifndef PGSQLPGAMOPTABLE_H +#define PGSQLPGAMOPTABLE_H + +/* function declarations */ +void init_pgsqlPgAmopTable(void); +void initialize_table_pgsqlPgAmopTable(void); +Netsnmp_Node_Handler pgsqlPgAmopTable_handler; +Netsnmp_First_Data_Point pgsqlPgAmopTable_get_first_data_point; +Netsnmp_Next_Data_Point pgsqlPgAmopTable_get_next_data_point; + +/* column number definitions for table pgsqlPgAmopTable */ + #define COLUMN_PGSQLPGAMOPENTRYOID 1 + #define COLUMN_PGSQLPGAMOPAMOPFAMILY 2 + #define COLUMN_PGSQLPGAMOPAMOPLEFTTYPE 3 + #define COLUMN_PGSQLPGAMOPAMOPRIGHTTYPE 4 + #define COLUMN_PGSQLPGAMOPAMOPSTRATEGY 5 + #define COLUMN_PGSQLPGAMOPAMOPREQCHECK 6 + #define COLUMN_PGSQLPGAMOPAMOPOPR 7 + #define COLUMN_PGSQLPGAMOPAMOPMETHOD 8 +#endif /* PGSQLPGAMOPTABLE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.c new file mode 100644 index 0000000..74d70f2 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.c @@ -0,0 +1,329 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $ + */ + +#include "pgsnmpd.h" +#include "pgsqlPgAmopTable.h" + + /* TODO: if this works, move it to pgsnmpd.h */ +#define CONNIDLEN 113 + /* Typical data structure for a row entry */ +struct pgsqlPgAmopTable_entry { + /* Index values */ + u_char pgsnmpdConnID[CONNIDLEN]; + size_t pgsnmpdConnID_len; + long rdbmsDbIndex; + long pgsqlPgAmopEntryOID; + + /* Column values */ + /*long pgsqlPgAmopEntryOID; */ + long pgsqlPgAmopAmopfamily; + long pgsqlPgAmopAmoplefttype; + long pgsqlPgAmopAmoprighttype; + long pgsqlPgAmopAmopstrategy; + long pgsqlPgAmopAmopreqcheck; + long pgsqlPgAmopAmopopr; + long pgsqlPgAmopAmopmethod; + + /* Illustrate using a simple linked list */ + int valid; + struct pgsqlPgAmopTable_entry *next; +}; + +struct pgsqlPgAmopTable_entry *pgsqlPgAmopTable_head; + +struct pgsqlPgAmopTable_entry *pgsqlPgAmopTable_createEntry( + char* pgsnmpdConnID, + size_t pgsnmpdConnID_len, + long rdbmsDbIndex, + long pgsqlPgAmopEntryOID + ); + +void +pgsqlPgAmopTable_removeEntry( struct pgsqlPgAmopTable_entry *entry ); + +/** Initializes the pgsqlPgAmopTable module */ +void +init_pgsqlPgAmopTable(void) +{ + /* here we initialize all the tables we're planning on supporting */ + initialize_table_pgsqlPgAmopTable(); +} + +void fill_pgsqlPgAmopTable(void) { + PGresult *pg_db_query; + int resultCount, i; + struct pgsqlPgAmopTable_entry *entry; + char pgsnmpdConnID[112] = "Default conn ID"; + size_t pgsnmpdConnID_len = strlen(pgsnmpdConnID) + 1; + long rdbmsDbIndex = 1; + + snmp_log(LOG_INFO, "Initializing pgsqlPgAmopTable\n"); + if (PQstatus(dbconn) == CONNECTION_OK) { + pg_db_query = PQexec(dbconn, "SELECT oid::INTEGER, amopfamily::INTEGER, amoplefttype::INTEGER, amoprighttype::INTEGER, amopstrategy, amopreqcheck, amopopr::INTEGER , amopmethod::INTEGER FROM pg_amop ORDER BY 1 ASC LIMIT 3"); + } + else { + snmp_log(LOG_ERR, "Can't get connected to database\n"); + return; + /* TODO: I should signal MFD_RESOURCE_UNAVAILABLE somehow, here */ + } + + if (PQresultStatus(pg_db_query) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database\n"); + PQclear(pg_db_query); + return; + /* TODO: I should signal MFD_RESOURCE_UNAVAILABLE somehow, here */ + } + resultCount = PQntuples(pg_db_query); + for (i = 0; i < resultCount; i++) { + entry = pgsqlPgAmopTable_createEntry(pgsnmpdConnID, pgsnmpdConnID_len, + rdbmsDbIndex, atol(PQgetvalue(pg_db_query, i, 0))); + entry->pgsqlPgAmopAmopfamily = atol(PQgetvalue(pg_db_query, i, 1)); + entry->pgsqlPgAmopAmoplefttype = atol(PQgetvalue(pg_db_query, i, 2)); + entry->pgsqlPgAmopAmoprighttype = atol(PQgetvalue(pg_db_query, i, 3)); + entry->pgsqlPgAmopAmopstrategy = atoi(PQgetvalue(pg_db_query, i, 4)); + entry->pgsqlPgAmopAmopreqcheck = atoi(PQgetvalue(pg_db_query, i, 5)); + entry->pgsqlPgAmopAmopopr = atol(PQgetvalue(pg_db_query, i, 6)); + entry->pgsqlPgAmopAmopmethod = atol(PQgetvalue(pg_db_query, i, 7)); + } + snmp_log(LOG_INFO, "Finished initializing pgsqlPgAmopTable with %d entries\n", resultCount); +} + +/* TODO # Determine the first/last column names */ + +/** Initialize the pgsqlPgAmopTable table by defining its contents and how it's structured */ +void +initialize_table_pgsqlPgAmopTable(void) +{ + static oid pgsqlPgAmopTable_oid[] = {1,3,6,1,4,1,27645,1,2,3}; + size_t pgsqlPgAmopTable_oid_len = OID_LENGTH(pgsqlPgAmopTable_oid); + netsnmp_handler_registration *reg; + netsnmp_iterator_info *iinfo; + netsnmp_table_registration_info *table_info; + struct pgsqlPgAmopTable_entry *entry; + char *connID = "Default conn ID\0"; + int conn_len = strlen(connID); + + reg = netsnmp_create_handler_registration( + "pgsqlPgAmopTable", pgsqlPgAmopTable_handler, + pgsqlPgAmopTable_oid, pgsqlPgAmopTable_oid_len, + HANDLER_CAN_RONLY + ); + + table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info ); + netsnmp_table_helper_add_indexes(table_info, + ASN_OCTET_STR, /* index: pgsnmpdConnID */ + ASN_INTEGER, /* index: rdbmsDbIndex */ + ASN_INTEGER, /* index: pgsqlPgAmopEntryOID */ + 0); + table_info->min_column = COLUMN_PGSQLPGAMOPENTRYOID; + table_info->max_column = COLUMN_PGSQLPGAMOPAMOPMETHOD; + + iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info ); + iinfo->get_first_data_point = pgsqlPgAmopTable_get_first_data_point; + iinfo->get_next_data_point = pgsqlPgAmopTable_get_next_data_point; + iinfo->table_reginfo = table_info; + + netsnmp_register_table_iterator( reg, iinfo ); + + /* Initialise the contents of the table here */ + fill_pgsqlPgAmopTable(); +} + +/* create a new row in the (unsorted) table */ +struct pgsqlPgAmopTable_entry * +pgsqlPgAmopTable_createEntry( + char* pgsnmpdConnID, + size_t pgsnmpdConnID_len, + long rdbmsDbIndex, + long pgsqlPgAmopEntryOID + ) { + struct pgsqlPgAmopTable_entry *entry; + + entry = SNMP_MALLOC_TYPEDEF(struct pgsqlPgAmopTable_entry); + if (!entry) + return NULL; + + memset(entry->pgsnmpdConnID, 0, CONNIDLEN); + memcpy(entry->pgsnmpdConnID, pgsnmpdConnID, pgsnmpdConnID_len); + entry->pgsnmpdConnID_len = pgsnmpdConnID_len; + entry->rdbmsDbIndex = rdbmsDbIndex; + entry->pgsqlPgAmopEntryOID = pgsqlPgAmopEntryOID; + entry->next = pgsqlPgAmopTable_head; + pgsqlPgAmopTable_head = entry; + return entry; +} + +/* remove a row from the table */ +void +pgsqlPgAmopTable_removeEntry( struct pgsqlPgAmopTable_entry *entry ) { + struct pgsqlPgAmopTable_entry *ptr, *prev; + + if (!entry) + return; /* Nothing to remove */ + + for ( ptr = pgsqlPgAmopTable_head, prev = NULL; + ptr != NULL; + prev = ptr, ptr = ptr->next ) { + if ( ptr == entry ) + break; + } + if ( !ptr ) + return; /* Can't find it */ + + if ( prev == NULL ) + pgsqlPgAmopTable_head = ptr->next; + else + prev->next = ptr->next; + + SNMP_FREE( entry ); /* XXX - release any other internal resources */ +} + + +/* Example iterator hook routines - using 'get_next' to do most of the work */ +netsnmp_variable_list * +pgsqlPgAmopTable_get_first_data_point(void **my_loop_context, + void **my_data_context, + netsnmp_variable_list *put_index_data, + netsnmp_iterator_info *mydata) +{ + *my_loop_context = pgsqlPgAmopTable_head; + snmp_log(LOG_INFO, "*** get_first called\n"); + return pgsqlPgAmopTable_get_next_data_point(my_loop_context, my_data_context, + put_index_data, mydata ); +} + +netsnmp_variable_list * +pgsqlPgAmopTable_get_next_data_point(void **my_loop_context, + void **my_data_context, + netsnmp_variable_list *put_index_data, + netsnmp_iterator_info *mydata) +{ + struct pgsqlPgAmopTable_entry *entry = (struct pgsqlPgAmopTable_entry *)*my_loop_context; + netsnmp_variable_list *idx = put_index_data; + + snmp_log(LOG_INFO, "*** get_next called\n"); + if ( entry ) { + snmp_set_var_value( idx, entry->pgsnmpdConnID, sizeof(entry->pgsnmpdConnID) ); + idx = idx->next_variable; + snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->rdbmsDbIndex ); + idx = idx->next_variable; + snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->pgsqlPgAmopEntryOID ); + idx = idx->next_variable; + *my_data_context = (void *)entry; + *my_loop_context = (void *)entry->next; + return put_index_data; + } else { + return NULL; + } +} + + +/** handles requests for the pgsqlPgAmopTable table */ +int +pgsqlPgAmopTable_handler( + netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) { + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + struct pgsqlPgAmopTable_entry *table_entry; + + snmp_log(LOG_INFO, "Handler called\n"); + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request=requests; request; request=request->next) { + table_entry = (struct pgsqlPgAmopTable_entry *) + netsnmp_extract_iterator_context(request); + table_info = netsnmp_extract_table_info( request); + + switch (table_info->colnum) { + case COLUMN_PGSQLPGAMOPENTRYOID: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopEntryOID); + break; + case COLUMN_PGSQLPGAMOPAMOPFAMILY: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopfamily); + break; + case COLUMN_PGSQLPGAMOPAMOPLEFTTYPE: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmoplefttype); + break; + case COLUMN_PGSQLPGAMOPAMOPRIGHTTYPE: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmoprighttype); + break; + case COLUMN_PGSQLPGAMOPAMOPSTRATEGY: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopstrategy); + break; + case COLUMN_PGSQLPGAMOPAMOPREQCHECK: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopreqcheck); + break; + case COLUMN_PGSQLPGAMOPAMOPOPR: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopopr); + break; + case COLUMN_PGSQLPGAMOPAMOPMETHOD: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAmopAmopmethod); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.h new file mode 100644 index 0000000..2d7ee0c --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/pgsqlPgAmopTable.h @@ -0,0 +1,24 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $ + */ +#ifndef PGSQLPGAMOPTABLE_H +#define PGSQLPGAMOPTABLE_H + +/* function declarations */ +void init_pgsqlPgAmopTable(void); +void initialize_table_pgsqlPgAmopTable(void); +Netsnmp_Node_Handler pgsqlPgAmopTable_handler; +Netsnmp_First_Data_Point pgsqlPgAmopTable_get_first_data_point; +Netsnmp_Next_Data_Point pgsqlPgAmopTable_get_next_data_point; + +/* column number definitions for table pgsqlPgAmopTable */ + #define COLUMN_PGSQLPGAMOPENTRYOID 1 + #define COLUMN_PGSQLPGAMOPAMOPFAMILY 2 + #define COLUMN_PGSQLPGAMOPAMOPLEFTTYPE 3 + #define COLUMN_PGSQLPGAMOPAMOPRIGHTTYPE 4 + #define COLUMN_PGSQLPGAMOPAMOPSTRATEGY 5 + #define COLUMN_PGSQLPGAMOPAMOPREQCHECK 6 + #define COLUMN_PGSQLPGAMOPAMOPOPR 7 + #define COLUMN_PGSQLPGAMOPAMOPMETHOD 8 +#endif /* PGSQLPGAMOPTABLE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.c new file mode 100644 index 0000000..b9e769d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.c @@ -0,0 +1,254 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $ + */ + +#include +#include +#include +#include "pgsqlPgAggregateTable.h" + +/** Initializes the pgsqlPgAggregateTable module */ +void +init_pgsqlPgAggregateTable(void) +{ + /* here we initialize all the tables we're planning on supporting */ + initialize_table_pgsqlPgAggregateTable(); +} + + # Determine the first/last column names + +/** Initialize the pgsqlPgAggregateTable table by defining its contents and how it's structured */ +void +initialize_table_pgsqlPgAggregateTable(void) +{ + static oid pgsqlPgAggregateTable_oid[] = {1,3,6,1,4,1,27645,1,2,1}; + size_t pgsqlPgAggregateTable_oid_len = OID_LENGTH(pgsqlPgAggregateTable_oid); + netsnmp_handler_registration *reg; + netsnmp_iterator_info *iinfo; + netsnmp_table_registration_info *table_info; + + reg = netsnmp_create_handler_registration( + "pgsqlPgAggregateTable", pgsqlPgAggregateTable_handler, + pgsqlPgAggregateTable_oid, pgsqlPgAggregateTable_oid_len, + HANDLER_CAN_RONLY + ); + + table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info ); + netsnmp_table_helper_add_indexes(table_info, + ASN_OCTET_STR, /* index: pgsnmpdConnID */ + ASN_INTEGER, /* index: rdbmsDbIndex */ + ASN_INTEGER, /* index: pgsqlPgAggregateEntryOID */ + 0); + table_info->min_column = COLUMN_PGSQLPGAGGREGATEAGGFNOID; + table_info->max_column = COLUMN_PGSQLPGAGGREGATEAGGINITVAL; + + iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info ); + iinfo->get_first_data_point = pgsqlPgAggregateTable_get_first_data_point; + iinfo->get_next_data_point = pgsqlPgAggregateTable_get_next_data_point; + iinfo->table_reginfo = table_info; + + netsnmp_register_table_iterator( reg, iinfo ); + + /* Initialise the contents of the table here */ +} + + /* Typical data structure for a row entry */ +struct pgsqlPgAggregateTable_entry { + /* Index values */ + char pgsnmpdConnID[NNN]; + size_t pgsnmpdConnID_len; + long rdbmsDbIndex; + long pgsqlPgAggregateEntryOID; + + /* Column values */ + long pgsqlPgAggregateAggfnoid; + long pgsqlPgAggregateAggtransfn; + long pgsqlPgAggregateAggfinalfn; + long pgsqlPgAggregateAggsortop; + long pgsqlPgAggregateAggtranstype; + char pgsqlPgAggregateAgginitval[NNN]; + size_t pgsqlPgAggregateAgginitval_len; + + /* Illustrate using a simple linked list */ + int valid; + struct pgsqlPgAggregateTable_entry *next; +}; + +struct pgsqlPgAggregateTable_entry *pgsqlPgAggregateTable_head; + +/* create a new row in the (unsorted) table */ +struct pgsqlPgAggregateTable_entry * +pgsqlPgAggregateTable_createEntry( + char* pgsnmpdConnID, + size_t pgsnmpdConnID_len, + long rdbmsDbIndex, + long pgsqlPgAggregateEntryOID, + ) { + struct pgsqlPgAggregateTable_entry *entry; + + entry = SNMP_MALLOC_TYPEDEF(struct pgsqlPgAggregateTable_entry); + if (!entry) + return NULL; + + memcpy(entry->pgsnmpdConnID, pgsnmpdConnID, pgsnmpdConnID_len); + entry->pgsnmpdConnID_len = pgsnmpdConnID_len; + entry->rdbmsDbIndex = rdbmsDbIndex; + entry->pgsqlPgAggregateEntryOID = pgsqlPgAggregateEntryOID; + entry->next = pgsqlPgAggregateTable_head; + pgsqlPgAggregateTable_head = entry; + return entry; +} + +/* remove a row from the table */ +void +pgsqlPgAggregateTable_removeEntry( struct pgsqlPgAggregateTable_entry *entry ) { + struct pgsqlPgAggregateTable_entry *ptr, *prev; + + if (!entry) + return; /* Nothing to remove */ + + for ( ptr = pgsqlPgAggregateTable_head, prev = NULL; + ptr != NULL; + prev = ptr, ptr = ptr->next ) { + if ( ptr == entry ) + break; + } + if ( !ptr ) + return; /* Can't find it */ + + if ( prev == NULL ) + pgsqlPgAggregateTable_head = ptr->next; + else + prev->next = ptr->next; + + SNMP_FREE( entry ); /* XXX - release any other internal resources */ +} + + +/* Example iterator hook routines - using 'get_next' to do most of the work */ +netsnmp_variable_list * +pgsqlPgAggregateTable_get_first_data_point(void **my_loop_context, + void **my_data_context, + netsnmp_variable_list *put_index_data, + netsnmp_iterator_info *mydata) +{ + *my_loop_context = pgsqlPgAggregateTable_head; + return pgsqlPgAggregateTable_get_next_data_point(my_loop_context, my_data_context, + put_index_data, mydata ); +} + +netsnmp_variable_list * +pgsqlPgAggregateTable_get_next_data_point(void **my_loop_context, + void **my_data_context, + netsnmp_variable_list *put_index_data, + netsnmp_iterator_info *mydata) +{ + struct pgsqlPgAggregateTable_entry *entry = (struct pgsqlPgAggregateTable_entry *)*my_loop_context; + netsnmp_variable_list *idx = put_index_data; + + if ( entry ) { + snmp_set_var_value( idx, entry->pgsnmpdConnID, sizeof(entry->pgsnmpdConnID) ); + idx = idx->next_variable; + snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->rdbmsDbIndex ); + idx = idx->next_variable; + snmp_set_var_typed_integer( idx, ASN_INTEGER, entry->pgsqlPgAggregateEntryOID ); + idx = idx->next_variable; + *my_data_context = (void *)entry; + *my_loop_context = (void *)entry->next; + return put_index_data; + } else { + return NULL; + } +} + + +/** handles requests for the pgsqlPgAggregateTable table */ +int +pgsqlPgAggregateTable_handler( + netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) { + + netsnmp_request_info *request; + netsnmp_table_request_info *table_info; + struct pgsqlPgAggregateTable_entry *table_entry; + + switch (reqinfo->mode) { + /* + * Read-support (also covers GetNext requests) + */ + case MODE_GET: + for (request=requests; request; request=request->next) { + table_entry = (struct pgsqlPgAggregateTable_entry *) + netsnmp_extract_iterator_context(request); + table_info = netsnmp_extract_table_info( request); + + switch (table_info->colnum) { + case COLUMN_PGSQLPGAGGREGATEAGGFNOID: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAggregateAggfnoid); + break; + case COLUMN_PGSQLPGAGGREGATEAGGTRANSFN: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAggregateAggtransfn); + break; + case COLUMN_PGSQLPGAGGREGATEAGGFINALFN: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAggregateAggfinalfn); + break; + case COLUMN_PGSQLPGAGGREGATEAGGSORTOP: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAggregateAggsortop); + break; + case COLUMN_PGSQLPGAGGREGATEAGGTRANSTYPE: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_integer( request->requestvb, ASN_INTEGER, + table_entry->pgsqlPgAggregateAggtranstype); + break; + case COLUMN_PGSQLPGAGGREGATEAGGINITVAL: + if ( !table_entry ) { + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHINSTANCE); + continue; + } + snmp_set_var_typed_value( request->requestvb, ASN_OCTET_STR, + (u_char*)table_entry->pgsqlPgAggregateAgginitval, + table_entry->pgsqlPgAggregateAgginitval_len); + break; + default: + netsnmp_set_request_error(reqinfo, request, + SNMP_NOSUCHOBJECT); + break; + } + } + break; + + } + return SNMP_ERR_NOERROR; +} diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.h new file mode 100644 index 0000000..57e2917 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAmopTable/tmp/pgsqlPgAggregateTable.h @@ -0,0 +1,23 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : mib2c.iterate.conf 15999 2007-03-25 22:32:02Z dts12 $ + */ +#ifndef PGSQLPGAGGREGATETABLE_H +#define PGSQLPGAGGREGATETABLE_H + +/* function declarations */ +void init_pgsqlPgAggregateTable(void); +void initialize_table_pgsqlPgAggregateTable(void); +Netsnmp_Node_Handler pgsqlPgAggregateTable_handler; +Netsnmp_First_Data_Point pgsqlPgAggregateTable_get_first_data_point; +Netsnmp_Next_Data_Point pgsqlPgAggregateTable_get_next_data_point; + +/* column number definitions for table pgsqlPgAggregateTable */ + #define COLUMN_PGSQLPGAGGREGATEENTRYOID 1 + #define COLUMN_PGSQLPGAGGREGATEAGGFNOID 2 + #define COLUMN_PGSQLPGAGGREGATEAGGTRANSFN 3 + #define COLUMN_PGSQLPGAGGREGATEAGGFINALFN 4 + #define COLUMN_PGSQLPGAGGREGATEAGGSORTOP 5 + #define COLUMN_PGSQLPGAGGREGATEAGGTRANSTYPE 6 + #define COLUMN_PGSQLPGAGGREGATEAGGINITVAL 7 +#endif /* PGSQLPGAGGREGATETABLE_H */ diff --git a/RDBMS-MIB b/RDBMS-MIB new file mode 100644 index 0000000..1cfa5ac --- /dev/null +++ b/RDBMS-MIB @@ -0,0 +1,1420 @@ + RDBMS-MIB DEFINITIONS ::= BEGIN + + IMPORTS + MODULE-IDENTITY, OBJECT-TYPE, NOTIFICATION-TYPE, + Counter32, Gauge32, Integer32 + FROM SNMPv2-SMI + DisplayString, DateAndTime, AutonomousType + FROM SNMPv2-TC + applIndex, applGroup + FROM APPLICATION-MIB + mib-2 + FROM RFC1213-MIB; + + rdbmsMIB MODULE-IDENTITY + LAST-UPDATED "9406150655Z" + ORGANIZATION "IETF RDBMSMIB Working Group" + CONTACT-INFO + " David Brower + + Postal: The ASK Group, INGRES DBMS Development + 1080 Marina Village Parkway + Alameda, CA 94501 + US + + Tel: +1 510 748 3418 + Fax: +1 510 748 2770 + + E-mail: daveb@ingres.com" + DESCRIPTION + "The MIB module to describe objects for generic relational + databases." + + ::= { mib-2 39 } + + rdbmsObjects OBJECT IDENTIFIER ::= { rdbmsMIB 1 } + + ---------------------------------------------------------------- + + rdbmsDbTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsDbEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of databases installed on a system." + ::= { rdbmsObjects 1 } + + rdbmsDbEntry OBJECT-TYPE + SYNTAX RdbmsDbEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry for a single database on the host. Whether a + particular database is represented by a row in rdbmsDbTable + may be dependent on the activity level of that database, + according to the product's implementation. An instance of + rdbmsRelState having the value active, other, or restricted + implies that an entry, corresponding to that instance, will + be present." + INDEX { rdbmsDbIndex } + ::= { rdbmsDbTable 1 } + + RdbmsDbEntry ::= + SEQUENCE { + rdbmsDbIndex INTEGER, + rdbmsDbPrivateMibOID OBJECT IDENTIFIER, + rdbmsDbVendorName DisplayString, + rdbmsDbName DisplayString, + rdbmsDbContact DisplayString + } + + rdbmsDbIndex OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "A numeric index, unique among all the databases from all + products on this host. This value is a surrogate for the + conceptually unique key, which is {PrivateMibOID, + databasename}" + ::= { rdbmsDbEntry 1 } + + rdbmsDbPrivateMibOID OBJECT-TYPE + SYNTAX OBJECT IDENTIFIER + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The authoritative identification for the private MIB for + this database, presumably based on the vendor, e.g., { + enterprises 111 } for Oracle + databases, {enterprises 757 } for + Ingres databases, { enterprises 897 } for Sybase databases, etc. + + If no OBJECT IDENTIFIER exists for the private MIB, attempts + + to access this object will return noSuchName (SNMPv1) + or noSuchInstance (SNMPv2)." + ::= { rdbmsDbEntry 2 } + + rdbmsDbVendorName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The name of the vendor whose RDBMS manages this database, + for informational purposes." + ::= { rdbmsDbEntry 3 } + + rdbmsDbName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The name of this database, in a product specific format. The + product may need to qualify the name in some way to resolve + conflicts if it is possible for a database name to be + duplicated on a host. It might be necessary to construct a + hierarchical name embedding the RDBMS instance/installation + on the host, and/or the owner of the database. For instance, + '/test-installation/database-owner/database-name'." + ::= { rdbmsDbEntry 4 } + + rdbmsDbContact OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The textual identification of the contact person for this + managed database, together with information on how to contact + this person. + + Note: if there is no server associated with this database, an + agent may need to keep this in other persistent storage, + e.g., a configuration file. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsDbEntry 5 } + + ---------------------------------------------------------------- + + rdbmsDbInfoTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsDbInfoEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of additional information about databases present + on the host." + ::= { rdbmsObjects 2 } + + rdbmsDbInfoEntry OBJECT-TYPE + SYNTAX RdbmsDbInfoEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Information that must be present if the database is actively + opened. If the database is not actively opened, then + attempts to access corresponding instances in this table may + result in either noSuchName (SNMPv1) or noSuchInstance + (SNMPv2). 'Actively opened' means at least one of the + rdbmsRelState entries for this database in the rdbmsRelTable + is active(2)." + INDEX { rdbmsDbIndex } + ::= { rdbmsDbInfoTable 1 } + + RdbmsDbInfoEntry ::= + SEQUENCE { + rdbmsDbInfoProductName DisplayString, + rdbmsDbInfoVersion DisplayString, + rdbmsDbInfoSizeUnits INTEGER, + rdbmsDbInfoSizeAllocated INTEGER, + rdbmsDbInfoSizeUsed INTEGER, + rdbmsDbInfoLastBackup DateAndTime + } + + rdbmsDbInfoProductName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The textual product name of the server that created or last + restructured this database. The format is product specific." + ::= { rdbmsDbInfoEntry 1 } + + rdbmsDbInfoVersion OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + + STATUS current + DESCRIPTION + "The version number of the server that created or last + restructured this database. The format is product specific." + ::= { rdbmsDbInfoEntry 2 } + + rdbmsDbInfoSizeUnits OBJECT-TYPE + SYNTAX INTEGER { + bytes(1), + kbytes(2), + mbytes(3), + gbytes(4), + tbytes(5) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Identification of the units used to measure the size of this + database in rdbmsDbInfoSizeAllocated and rdbmsDbInfoSizeUsed. + bytes(1) indicates individual bytes, kbytes(2) indicates + units of kilobytes, mbytes(3) indicates units of megabytes, + gbytes(4) indicates units of gigabytes, and tbytes(5) + indicates units of terabytes. All are binary multiples -- 1K + = 1024. If writable, changes here are reflected in the get + values of the associated objects." + + ::= { rdbmsDbInfoEntry 3 } + + rdbmsDbInfoSizeAllocated OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The estimated size of this database (in + rdbmsDbInfoSizeUnits), which is the disk space that has been + allocated to it and is no longer available to users on this + host. rdbmsDbInfoSize does not necessarily indicate the + amount of space actually in use for database data. Some + databases may support extending allocated size, and others + may not. + + Note that a compliant agent does not need to + allow write access to this object." + + -- Note: computing SizeAllocated may be expensive, and SNMP + -- agents might cache the value to increase performance. + + ::= { rdbmsDbInfoEntry 4 } + + rdbmsDbInfoSizeUsed OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The estimated size of this database, in rdbmsDbInfoSizeUnits, + which is actually in use for database data." + + -- Note: computing SizeUsed may be expensive, and SNMP + -- agents might cache the value to increase performance. + ::= { rdbmsDbInfoEntry 5 } + + rdbmsDbInfoLastBackup OBJECT-TYPE + SYNTAX DateAndTime + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The date and time that the latest complete or partial backup + of the database was taken. If a database has never been + backed up, then attempts to access this object will + result in either noSuchName (SNMPv1) or noSuchInstance + (SNMPv2)." + ::= { rdbmsDbInfoEntry 6 } + + ---------------------------------------------------------------- + + rdbmsDbParamTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsDbParamEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of configuration parameters for a database. + Entries should be populated according to the following + guidelines: + (1) The value should be specified through administrative + (human) intervention. + (2) It should be configured on a per-database basis. + (3) One of the following is true: + (a) The parameter has a non-numeric value; + (b) The current value is numeric, but it only changes due + to human intervention; + (c) The current value is numeric and dynamic, but the + RDBMS does not track access/allocation failures + related to the parameter; + (d) The current value is numeric and dynamic, the + RDBMS tracks changes in access/allocation failures + related to the parameter, but the failure has no + significant impact on RDBMS performance or + + availability. + (e) The current value is numeric and dynamic, the + RDBMS tracks changes in access/allocation failures + related to the parameter, the failure has + significant impact on RDBMS performance or + availability, and is shown in the + rdbmsDbLimitedResource table." + ::= { rdbmsObjects 3 } + + rdbmsDbParamEntry OBJECT-TYPE + SYNTAX RdbmsDbParamEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry for a single configuration parameter for a database. + Parameters with single values have a subindex value of one. + If the parameter is naturally considered to contain a + variable number of members of a class, e.g. members of the + DBA user group, or files which are part of the database, then + it must be presented as a set of rows. If, on the other + hand, the parameter represents a set of choices from a class, + e.g. the permissions on a file or the options chosen out of + the set of all options allowed, AND is guaranteed to always + fit in the 255 character length of a DisplayString, then it + may be presented as a comma separated list with a subindex + value of one. Zero may not be used as a subindex value. + + If the database is not actively opened, then attempts + to access corresponding instances in this table may result in + either noSuchName (SNMPv1) or noSuchInstance (SNMPv2). + 'Actively opened' means at least one of the + rdbmsRelState entries for this database in the rdbmsRelTable + is active(2)." + INDEX { rdbmsDbIndex, rdbmsDbParamName, rdbmsDbParamSubIndex } + ::= { rdbmsDbParamTable 1 } + + RdbmsDbParamEntry ::= + SEQUENCE { + rdbmsDbParamName DisplayString, + rdbmsDbParamSubIndex INTEGER, + rdbmsDbParamID AutonomousType, + rdbmsDbParamCurrValue DisplayString, + rdbmsDbParamComment DisplayString + } + + rdbmsDbParamName OBJECT-TYPE + SYNTAX DisplayString (SIZE (1..64)) + MAX-ACCESS not-accessible + + STATUS current + DESCRIPTION + "The name of a configuration parameter for a database. This + name is product-specific. The length is limited to 64 + characters to constrain the number of sub-identifiers needed + for instance identification (and to minimize network + traffic)." + + ::= { rdbmsDbParamEntry 1 } + + rdbmsDbParamSubIndex OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The subindex value for this parameter. If the parameter is + naturally considered to contain a variable number of members + of a class, e.g. members of the DBA user group, or files + which are part of the database, then it must be presented as + a set of rows. If, on the other hand, the parameter + represents a set of choices from a class, e.g. the + permissions on a file or the options chosen out of the set of + all options allowed, AND is guaranteed to always fit in the + 255 character length of a DisplayString, then it may be + presented as a comma separated list with a subindex value of + one. Zero may not be used as a value." + ::= { rdbmsDbParamEntry 2 } + + rdbmsDbParamID OBJECT-TYPE + SYNTAX AutonomousType + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The ID of the parameter which may be described in some other + MIB (e.g., an enterprise-specific MIB module). If there is + no ID for this rdbmsDbParamName, attempts to access this + object will return noSuchName (SNMPv1) or noSuchInstance + (SNMPv2)." + ::= { rdbmsDbParamEntry 3 } + + rdbmsDbParamCurrValue OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The value for a configuration parameter now in effect, the + actual setting for the database. While there may multiple + values in the temporal domain of interest (for instance, the + + value to take effect at the next restart), this is the + current setting. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsDbParamEntry 4 } + + rdbmsDbParamComment OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Annotation which describes the purpose of a configuration + parameter or the reason for a particular parameter's + setting. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsDbParamEntry 5 } + + ---------------------------------------------------------------- + + rdbmsDbLimitedResourceTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsDbLimitedResourceEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of limited resources that are kept per-database." + ::= { rdbmsObjects 4 } + + rdbmsDbLimitedResourceEntry OBJECT-TYPE + SYNTAX RdbmsDbLimitedResourceEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry for a single limited resource kept per-database. + A limited resource has maximum use determined by a parameter + that might or might not be changeable at run time, or visible + in the rdbmsDbParamTable. Examples would be the number of + available locks, or disk space on a partition. Arrays of + resources are supported through an integer sub index, which + should have the value of one for single-instance names. + + Limited resources that are shared across databases, are best + put in the rdbmsSvrLimitedResourceTable instead of this one. + + If the database is not actively opened, then attempts to + access corresponding instances in this table may result in + either noSuchName (SNMPv1) or noSuchInstance (SNMPv2). + 'Actively opened' means at least one of the rdbmsRelState + entries for this database in the rdbmsRelTable is active(2)." + + INDEX { rdbmsDbIndex, rdbmsDbLimitedResourceName } + ::= { rdbmsDbLimitedResourceTable 1 } + + RdbmsDbLimitedResourceEntry ::= + SEQUENCE { + rdbmsDbLimitedResourceName DisplayString, + rdbmsDbLimitedResourceID AutonomousType, + rdbmsDbLimitedResourceLimit INTEGER, + rdbmsDbLimitedResourceCurrent INTEGER, + rdbmsDbLimitedResourceHighwater INTEGER, + rdbmsDbLimitedResourceFailures Counter32, + rdbmsDbLimitedResourceDescription DisplayString + } + + rdbmsDbLimitedResourceName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The name of the resource, for instance 'global locks' or + 'locks for the FOO database', or 'data space on /dev/rdsk/5s0 + for FOO'. The length is limited to 64 characters to constrain + the number of sub-identifiers needed for instance + identification (and to minimize network traffic)." + ::= { rdbmsDbLimitedResourceEntry 1 } + + rdbmsDbLimitedResourceID OBJECT-TYPE + SYNTAX AutonomousType + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The ID of the resource which may be described in some other + MIB (e.g., an enterprise-specific MIB module). If there is + no ID for this rdbmsDbLimitedResourceName, attempts to access + this object will return noSuchName (SNMPv1) or noSuchInstance + (SNMPv2)." + ::= { rdbmsDbLimitedResourceEntry 2 } + + rdbmsDbLimitedResourceLimit OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-write + STATUS current + + DESCRIPTION + "The maximum value the resource use may attain. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsDbLimitedResourceEntry 3 } + + rdbmsDbLimitedResourceCurrent OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The current value for the resource." + ::= { rdbmsDbLimitedResourceEntry 4 } + + rdbmsDbLimitedResourceHighwater OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The maximum value of the resource seen since applUpTime + was reset for the earliest server which has the database + actively opened. + + If there are two servers with the database open, and the + oldest one dies, the proper way to invalidate the value is by + resetting sysUpTime." + ::= { rdbmsDbLimitedResourceEntry 5 } + + rdbmsDbLimitedResourceFailures OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of times the system wanted to exceed the limit of + the resource since applUpTime was reset for the earliest + server which has the database actively opened. + + If there are two servers with the DB open, and the + oldest one dies, the proper way to invalidate the value is by + resetting sysUpTime." + ::= { rdbmsDbLimitedResourceEntry 6 } + + rdbmsDbLimitedResourceDescription OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + + DESCRIPTION + "A description of the resource and the meaning of the integer + units used for Limit, Current, and Highwater. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsDbLimitedResourceEntry 7 } + + ---------------------------------------------------------------- + + rdbmsSrvTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsSrvEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of database servers running or installed + on a system." + ::= { rdbmsObjects 5 } + + rdbmsSrvEntry OBJECT-TYPE + SYNTAX RdbmsSrvEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry for a single database server. A server is an + independent entity that provides access to one or more + databases. Failure of one does not affect access to + databases through any other servers. There might be one or + more servers providing access to a database. A server may be + a 'process' or collection of 'processes', as interpreted by + the product." + INDEX { applIndex } + ::= { rdbmsSrvTable 1 } + + RdbmsSrvEntry ::= + SEQUENCE { + rdbmsSrvPrivateMibOID OBJECT IDENTIFIER, + rdbmsSrvVendorName DisplayString, + rdbmsSrvProductName DisplayString, + rdbmsSrvContact DisplayString + } + + rdbmsSrvPrivateMibOID OBJECT-TYPE + SYNTAX OBJECT IDENTIFIER + MAX-ACCESS read-only + STATUS current + DESCRIPTION + + "The authoritative identification for the private MIB for this + server, presumably based on the vendor, e.g., { enterprises + 111 } for Oracle servers, { + enterprises 757 } for Ingres + servers, { enterprises 897 } for + Sybase servers, etc. + + If no OBJECT IDENTIFIER exists for the private MIB, attempts + to access this object will return noSuchName (SNMPv1) + or noSuchInstance (SNMPv2)." + ::= { rdbmsSrvEntry 1 } + + rdbmsSrvVendorName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The name of the vendor whose RDBMS manages this database, + for informational purposes." + ::= { rdbmsSrvEntry 2 } + + rdbmsSrvProductName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The product name of this server. This is normally the + vendor's formal name for the product, in product specific + format." + ::= { rdbmsSrvEntry 3 } + + rdbmsSrvContact OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The textual identification of the contact person for this + managed server, together with information on how to contact + this person. + + Note: if there is no active server associated with this + object, an agent may need to keep this in other persistent + storage, e.g., a configuration file. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsSrvEntry 4 } + + ---------------------------------------------------------------- + + rdbmsSrvInfoTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsSrvInfoEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of additional information about database servers. + + Entries in this table correspond to applications in the + APPLICATION-MIB applTable. Some objects in that table are + application-specific. When they are associated with an RDBMS + server in this table, the objects have the following + meanings. + + applName - The name of this server, i.e., the process or + group of processes providing access to this database. The + exact format will be product and host specific. + + applVersion - The version number of this server, in product + specific format. + + applOperStatus - up(1) means operational and available for + general use. down(2) means the server is not available for + use, but is known to the agent. The other states have broad + meaning, and may need to be supplemented by the vendor + private MIB. Halted(3) implies an administrative state of + unavailability. Congested(4) implies a resource or or + administrative limit is prohibiting new inbound associations. + The 'available soon' description of restarting(5) may include + an indeterminate amount of recovery. + + applLastChange is the time the agent noticed the most recent + change to applOperStatus. + + applInboundAssociation is the number of currently active + local and remote conversations (usually SQL connects). + + applOutboundAssociations is not provided by this MIB. + + applAccumulatedInboundAssociations is the total number of + local and remote conversations started since the server came + up. + + applAccumulatedOutbound associations is not provided by this + MIB. + + applLastInboundActivity is the time the most recent local or + + remote conversation was attempted or disconnected. + + applLastOutboundActivity is not provided by this MIB. + + applRejectedInboundAssociations is the number of local or + remote conversations rejected by the server for + administrative reasons or because of resource limitations. + + applFailedOutboundAssociations is not provided by this MIB." + + ::= { rdbmsObjects 6 } + + rdbmsSrvInfoEntry OBJECT-TYPE + SYNTAX RdbmsSrvInfoEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Information that must be present for a single 'up' database + server, with visibility determined by the value of the + corresponding applOperStatus object. If an instance of + applOperStatus is not up(1), then attempts to access + corresponding instances in this table may result in either + noSuchName (SNMPv1) or noSuchInstance (SNMPv2) being returned + by the agent." + INDEX { applIndex } + ::= { rdbmsSrvInfoTable 1 } + + RdbmsSrvInfoEntry ::= + SEQUENCE { + rdbmsSrvInfoStartupTime DateAndTime, + rdbmsSrvInfoFinishedTransactions Gauge32, + rdbmsSrvInfoDiskReads Counter32, + rdbmsSrvInfoDiskWrites Counter32, + rdbmsSrvInfoLogicalReads Counter32, + rdbmsSrvInfoLogicalWrites Counter32, + rdbmsSrvInfoPageWrites Counter32, + rdbmsSrvInfoPageReads Counter32, + rdbmsSrvInfoDiskOutOfSpaces Counter32, + rdbmsSrvInfoHandledRequests Counter32, + rdbmsSrvInfoRequestRecvs Counter32, + rdbmsSrvInfoRequestSends Counter32, + rdbmsSrvInfoHighwaterInboundAssociations Gauge32, + rdbmsSrvInfoMaxInboundAssociations Gauge32 + } + + rdbmsSrvInfoStartupTime OBJECT-TYPE + SYNTAX DateAndTime + MAX-ACCESS read-only + + STATUS current + DESCRIPTION + "The date and time at which this server was last started." + ::= { rdbmsSrvInfoEntry 1 } + + rdbmsSrvInfoFinishedTransactions OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of transactions visible to this server that have + been completed by either commit or abort. Some database + operations, such as read-only queries, may not result in the + creation of a transaction." + ::= { rdbmsSrvInfoEntry 2 } + + rdbmsSrvInfoDiskReads OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of reads of database files issued to the + operating system by this server since startup. Numbers are + not comparable between products. What constitutes a + readand how it is accounted is product-specific." + ::= { rdbmsSrvInfoEntry 3 } + + rdbmsSrvInfoLogicalReads OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of logical reads of database files made + internally by this server since startup. The values of this + object and those of rdbmsSrvInfoDiskReads reveal the effect + of caching on read operation. Numbers are not comparable + between products, and may only be meaningful when aggregated + across all servers sharing a common cache." + ::= { rdbmsSrvInfoEntry 4 } + + rdbmsSrvInfoDiskWrites OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of writes to database files issued to the + operating system by this server since startup. Numbers are + not comparable between products." + + ::= { rdbmsSrvInfoEntry 5 } + + rdbmsSrvInfoLogicalWrites OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of times parts of the database files have + been marked 'dirty' and in need of writing to the disk. This + value and rdbmsSrvInfoDiskWrites give some indication of the + effect of 'write-behind' strategies in reducing the number of + disk writes compared to database operations. Because the + writes may be done by servers other than those marking the + parts of the database files dirty, these values may only be + meaningful when aggregated across all servers sharing a + common cache. Numbers are not comparable between products." + ::= { rdbmsSrvInfoEntry 6 } + + rdbmsSrvInfoPageReads OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of pages in database files read by this + server since startup. 'Pages' are product specific units of + disk i/o operations. This value, along with + rdbmsSrvInfoDiskReads, reveals the effect of any grouping + read-ahead that may be used to enhance performance of some + queries, such as scans." + ::= { rdbmsSrvInfoEntry 7} + + rdbmsSrvInfoPageWrites OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of pages in database files written by this + server since startup. Pages are product-specific units of + disk I/O. This value, with rdbmsSrvInfoDiskWrites, shows the + effect of write strategies that collapse logical writes of + contiguous pages into single calls to the operating system." + ::= { rdbmsSrvInfoEntry 8 } + + rdbmsSrvInfoDiskOutOfSpaces OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + + "The total number of times the server has been unable to + obtain disk space that it wanted, since server startup. This + would be inspected by an agent on receipt of an + rdbmsOutOfSpace trap." + ::= { rdbmsSrvInfoEntry 9 } + + rdbmsSrvInfoHandledRequests OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of requests made to the server on inbound + associations. The meaning of 'requests' is product specific, + and is not comparable between products. + + This is intended to encapsulate high level semantic + operations between clients and servers, or between peers. + For instance, one request might correspond to a 'select' or + an 'insert' statement. It is not intended to capture disk + i/o described in rdbmsSrvInfoDiskReads and + rdbmsSrvInfoDiskWrites." + ::= { rdbmsSrvInfoEntry 10 } + + rdbmsSrvInfoRequestRecvs OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of receive operations made processing any requests + on inbound associations. The meaning of operations is product + specific, and is not comparable between products. + + This is intended to capture lower-level i/o operations than + shown by HandledRequests, between clients and servers, or + between peers. For instance, it might roughly correspond to + the amount of data given with an 'insert' statement. It is + not intended to capture disk i/o described in + rdbmsSrvInfoDiskReads and rdbmsSrvInfoDiskWrites." + ::= { rdbmsSrvInfoEntry 11 } + + rdbmsSrvInfoRequestSends OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of send operations made processing requests + handled on inbound associations. The meaning of operations + is product specific, and is not comparable between products. + + This is intended to capture lower-level i/o operations than + shown by HandledRequests, between between clients and + servers, or between peers. It might roughly correspond to + the number of rows returned by a 'select' statement. It is + not intended to capture disk i/o described in DiskReads." + ::= { rdbmsSrvInfoEntry 12 } + + rdbmsSrvInfoHighwaterInboundAssociations OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The greatest number of inbound associations that have been + simultaneously open to this server since startup." + ::= { rdbmsSrvInfoEntry 13 } + + rdbmsSrvInfoMaxInboundAssociations OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The greatest number of inbound associations that can be + simultaneously open with this server. If there is no limit, + then the value should be zero. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsSrvInfoEntry 14 } + + ---------------------------------------------------------------- + + rdbmsSrvParamTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsSrvParamEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of configuration parameters for a server. Entries + should be populated according to the following guidelines: + (1) The value should be specified through administrative + (human) intervention. + (2) It should be configured on a per-server or a more global + basis, with duplicate entries for each server sharing + use of the parameter. + (3) One of the following is true: + (a) The parameter has a non-numeric value; + (b) The current value is numeric, but it only changes due + to human intervention; + + (c) The current value is numeric and dynamic, but the + RDBMS does not track access/allocation failures + related to the parameter; + (d) The current value is numeric and dynamic, the + RDBMS tracks changes in access/allocation failures + related to the parameter, but the failure has no + significant impact on RDBMS performance or + availability. + (e) The current value is numeric and dynamic, the + RDBMS tracks changes in access/allocation failures + related to the parameter, the failure has + significant impact on RDBMS performance or + availability, and is shown in the + rdbmsSrvLimitedResource table." + ::= { rdbmsObjects 7 } + + rdbmsSrvParamEntry OBJECT-TYPE + SYNTAX RdbmsSrvParamEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry for a single configuration parameter for a server. + Parameters with single values have a subindex value of one. + If the parameter is naturally considered to contain a + variable number of members of a class, e.g. members of the + DBA user group, or tracepoints active in the server, then it + must be presented as a set of rows. If, on the other hand, + the parameter represents a set of choices from a class, + e.g. the permissions on a file or the options chosen out of + the set of all options allowed, AND is guaranteed to always + fit in the 255 character length of a DisplayString, then it + may be presented as a comma separated list with a subindex + value of one. Zero may not be used as a subindex value. + + Entries for a server must be present if the value of the + corresponding applOperStatus object is up(1). If an instance + of applOperStatus is not up(1), then attempts to access + corresponding instances in this table may result in either + noSuchName (SNMPv1) or noSuchInstance (SNMPv2) being returned + by the agent." + INDEX { applIndex, rdbmsSrvParamName, rdbmsSrvParamSubIndex } + ::= { rdbmsSrvParamTable 1 } + + RdbmsSrvParamEntry ::= + SEQUENCE { + rdbmsSrvParamName DisplayString, + rdbmsSrvParamSubIndex INTEGER, + rdbmsSrvParamID AutonomousType, + + rdbmsSrvParamCurrValue DisplayString, + rdbmsSrvParamComment DisplayString + } + + rdbmsSrvParamName OBJECT-TYPE + SYNTAX DisplayString (SIZE (1..64)) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The name of a configuration parameter for a server. This + name is product-specific. The length is limited to 64 + characters to constrain the number of sub-identifiers needed + for instance identification (and to minimize network + traffic)." + ::= { rdbmsSrvParamEntry 1 } + + rdbmsSrvParamSubIndex OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The subindex value for this parameter. If the parameter is + naturally considered to contain a variable number of members + of a class, e.g. members of the DBA user group, or files + which are part of the database, then it must be presented as + a set of rows. If, on the other hand, the parameter + represents a set of choices from a class, e.g. the + permissions on a file or the options chosen out of the set of + all options allowed, AND is guaranteed to always fit in the + 255 character length of a DisplayString, then it may be + presented as a comma separated list with a subindex value of + one. Zero may not be used as a value." + ::= { rdbmsSrvParamEntry 2 } + + rdbmsSrvParamID OBJECT-TYPE + SYNTAX AutonomousType + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The ID of the parameter which may be described in some + other MIB. If there is no ID for this rdbmsSrvParamName, + attempts to access this object will return noSuchName + (SNMPv1) or noSuchInstance (SNMPv2)." + ::= { rdbmsSrvParamEntry 3 } + + rdbmsSrvParamCurrValue OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + + STATUS current + DESCRIPTION + "The value for a configuration parameter now in effect, the + actual setting for the server. While there may multiple + values in the temporal domain of interest (for instance, the + value to take effect at the next restart), this is the + current setting. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsSrvParamEntry 4 } + + rdbmsSrvParamComment OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Annotation which describes the purpose of a configuration + parameter or the reason for a particular parameter's + setting. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsSrvParamEntry 5 } + + ---------------------------------------------------------------- + + rdbmsSrvLimitedResourceTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsSrvLimitedResourceEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The table of limited resources relevant to a server." + ::= { rdbmsObjects 8 } + + rdbmsSrvLimitedResourceEntry OBJECT-TYPE + SYNTAX RdbmsSrvLimitedResourceEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry for a single limited resource kept by the server. + A limited resource has maximum use determined by a parameter + that might or might not changeable at run time, or visible in + the rbmsSrvParamTable. Examples would be the number of + available locks, or number of concurrent executions allowed + in a server. Arrays of resources are supported through an + + integer subindex, which should have the value of one for + single-instance names. + + Limited resources that are shared across servers or databases + are best duplicated in this table across + all servers accessing the resource." + INDEX { applIndex, rdbmsSrvLimitedResourceName } + ::= { rdbmsSrvLimitedResourceTable 1 } + + RdbmsSrvLimitedResourceEntry ::= + SEQUENCE { + rdbmsSrvLimitedResourceName DisplayString, + rdbmsSrvLimitedResourceID AutonomousType, + rdbmsSrvLimitedResourceLimit INTEGER, + rdbmsSrvLimitedResourceCurrent INTEGER, + rdbmsSrvLimitedResourceHighwater INTEGER, + rdbmsSrvLimitedResourceFailures Counter32, + rdbmsSrvLimitedResourceDescription DisplayString + } + + rdbmsSrvLimitedResourceName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The name of the resource, for instance 'threads' or + 'semaphores', or 'buffer pages'" + ::= { rdbmsSrvLimitedResourceEntry 1 } + + rdbmsSrvLimitedResourceID OBJECT-TYPE + SYNTAX AutonomousType + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The ID of the resource which may be described in some other + MIB. If there is no ID for this rdbmsSrvLimitedResourceName, + attempts to access this object will return noSuchName + (SNMPv1) or noSuchInstance (SNMPv2)." + ::= { rdbmsSrvLimitedResourceEntry 2 } + + rdbmsSrvLimitedResourceLimit OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-write + STATUS current + + DESCRIPTION + "The maximum value the resource use may attain. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsSrvLimitedResourceEntry 3 } + + rdbmsSrvLimitedResourceCurrent OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The current value for the resource." + ::= { rdbmsSrvLimitedResourceEntry 4 } + + rdbmsSrvLimitedResourceHighwater OBJECT-TYPE + SYNTAX INTEGER (1..2147483647) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The maximum value of the resource seen since applUpTime + was reset." + ::= { rdbmsSrvLimitedResourceEntry 5 } + + rdbmsSrvLimitedResourceFailures OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of times the system wanted to exceed the limit of + the resource since applUpTime was reset." + ::= { rdbmsSrvLimitedResourceEntry 6 } + + rdbmsSrvLimitedResourceDescription OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "A description of the resource and the meaning of the integer + units used for Limit, Current, and Highwater. + + Note that a compliant agent does not need to + allow write access to this object." + + ::= { rdbmsSrvLimitedResourceEntry 7 } + + ---------------------------------------------------------------- + + rdbmsRelTable OBJECT-TYPE + SYNTAX SEQUENCE OF RdbmsRelEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "A table relating databases and servers present on a host." + ::= { rdbmsObjects 9 } + + rdbmsRelEntry OBJECT-TYPE + SYNTAX RdbmsRelEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry relating a single database server to a single + database to which it may provide access. The table is + indexed first by the index of rdbmsDbTable, and then + rdbmsSrvTable, so that all servers capable of providing + access to a given database may be found by SNMP traversal + operations (get-next and get-bulk). The makeup of this table + depends on the product's architecture, e.g. if it is one + server - many databases, then each server will appear n + times, where n is the number of databases it may access, and + each database will appear once. If the architecture is one + database - many servers, then each server will appear once + and each database will appear n times, where n is the number + of servers that may be accessing it." + INDEX { rdbmsDbIndex, applIndex } + ::= { rdbmsRelTable 1 } + + RdbmsRelEntry ::= + SEQUENCE { + rdbmsRelState INTEGER, + rdbmsRelActiveTime DateAndTime + } + + rdbmsRelState OBJECT-TYPE + SYNTAX INTEGER{ + other(1), + active(2), + available(3), + restricted(4), + unavailable(5) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + + "The state of this server's access to this database. + Active(2) means the server is actively using the database. + Available(3) means the server could use the database if + necessary. Restricted(4) means the database is in some + administratively determined state of less-than-complete + availability. Unavailable(5) means the database is not + available through this server. Other(1) means the + database/server is in some other condition, possibly + described in the vendor private MIB." + + ::= { rdbmsRelEntry 1 } + + rdbmsRelActiveTime OBJECT-TYPE + SYNTAX DateAndTime + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The time the database was made active by the server. If an + instance of rdbmsRelState is not active(1), then attempts to + access the corresponding instance of this object may result + in either noSuchName (SNMPv1) or noSuchInstance (SNMPv2) + being returned by the agent." + ::= { rdbmsRelEntry 2 } + + ---------------------------------------------------------------- + + -- Well known resources for which limits, high water marks, + -- access or allocation failures, and current levels of use + -- are possibly available in either the rdbmsDbLimitedResources + -- or the rdbmsSrvLimitedResources tables. + + rdbmsWellKnownLimitedResources OBJECT IDENTIFIER + ::= { rdbmsObjects 10 } + + rdbmsLogSpace OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Storage allocated for redo and undo logs." + ::= { rdbmsWellKnownLimitedResources 1} + + ---------------------------------------------------------------- + + rdbmsTraps OBJECT IDENTIFIER ::= { rdbmsMIB 2 } + + rdbmsStateChange NOTIFICATION-TYPE + OBJECTS { rdbmsRelState } + STATUS current + DESCRIPTION + + "An rdbmsStateChange trap signifies that one of the database + server/databases managed by this agent has changed its + rdbmsRelState in a way that makes it less accessible for use. + For these purposes, both active(2) and available(3) are + considered fully accessible. The state sent with the trap is + the new, less accessible state." + ::= { rdbmsTraps 1 } + + rdbmsOutOfSpace NOTIFICATION-TYPE + OBJECTS { rdbmsSrvInfoDiskOutOfSpaces } + STATUS current + DESCRIPTION + "An rdbmsOutOfSpace trap signifies that one of the database + servers managed by this agent has been unable to allocate + space for one of the databases managed by this agent. Care + should be taken to avoid flooding the network with these + traps." + ::= { rdbmsTraps 2 } + + ---------------------------------------------------------------- + + -- compliance information + + rdbmsConformance OBJECT IDENTIFIER ::= { rdbmsMIB 3 } + rdbmsCompliances OBJECT IDENTIFIER ::= { rdbmsConformance 1 } + rdbmsGroups OBJECT IDENTIFIER ::= { rdbmsConformance 2 } + + -- compliance statements + + rdbmsCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for SNMP entities which + implement the RDBMS MIB" + MODULE HOST-RESOURCES-MIB + MANDATORY-GROUPS { hrSystem } + MODULE APPLICATION-MIB + MANDATORY-GROUPS { applGroup } + MODULE RDBMS-MIB + MANDATORY-GROUPS { rdbmsGroup } + + GROUP rdbmsGroup + DESCRIPTION + "The rdbmsGroup is mandatory, but no write access + to objects is required for compliance." + OBJECT rdbmsDbContact + MIN-ACCESS read-only + DESCRIPTION + + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsDbParamCurrValue + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsDbParamComment + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsDbLimitedResourceLimit + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsDbLimitedResourceDescription + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsSrvContact + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsSrvInfoMaxInboundAssociations + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsSrvParamCurrValue + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsSrvParamComment + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsSrvLimitedResourceLimit + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + OBJECT rdbmsSrvLimitedResourceDescription + + MIN-ACCESS read-only + DESCRIPTION + "A compliant system need not allow write-access to this + object." + + ::= { rdbmsCompliances 1 } + + -- units of conformance + + -- rdbmsStateChange and rdbmsOutOfSpace traps are omitted + -- intentionally. They are not required or part of any + -- conformance group. + + rdbmsGroup OBJECT-GROUP + OBJECTS { + rdbmsDbPrivateMibOID, rdbmsDbVendorName, + rdbmsDbName, rdbmsDbContact, + + rdbmsDbInfoProductName, rdbmsDbInfoVersion, + rdbmsDbInfoSizeUnits, rdbmsDbInfoSizeAllocated, + rdbmsDbInfoSizeUsed, rdbmsDbInfoLastBackup, + + rdbmsDbParamCurrValue, rdbmsDbParamComment, + + rdbmsDbLimitedResourceLimit, + rdbmsDbLimitedResourceCurrent, + rdbmsDbLimitedResourceHighwater, + rdbmsDbLimitedResourceFailures, + rdbmsDbLimitedResourceDescription, + + rdbmsSrvPrivateMibOID, rdbmsSrvVendorName, + rdbmsSrvProductName, rdbmsSrvContact, + + rdbmsSrvInfoStartupTime, + rdbmsSrvInfoFinishedTransactions, + rdbmsSrvInfoDiskReads, rdbmsSrvInfoDiskWrites, + rdbmsSrvInfoLogicalReads, rdbmsSrvInfoLogicalWrites, + rdbmsSrvInfoPageReads, rdbmsSrvInfoPageWrites, + rdbmsSrvInfoHandledRequests, + rdbmsSrvInfoRequestRecvs, rdbmsSrvInfoRequestSends, + rdbmsSrvInfoHighwaterInboundAssociations, + rdbmsSrvInfoMaxInboundAssociations, + + rdbmsSrvParamCurrValue, rdbmsSrvParamComment, + + rdbmsSrvLimitedResourceLimit, + rdbmsSrvLimitedResourceCurrent, + rdbmsSrvLimitedResourceHighwater, + + rdbmsSrvLimitedResourceFailures, + rdbmsSrvLimitedResourceDescription, + + rdbmsRelState, rdbmsRelActiveTime } + STATUS current + DESCRIPTION + "A collection of objects providing basic instrumentation of an + RDBMS entity." + ::= { rdbmsGroups 1 } + + ---------------------------------------------------------------- + + END diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/README b/RDBMS-MIB_src/rdbmsDbInfoTable/README new file mode 100644 index 0000000..c4a8778 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/README @@ -0,0 +1 @@ +For PostgreSQL version 8.0.x the rdbmsDbInfoSize* fields are returned as 0, because that information is unavailable. diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.c b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.c new file mode 100644 index 0000000..7bc63ef --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.c @@ -0,0 +1,123 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable.c,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbInfoTable.h" +#include "rdbmsDbInfoTable_interface.h" + +oid rdbmsDbInfoTable_oid[] = { RDBMSDBINFOTABLE_OID }; +int rdbmsDbInfoTable_oid_size = OID_LENGTH(rdbmsDbInfoTable_oid); + +void initialize_table_rdbmsDbInfoTable(void); + + +/** + * Initializes the rdbmsDbInfoTable module + */ +void +init_rdbmsDbInfoTable(void) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:init_rdbmsDbInfoTable","called\n")); + + /* + * TODO:300:o: Perform rdbmsDbInfoTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("rdbmsDbInfoTable")) + initialize_table_rdbmsDbInfoTable(); + +} /* init_rdbmsDbInfoTable */ + +/** + * Initialize the table rdbmsDbInfoTable + * (Define its contents and how it's structured) + */ +void +initialize_table_rdbmsDbInfoTable(void) +{ + rdbmsDbInfoTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:initialize_table_rdbmsDbInfoTable","called\n")); + + /* + * TODO:301:o: Perform rdbmsDbInfoTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize rdbmsDbInfoTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("rdbmsDbInfoTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _rdbmsDbInfoTable_initialize_interface(user_context, flags); +} /* initialize_table_rdbmsDbInfoTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +rdbmsDbInfoTable_pre_request(rdbmsDbInfoTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform rdbmsDbInfoTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbInfoTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +rdbmsDbInfoTable_post_request(rdbmsDbInfoTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_post_request","called\n")); + + /* + * TODO:511:o: Perform rdbmsDbInfoTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbInfoTable_post_request */ + + +/** @{ */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.h b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.h new file mode 100644 index 0000000..321aa86 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable.h @@ -0,0 +1,223 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable.h,v 1.5 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBINFOTABLE_H +#define RDBMSDBINFOTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(RDBMS-MIB/rdbmsDbInfoTable/rdbmsDbInfoTable_interface); +config_require(RDBMS-MIB/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access); +config_require(RDBMS-MIB/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "rdbmsDbInfoTable_oids.h" + +/* enum definions */ +#include "rdbmsDbInfoTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_rdbmsDbInfoTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbInfoTable is subid 2 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.2, length: 9 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review rdbmsDbInfoTable registration context. + */ +typedef netsnmp_data_list * rdbmsDbInfoTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review rdbmsDbInfoTable data context structure. + * This structure is used to represent the data for rdbmsDbInfoTable. + */ +/* + * This structure contains storage for all the columns defined in the + * rdbmsDbInfoTable. + */ +typedef struct rdbmsDbInfoTable_data_s { + + /* + * rdbmsDbInfoProductName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char rdbmsDbInfoProductName[255]; +size_t rdbmsDbInfoProductName_len; /* # of char elements, not bytes */ + + /* + * rdbmsDbInfoVersion(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char rdbmsDbInfoVersion[255]; +size_t rdbmsDbInfoVersion_len; /* # of char elements, not bytes */ + + /* + * rdbmsDbInfoSizeUnits(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long rdbmsDbInfoSizeUnits; + + /* + * rdbmsDbInfoSizeAllocated(4)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/R/d/h + */ + long rdbmsDbInfoSizeAllocated; + + /* + * rdbmsDbInfoSizeUsed(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + long rdbmsDbInfoSizeUsed; + + /* + * rdbmsDbInfoLastBackup(6)/DateAndTime/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ +/* char rdbmsDbInfoLastBackup[255]; +size_t rdbmsDbInfoLastBackup_len; *//* # of char elements, not bytes */ + int lastBackupYear; + int lastBackupMonth; + int lastBackupDay; + int lastBackupHour; + int lastBackupMinutes; + int lastBackupSeconds; + /* the terminology here was stolen from net-snmp */ + int lastBackupDeciSeconds; + + int utc_offset_direction; + int utc_offset_hours; + int utc_offset_minutes; +} rdbmsDbInfoTable_data; + + +/* + * TODO:120:r: |-> Review rdbmsDbInfoTable mib index. + * This structure is used to represent the index for rdbmsDbInfoTable. + */ +typedef struct rdbmsDbInfoTable_mib_index_s { + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + +} rdbmsDbInfoTable_mib_index; + + /* + * TODO:121:r: | |-> Review rdbmsDbInfoTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. +*/ +#define MAX_rdbmsDbInfoTable_IDX_LEN 1 + + +/* ********************************************************************* + * TODO:130:o: |-> Review rdbmsDbInfoTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * rdbmsDbInfoTable_rowreq_ctx pointer. + */ +typedef struct rdbmsDbInfoTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_rdbmsDbInfoTable_IDX_LEN]; + + rdbmsDbInfoTable_mib_index tbl_idx; + + rdbmsDbInfoTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + rdbmsDbInfoTable_registration_ptr rdbmsDbInfoTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to rdbmsDbInfoTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *rdbmsDbInfoTable_data_list; + +} rdbmsDbInfoTable_rowreq_ctx; + +typedef struct rdbmsDbInfoTable_ref_rowreq_ctx_s { + rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx; +} rdbmsDbInfoTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int rdbmsDbInfoTable_pre_request(rdbmsDbInfoTable_registration_ptr user_context); + int rdbmsDbInfoTable_post_request(rdbmsDbInfoTable_registration_ptr user_context); + + +extern oid rdbmsDbInfoTable_oid[]; +extern int rdbmsDbInfoTable_oid_size; + + +#include "rdbmsDbInfoTable_interface.h" +#include "rdbmsDbInfoTable_data_access.h" +#include "rdbmsDbInfoTable_data_get.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBINFOTABLE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.c b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.c new file mode 100644 index 0000000..00755f1 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.c @@ -0,0 +1,418 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_data_access.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_data_access.c,v 1.9 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbInfoTable.h" +#include "rdbmsDbInfoTable_data_access.h" + +const char *rdbmsDbInfoProductName = { "PostgreSQL" }; + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbInfoTable is subid 2 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.2, length: 9 +*/ + +/** + * initialization for rdbmsDbInfoTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param rdbmsDbInfoTable_reg + * Pointer to rdbmsDbInfoTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +rdbmsDbInfoTable_init_data(rdbmsDbInfoTable_registration_ptr rdbmsDbInfoTable_reg) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_init_data","called\n")); + + /* + * TODO:303:o: Initialize rdbmsDbInfoTable data. + */ + + return MFD_SUCCESS; +} /* rdbmsDbInfoTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +rdbmsDbInfoTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to rdbmsDbInfoTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up rdbmsDbInfoTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = RDBMSDBINFOTABLE_CACHE_TIMEOUT; /* seconds */ +} /* rdbmsDbInfoTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement rdbmsDbInfoTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * rdbmsDbInfoTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +rdbmsDbInfoTable_cache_load(netsnmp_container *container) +{ + rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + int i, resultCount, errorCode = MFD_SUCCESS, tmpInt; + PGresult *pg_db_qry, *pgsnmpd_tbl_qry; + char *db_oid, *tmpString; + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_cache_load","called\n")); + + if (PQstatus(dbconn) == CONNECTION_OK) + if (PQserverVersion(dbconn) < 80100) + pg_db_qry = PQexec(dbconn, "SELECT oid, version(), 0 FROM pg_database"); + else + pg_db_qry = PQexec(dbconn, "SELECT oid, version(), pg_database_size(datname) FROM pg_database"); + else { + snmp_log(LOG_ERR, "Can't get connected to the database"); + return MFD_RESOURCE_UNAVAILABLE; + } + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database"); + PQclear(pg_db_qry); + /* It's probably an error if I didn't find *any* information */ + return MFD_RESOURCE_UNAVAILABLE; + } + + resultCount = PQntuples(pg_db_qry); + + + /* + * TODO:351:M: |-> Load/update data in the rdbmsDbInfoTable container. + * loop over your rdbmsDbInfoTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new rdbmsDbInfoTable rowreq context. + */ + rowreq_ctx = rdbmsDbInfoTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + db_oid = PQgetvalue(pg_db_qry, i, 0); + if(MFD_SUCCESS != rdbmsDbInfoTable_indexes_set(rowreq_ctx + , atol(db_oid) + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "rdbmsDbInfoTable cache.\n"); + rdbmsDbInfoTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + + /* + * TODO:352:r: | |-> populate rdbmsDbInfoTable data context. + * Populate data context here. (optionally, delay until row prep) + */ + + rowreq_ctx->data.rdbmsDbInfoProductName_len = 255; + rowreq_ctx->data.rdbmsDbInfoVersion_len = 255; + + pgsnmpd_tbl_qry = NULL; + tmpInt = sizeof("SELECT EXTRACT(YEAR FROM last_backup), EXTRACT(MONTH FROM last_backup), EXTRACT(DAY FROM last_backup), EXTRACT(HOUR FROM last_backup), EXTRACT(MINUTE FROM last_backup), EXTRACT(SECOND FROM last_backup), EXTRACT(MILLISECOND FROM last_backup), EXTRACT(TIMEZONE_HOUR FROM last_backup), EXTRACT(TIMEZONE_MINUTE FROM last_backup) FROM pgsnmpd_rdbmsDbTable WHERE database_oid = %s") + sizeof(*db_oid); + tmpString = calloc(tmpInt, sizeof(char*)); + if (tmpString == NULL) snmp_log(LOG_ERR, "Couldn't allocate memory to query pgsnmpd-specific database table\n"); + else { + snmp_log(LOG_INFO, "Gathering rdbmsDbTable information from pgsnmpd_rdbmsDbTable\n"); + snprintf(tmpString, sizeof(char*) * tmpInt, "SELECT EXTRACT(YEAR FROM last_backup), EXTRACT(MONTH FROM last_backup), EXTRACT(DAY FROM last_backup), EXTRACT(HOUR FROM last_backup), EXTRACT(MINUTE FROM last_backup), EXTRACT(SECOND FROM last_backup), EXTRACT(MILLISECOND FROM last_backup), EXTRACT(TIMEZONE_HOUR FROM last_backup), EXTRACT(TIMEZONE_MINUTE FROM last_backup) FROM pgsnmpd_rdbmsDbTable WHERE database_oid = %s", db_oid); + pgsnmpd_tbl_qry = PQexec(dbconn, tmpString); + /* Ignore errors so that pgsnmpd will run without this table being available. Note that this error is INFO level, + * instead of something higher, because we're designed to work without this table */ + + if (PQresultStatus(pgsnmpd_tbl_qry) == PGRES_TUPLES_OK && PQntuples(pgsnmpd_tbl_qry) > 0) { + rowreq_ctx->data.lastBackupYear = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 0)); + rowreq_ctx->data.lastBackupMonth = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 1)); + rowreq_ctx->data.lastBackupDay = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 2)); + rowreq_ctx->data.lastBackupHour = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 3)); + rowreq_ctx->data.lastBackupMinutes = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 4)); + rowreq_ctx->data.lastBackupSeconds = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 5)); + rowreq_ctx->data.lastBackupDeciSeconds = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 6)); + rowreq_ctx->data.utc_offset_hours = abs(atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 7))); + rowreq_ctx->data.utc_offset_minutes = atoi(PQgetvalue(pgsnmpd_tbl_qry, 0, 8)); + tmpInt = rowreq_ctx->data.utc_offset_hours * 60 + rowreq_ctx->data.utc_offset_minutes; + if (tmpInt == 0) rowreq_ctx->data.utc_offset_direction = 0; + else + rowreq_ctx->data.utc_offset_direction = (tmpInt > 0 ? 1 : -1); + } + else snmp_log(LOG_INFO, "Unable to find relevant data in pgsnmpd_rdbmsDbTable\n"); + free(tmpString); + } + + /* + * TRANSIENT or semi-TRANSIENT data: + * copy data or save any info needed to do it in row_prep. + */ + /* + * setup/save data for rdbmsDbInfoProductName + * rdbmsDbInfoProductName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + /* + * TODO:246:r: |-> Define rdbmsDbInfoProductName mapping. + * Map values between raw/native values and MIB values + * + * if(MFD_SUCCESS != + * rdbmsDbInfoProductName_map(&rowreq_ctx->data.rdbmsDbInfoProductName, &rowreq_ctx->data.rdbmsDbInfoProductName_len, + * rdbmsDbInfoProductName, rdbmsDbInfoProductName_len, 0)) { + * return MFD_ERROR; + * } + */ + /* + * make sure there is enough space for rdbmsDbInfoProductName data + */ + if ((NULL == rowreq_ctx->data.rdbmsDbInfoProductName) || + (rowreq_ctx->data.rdbmsDbInfoProductName_len < (strlen(rdbmsDbInfoProductName) * sizeof(rowreq_ctx->data.rdbmsDbInfoProductName[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + errorCode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbInfoProductName_len = strlen(rdbmsDbInfoProductName) * sizeof(rowreq_ctx->data.rdbmsDbInfoProductName[0]); + memcpy( rowreq_ctx->data.rdbmsDbInfoProductName, rdbmsDbInfoProductName, rowreq_ctx->data.rdbmsDbInfoProductName_len ); + + /* + * setup/save data for rdbmsDbInfoVersion + * rdbmsDbInfoVersion(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + /* + * TODO:246:r: |-> Define rdbmsDbInfoVersion mapping. + * Map values between raw/native values and MIB values + * + * if(MFD_SUCCESS != + * rdbmsDbInfoVersion_map(&rowreq_ctx->data.rdbmsDbInfoVersion, &rowreq_ctx->data.rdbmsDbInfoVersion_len, + * rdbmsDbInfoVersion, rdbmsDbInfoVersion_len, 0)) { + * return MFD_ERROR; + * } + */ + /* + * make sure there is enough space for rdbmsDbInfoVersion data + */ + tmpString = PQgetvalue(pg_db_qry, i, 1); + tmpInt = strlen(tmpString); + if ((NULL == rowreq_ctx->data.rdbmsDbInfoVersion) || + (rowreq_ctx->data.rdbmsDbInfoVersion_len < (tmpInt * sizeof(rowreq_ctx->data.rdbmsDbInfoVersion[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + errorCode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbInfoVersion_len = tmpInt * sizeof(rowreq_ctx->data.rdbmsDbInfoVersion[0]); + memcpy( rowreq_ctx->data.rdbmsDbInfoVersion, tmpString, rowreq_ctx->data.rdbmsDbInfoVersion_len ); + + /* + * setup/save data for rdbmsDbInfoSizeUnits + * rdbmsDbInfoSizeUnits(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + /* + * TODO:246:r: |-> Define rdbmsDbInfoSizeUnits mapping. + * Map values between raw/native values and MIB values + * + * enums usually need mapping. + */ + if(MFD_SUCCESS != + rdbmsDbInfoSizeUnits_map(&rowreq_ctx->data.rdbmsDbInfoSizeUnits, INTERNAL_RDBMSDBINFOSIZEUNITS_BYTES)) { + errorCode = MFD_ERROR; + break; + } + + /* + * setup/save data for rdbmsDbInfoSizeAllocated + * rdbmsDbInfoSizeAllocated(4)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/R/d/h + */ + /* + * TODO:246:r: |-> Define rdbmsDbInfoSizeAllocated mapping. + * Map values between raw/native values and MIB values + * + * Integer based value can usually just do a direct copy. + */ + rowreq_ctx->data.rdbmsDbInfoSizeAllocated = strtoul(PQgetvalue(pg_db_qry, i, 2), NULL, 10); + + /* + * setup/save data for rdbmsDbInfoSizeUsed + * rdbmsDbInfoSizeUsed(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + /* + * TODO:246:r: |-> Define rdbmsDbInfoSizeUsed mapping. + * Map values between raw/native values and MIB values + * + * Integer based value can usually just do a direct copy. + */ + rowreq_ctx->data.rdbmsDbInfoSizeUsed = strtoul(PQgetvalue(pg_db_qry, i, 2), NULL, 10); + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + PQclear(pgsnmpd_tbl_qry); + } + + DEBUGMSGT(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_cache_load", + "inserted %d records\n", count)); + + PQclear(pg_db_qry); + return errorCode; +} /* rdbmsDbInfoTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +rdbmsDbInfoTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_cache_free","called\n")); + + /* + * TODO:380:M: Free rdbmsDbInfoTable cache. + */ +} /* rdbmsDbInfoTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +rdbmsDbInfoTable_row_prep( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* rdbmsDbInfoTable_row_prep */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.h b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.h new file mode 100644 index 0000000..5931bcf --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_access.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_data_access.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_data_access.h,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBINFOTABLE_DATA_ACCESS_H +#define RDBMSDBINFOTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbInfoTable is subid 2 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.2, length: 9 +*/ + + + int rdbmsDbInfoTable_init_data(rdbmsDbInfoTable_registration_ptr rdbmsDbInfoTable_reg); + + +/* + * TODO:180:o: Review rdbmsDbInfoTable cache timeout. + * The number of seconds before the cache times out + */ +#define RDBMSDBINFOTABLE_CACHE_TIMEOUT 60 + +void rdbmsDbInfoTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int rdbmsDbInfoTable_cache_load(netsnmp_container *container); +void rdbmsDbInfoTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int rdbmsDbInfoTable_row_prep( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBINFOTABLE_DATA_ACCESS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.c b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.c new file mode 100644 index 0000000..5da7220 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.c @@ -0,0 +1,847 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_data_get.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_data_get.c,v 1.5 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbInfoTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement rdbmsDbInfoTable get routines. + * TODO:240:M: Implement rdbmsDbInfoTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbInfoTable is subid 2 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.2, length: 9 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement rdbmsDbInfoTable data context functions. + */ + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +rdbmsDbInfoTable_indexes_set_tbl_idx(rdbmsDbInfoTable_mib_index *tbl_idx, long rdbmsDbIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_indexes_set_tbl_idx","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + + return MFD_SUCCESS; +} /* rdbmsDbInfoTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +rdbmsDbInfoTable_indexes_set(rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_indexes_set","called\n")); + + if(MFD_SUCCESS != rdbmsDbInfoTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , rdbmsDbIndex_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != rdbmsDbInfoTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsDbInfoTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbInfoEntry.rdbmsDbInfoProductName + * rdbmsDbInfoProductName is subid 1 of rdbmsDbInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.2.1.1 + * Description: +The textual product name of the server that created or last + restructured this database. The format is product specific. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbInfoProductName.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbInfoProductName_map(char **mib_rdbmsDbInfoProductName_val_ptr_ptr, size_t *mib_rdbmsDbInfoProductName_val_ptr_len_ptr, char *raw_rdbmsDbInfoProductName_val_ptr, size_t raw_rdbmsDbInfoProductName_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbInfoProductName_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbInfoProductName_val_ptr_ptr) && (NULL != mib_rdbmsDbInfoProductName_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoProductName_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbInfoProductName non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbInfoProductName_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbInfoProductName_val_ptr_ptr) || (*mib_rdbmsDbInfoProductName_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbInfoProductName_val_ptr_ptr = realloc( *mib_rdbmsDbInfoProductName_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbInfoProductName_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbInfoProductName_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbInfoProductName_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbInfoProductName_val_ptr_ptr, raw_rdbmsDbInfoProductName_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbInfoProductName_map */ + +/** + * Extract the current value of the rdbmsDbInfoProductName data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbInfoProductName_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbInfoProductName_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbInfoProductName. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbInfoProductName_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbInfoProductName_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbInfoProductName_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbInfoProductName_val_ptr_ptr, size_t *rdbmsDbInfoProductName_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbInfoProductName_val_ptr_ptr) && (NULL != *rdbmsDbInfoProductName_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbInfoProductName_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoProductName_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbInfoProductName data. + * set (* rdbmsDbInfoProductName_val_ptr_ptr ) and (* rdbmsDbInfoProductName_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbInfoProductName data + */ + if ((NULL == (* rdbmsDbInfoProductName_val_ptr_ptr )) || + ((* rdbmsDbInfoProductName_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbInfoProductName_len * sizeof((* rdbmsDbInfoProductName_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbInfoProductName data + */ + (* rdbmsDbInfoProductName_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbInfoProductName_len * sizeof((* rdbmsDbInfoProductName_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbInfoProductName_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbInfoProductName_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbInfoProductName_len * sizeof((* rdbmsDbInfoProductName_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbInfoProductName_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbInfoProductName, (* rdbmsDbInfoProductName_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbInfoProductName_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbInfoEntry.rdbmsDbInfoVersion + * rdbmsDbInfoVersion is subid 2 of rdbmsDbInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.2.1.2 + * Description: +The version number of the server that created or last + restructured this database. The format is product specific. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbInfoVersion.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbInfoVersion_map(char **mib_rdbmsDbInfoVersion_val_ptr_ptr, size_t *mib_rdbmsDbInfoVersion_val_ptr_len_ptr, char *raw_rdbmsDbInfoVersion_val_ptr, size_t raw_rdbmsDbInfoVersion_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbInfoVersion_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbInfoVersion_val_ptr_ptr) && (NULL != mib_rdbmsDbInfoVersion_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoVersion_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbInfoVersion non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbInfoVersion_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbInfoVersion_val_ptr_ptr) || (*mib_rdbmsDbInfoVersion_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbInfoVersion_val_ptr_ptr = realloc( *mib_rdbmsDbInfoVersion_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbInfoVersion_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbInfoVersion_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbInfoVersion_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbInfoVersion_val_ptr_ptr, raw_rdbmsDbInfoVersion_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbInfoVersion_map */ + +/** + * Extract the current value of the rdbmsDbInfoVersion data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbInfoVersion_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbInfoVersion_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbInfoVersion. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbInfoVersion_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbInfoVersion_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbInfoVersion_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbInfoVersion_val_ptr_ptr, size_t *rdbmsDbInfoVersion_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbInfoVersion_val_ptr_ptr) && (NULL != *rdbmsDbInfoVersion_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbInfoVersion_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoVersion_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbInfoVersion data. + * set (* rdbmsDbInfoVersion_val_ptr_ptr ) and (* rdbmsDbInfoVersion_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbInfoVersion data + */ + if ((NULL == (* rdbmsDbInfoVersion_val_ptr_ptr )) || + ((* rdbmsDbInfoVersion_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbInfoVersion_len * sizeof((* rdbmsDbInfoVersion_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbInfoVersion data + */ + (* rdbmsDbInfoVersion_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbInfoVersion_len * sizeof((* rdbmsDbInfoVersion_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbInfoVersion_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbInfoVersion_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbInfoVersion_len * sizeof((* rdbmsDbInfoVersion_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbInfoVersion_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbInfoVersion, (* rdbmsDbInfoVersion_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbInfoVersion_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbInfoEntry.rdbmsDbInfoSizeUnits + * rdbmsDbInfoSizeUnits is subid 3 of rdbmsDbInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.2.1.3 + * Description: +Identification of the units used to measure the size of this + database in rdbmsDbInfoSizeAllocated and rdbmsDbInfoSizeUsed. + bytes(1) indicates individual bytes, kbytes(2) indicates + units of kilobytes, mbytes(3) indicates units of megabytes, + gbytes(4) indicates units of gigabytes, and tbytes(5) + indicates units of terabytes. All are binary multiples -- 1K + = 1024. If writable, changes here are reflected in the get + values of the associated objects. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 4/8. Values: bytes(1), kbytes(2), mbytes(3), gbytes(4), tbytes(5) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbInfoSizeUnits.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbInfoSizeUnits_map(u_long *mib_rdbmsDbInfoSizeUnits_val_ptr, u_long raw_rdbmsDbInfoSizeUnits_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbInfoSizeUnits_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoSizeUnits_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbInfoSizeUnits enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_rdbmsDbInfoSizeUnits_val) { + case INTERNAL_RDBMSDBINFOSIZEUNITS_BYTES: + *mib_rdbmsDbInfoSizeUnits_val_ptr = RDBMSDBINFOSIZEUNITS_BYTES; + break; + + case INTERNAL_RDBMSDBINFOSIZEUNITS_KBYTES: + *mib_rdbmsDbInfoSizeUnits_val_ptr = RDBMSDBINFOSIZEUNITS_KBYTES; + break; + + case INTERNAL_RDBMSDBINFOSIZEUNITS_MBYTES: + *mib_rdbmsDbInfoSizeUnits_val_ptr = RDBMSDBINFOSIZEUNITS_MBYTES; + break; + + case INTERNAL_RDBMSDBINFOSIZEUNITS_GBYTES: + *mib_rdbmsDbInfoSizeUnits_val_ptr = RDBMSDBINFOSIZEUNITS_GBYTES; + break; + + case INTERNAL_RDBMSDBINFOSIZEUNITS_TBYTES: + *mib_rdbmsDbInfoSizeUnits_val_ptr = RDBMSDBINFOSIZEUNITS_TBYTES; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for rdbmsDbInfoSizeUnits\n", raw_rdbmsDbInfoSizeUnits_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsDbInfoSizeUnits_map */ + +/** + * Extract the current value of the rdbmsDbInfoSizeUnits data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbInfoSizeUnits_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbInfoSizeUnits_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsDbInfoSizeUnits_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbInfoSizeUnits_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoSizeUnits_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbInfoSizeUnits data. + * set (* rdbmsDbInfoSizeUnits_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbInfoSizeUnits_val_ptr ) = rowreq_ctx->data.rdbmsDbInfoSizeUnits; + + return MFD_SUCCESS; +} /* rdbmsDbInfoSizeUnits_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbInfoEntry.rdbmsDbInfoSizeAllocated + * rdbmsDbInfoSizeAllocated is subid 4 of rdbmsDbInfoEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.2.1.4 + * Description: +The estimated size of this database (in + rdbmsDbInfoSizeUnits), which is the disk space that has been + allocated to it and is no longer available to users on this + host. rdbmsDbInfoSize does not necessarily indicate the + amount of space actually in use for database data. Some + databases may support extending allocated size, and others + may not. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 1 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbInfoSizeAllocated.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbInfoSizeAllocated_map(long *mib_rdbmsDbInfoSizeAllocated_val_ptr, long raw_rdbmsDbInfoSizeAllocated_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbInfoSizeAllocated_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoSizeAllocated_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbInfoSizeAllocated mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbInfoSizeAllocated_val_ptr) = raw_rdbmsDbInfoSizeAllocated_val; + + return MFD_SUCCESS; +} /* rdbmsDbInfoSizeAllocated_map */ + +/** + * Extract the current value of the rdbmsDbInfoSizeAllocated data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbInfoSizeAllocated_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbInfoSizeAllocated_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbInfoSizeAllocated_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbInfoSizeAllocated_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoSizeAllocated_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbInfoSizeAllocated data. + * set (* rdbmsDbInfoSizeAllocated_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbInfoSizeAllocated_val_ptr ) = rowreq_ctx->data.rdbmsDbInfoSizeAllocated; + + return MFD_SUCCESS; +} /* rdbmsDbInfoSizeAllocated_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbInfoEntry.rdbmsDbInfoSizeUsed + * rdbmsDbInfoSizeUsed is subid 5 of rdbmsDbInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.2.1.5 + * Description: +The estimated size of this database, in rdbmsDbInfoSizeUnits, + which is actually in use for database data. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbInfoSizeUsed.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbInfoSizeUsed_map(long *mib_rdbmsDbInfoSizeUsed_val_ptr, long raw_rdbmsDbInfoSizeUsed_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbInfoSizeUsed_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoSizeUsed_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbInfoSizeUsed mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbInfoSizeUsed_val_ptr) = raw_rdbmsDbInfoSizeUsed_val; + + return MFD_SUCCESS; +} /* rdbmsDbInfoSizeUsed_map */ + +/** + * Extract the current value of the rdbmsDbInfoSizeUsed data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbInfoSizeUsed_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbInfoSizeUsed_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbInfoSizeUsed_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbInfoSizeUsed_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoSizeUsed_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbInfoSizeUsed data. + * set (* rdbmsDbInfoSizeUsed_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbInfoSizeUsed_val_ptr ) = rowreq_ctx->data.rdbmsDbInfoSizeUsed; + + return MFD_SUCCESS; +} /* rdbmsDbInfoSizeUsed_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbInfoEntry.rdbmsDbInfoLastBackup + * rdbmsDbInfoLastBackup is subid 6 of rdbmsDbInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.2.1.6 + * Description: +The date and time that the latest complete or partial backup + of the database was taken. If a database has never been + backed up, then attempts to access this object will + result in either noSuchName (SNMPv1) or noSuchInstance + (SNMPv2). + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 2d-1d-1d,1d:1d:1d.1d,1a1d:1d + * + * Ranges: 8, 11; + * + * Its syntax is DateAndTime (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 11) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbInfoLastBackup.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbInfoLastBackup_map(char **mib_rdbmsDbInfoLastBackup_val_ptr_ptr, size_t *mib_rdbmsDbInfoLastBackup_val_ptr_len_ptr, char *raw_rdbmsDbInfoLastBackup_val_ptr, size_t raw_rdbmsDbInfoLastBackup_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbInfoLastBackup_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbInfoLastBackup_val_ptr_ptr) && (NULL != mib_rdbmsDbInfoLastBackup_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoLastBackup_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbInfoLastBackup non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbInfoLastBackup_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbInfoLastBackup_val_ptr_ptr) || (*mib_rdbmsDbInfoLastBackup_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbInfoLastBackup_val_ptr_ptr = realloc( *mib_rdbmsDbInfoLastBackup_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbInfoLastBackup_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbInfoLastBackup_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbInfoLastBackup_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbInfoLastBackup_val_ptr_ptr, raw_rdbmsDbInfoLastBackup_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbInfoLastBackup_map */ + +/** + * Extract the current value of the rdbmsDbInfoLastBackup data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbInfoLastBackup_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbInfoLastBackup_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbInfoLastBackup. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbInfoLastBackup_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbInfoLastBackup_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbInfoLastBackup_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbInfoLastBackup_val_ptr_ptr, size_t *rdbmsDbInfoLastBackup_val_ptr_len_ptr ) +{ + /* temporary storage for date. If you have any of this data available + directly, use it instead. */ +/* int year, month, day, hour, minutes, seconds, deci_seconds; + * int rc, utc_offset_direction, utc_offset_hours, utc_offset_minutes; */ + int rc; + + /** we should have a pointer and enough storage */ + /* Josh changed mib2c's template from rdbmsDbInfoLastBackup_ptr_ptr and rdbmsDbInfoLastBackup_len_ptr to rdbmsDbInfoLastBackup_val_ptr_ptr and + * rdbmsDbInfoLastBackup_val_ptr_len_ptr respectively, both here and in the call to netsnmp_dateandtime_set_buf_from_vars. I'm not sure this was + * the right thing to do, but it does appear to work */ + netsnmp_assert( (NULL != rdbmsDbInfoLastBackup_val_ptr_ptr) && (NULL != *rdbmsDbInfoLastBackup_val_ptr_ptr)); + netsnmp_assert( (NULL != rdbmsDbInfoLastBackup_val_ptr_len_ptr) && ((* rdbmsDbInfoLastBackup_val_ptr_len_ptr) >= 11)); + + /* + * TODO:231:o: |-> copy rdbmsDbInfoLastBackup data. + * get the date from your context pointer. + */ + /*return MFD_SKIP; * TODO:234:M: |-> Remove SKIP once you've set rdbmsDbInfoLastBackup data */ + + /* call convenience function to set data */ + rc = netsnmp_dateandtime_set_buf_from_vars((u_char *)*rdbmsDbInfoLastBackup_val_ptr_ptr, rdbmsDbInfoLastBackup_val_ptr_len_ptr, + rowreq_ctx->data.lastBackupYear, + rowreq_ctx->data.lastBackupMonth, + rowreq_ctx->data.lastBackupDay, + rowreq_ctx->data.lastBackupHour, + rowreq_ctx->data.lastBackupMinutes, + rowreq_ctx->data.lastBackupSeconds, + rowreq_ctx->data.lastBackupDeciSeconds, + rowreq_ctx->data.utc_offset_direction, + rowreq_ctx->data.utc_offset_hours, + rowreq_ctx->data.utc_offset_minutes ); + if(rc != SNMP_ERR_NOERROR) + return rc; + + return MFD_SUCCESS; +} /* rdbmsDbInfoLastBackup_get */ + + + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.h b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.h new file mode 100644 index 0000000..ba9adf3 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_data_get.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_data_get.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_data_get.h,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBINFOTABLE_DATA_GET_H +#define RDBMSDBINFOTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbInfoTable is subid 2 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.2, length: 9 +*/ + /* + * indexes + */ + int rdbmsDbIndex_map(long *mib_rdbmsDbIndex_val_ptr, long raw_rdbmsDbIndex_val); + + int rdbmsDbInfoProductName_map(char **mib_rdbmsDbInfoProductName_val_ptr_ptr, size_t *mib_rdbmsDbInfoProductName_val_ptr_len_ptr, char *raw_rdbmsDbInfoProductName_val_ptr, size_t raw_rdbmsDbInfoProductName_val_ptr_len, int allow_realloc); + int rdbmsDbInfoProductName_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbInfoProductName_val_ptr_ptr, size_t *rdbmsDbInfoProductName_val_ptr_len_ptr ); + int rdbmsDbInfoVersion_map(char **mib_rdbmsDbInfoVersion_val_ptr_ptr, size_t *mib_rdbmsDbInfoVersion_val_ptr_len_ptr, char *raw_rdbmsDbInfoVersion_val_ptr, size_t raw_rdbmsDbInfoVersion_val_ptr_len, int allow_realloc); + int rdbmsDbInfoVersion_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbInfoVersion_val_ptr_ptr, size_t *rdbmsDbInfoVersion_val_ptr_len_ptr ); + int rdbmsDbInfoSizeUnits_map(u_long *mib_rdbmsDbInfoSizeUnits_val_ptr, u_long raw_rdbmsDbInfoSizeUnits_val); + int rdbmsDbInfoSizeUnits_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsDbInfoSizeUnits_val_ptr ); + int rdbmsDbInfoSizeAllocated_map(long *mib_rdbmsDbInfoSizeAllocated_val_ptr, long raw_rdbmsDbInfoSizeAllocated_val); + int rdbmsDbInfoSizeAllocated_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbInfoSizeAllocated_val_ptr ); + int rdbmsDbInfoSizeUsed_map(long *mib_rdbmsDbInfoSizeUsed_val_ptr, long raw_rdbmsDbInfoSizeUsed_val); + int rdbmsDbInfoSizeUsed_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbInfoSizeUsed_val_ptr ); + int rdbmsDbInfoLastBackup_map(char **mib_rdbmsDbInfoLastBackup_val_ptr_ptr, size_t *mib_rdbmsDbInfoLastBackup_val_ptr_len_ptr, char *raw_rdbmsDbInfoLastBackup_val_ptr, size_t raw_rdbmsDbInfoLastBackup_val_ptr_len, int allow_realloc); + int rdbmsDbInfoLastBackup_get( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbInfoLastBackup_val_ptr_ptr, size_t *rdbmsDbInfoLastBackup_val_ptr_len_ptr ); + + +int rdbmsDbInfoTable_indexes_set_tbl_idx(rdbmsDbInfoTable_mib_index *tbl_idx, long rdbmsDbIndex_val); +int rdbmsDbInfoTable_indexes_set(rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBINFOTABLE_DATA_GET_H */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_enums.h b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_enums.h new file mode 100644 index 0000000..30b62bb --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_enums.h @@ -0,0 +1,76 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_enums.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_enums.h,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBINFOTABLE_ENUMS_H +#define RDBMSDBINFOTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table rdbmsDbInfoTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * rdbmsDbInfoSizeUnits (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef RDBMSDBINFOSIZEUNITS_ENUMS +#define RDBMSDBINFOSIZEUNITS_ENUMS + +#define RDBMSDBINFOSIZEUNITS_BYTES 1 +#define RDBMSDBINFOSIZEUNITS_KBYTES 2 +#define RDBMSDBINFOSIZEUNITS_MBYTES 3 +#define RDBMSDBINFOSIZEUNITS_GBYTES 4 +#define RDBMSDBINFOSIZEUNITS_TBYTES 5 + + +#endif /* RDBMSDBINFOSIZEUNITS_ENUMS */ + + /* + * TODO:140:o: Define interal representation of rdbmsDbInfoSizeUnits enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_RDBMSDBINFOSIZEUNITS_BYTES 1 +#define INTERNAL_RDBMSDBINFOSIZEUNITS_KBYTES 2 +#define INTERNAL_RDBMSDBINFOSIZEUNITS_MBYTES 3 +#define INTERNAL_RDBMSDBINFOSIZEUNITS_GBYTES 4 +#define INTERNAL_RDBMSDBINFOSIZEUNITS_TBYTES 5 + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBINFOTABLE_ENUMS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.c b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.c new file mode 100644 index 0000000..5de7a4d --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.c @@ -0,0 +1,716 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_interface.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_interface.c,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbInfoTable.h" +#include "rdbmsDbInfoTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbInfoTable is subid 2 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.2, length: 9 +*/ +typedef struct rdbmsDbInfoTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + rdbmsDbInfoTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} rdbmsDbInfoTable_interface_ctx; + +static rdbmsDbInfoTable_interface_ctx rdbmsDbInfoTable_if_ctx; + +static void _rdbmsDbInfoTable_container_init( + rdbmsDbInfoTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_rdbmsDbInfoTable_pre_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbInfoTable_post_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbInfoTable_object_lookup; +static Netsnmp_Node_Handler _mfd_rdbmsDbInfoTable_get_values; +/** + * @internal + * Initialize the table rdbmsDbInfoTable + * (Define its contents and how it's structured) + */ +void +_rdbmsDbInfoTable_initialize_interface(rdbmsDbInfoTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &rdbmsDbInfoTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &rdbmsDbInfoTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_rdbmsDbInfoTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for rdbmsDbInfoTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_INTEGER, /** index: rdbmsDbIndex */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = RDBMSDBINFOTABLE_MIN_COL; + tbl_info->max_column = RDBMSDBINFOTABLE_MAX_COL; + + /* + * save users context + */ + rdbmsDbInfoTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + rdbmsDbInfoTable_init_data(reg_ptr); + + /* + * set up the container + */ + _rdbmsDbInfoTable_container_init(&rdbmsDbInfoTable_if_ctx); + if (NULL == rdbmsDbInfoTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for rdbmsDbInfoTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_rdbmsDbInfoTable_object_lookup; + access_multiplexer->get_values = _mfd_rdbmsDbInfoTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_rdbmsDbInfoTable_pre_request; + access_multiplexer->post_request = _mfd_rdbmsDbInfoTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("rdbmsDbInfoTable:init_rdbmsDbInfoTable", + "Registering rdbmsDbInfoTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("rdbmsDbInfoTable", handler, + rdbmsDbInfoTable_oid, + rdbmsDbInfoTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table rdbmsDbInfoTable\n"); + return; + } + reginfo->my_reg_void = &rdbmsDbInfoTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + rdbmsDbInfoTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != rdbmsDbInfoTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(rdbmsDbInfoTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _rdbmsDbInfoTable_initialize_interface */ + +void +rdbmsDbInfoTable_valid_columns_set(netsnmp_column_info *vc) +{ + rdbmsDbInfoTable_if_ctx.tbl_info.valid_columns = vc; +} /* rdbmsDbInfoTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +rdbmsDbInfoTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbInfoTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_index_to_oid","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_rdbmsDbIndex); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbInfoTable_index_to_oid */ + +/** + * extract rdbmsDbInfoTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +rdbmsDbInfoTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbInfoTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbInfoTable:rdbmsDbInfoTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_rdbmsDbIndex ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbInfoTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a rdbmsDbInfoTable_rowreq_ctx + */ +rdbmsDbInfoTable_rowreq_ctx * +rdbmsDbInfoTable_allocate_rowreq_ctx(void) +{ + rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(rdbmsDbInfoTable_rowreq_ctx); + + DEBUGMSGTL(("internal:rdbmsDbInfoTable:rdbmsDbInfoTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "rdbmsDbInfoTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->rdbmsDbInfoTable_data_list = NULL; + rowreq_ctx->rdbmsDbInfoTable_reg = rdbmsDbInfoTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* rdbmsDbInfoTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a rdbmsDbInfoTable_rowreq_ctx + */ +void +rdbmsDbInfoTable_release_rowreq_ctx(rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbInfoTable:rdbmsDbInfoTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* rdbmsDbInfoTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbInfoTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = rdbmsDbInfoTable_pre_request(rdbmsDbInfoTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbInfoTable","error %d from " + "rdbmsDbInfoTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbInfoTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbInfoTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx; + int rc = rdbmsDbInfoTable_post_request(rdbmsDbInfoTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbInfoTable","error %d from " + "rdbmsDbInfoTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(rdbmsDbInfoTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(rdbmsDbInfoTable_if_ctx.container, rowreq_ctx); + rdbmsDbInfoTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbInfoTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbInfoTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_mfd_rdbmsDbInfoTable_object_lookup","called\n")); + + /* + * get our context from mfd + * rdbmsDbInfoTable_interface_ctx *if_ctx = + * (rdbmsDbInfoTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + rdbmsDbInfoTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbInfoTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbInfoTable_get_column( rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_mfd_rdbmsDbInfoTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbInfoProductName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_RDBMSDBINFOPRODUCTNAME: + var->type = ASN_OCTET_STR; +rc = rdbmsDbInfoProductName_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbInfoVersion(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_RDBMSDBINFOVERSION: + var->type = ASN_OCTET_STR; +rc = rdbmsDbInfoVersion_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbInfoSizeUnits(3)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_RDBMSDBINFOSIZEUNITS: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = rdbmsDbInfoSizeUnits_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* rdbmsDbInfoSizeAllocated(4)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/R/d/h */ + case COLUMN_RDBMSDBINFOSIZEALLOCATED: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = rdbmsDbInfoSizeAllocated_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* rdbmsDbInfoSizeUsed(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h */ + case COLUMN_RDBMSDBINFOSIZEUSED: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = rdbmsDbInfoSizeUsed_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* rdbmsDbInfoLastBackup(6)/DateAndTime/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_RDBMSDBINFOLASTBACKUP: + var->type = ASN_OCTET_STR; +rc = rdbmsDbInfoLastBackup_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbInfoTable_get_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbInfoTable_get_column */ + +int +_mfd_rdbmsDbInfoTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_mfd_rdbmsDbInfoTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbInfoTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbInfoTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for rdbmsDbInfoTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return rdbmsDbInfoTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + rdbmsDbInfoTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in rdbmsDbInfoTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + rdbmsDbInfoTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_rdbmsDbInfoTable_container_init(rdbmsDbInfoTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbInfoTable:_rdbmsDbInfoTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + rdbmsDbInfoTable_oid, + rdbmsDbInfoTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for rdbmsDbInfoTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + rdbmsDbInfoTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("rdbmsDbInfoTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "rdbmsDbInfoTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _rdbmsDbInfoTable_container_init */ + diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.h b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.h new file mode 100644 index 0000000..ff9df1b --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_interface.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_interface.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_interface.h,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBINFOTABLE_INTERFACE_H +#define RDBMSDBINFOTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "rdbmsDbInfoTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _rdbmsDbInfoTable_initialize_interface(rdbmsDbInfoTable_registration_ptr user_ctx, + u_long flags); + + rdbmsDbInfoTable_rowreq_ctx * rdbmsDbInfoTable_allocate_rowreq_ctx(void); +void rdbmsDbInfoTable_release_rowreq_ctx(rdbmsDbInfoTable_rowreq_ctx *rowreq_ctx); + +int rdbmsDbInfoTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbInfoTable_mib_index *mib_idx); +int rdbmsDbInfoTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbInfoTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void rdbmsDbInfoTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBINFOTABLE_INTERFACE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_oids.h b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_oids.h new file mode 100644 index 0000000..9333aef --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbInfoTable/rdbmsDbInfoTable_oids.h @@ -0,0 +1,39 @@ +/*------------------------------------------------------------------------- + * rdbmsDbInfoTable_oids.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbInfoTable_oids.h,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBINFOTABLE_OIDS_H +#define RDBMSDBINFOTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table rdbmsDbInfoTable */ +#define RDBMSDBINFOTABLE_OID 1,3,6,1,2,1,39,1,2 +#define COLUMN_RDBMSDBINFOPRODUCTNAME 1 +#define COLUMN_RDBMSDBINFOVERSION 2 +#define COLUMN_RDBMSDBINFOSIZEUNITS 3 +#define COLUMN_RDBMSDBINFOSIZEALLOCATED 4 +#define COLUMN_RDBMSDBINFOSIZEUSED 5 +#define COLUMN_RDBMSDBINFOLASTBACKUP 6 + +#define RDBMSDBINFOTABLE_MIN_COL COLUMN_RDBMSDBINFOPRODUCTNAME +#define RDBMSDBINFOTABLE_MAX_COL COLUMN_RDBMSDBINFOLASTBACKUP + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBINFOTABLE_OIDS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.c b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.c new file mode 100644 index 0000000..f5864d0 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.c @@ -0,0 +1,130 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbLimitedResourceTable.h" + +#include + +#include "rdbmsDbLimitedResourceTable_interface.h" + +oid rdbmsDbLimitedResourceTable_oid[] = { RDBMSDBLIMITEDRESOURCETABLE_OID }; +int rdbmsDbLimitedResourceTable_oid_size = OID_LENGTH(rdbmsDbLimitedResourceTable_oid); + +void initialize_table_rdbmsDbLimitedResourceTable(void); + + +/** + * Initializes the rdbmsDbLimitedResourceTable module + */ +void +init_rdbmsDbLimitedResourceTable(void) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:init_rdbmsDbLimitedResourceTable","called\n")); + + /* + * TODO:300:o: Perform rdbmsDbLimitedResourceTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("rdbmsDbLimitedResourceTable")) + initialize_table_rdbmsDbLimitedResourceTable(); + +} /* init_rdbmsDbLimitedResourceTable */ + +/** + * Initialize the table rdbmsDbLimitedResourceTable + * (Define its contents and how it's structured) + */ +void +initialize_table_rdbmsDbLimitedResourceTable(void) +{ + rdbmsDbLimitedResourceTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:initialize_table_rdbmsDbLimitedResourceTable","called\n")); + + /* + * TODO:301:o: Perform rdbmsDbLimitedResourceTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize rdbmsDbLimitedResourceTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("rdbmsDbLimitedResourceTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _rdbmsDbLimitedResourceTable_initialize_interface(user_context, flags); +} /* initialize_table_rdbmsDbLimitedResourceTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +rdbmsDbLimitedResourceTable_pre_request(rdbmsDbLimitedResourceTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform rdbmsDbLimitedResourceTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +rdbmsDbLimitedResourceTable_post_request(rdbmsDbLimitedResourceTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_post_request","called\n")); + + /* + * TODO:511:o: Perform rdbmsDbLimitedResourceTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceTable_post_request */ + + +/** @{ */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.h new file mode 100644 index 0000000..952db46 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable.h @@ -0,0 +1,224 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_H +#define RDBMSDBLIMITEDRESOURCETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(RDBMS-MIB/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface); +config_require(RDBMS-MIB/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access); +config_require(RDBMS-MIB/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get); +config_require(RDBMS-MIB/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "rdbmsDbLimitedResourceTable_oids.h" + +/* enum definions */ +#include "rdbmsDbLimitedResourceTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_rdbmsDbLimitedResourceTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbLimitedResourceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbLimitedResourceTable is subid 4 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.4, length: 9 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review rdbmsDbLimitedResourceTable registration context. + */ +typedef netsnmp_data_list * rdbmsDbLimitedResourceTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review rdbmsDbLimitedResourceTable data context structure. + * This structure is used to represent the data for rdbmsDbLimitedResourceTable. + */ +/* + * This structure contains storage for all the columns defined in the + * rdbmsDbLimitedResourceTable. + */ +typedef struct rdbmsDbLimitedResourceTable_data_s { + + /* + * rdbmsDbLimitedResourceID(2)/AutonomousType/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h + */ + oid rdbmsDbLimitedResourceID[128]; +size_t rdbmsDbLimitedResourceID_len; /* # of oid elements, not bytes */ + + /* + * rdbmsDbLimitedResourceLimit(3)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/R/d/h + */ + long rdbmsDbLimitedResourceLimit; + + /* + * rdbmsDbLimitedResourceCurrent(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + long rdbmsDbLimitedResourceCurrent; + + /* + * rdbmsDbLimitedResourceHighwater(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h + */ + long rdbmsDbLimitedResourceHighwater; + + /* + * rdbmsDbLimitedResourceFailures(6)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsDbLimitedResourceFailures; + + /* + * rdbmsDbLimitedResourceDescription(7)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + char rdbmsDbLimitedResourceDescription[255]; +size_t rdbmsDbLimitedResourceDescription_len; /* # of char elements, not bytes */ + +} rdbmsDbLimitedResourceTable_data; + + +/* + * TODO:120:r: |-> Review rdbmsDbLimitedResourceTable mib index. + * This structure is used to represent the index for rdbmsDbLimitedResourceTable. + */ +typedef struct rdbmsDbLimitedResourceTable_mib_index_s { + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + /* + * rdbmsDbLimitedResourceName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + /** 128 - 1(other indexes) - oid length(11) = 115 */ + char rdbmsDbLimitedResourceName[115]; + size_t rdbmsDbLimitedResourceName_len; + + +} rdbmsDbLimitedResourceTable_mib_index; + + /* + * TODO:121:r: | |-> Review rdbmsDbLimitedResourceTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + * Guessing 128 - col/entry(2) - oid len(9) +*/ +#define MAX_rdbmsDbLimitedResourceTable_IDX_LEN 117 + + +/* ********************************************************************* + * TODO:130:o: |-> Review rdbmsDbLimitedResourceTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * rdbmsDbLimitedResourceTable_rowreq_ctx pointer. + */ +typedef struct rdbmsDbLimitedResourceTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_rdbmsDbLimitedResourceTable_IDX_LEN]; + + rdbmsDbLimitedResourceTable_mib_index tbl_idx; + + rdbmsDbLimitedResourceTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + rdbmsDbLimitedResourceTable_registration_ptr rdbmsDbLimitedResourceTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to rdbmsDbLimitedResourceTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *rdbmsDbLimitedResourceTable_data_list; + +} rdbmsDbLimitedResourceTable_rowreq_ctx; + +typedef struct rdbmsDbLimitedResourceTable_ref_rowreq_ctx_s { + rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx; +} rdbmsDbLimitedResourceTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int rdbmsDbLimitedResourceTable_pre_request(rdbmsDbLimitedResourceTable_registration_ptr user_context); + int rdbmsDbLimitedResourceTable_post_request(rdbmsDbLimitedResourceTable_registration_ptr user_context); + + +extern oid rdbmsDbLimitedResourceTable_oid[]; +extern int rdbmsDbLimitedResourceTable_oid_size; + + +#include "rdbmsDbLimitedResourceTable_interface.h" +#include "rdbmsDbLimitedResourceTable_data_access.h" +#include "rdbmsDbLimitedResourceTable_data_get.h" +#include "rdbmsDbLimitedResourceTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.c b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.c new file mode 100644 index 0000000..e36e3ac --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.c @@ -0,0 +1,307 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_data_access.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_data_access.c,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbLimitedResourceTable.h" +#include "rdbmsDbLimitedResourceTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbLimitedResourceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbLimitedResourceTable is subid 4 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.4, length: 9 +*/ + +/** + * initialization for rdbmsDbLimitedResourceTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param rdbmsDbLimitedResourceTable_reg + * Pointer to rdbmsDbLimitedResourceTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +rdbmsDbLimitedResourceTable_init_data(rdbmsDbLimitedResourceTable_registration_ptr rdbmsDbLimitedResourceTable_reg) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_init_data","called\n")); + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +rdbmsDbLimitedResourceTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to rdbmsDbLimitedResourceTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up rdbmsDbLimitedResourceTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = RDBMSDBLIMITEDRESOURCETABLE_CACHE_TIMEOUT; /* seconds */ +} /* rdbmsDbLimitedResourceTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement rdbmsDbLimitedResourceTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * rdbmsDbLimitedResourceTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +rdbmsDbLimitedResourceTable_cache_load(netsnmp_container *container) +{ + rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + PGresult *pg_db_qry; + int i, resultCount, errorCode = MFD_SUCCESS, tmpInt; + char *tmpString; + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_cache_load","called\n")); + + if (PQstatus(dbconn) == CONNECTION_OK) + /* We can probably add new data to the rdbmsDbLimitedResourceTable by UNION-ing new queries with this one + * SELECT , , , , , , */ + pg_db_qry = PQexec(dbconn, "SELECT oid, 'XID', 2000000000, AGE(datfrozenxid), 0, 0, 'Transactions since last vacuum' FROM pg_database"); + else { + snmp_log(LOG_ERR, "Can't get connected to the database"); + return -1; + } + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database"); + PQclear(pg_db_qry); + /*PQfinish(dbconn);*/ + return -1; + } + + resultCount = PQntuples(pg_db_qry); + + /* + * TODO:351:M: |-> Load/update data in the rdbmsDbLimitedResourceTable container. + * loop over your rdbmsDbLimitedResourceTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new rdbmsDbLimitedResourceTable rowreq context. + */ + rowreq_ctx = rdbmsDbLimitedResourceTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + errorCode = MFD_RESOURCE_UNAVAILABLE; + break; + } + tmpInt = atoi(PQgetvalue(pg_db_qry, i, 0)); + tmpString = PQgetvalue(pg_db_qry, i, 1); + if(MFD_SUCCESS != rdbmsDbLimitedResourceTable_indexes_set(rowreq_ctx + , tmpInt + , tmpString, strlen(tmpString) + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "rdbmsDbLimitedResourceTable cache.\n"); + rdbmsDbLimitedResourceTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len = 255; + + /* COMMENTED OUT UNTIL WE HAVE PGSNMPD-MIB SO THIS VALUE CAN POINT TO SOMETING + if ((NULL == rowreq_ctx->data.rdbmsDbLimitedResourceID) || + (rowreq_ctx->data.rdbmsDbLimitedResourceID_len < (rdbmsDbLimitedResourceID_len * sizeof(rowreq_ctx->data.rdbmsDbLimitedResourceID[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + rowreq_ctx->data.rdbmsDbLimitedResourceID_len = rdbmsDbLimitedResourceID_len * sizeof(rowreq_ctx->data.rdbmsDbLimitedResourceID[0]); + memcpy( rowreq_ctx->data.rdbmsDbLimitedResourceID, rdbmsDbLimitedResourceID, rowreq_ctx->data.rdbmsDbLimitedResourceID_len ); */ + + rowreq_ctx->data.rdbmsDbLimitedResourceLimit = atoi(PQgetvalue(pg_db_qry, i, 2)); + + rowreq_ctx->data.rdbmsDbLimitedResourceCurrent = atoi(PQgetvalue(pg_db_qry, i, 3)); + + rowreq_ctx->data.rdbmsDbLimitedResourceHighwater = atoi(PQgetvalue(pg_db_qry, i, 4)); + + rowreq_ctx->data.rdbmsDbLimitedResourceFailures = atoi(PQgetvalue(pg_db_qry, i, 5)); + + tmpString = PQgetvalue(pg_db_qry, i, 6); + tmpInt = strlen(tmpString); + if ((NULL == rowreq_ctx->data.rdbmsDbLimitedResourceDescription) || + (rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len < (tmpInt * sizeof(rowreq_ctx->data.rdbmsDbLimitedResourceDescription[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + errorCode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len = tmpInt * sizeof(rowreq_ctx->data.rdbmsDbLimitedResourceDescription[0]); + memcpy( rowreq_ctx->data.rdbmsDbLimitedResourceDescription, tmpString, rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len ); + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + DEBUGMSGT(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_cache_load", + "inserted %d records\n", count)); + + PQclear(pg_db_qry); + return errorCode; +} /* rdbmsDbLimitedResourceTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +rdbmsDbLimitedResourceTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_cache_free","called\n")); + + /* + * TODO:380:M: Free rdbmsDbLimitedResourceTable cache. + */ +} /* rdbmsDbLimitedResourceTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +rdbmsDbLimitedResourceTable_row_prep( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceTable_row_prep */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.h new file mode 100644 index 0000000..6e24990 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_access.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_data_access.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_data_access.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_DATA_ACCESS_H +#define RDBMSDBLIMITEDRESOURCETABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbLimitedResourceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbLimitedResourceTable is subid 4 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.4, length: 9 +*/ + + + int rdbmsDbLimitedResourceTable_init_data(rdbmsDbLimitedResourceTable_registration_ptr rdbmsDbLimitedResourceTable_reg); + + +/* + * TODO:180:o: Review rdbmsDbLimitedResourceTable cache timeout. + * The number of seconds before the cache times out + */ +#define RDBMSDBLIMITEDRESOURCETABLE_CACHE_TIMEOUT 60 + +void rdbmsDbLimitedResourceTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int rdbmsDbLimitedResourceTable_cache_load(netsnmp_container *container); +void rdbmsDbLimitedResourceTable_cache_free(netsnmp_container *container); + + int rdbmsDbLimitedResourceTable_row_prep( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_DATA_ACCESS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.c b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.c new file mode 100644 index 0000000..606fb3e --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.c @@ -0,0 +1,868 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_data_get.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_data_get.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbLimitedResourceTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement rdbmsDbLimitedResourceTable get routines. + * TODO:240:M: Implement rdbmsDbLimitedResourceTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbLimitedResourceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbLimitedResourceTable is subid 4 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.4, length: 9 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement rdbmsDbLimitedResourceTable data context functions. + */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceName + * rdbmsDbLimitedResourceName is subid 1 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.39.1.4.1.1 + * Description: +The name of the resource, for instance 'global locks' or + 'locks for the FOO database', or 'data space on /dev/rdsk/5s0 + for FOO'. The length is limited to 64 characters to constrain + the number of sub-identifiers needed for instance + identification (and to minimize network traffic). + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE rdbmsDbLimitedResourceName IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceName.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceName_map(char **mib_rdbmsDbLimitedResourceName_val_ptr_ptr, size_t *mib_rdbmsDbLimitedResourceName_val_ptr_len_ptr, char *raw_rdbmsDbLimitedResourceName_val_ptr, size_t raw_rdbmsDbLimitedResourceName_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbLimitedResourceName_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbLimitedResourceName_val_ptr_ptr) && (NULL != mib_rdbmsDbLimitedResourceName_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceName_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbLimitedResourceName non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbLimitedResourceName_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbLimitedResourceName_val_ptr_ptr) || (*mib_rdbmsDbLimitedResourceName_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbLimitedResourceName_val_ptr_ptr = realloc( *mib_rdbmsDbLimitedResourceName_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbLimitedResourceName_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbLimitedResourceName_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbLimitedResourceName_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbLimitedResourceName_val_ptr_ptr, raw_rdbmsDbLimitedResourceName_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceName_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +rdbmsDbLimitedResourceTable_indexes_set_tbl_idx(rdbmsDbLimitedResourceTable_mib_index *tbl_idx, long rdbmsDbIndex_val, char *rdbmsDbLimitedResourceName_val_ptr, size_t rdbmsDbLimitedResourceName_val_ptr_len) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_indexes_set_tbl_idx","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + /* rdbmsDbLimitedResourceName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + tbl_idx->rdbmsDbLimitedResourceName_len = sizeof(tbl_idx->rdbmsDbLimitedResourceName); + /* + * make sure there is enough space for rdbmsDbLimitedResourceName data + */ + if ((NULL == tbl_idx->rdbmsDbLimitedResourceName) || + (tbl_idx->rdbmsDbLimitedResourceName_len < (rdbmsDbLimitedResourceName_val_ptr_len * sizeof(tbl_idx->rdbmsDbLimitedResourceName[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->rdbmsDbLimitedResourceName_len = rdbmsDbLimitedResourceName_val_ptr_len * sizeof(tbl_idx->rdbmsDbLimitedResourceName[0]); + memcpy( tbl_idx->rdbmsDbLimitedResourceName, rdbmsDbLimitedResourceName_val_ptr, tbl_idx->rdbmsDbLimitedResourceName_len ); + + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +rdbmsDbLimitedResourceTable_indexes_set(rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val, char *rdbmsDbLimitedResourceName_val_ptr, size_t rdbmsDbLimitedResourceName_val_ptr_len) +{ + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_indexes_set","called\n")); + + if(MFD_SUCCESS != rdbmsDbLimitedResourceTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , rdbmsDbIndex_val + , rdbmsDbLimitedResourceName_val_ptr, rdbmsDbLimitedResourceName_val_ptr_len + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != rdbmsDbLimitedResourceTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceID + * rdbmsDbLimitedResourceID is subid 2 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.4.1.2 + * Description: +The ID of the resource which may be described in some other + MIB (e.g., an enterprise-specific MIB module). If there is + no ID for this rdbmsDbLimitedResourceName, attempts to access + this object will return noSuchName (SNMPv1) or noSuchInstance + (SNMPv2). + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is AutonomousType (based on perltype OBJECTID) + * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceID_map(oid **mib_rdbmsDbLimitedResourceID_val_ptr_ptr, size_t *mib_rdbmsDbLimitedResourceID_val_ptr_len_ptr, oid *raw_rdbmsDbLimitedResourceID_val_ptr, size_t raw_rdbmsDbLimitedResourceID_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbLimitedResourceID_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbLimitedResourceID_val_ptr_ptr) && (NULL != mib_rdbmsDbLimitedResourceID_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceID_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbLimitedResourceID non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbLimitedResourceID_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbLimitedResourceID_val_ptr_ptr) || (*mib_rdbmsDbLimitedResourceID_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbLimitedResourceID_val_ptr_ptr = realloc( *mib_rdbmsDbLimitedResourceID_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbLimitedResourceID_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbLimitedResourceID_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbLimitedResourceID_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbLimitedResourceID_val_ptr_ptr, raw_rdbmsDbLimitedResourceID_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceID_map */ + +/** + * Extract the current value of the rdbmsDbLimitedResourceID data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbLimitedResourceID_val_ptr_ptr + * Pointer to storage for a oid variable + * @param rdbmsDbLimitedResourceID_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbLimitedResourceID. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbLimitedResourceID_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbLimitedResourceID_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbLimitedResourceID_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, oid **rdbmsDbLimitedResourceID_val_ptr_ptr, size_t *rdbmsDbLimitedResourceID_val_ptr_len_ptr ) +{ + /* Until PGSNMPD-MIB exists, there's nothing to see here */ + return MFD_SKIP; + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbLimitedResourceID_val_ptr_ptr) && (NULL != *rdbmsDbLimitedResourceID_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbLimitedResourceID_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceID_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbLimitedResourceID data. + * set (* rdbmsDbLimitedResourceID_val_ptr_ptr ) and (* rdbmsDbLimitedResourceID_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbLimitedResourceID data + */ + if ((NULL == (* rdbmsDbLimitedResourceID_val_ptr_ptr )) || + ((* rdbmsDbLimitedResourceID_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbLimitedResourceID_len * sizeof((* rdbmsDbLimitedResourceID_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbLimitedResourceID data + */ + (* rdbmsDbLimitedResourceID_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbLimitedResourceID_len * sizeof((* rdbmsDbLimitedResourceID_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbLimitedResourceID_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbLimitedResourceID_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbLimitedResourceID_len * sizeof((* rdbmsDbLimitedResourceID_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbLimitedResourceID_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbLimitedResourceID, (* rdbmsDbLimitedResourceID_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceID_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceLimit + * rdbmsDbLimitedResourceLimit is subid 3 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.4.1.3 + * Description: +The maximum value the resource use may attain. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 1 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceLimit.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceLimit_map(long *mib_rdbmsDbLimitedResourceLimit_val_ptr, long raw_rdbmsDbLimitedResourceLimit_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbLimitedResourceLimit_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceLimit_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbLimitedResourceLimit mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbLimitedResourceLimit_val_ptr) = raw_rdbmsDbLimitedResourceLimit_val; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceLimit_map */ + +/** + * Extract the current value of the rdbmsDbLimitedResourceLimit data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbLimitedResourceLimit_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbLimitedResourceLimit_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbLimitedResourceLimit_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbLimitedResourceLimit_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceLimit_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbLimitedResourceLimit data. + * set (* rdbmsDbLimitedResourceLimit_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbLimitedResourceLimit_val_ptr ) = rowreq_ctx->data.rdbmsDbLimitedResourceLimit; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceLimit_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceCurrent + * rdbmsDbLimitedResourceCurrent is subid 4 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.4.1.4 + * Description: +The current value for the resource. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceCurrent.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceCurrent_map(long *mib_rdbmsDbLimitedResourceCurrent_val_ptr, long raw_rdbmsDbLimitedResourceCurrent_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbLimitedResourceCurrent_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceCurrent_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbLimitedResourceCurrent mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbLimitedResourceCurrent_val_ptr) = raw_rdbmsDbLimitedResourceCurrent_val; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceCurrent_map */ + +/** + * Extract the current value of the rdbmsDbLimitedResourceCurrent data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbLimitedResourceCurrent_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbLimitedResourceCurrent_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbLimitedResourceCurrent_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbLimitedResourceCurrent_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceCurrent_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbLimitedResourceCurrent data. + * set (* rdbmsDbLimitedResourceCurrent_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbLimitedResourceCurrent_val_ptr ) = rowreq_ctx->data.rdbmsDbLimitedResourceCurrent; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceCurrent_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceHighwater + * rdbmsDbLimitedResourceHighwater is subid 5 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.4.1.5 + * Description: +The maximum value of the resource seen since applUpTime + was reset for the earliest server which has the database + actively opened. + + If there are two servers with the database open, and the + oldest one dies, the proper way to invalidate the value is by + resetting sysUpTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceHighwater.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceHighwater_map(long *mib_rdbmsDbLimitedResourceHighwater_val_ptr, long raw_rdbmsDbLimitedResourceHighwater_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbLimitedResourceHighwater_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceHighwater_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbLimitedResourceHighwater mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbLimitedResourceHighwater_val_ptr) = raw_rdbmsDbLimitedResourceHighwater_val; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceHighwater_map */ + +/** + * Extract the current value of the rdbmsDbLimitedResourceHighwater data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbLimitedResourceHighwater_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbLimitedResourceHighwater_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbLimitedResourceHighwater_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbLimitedResourceHighwater_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceHighwater_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbLimitedResourceHighwater data. + * set (* rdbmsDbLimitedResourceHighwater_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbLimitedResourceHighwater_val_ptr ) = rowreq_ctx->data.rdbmsDbLimitedResourceHighwater; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceHighwater_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceFailures + * rdbmsDbLimitedResourceFailures is subid 6 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.4.1.6 + * Description: +The number of times the system wanted to exceed the limit of + the resource since applUpTime was reset for the earliest + server which has the database actively opened. + + If there are two servers with the DB open, and the + oldest one dies, the proper way to invalidate the value is by + resetting sysUpTime. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceFailures.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceFailures_map(u_long *mib_rdbmsDbLimitedResourceFailures_val_ptr, u_long raw_rdbmsDbLimitedResourceFailures_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbLimitedResourceFailures_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceFailures_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbLimitedResourceFailures mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbLimitedResourceFailures_val_ptr) = raw_rdbmsDbLimitedResourceFailures_val; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceFailures_map */ + +/** + * Extract the current value of the rdbmsDbLimitedResourceFailures data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbLimitedResourceFailures_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsDbLimitedResourceFailures_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsDbLimitedResourceFailures_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsDbLimitedResourceFailures_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceFailures_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbLimitedResourceFailures data. + * set (* rdbmsDbLimitedResourceFailures_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsDbLimitedResourceFailures_val_ptr ) = rowreq_ctx->data.rdbmsDbLimitedResourceFailures; + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceFailures_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbLimitedResourceEntry.rdbmsDbLimitedResourceDescription + * rdbmsDbLimitedResourceDescription is subid 7 of rdbmsDbLimitedResourceEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.4.1.7 + * Description: +A description of the resource and the meaning of the integer + units used for Limit, Current, and Highwater. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbLimitedResourceDescription.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbLimitedResourceDescription_map(char **mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr, size_t *mib_rdbmsDbLimitedResourceDescription_val_ptr_len_ptr, char *raw_rdbmsDbLimitedResourceDescription_val_ptr, size_t raw_rdbmsDbLimitedResourceDescription_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbLimitedResourceDescription_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr) && (NULL != mib_rdbmsDbLimitedResourceDescription_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceDescription_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbLimitedResourceDescription non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbLimitedResourceDescription_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr) || (*mib_rdbmsDbLimitedResourceDescription_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr = realloc( *mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbLimitedResourceDescription_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr, raw_rdbmsDbLimitedResourceDescription_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceDescription_map */ + +/** + * Extract the current value of the rdbmsDbLimitedResourceDescription data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbLimitedResourceDescription_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbLimitedResourceDescription_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbLimitedResourceDescription. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbLimitedResourceDescription_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbLimitedResourceDescription_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbLimitedResourceDescription_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbLimitedResourceDescription_val_ptr_ptr, size_t *rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbLimitedResourceDescription_val_ptr_ptr) && (NULL != *rdbmsDbLimitedResourceDescription_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceDescription_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbLimitedResourceDescription data. + * set (* rdbmsDbLimitedResourceDescription_val_ptr_ptr ) and (* rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbLimitedResourceDescription data + */ + if ((NULL == (* rdbmsDbLimitedResourceDescription_val_ptr_ptr )) || + ((* rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len * sizeof((* rdbmsDbLimitedResourceDescription_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbLimitedResourceDescription data + */ + (* rdbmsDbLimitedResourceDescription_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len * sizeof((* rdbmsDbLimitedResourceDescription_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbLimitedResourceDescription_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbLimitedResourceDescription_len * sizeof((* rdbmsDbLimitedResourceDescription_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbLimitedResourceDescription_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbLimitedResourceDescription, (* rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbLimitedResourceDescription_get */ + + + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.h new file mode 100644 index 0000000..896e133 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_get.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_data_get.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_data_get.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_DATA_GET_H +#define RDBMSDBLIMITEDRESOURCETABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbLimitedResourceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbLimitedResourceTable is subid 4 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.4, length: 9 +*/ + /* + * indexes + */ + int rdbmsDbIndex_map(long *mib_rdbmsDbIndex_val_ptr, long raw_rdbmsDbIndex_val); + int rdbmsDbLimitedResourceName_map(char **mib_rdbmsDbLimitedResourceName_val_ptr_ptr, size_t *mib_rdbmsDbLimitedResourceName_val_ptr_len_ptr, char *raw_rdbmsDbLimitedResourceName_val_ptr, size_t raw_rdbmsDbLimitedResourceName_val_ptr_len, int allow_realloc); + + int rdbmsDbLimitedResourceID_map(oid **mib_rdbmsDbLimitedResourceID_val_ptr_ptr, size_t *mib_rdbmsDbLimitedResourceID_val_ptr_len_ptr, oid *raw_rdbmsDbLimitedResourceID_val_ptr, size_t raw_rdbmsDbLimitedResourceID_val_ptr_len, int allow_realloc); + int rdbmsDbLimitedResourceID_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, oid **rdbmsDbLimitedResourceID_val_ptr_ptr, size_t *rdbmsDbLimitedResourceID_val_ptr_len_ptr ); + int rdbmsDbLimitedResourceLimit_map(long *mib_rdbmsDbLimitedResourceLimit_val_ptr, long raw_rdbmsDbLimitedResourceLimit_val); + int rdbmsDbLimitedResourceLimit_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbLimitedResourceLimit_val_ptr ); + int rdbmsDbLimitedResourceCurrent_map(long *mib_rdbmsDbLimitedResourceCurrent_val_ptr, long raw_rdbmsDbLimitedResourceCurrent_val); + int rdbmsDbLimitedResourceCurrent_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbLimitedResourceCurrent_val_ptr ); + int rdbmsDbLimitedResourceHighwater_map(long *mib_rdbmsDbLimitedResourceHighwater_val_ptr, long raw_rdbmsDbLimitedResourceHighwater_val); + int rdbmsDbLimitedResourceHighwater_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long * rdbmsDbLimitedResourceHighwater_val_ptr ); + int rdbmsDbLimitedResourceFailures_map(u_long *mib_rdbmsDbLimitedResourceFailures_val_ptr, u_long raw_rdbmsDbLimitedResourceFailures_val); + int rdbmsDbLimitedResourceFailures_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsDbLimitedResourceFailures_val_ptr ); + int rdbmsDbLimitedResourceDescription_map(char **mib_rdbmsDbLimitedResourceDescription_val_ptr_ptr, size_t *mib_rdbmsDbLimitedResourceDescription_val_ptr_len_ptr, char *raw_rdbmsDbLimitedResourceDescription_val_ptr, size_t raw_rdbmsDbLimitedResourceDescription_val_ptr_len, int allow_realloc); + int rdbmsDbLimitedResourceDescription_get( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbLimitedResourceDescription_val_ptr_ptr, size_t *rdbmsDbLimitedResourceDescription_val_ptr_len_ptr ); + + +int rdbmsDbLimitedResourceTable_indexes_set_tbl_idx(rdbmsDbLimitedResourceTable_mib_index *tbl_idx, long rdbmsDbIndex_val, char *rdbmsDbLimitedResourceName_val_ptr, size_t rdbmsDbLimitedResourceName_val_ptr_len); +int rdbmsDbLimitedResourceTable_indexes_set(rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val, char *rdbmsDbLimitedResourceName_val_ptr, size_t rdbmsDbLimitedResourceName_val_ptr_len); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_DATA_GET_H */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.c b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.c new file mode 100644 index 0000000..cfbcb24 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.c @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_data_set.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_data_set.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbLimitedResourceTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.h new file mode 100644 index 0000000..36b90b9 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_data_set.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_data_set.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_data_set.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_DATA_SET_H +#define RDBMSDBLIMITEDRESOURCETABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_DATA_SET_H */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_enums.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_enums.h new file mode 100644 index 0000000..6a25754 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_enums.h @@ -0,0 +1,47 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_enums.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_enums.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_ENUMS_H +#define RDBMSDBLIMITEDRESOURCETABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table rdbmsDbLimitedResourceTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_ENUMS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.c b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.c new file mode 100644 index 0000000..28eb874 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.c @@ -0,0 +1,747 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_interface.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_interface.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbLimitedResourceTable.h" + + +#include + +#include "rdbmsDbLimitedResourceTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbLimitedResourceTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbLimitedResourceTable is subid 4 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.4, length: 9 +*/ +typedef struct rdbmsDbLimitedResourceTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + rdbmsDbLimitedResourceTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} rdbmsDbLimitedResourceTable_interface_ctx; + +static rdbmsDbLimitedResourceTable_interface_ctx rdbmsDbLimitedResourceTable_if_ctx; + +static void _rdbmsDbLimitedResourceTable_container_init( + rdbmsDbLimitedResourceTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_rdbmsDbLimitedResourceTable_pre_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbLimitedResourceTable_post_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbLimitedResourceTable_object_lookup; +static Netsnmp_Node_Handler _mfd_rdbmsDbLimitedResourceTable_get_values; +/** + * @internal + * Initialize the table rdbmsDbLimitedResourceTable + * (Define its contents and how it's structured) + */ +void +_rdbmsDbLimitedResourceTable_initialize_interface(rdbmsDbLimitedResourceTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &rdbmsDbLimitedResourceTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &rdbmsDbLimitedResourceTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_rdbmsDbLimitedResourceTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for rdbmsDbLimitedResourceTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_INTEGER, /** index: rdbmsDbIndex */ + ASN_OCTET_STR, /** index: rdbmsDbLimitedResourceName */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = RDBMSDBLIMITEDRESOURCETABLE_MIN_COL; + tbl_info->max_column = RDBMSDBLIMITEDRESOURCETABLE_MAX_COL; + + /* + * save users context + */ + rdbmsDbLimitedResourceTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + rdbmsDbLimitedResourceTable_init_data(reg_ptr); + + /* + * set up the container + */ + _rdbmsDbLimitedResourceTable_container_init(&rdbmsDbLimitedResourceTable_if_ctx); + if (NULL == rdbmsDbLimitedResourceTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for rdbmsDbLimitedResourceTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_rdbmsDbLimitedResourceTable_object_lookup; + access_multiplexer->get_values = _mfd_rdbmsDbLimitedResourceTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_rdbmsDbLimitedResourceTable_pre_request; + access_multiplexer->post_request = _mfd_rdbmsDbLimitedResourceTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("rdbmsDbLimitedResourceTable:init_rdbmsDbLimitedResourceTable", + "Registering rdbmsDbLimitedResourceTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("rdbmsDbLimitedResourceTable", handler, + rdbmsDbLimitedResourceTable_oid, + rdbmsDbLimitedResourceTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table rdbmsDbLimitedResourceTable\n"); + return; + } + reginfo->my_reg_void = &rdbmsDbLimitedResourceTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + rdbmsDbLimitedResourceTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != rdbmsDbLimitedResourceTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(rdbmsDbLimitedResourceTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _rdbmsDbLimitedResourceTable_initialize_interface */ + +void +rdbmsDbLimitedResourceTable_valid_columns_set(netsnmp_column_info *vc) +{ + rdbmsDbLimitedResourceTable_if_ctx.tbl_info.valid_columns = vc; +} /* rdbmsDbLimitedResourceTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +rdbmsDbLimitedResourceTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbLimitedResourceTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * rdbmsDbLimitedResourceName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_rdbmsDbLimitedResourceName; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_rdbmsDbLimitedResourceName, 0x00, sizeof(var_rdbmsDbLimitedResourceName) ); + var_rdbmsDbLimitedResourceName.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = &var_rdbmsDbLimitedResourceName; var_rdbmsDbLimitedResourceName.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_index_to_oid","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + /* rdbmsDbLimitedResourceName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + snmp_set_var_value(&var_rdbmsDbLimitedResourceName, (u_char*)&mib_idx->rdbmsDbLimitedResourceName, + mib_idx->rdbmsDbLimitedResourceName_len * sizeof(mib_idx->rdbmsDbLimitedResourceName[0])); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_rdbmsDbIndex); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbLimitedResourceTable_index_to_oid */ + +/** + * extract rdbmsDbLimitedResourceTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +rdbmsDbLimitedResourceTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbLimitedResourceTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * rdbmsDbLimitedResourceName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_rdbmsDbLimitedResourceName; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_rdbmsDbLimitedResourceName, 0x00, sizeof(var_rdbmsDbLimitedResourceName) ); + var_rdbmsDbLimitedResourceName.type = ASN_OCTET_STR; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = &var_rdbmsDbLimitedResourceName; var_rdbmsDbLimitedResourceName.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_rdbmsDbIndex ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + /* + * NOTE: val_len is in bytes, rdbmsDbLimitedResourceName_len might not be + */ + if(var_rdbmsDbLimitedResourceName.val_len > sizeof(mib_idx->rdbmsDbLimitedResourceName)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->rdbmsDbLimitedResourceName, var_rdbmsDbLimitedResourceName.val.string, var_rdbmsDbLimitedResourceName.val_len); + mib_idx->rdbmsDbLimitedResourceName_len = var_rdbmsDbLimitedResourceName.val_len / sizeof(mib_idx->rdbmsDbLimitedResourceName[0]); + } + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbLimitedResourceTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a rdbmsDbLimitedResourceTable_rowreq_ctx + */ +rdbmsDbLimitedResourceTable_rowreq_ctx * +rdbmsDbLimitedResourceTable_allocate_rowreq_ctx(void) +{ + rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(rdbmsDbLimitedResourceTable_rowreq_ctx); + + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "rdbmsDbLimitedResourceTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->rdbmsDbLimitedResourceTable_data_list = NULL; + rowreq_ctx->rdbmsDbLimitedResourceTable_reg = rdbmsDbLimitedResourceTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* rdbmsDbLimitedResourceTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a rdbmsDbLimitedResourceTable_rowreq_ctx + */ +void +rdbmsDbLimitedResourceTable_release_rowreq_ctx(rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:rdbmsDbLimitedResourceTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* rdbmsDbLimitedResourceTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbLimitedResourceTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = rdbmsDbLimitedResourceTable_pre_request(rdbmsDbLimitedResourceTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable","error %d from " + "rdbmsDbLimitedResourceTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbLimitedResourceTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbLimitedResourceTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx; + int rc = rdbmsDbLimitedResourceTable_post_request(rdbmsDbLimitedResourceTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable","error %d from " + "rdbmsDbLimitedResourceTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(rdbmsDbLimitedResourceTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(rdbmsDbLimitedResourceTable_if_ctx.container, rowreq_ctx); + rdbmsDbLimitedResourceTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbLimitedResourceTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbLimitedResourceTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_mfd_rdbmsDbLimitedResourceTable_object_lookup","called\n")); + + /* + * get our context from mfd + * rdbmsDbLimitedResourceTable_interface_ctx *if_ctx = + * (rdbmsDbLimitedResourceTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + rdbmsDbLimitedResourceTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbLimitedResourceTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbLimitedResourceTable_get_column( rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_mfd_rdbmsDbLimitedResourceTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbLimitedResourceID(2)/AutonomousType/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h */ + case COLUMN_RDBMSDBLIMITEDRESOURCEID: + var->type = ASN_OBJECT_ID; +rc = rdbmsDbLimitedResourceID_get(rowreq_ctx, (oid **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbLimitedResourceLimit(3)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/R/d/h */ + case COLUMN_RDBMSDBLIMITEDRESOURCELIMIT: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = rdbmsDbLimitedResourceLimit_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* rdbmsDbLimitedResourceCurrent(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h */ + case COLUMN_RDBMSDBLIMITEDRESOURCECURRENT: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = rdbmsDbLimitedResourceCurrent_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* rdbmsDbLimitedResourceHighwater(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h */ + case COLUMN_RDBMSDBLIMITEDRESOURCEHIGHWATER: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = rdbmsDbLimitedResourceHighwater_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* rdbmsDbLimitedResourceFailures(6)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h */ + case COLUMN_RDBMSDBLIMITEDRESOURCEFAILURES: + var->val_len = sizeof(u_long); + var->type = ASN_COUNTER; +rc = rdbmsDbLimitedResourceFailures_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* rdbmsDbLimitedResourceDescription(7)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBLIMITEDRESOURCEDESCRIPTION: + var->type = ASN_OCTET_STR; +rc = rdbmsDbLimitedResourceDescription_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbLimitedResourceTable_get_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbLimitedResourceTable_get_column */ + +int +_mfd_rdbmsDbLimitedResourceTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_mfd_rdbmsDbLimitedResourceTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbLimitedResourceTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbLimitedResourceTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for rdbmsDbLimitedResourceTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return rdbmsDbLimitedResourceTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + rdbmsDbLimitedResourceTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in rdbmsDbLimitedResourceTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + rdbmsDbLimitedResourceTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_rdbmsDbLimitedResourceTable_container_init(rdbmsDbLimitedResourceTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbLimitedResourceTable:_rdbmsDbLimitedResourceTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + rdbmsDbLimitedResourceTable_oid, + rdbmsDbLimitedResourceTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for rdbmsDbLimitedResourceTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + rdbmsDbLimitedResourceTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("rdbmsDbLimitedResourceTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "rdbmsDbLimitedResourceTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _rdbmsDbLimitedResourceTable_container_init */ + diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.h new file mode 100644 index 0000000..c76fd43 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_interface.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_interface.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_interface.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_INTERFACE_H +#define RDBMSDBLIMITEDRESOURCETABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "rdbmsDbLimitedResourceTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _rdbmsDbLimitedResourceTable_initialize_interface(rdbmsDbLimitedResourceTable_registration_ptr user_ctx, + u_long flags); + + rdbmsDbLimitedResourceTable_rowreq_ctx * rdbmsDbLimitedResourceTable_allocate_rowreq_ctx(void); +void rdbmsDbLimitedResourceTable_release_rowreq_ctx(rdbmsDbLimitedResourceTable_rowreq_ctx *rowreq_ctx); + +int rdbmsDbLimitedResourceTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbLimitedResourceTable_mib_index *mib_idx); +int rdbmsDbLimitedResourceTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbLimitedResourceTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void rdbmsDbLimitedResourceTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_INTERFACE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_oids.h b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_oids.h new file mode 100644 index 0000000..2d50d40 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbLimitedResourceTable/rdbmsDbLimitedResourceTable_oids.h @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------- + * rdbmsDbLimitedResourceTable_oids.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbLimitedResourceTable_oids.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBLIMITEDRESOURCETABLE_OIDS_H +#define RDBMSDBLIMITEDRESOURCETABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table rdbmsDbLimitedResourceTable */ +#define RDBMSDBLIMITEDRESOURCETABLE_OID 1,3,6,1,2,1,39,1,4 +#define COLUMN_RDBMSDBLIMITEDRESOURCENAME 1 +#define COLUMN_RDBMSDBLIMITEDRESOURCEID 2 +#define COLUMN_RDBMSDBLIMITEDRESOURCELIMIT 3 +#define COLUMN_RDBMSDBLIMITEDRESOURCECURRENT 4 +#define COLUMN_RDBMSDBLIMITEDRESOURCEHIGHWATER 5 +#define COLUMN_RDBMSDBLIMITEDRESOURCEFAILURES 6 +#define COLUMN_RDBMSDBLIMITEDRESOURCEDESCRIPTION 7 + +#define RDBMSDBLIMITEDRESOURCETABLE_MIN_COL COLUMN_RDBMSDBLIMITEDRESOURCEID +#define RDBMSDBLIMITEDRESOURCETABLE_MAX_COL COLUMN_RDBMSDBLIMITEDRESOURCEDESCRIPTION + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBLIMITEDRESOURCETABLE_OIDS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.c b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.c new file mode 100644 index 0000000..5082c83 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.c @@ -0,0 +1,130 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbParamTable.h" + +#include + +#include "rdbmsDbParamTable_interface.h" + +oid rdbmsDbParamTable_oid[] = { RDBMSDBPARAMTABLE_OID }; +int rdbmsDbParamTable_oid_size = OID_LENGTH(rdbmsDbParamTable_oid); + +void initialize_table_rdbmsDbParamTable(void); + + +/** + * Initializes the rdbmsDbParamTable module + */ +void +init_rdbmsDbParamTable(void) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:init_rdbmsDbParamTable","called\n")); + + /* + * TODO:300:o: Perform rdbmsDbParamTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("rdbmsDbParamTable")) + initialize_table_rdbmsDbParamTable(); + +} /* init_rdbmsDbParamTable */ + +/** + * Initialize the table rdbmsDbParamTable + * (Define its contents and how it's structured) + */ +void +initialize_table_rdbmsDbParamTable(void) +{ + rdbmsDbParamTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:initialize_table_rdbmsDbParamTable","called\n")); + + /* + * TODO:301:o: Perform rdbmsDbParamTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize rdbmsDbParamTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("rdbmsDbParamTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _rdbmsDbParamTable_initialize_interface(user_context, flags); +} /* initialize_table_rdbmsDbParamTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +rdbmsDbParamTable_pre_request(rdbmsDbParamTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform rdbmsDbParamTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbParamTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +rdbmsDbParamTable_post_request(rdbmsDbParamTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_post_request","called\n")); + + /* + * TODO:511:o: Perform rdbmsDbParamTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbParamTable_post_request */ + + +/** @{ */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.h new file mode 100644 index 0000000..bfcf5fd --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable.h @@ -0,0 +1,214 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_H +#define RDBMSDBPARAMTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(RDBMS-MIB/rdbmsDbParamTable/rdbmsDbParamTable_interface); +config_require(RDBMS-MIB/rdbmsDbParamTable/rdbmsDbParamTable_data_access); +config_require(RDBMS-MIB/rdbmsDbParamTable/rdbmsDbParamTable_data_get); +config_require(RDBMS-MIB/rdbmsDbParamTable/rdbmsDbParamTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "rdbmsDbParamTable_oids.h" + +/* enum definions */ +#include "rdbmsDbParamTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_rdbmsDbParamTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbParamTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbParamTable is subid 3 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.3, length: 9 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review rdbmsDbParamTable registration context. + */ +typedef netsnmp_data_list * rdbmsDbParamTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review rdbmsDbParamTable data context structure. + * This structure is used to represent the data for rdbmsDbParamTable. + */ +/* + * This structure contains storage for all the columns defined in the + * rdbmsDbParamTable. + */ +typedef struct rdbmsDbParamTable_data_s { + + /* + * rdbmsDbParamID(3)/AutonomousType/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h + */ + oid rdbmsDbParamID[128]; +size_t rdbmsDbParamID_len; /* # of oid elements, not bytes */ + + /* + * rdbmsDbParamCurrValue(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + char rdbmsDbParamCurrValue[255]; +size_t rdbmsDbParamCurrValue_len; /* # of char elements, not bytes */ + + /* + * rdbmsDbParamComment(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + char rdbmsDbParamComment[255]; +size_t rdbmsDbParamComment_len; /* # of char elements, not bytes */ + +} rdbmsDbParamTable_data; + + +/* + * TODO:120:r: |-> Review rdbmsDbParamTable mib index. + * This structure is used to represent the index for rdbmsDbParamTable. + */ +typedef struct rdbmsDbParamTable_mib_index_s { + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + /* + * rdbmsDbParamName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + char rdbmsDbParamName[64]; + size_t rdbmsDbParamName_len; + + /* + * rdbmsDbParamSubIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbParamSubIndex; + + +} rdbmsDbParamTable_mib_index; + + /* + * TODO:121:r: | |-> Review rdbmsDbParamTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + * Guessing 128 - col/entry(2) - oid len(9) +*/ +#define MAX_rdbmsDbParamTable_IDX_LEN 67 + + +/* ********************************************************************* + * TODO:130:o: |-> Review rdbmsDbParamTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * rdbmsDbParamTable_rowreq_ctx pointer. + */ +typedef struct rdbmsDbParamTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_rdbmsDbParamTable_IDX_LEN]; + + rdbmsDbParamTable_mib_index tbl_idx; + + rdbmsDbParamTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + rdbmsDbParamTable_registration_ptr rdbmsDbParamTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to rdbmsDbParamTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *rdbmsDbParamTable_data_list; + +} rdbmsDbParamTable_rowreq_ctx; + +typedef struct rdbmsDbParamTable_ref_rowreq_ctx_s { + rdbmsDbParamTable_rowreq_ctx *rowreq_ctx; +} rdbmsDbParamTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int rdbmsDbParamTable_pre_request(rdbmsDbParamTable_registration_ptr user_context); + int rdbmsDbParamTable_post_request(rdbmsDbParamTable_registration_ptr user_context); + + +extern oid rdbmsDbParamTable_oid[]; +extern int rdbmsDbParamTable_oid_size; + + +#include "rdbmsDbParamTable_interface.h" +#include "rdbmsDbParamTable_data_access.h" +#include "rdbmsDbParamTable_data_get.h" +#include "rdbmsDbParamTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.c b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.c new file mode 100644 index 0000000..e8d09cd --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.c @@ -0,0 +1,394 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_data_access.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_data_access.c,v 1.6 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbParamTable.h" +#include "rdbmsDbParamTable_data_access.h" +#include "pg_array.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbParamTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbParamTable is subid 3 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.3, length: 9 +*/ + +/** + * initialization for rdbmsDbParamTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param rdbmsDbParamTable_reg + * Pointer to rdbmsDbParamTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +rdbmsDbParamTable_init_data(rdbmsDbParamTable_registration_ptr rdbmsDbParamTable_reg) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_init_data","called\n")); + + /* + * TODO:303:o: Initialize rdbmsDbParamTable data. + */ + + return MFD_SUCCESS; +} /* rdbmsDbParamTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +rdbmsDbParamTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to rdbmsDbParamTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up rdbmsDbParamTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = RDBMSDBPARAMTABLE_CACHE_TIMEOUT; /* seconds */ +} /* rdbmsDbParamTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement rdbmsDbParamTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * rdbmsDbParamTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +rdbmsDbParamTable_cache_load(netsnmp_container *container) +{ + rdbmsDbParamTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + int i, j, resultCount, errorCode = MFD_SUCCESS, elements; + + long rdbmsDbParamSubIndex = 0; + PGresult *qryRes; + char **array; + + int rdbmsDbIndex; + int rdbmsDbParamCurrValue_len, rdbmsDbParamComment_len = 0, rdbmsDbParamName_len; + char rdbmsDbParamCurrValue[255], rdbmsDbParamComment[255] = { "" }, *tmp, rdbmsDbParamName[64]; + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_cache_load","called\n")); + + /* + * TODO:351:M: |-> Load/update data in the rdbmsDbParamTable container. + * loop over your rdbmsDbParamTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + + if (PQstatus(dbconn) == CONNECTION_OK) + qryRes = PQexec(dbconn, "SELECT oid, datname, datconfig FROM pg_database"); + else { + snmp_log(LOG_ERR, "Can't get connected to the database"); + return MFD_RESOURCE_UNAVAILABLE; + } + if (PQresultStatus(qryRes) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database"); + PQclear(qryRes); + /*PQfinish(dbconn);*/ + /* It's probably an error if I didn't find *any* databases */ + return MFD_RESOURCE_UNAVAILABLE; + } + + resultCount = PQntuples(qryRes); + for (i = 0; i < resultCount; i++) { + rdbmsDbIndex = atoi(PQgetvalue(qryRes, i, 0)); + array = pg_text_array_parse(PQgetvalue(qryRes, i, 2), &elements); + if (!array) { + snmp_log(LOG_INFO, "No rdbmsDbParamTable values found for database %s\n", PQgetvalue(qryRes, i, 1)); + continue; + } + for (j = 0; j < elements; j++) { + tmp = strchr(array[j], '='); + if (!tmp) continue; + memset(rdbmsDbParamName, 0, 64); + strncpy(rdbmsDbParamName, array[j], ((tmp - array[j]) < 64 ? (tmp - array[j]) : 64)); + strncpy(rdbmsDbParamCurrValue, tmp+1, 255); + rdbmsDbParamName_len = strlen(rdbmsDbParamName); + rdbmsDbParamCurrValue_len = strlen(rdbmsDbParamCurrValue); + + /* + * TODO:352:M: | |-> set indexes in new rdbmsDbParamTable rowreq context. + */ + rowreq_ctx = rdbmsDbParamTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + errorCode = MFD_RESOURCE_UNAVAILABLE; + break; + } + if(MFD_SUCCESS != rdbmsDbParamTable_indexes_set(rowreq_ctx + , rdbmsDbIndex + , rdbmsDbParamName, rdbmsDbParamName_len + , rdbmsDbParamSubIndex + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "rdbmsDbParamTable cache.\n"); + rdbmsDbParamTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + + /* + * TODO:352:r: | |-> populate rdbmsDbParamTable data context. + * Populate data context here. (optionally, delay until row prep) + */ + rowreq_ctx->data.rdbmsDbParamID_len = 128; + rowreq_ctx->data.rdbmsDbParamCurrValue_len = 255; + rowreq_ctx->data.rdbmsDbParamComment_len = 255; + /* + * TRANSIENT or semi-TRANSIENT data: + * copy data or save any info needed to do it in row_prep. + */ + /* + * setup/save data for rdbmsDbParamID + * rdbmsDbParamID(3)/AutonomousType/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h + */ + /* + * TODO:246:r: |-> Define rdbmsDbParamID mapping. + * Map values between raw/native values and MIB values + * + * if(MFD_SUCCESS != + * rdbmsDbParamID_map(&rowreq_ctx->data.rdbmsDbParamID, &rowreq_ctx->data.rdbmsDbParamID_len, + * rdbmsDbParamID, rdbmsDbParamID_len, 0)) { + * return MFD_ERROR; + * } + */ + /* + * make sure there is enough space for rdbmsDbParamID data + */ + /* See comment in rdbmsDbParamID_get() -- we don't need this value + if ((NULL == rowreq_ctx->data.rdbmsDbParamID) || + (rowreq_ctx->data.rdbmsDbParamID_len < (rdbmsDbParamID_len * sizeof(rowreq_ctx->data.rdbmsDbParamID[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + errorCode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbParamID_len = rdbmsDbParamID_len * sizeof(rowreq_ctx->data.rdbmsDbParamID[0]); + memcpy( rowreq_ctx->data.rdbmsDbParamID, rdbmsDbParamID, rowreq_ctx->data.rdbmsDbParamID_len ); + */ + + /* + * setup/save data for rdbmsDbParamCurrValue + * rdbmsDbParamCurrValue(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + /* + * TODO:246:r: |-> Define rdbmsDbParamCurrValue mapping. + * Map values between raw/native values and MIB values + * + * if(MFD_SUCCESS != + * rdbmsDbParamCurrValue_map(&rowreq_ctx->data.rdbmsDbParamCurrValue, &rowreq_ctx->data.rdbmsDbParamCurrValue_len, + * rdbmsDbParamCurrValue, rdbmsDbParamCurrValue_len, 0)) { + * return MFD_ERROR; + * } + */ + /* + * make sure there is enough space for rdbmsDbParamCurrValue data + */ + if ((NULL == rowreq_ctx->data.rdbmsDbParamCurrValue) || + (rowreq_ctx->data.rdbmsDbParamCurrValue_len < (rdbmsDbParamCurrValue_len * sizeof(rowreq_ctx->data.rdbmsDbParamCurrValue[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + errorCode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbParamCurrValue_len = rdbmsDbParamCurrValue_len * sizeof(rowreq_ctx->data.rdbmsDbParamCurrValue[0]); + memcpy( rowreq_ctx->data.rdbmsDbParamCurrValue, rdbmsDbParamCurrValue, rowreq_ctx->data.rdbmsDbParamCurrValue_len ); + + /* + * setup/save data for rdbmsDbParamComment + * rdbmsDbParamComment(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + /* + * TODO:246:r: |-> Define rdbmsDbParamComment mapping. + * Map values between raw/native values and MIB values + * + * if(MFD_SUCCESS != + * rdbmsDbParamComment_map(&rowreq_ctx->data.rdbmsDbParamComment, &rowreq_ctx->data.rdbmsDbParamComment_len, + * rdbmsDbParamComment, rdbmsDbParamComment_len, 0)) { + * return MFD_ERROR; + * } + */ + /* + * make sure there is enough space for rdbmsDbParamComment data + */ + if ((NULL == rowreq_ctx->data.rdbmsDbParamComment) || + (rowreq_ctx->data.rdbmsDbParamComment_len < (rdbmsDbParamComment_len * sizeof(rowreq_ctx->data.rdbmsDbParamComment[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + errorCode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbParamComment_len = rdbmsDbParamComment_len * sizeof(rowreq_ctx->data.rdbmsDbParamComment[0]); + memcpy( rowreq_ctx->data.rdbmsDbParamComment, rdbmsDbParamComment, rowreq_ctx->data.rdbmsDbParamComment_len ); + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + pg_text_array_free(array, elements); + } + + DEBUGMSGT(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_cache_load", + "inserted %d records\n", count)); + + PQclear(qryRes); + return errorCode; +} /* rdbmsDbParamTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +rdbmsDbParamTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_cache_free","called\n")); + + /* + * TODO:380:M: Free rdbmsDbParamTable cache. + */ +} /* rdbmsDbParamTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +rdbmsDbParamTable_row_prep( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* rdbmsDbParamTable_row_prep */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.h new file mode 100644 index 0000000..5bdccf1 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_access.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_data_access.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_data_access.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_DATA_ACCESS_H +#define RDBMSDBPARAMTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbParamTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbParamTable is subid 3 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.3, length: 9 +*/ + + + int rdbmsDbParamTable_init_data(rdbmsDbParamTable_registration_ptr rdbmsDbParamTable_reg); + + +/* + * TODO:180:o: Review rdbmsDbParamTable cache timeout. + * The number of seconds before the cache times out + */ +#define RDBMSDBPARAMTABLE_CACHE_TIMEOUT 60 + +void rdbmsDbParamTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int rdbmsDbParamTable_cache_load(netsnmp_container *container); +void rdbmsDbParamTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int rdbmsDbParamTable_row_prep( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_DATA_ACCESS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.c b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.c new file mode 100644 index 0000000..77537a2 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.c @@ -0,0 +1,732 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_data_get.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_data_get.c,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbParamTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement rdbmsDbParamTable get routines. + * TODO:240:M: Implement rdbmsDbParamTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbParamTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbParamTable is subid 3 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.3, length: 9 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement rdbmsDbParamTable data context functions. + */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbParamEntry.rdbmsDbParamName + * rdbmsDbParamName is subid 1 of rdbmsDbParamEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.39.1.3.1.1 + * Description: +The name of a configuration parameter for a database. This + name is product-specific. The length is limited to 64 + characters to constrain the number of sub-identifiers needed + for instance identification (and to minimize network + traffic). + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 1 - 64; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 64) + * + * + * + * NOTE: NODE rdbmsDbParamName IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbParamName.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbParamName_map(char **mib_rdbmsDbParamName_val_ptr_ptr, size_t *mib_rdbmsDbParamName_val_ptr_len_ptr, char *raw_rdbmsDbParamName_val_ptr, size_t raw_rdbmsDbParamName_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbParamName_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbParamName_val_ptr_ptr) && (NULL != mib_rdbmsDbParamName_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamName_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbParamName non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbParamName_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbParamName_val_ptr_ptr) || (*mib_rdbmsDbParamName_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbParamName_val_ptr_ptr = realloc( *mib_rdbmsDbParamName_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbParamName_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbParamName_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbParamName_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbParamName_val_ptr_ptr, raw_rdbmsDbParamName_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbParamName_map */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbParamEntry.rdbmsDbParamSubIndex + * rdbmsDbParamSubIndex is subid 2 of rdbmsDbParamEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.39.1.3.1.2 + * Description: +The subindex value for this parameter. If the parameter is + naturally considered to contain a variable number of members + of a class, e.g. members of the DBA user group, or files + which are part of the database, then it must be presented as + a set of rows. If, on the other hand, the parameter + represents a set of choices from a class, e.g. the + permissions on a file or the options chosen out of the set of + all options allowed, AND is guaranteed to always fit in the + 255 character length of a DisplayString, then it may be + presented as a comma separated list with a subindex value of + one. Zero may not be used as a value. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + * + * + * + * NOTE: NODE rdbmsDbParamSubIndex IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbParamSubIndex.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbParamSubIndex_map(long *mib_rdbmsDbParamSubIndex_val_ptr, long raw_rdbmsDbParamSubIndex_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbParamSubIndex_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamSubIndex_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbParamSubIndex mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbParamSubIndex_val_ptr) = raw_rdbmsDbParamSubIndex_val; + + return MFD_SUCCESS; +} /* rdbmsDbParamSubIndex_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +rdbmsDbParamTable_indexes_set_tbl_idx(rdbmsDbParamTable_mib_index *tbl_idx, long rdbmsDbIndex_val, char *rdbmsDbParamName_val_ptr, size_t rdbmsDbParamName_val_ptr_len, long rdbmsDbParamSubIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_indexes_set_tbl_idx","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + /* rdbmsDbParamName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + tbl_idx->rdbmsDbParamName_len = sizeof(tbl_idx->rdbmsDbParamName); + /* + * make sure there is enough space for rdbmsDbParamName data + */ + if ((NULL == tbl_idx->rdbmsDbParamName) || + (tbl_idx->rdbmsDbParamName_len < (rdbmsDbParamName_val_ptr_len * sizeof(tbl_idx->rdbmsDbParamName[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->rdbmsDbParamName_len = rdbmsDbParamName_val_ptr_len * sizeof(tbl_idx->rdbmsDbParamName[0]); + memcpy( tbl_idx->rdbmsDbParamName, rdbmsDbParamName_val_ptr, tbl_idx->rdbmsDbParamName_len ); + + /* rdbmsDbParamSubIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbParamSubIndex = rdbmsDbParamSubIndex_val; + + + return MFD_SUCCESS; +} /* rdbmsDbParamTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +rdbmsDbParamTable_indexes_set(rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val, char *rdbmsDbParamName_val_ptr, size_t rdbmsDbParamName_val_ptr_len, long rdbmsDbParamSubIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_indexes_set","called\n")); + + if(MFD_SUCCESS != rdbmsDbParamTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , rdbmsDbIndex_val + , rdbmsDbParamName_val_ptr, rdbmsDbParamName_val_ptr_len + , rdbmsDbParamSubIndex_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != rdbmsDbParamTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsDbParamTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbParamEntry.rdbmsDbParamID + * rdbmsDbParamID is subid 3 of rdbmsDbParamEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.3.1.3 + * Description: +The ID of the parameter which may be described in some other + MIB (e.g., an enterprise-specific MIB module). If there is + no ID for this rdbmsDbParamName, attempts to access this + object will return noSuchName (SNMPv1) or noSuchInstance + (SNMPv2). + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is AutonomousType (based on perltype OBJECTID) + * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) + * This data type requires a length. (Max 2147483647) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbParamID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbParamID_map(oid **mib_rdbmsDbParamID_val_ptr_ptr, size_t *mib_rdbmsDbParamID_val_ptr_len_ptr, oid *raw_rdbmsDbParamID_val_ptr, size_t raw_rdbmsDbParamID_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbParamID_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbParamID_val_ptr_ptr) && (NULL != mib_rdbmsDbParamID_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamID_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbParamID non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbParamID_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbParamID_val_ptr_ptr) || (*mib_rdbmsDbParamID_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbParamID_val_ptr_ptr = realloc( *mib_rdbmsDbParamID_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbParamID_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbParamID_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbParamID_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbParamID_val_ptr_ptr, raw_rdbmsDbParamID_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbParamID_map */ + +/** + * Extract the current value of the rdbmsDbParamID data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbParamID_val_ptr_ptr + * Pointer to storage for a oid variable + * @param rdbmsDbParamID_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbParamID. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbParamID_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbParamID_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbParamID_get( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, oid **rdbmsDbParamID_val_ptr_ptr, size_t *rdbmsDbParamID_val_ptr_len_ptr ) +{ + /* Until we have a parameter with multiple values that won't fit into + * a 255 character string when rendered as a comma-separated list, we + * don't need a value at this OID */ + return MFD_SKIP; + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbParamID_val_ptr_ptr) && (NULL != *rdbmsDbParamID_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbParamID_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamID_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbParamID data. + * set (* rdbmsDbParamID_val_ptr_ptr ) and (* rdbmsDbParamID_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbParamID data + */ + if ((NULL == (* rdbmsDbParamID_val_ptr_ptr )) || + ((* rdbmsDbParamID_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbParamID_len * sizeof((* rdbmsDbParamID_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbParamID data + */ + (* rdbmsDbParamID_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbParamID_len * sizeof((* rdbmsDbParamID_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbParamID_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbParamID_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbParamID_len * sizeof((* rdbmsDbParamID_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbParamID_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbParamID, (* rdbmsDbParamID_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbParamID_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbParamEntry.rdbmsDbParamCurrValue + * rdbmsDbParamCurrValue is subid 4 of rdbmsDbParamEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.3.1.4 + * Description: +The value for a configuration parameter now in effect, the + actual setting for the database. While there may multiple + values in the temporal domain of interest (for instance, the + + value to take effect at the next restart), this is the + current setting. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbParamCurrValue.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbParamCurrValue_map(char **mib_rdbmsDbParamCurrValue_val_ptr_ptr, size_t *mib_rdbmsDbParamCurrValue_val_ptr_len_ptr, char *raw_rdbmsDbParamCurrValue_val_ptr, size_t raw_rdbmsDbParamCurrValue_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbParamCurrValue_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbParamCurrValue_val_ptr_ptr) && (NULL != mib_rdbmsDbParamCurrValue_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamCurrValue_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbParamCurrValue non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbParamCurrValue_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbParamCurrValue_val_ptr_ptr) || (*mib_rdbmsDbParamCurrValue_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbParamCurrValue_val_ptr_ptr = realloc( *mib_rdbmsDbParamCurrValue_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbParamCurrValue_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbParamCurrValue_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbParamCurrValue_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbParamCurrValue_val_ptr_ptr, raw_rdbmsDbParamCurrValue_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbParamCurrValue_map */ + +/** + * Extract the current value of the rdbmsDbParamCurrValue data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbParamCurrValue_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbParamCurrValue_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbParamCurrValue. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbParamCurrValue_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbParamCurrValue_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbParamCurrValue_get( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbParamCurrValue_val_ptr_ptr, size_t *rdbmsDbParamCurrValue_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbParamCurrValue_val_ptr_ptr) && (NULL != *rdbmsDbParamCurrValue_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbParamCurrValue_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamCurrValue_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbParamCurrValue data. + * set (* rdbmsDbParamCurrValue_val_ptr_ptr ) and (* rdbmsDbParamCurrValue_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbParamCurrValue data + */ + if ((NULL == (* rdbmsDbParamCurrValue_val_ptr_ptr )) || + ((* rdbmsDbParamCurrValue_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbParamCurrValue_len * sizeof((* rdbmsDbParamCurrValue_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbParamCurrValue data + */ + (* rdbmsDbParamCurrValue_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbParamCurrValue_len * sizeof((* rdbmsDbParamCurrValue_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbParamCurrValue_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbParamCurrValue_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbParamCurrValue_len * sizeof((* rdbmsDbParamCurrValue_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbParamCurrValue_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbParamCurrValue, (* rdbmsDbParamCurrValue_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbParamCurrValue_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbParamEntry.rdbmsDbParamComment + * rdbmsDbParamComment is subid 5 of rdbmsDbParamEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.3.1.5 + * Description: +Annotation which describes the purpose of a configuration + parameter or the reason for a particular parameter's + setting. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbParamComment.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbParamComment_map(char **mib_rdbmsDbParamComment_val_ptr_ptr, size_t *mib_rdbmsDbParamComment_val_ptr_len_ptr, char *raw_rdbmsDbParamComment_val_ptr, size_t raw_rdbmsDbParamComment_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbParamComment_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbParamComment_val_ptr_ptr) && (NULL != mib_rdbmsDbParamComment_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamComment_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbParamComment non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbParamComment_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbParamComment_val_ptr_ptr) || (*mib_rdbmsDbParamComment_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbParamComment_val_ptr_ptr = realloc( *mib_rdbmsDbParamComment_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbParamComment_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbParamComment_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbParamComment_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbParamComment_val_ptr_ptr, raw_rdbmsDbParamComment_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbParamComment_map */ + +/** + * Extract the current value of the rdbmsDbParamComment data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbParamComment_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbParamComment_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbParamComment. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbParamComment_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbParamComment_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbParamComment_get( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbParamComment_val_ptr_ptr, size_t *rdbmsDbParamComment_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbParamComment_val_ptr_ptr) && (NULL != *rdbmsDbParamComment_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbParamComment_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamComment_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbParamComment data. + * set (* rdbmsDbParamComment_val_ptr_ptr ) and (* rdbmsDbParamComment_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbParamComment data + */ + if ((NULL == (* rdbmsDbParamComment_val_ptr_ptr )) || + ((* rdbmsDbParamComment_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbParamComment_len * sizeof((* rdbmsDbParamComment_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbParamComment data + */ + (* rdbmsDbParamComment_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbParamComment_len * sizeof((* rdbmsDbParamComment_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbParamComment_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbParamComment_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbParamComment_len * sizeof((* rdbmsDbParamComment_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbParamComment_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbParamComment, (* rdbmsDbParamComment_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbParamComment_get */ + + + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.h new file mode 100644 index 0000000..d9ac635 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_get.h @@ -0,0 +1,65 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_data_get.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_data_get.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_DATA_GET_H +#define RDBMSDBPARAMTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbParamTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbParamTable is subid 3 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.3, length: 9 +*/ + /* + * indexes + */ + int rdbmsDbParamName_map(char **mib_rdbmsDbParamName_val_ptr_ptr, size_t *mib_rdbmsDbParamName_val_ptr_len_ptr, char *raw_rdbmsDbParamName_val_ptr, size_t raw_rdbmsDbParamName_val_ptr_len, int allow_realloc); + int rdbmsDbParamSubIndex_map(long *mib_rdbmsDbParamSubIndex_val_ptr, long raw_rdbmsDbParamSubIndex_val); + + int rdbmsDbParamID_map(oid **mib_rdbmsDbParamID_val_ptr_ptr, size_t *mib_rdbmsDbParamID_val_ptr_len_ptr, oid *raw_rdbmsDbParamID_val_ptr, size_t raw_rdbmsDbParamID_val_ptr_len, int allow_realloc); + int rdbmsDbParamID_get( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, oid **rdbmsDbParamID_val_ptr_ptr, size_t *rdbmsDbParamID_val_ptr_len_ptr ); + int rdbmsDbParamCurrValue_map(char **mib_rdbmsDbParamCurrValue_val_ptr_ptr, size_t *mib_rdbmsDbParamCurrValue_val_ptr_len_ptr, char *raw_rdbmsDbParamCurrValue_val_ptr, size_t raw_rdbmsDbParamCurrValue_val_ptr_len, int allow_realloc); + int rdbmsDbParamCurrValue_get( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbParamCurrValue_val_ptr_ptr, size_t *rdbmsDbParamCurrValue_val_ptr_len_ptr ); + int rdbmsDbParamComment_map(char **mib_rdbmsDbParamComment_val_ptr_ptr, size_t *mib_rdbmsDbParamComment_val_ptr_len_ptr, char *raw_rdbmsDbParamComment_val_ptr, size_t raw_rdbmsDbParamComment_val_ptr_len, int allow_realloc); + int rdbmsDbParamComment_get( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbParamComment_val_ptr_ptr, size_t *rdbmsDbParamComment_val_ptr_len_ptr ); + + +int rdbmsDbParamTable_indexes_set_tbl_idx(rdbmsDbParamTable_mib_index *tbl_idx, long rdbmsDbIndex_val, char *rdbmsDbParamName_val_ptr, size_t rdbmsDbParamName_val_ptr_len, long rdbmsDbParamSubIndex_val); +int rdbmsDbParamTable_indexes_set(rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val, char *rdbmsDbParamName_val_ptr, size_t rdbmsDbParamName_val_ptr_len, long rdbmsDbParamSubIndex_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_DATA_GET_H */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.c b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.c new file mode 100644 index 0000000..073d8c9 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.c @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_data_set.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_data_set.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsDbParamTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.h new file mode 100644 index 0000000..228dfeb --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_data_set.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_data_set.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_data_set.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_DATA_SET_H +#define RDBMSDBPARAMTABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_DATA_SET_H */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_enums.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_enums.h new file mode 100644 index 0000000..8423de9 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_enums.h @@ -0,0 +1,47 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_enums.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_enums.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_ENUMS_H +#define RDBMSDBPARAMTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table rdbmsDbParamTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_ENUMS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.c b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.c new file mode 100644 index 0000000..0603155 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.c @@ -0,0 +1,739 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_interface.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_interface.c,v 1.3 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbParamTable.h" +#include "rdbmsDbParamTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbParamTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbParamTable is subid 3 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.3, length: 9 +*/ +typedef struct rdbmsDbParamTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + rdbmsDbParamTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} rdbmsDbParamTable_interface_ctx; + +static rdbmsDbParamTable_interface_ctx rdbmsDbParamTable_if_ctx; + +static void _rdbmsDbParamTable_container_init( + rdbmsDbParamTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_rdbmsDbParamTable_pre_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbParamTable_post_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbParamTable_object_lookup; +static Netsnmp_Node_Handler _mfd_rdbmsDbParamTable_get_values; +/** + * @internal + * Initialize the table rdbmsDbParamTable + * (Define its contents and how it's structured) + */ +void +_rdbmsDbParamTable_initialize_interface(rdbmsDbParamTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &rdbmsDbParamTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &rdbmsDbParamTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:rdbmsDbParamTable:_rdbmsDbParamTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for rdbmsDbParamTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_INTEGER, /** index: rdbmsDbIndex */ + ASN_OCTET_STR, /** index: rdbmsDbParamName */ + ASN_INTEGER, /** index: rdbmsDbParamSubIndex */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = RDBMSDBPARAMTABLE_MIN_COL; + tbl_info->max_column = RDBMSDBPARAMTABLE_MAX_COL; + + /* + * save users context + */ + rdbmsDbParamTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + rdbmsDbParamTable_init_data(reg_ptr); + + /* + * set up the container + */ + _rdbmsDbParamTable_container_init(&rdbmsDbParamTable_if_ctx); + if (NULL == rdbmsDbParamTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for rdbmsDbParamTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_rdbmsDbParamTable_object_lookup; + access_multiplexer->get_values = _mfd_rdbmsDbParamTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_rdbmsDbParamTable_pre_request; + access_multiplexer->post_request = _mfd_rdbmsDbParamTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("rdbmsDbParamTable:init_rdbmsDbParamTable", + "Registering rdbmsDbParamTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("rdbmsDbParamTable", handler, + rdbmsDbParamTable_oid, + rdbmsDbParamTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table rdbmsDbParamTable\n"); + return; + } + reginfo->my_reg_void = &rdbmsDbParamTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + rdbmsDbParamTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != rdbmsDbParamTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(rdbmsDbParamTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _rdbmsDbParamTable_initialize_interface */ + +void +rdbmsDbParamTable_valid_columns_set(netsnmp_column_info *vc) +{ + rdbmsDbParamTable_if_ctx.tbl_info.valid_columns = vc; +} /* rdbmsDbParamTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +rdbmsDbParamTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbParamTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * rdbmsDbParamName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_rdbmsDbParamName; + /* + * rdbmsDbParamSubIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbParamSubIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_rdbmsDbParamName, 0x00, sizeof(var_rdbmsDbParamName) ); + var_rdbmsDbParamName.type = ASN_OCTET_STR; + memset( &var_rdbmsDbParamSubIndex, 0x00, sizeof(var_rdbmsDbParamSubIndex) ); + var_rdbmsDbParamSubIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = &var_rdbmsDbParamName; var_rdbmsDbParamName.next_variable = &var_rdbmsDbParamSubIndex; var_rdbmsDbParamSubIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_index_to_oid","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + /* rdbmsDbParamName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + snmp_set_var_value(&var_rdbmsDbParamName, (u_char*)&mib_idx->rdbmsDbParamName, + mib_idx->rdbmsDbParamName_len * sizeof(mib_idx->rdbmsDbParamName[0])); + + /* rdbmsDbParamSubIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbParamSubIndex, (u_char*)&mib_idx->rdbmsDbParamSubIndex, + sizeof(mib_idx->rdbmsDbParamSubIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_rdbmsDbIndex); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbParamTable_index_to_oid */ + +/** + * extract rdbmsDbParamTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +rdbmsDbParamTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbParamTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * rdbmsDbParamName(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_rdbmsDbParamName; + /* + * rdbmsDbParamSubIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbParamSubIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_rdbmsDbParamName, 0x00, sizeof(var_rdbmsDbParamName) ); + var_rdbmsDbParamName.type = ASN_OCTET_STR; + memset( &var_rdbmsDbParamSubIndex, 0x00, sizeof(var_rdbmsDbParamSubIndex) ); + var_rdbmsDbParamSubIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = &var_rdbmsDbParamName; var_rdbmsDbParamName.next_variable = &var_rdbmsDbParamSubIndex; var_rdbmsDbParamSubIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbParamTable:rdbmsDbParamTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_rdbmsDbIndex ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + /* + * NOTE: val_len is in bytes, rdbmsDbParamName_len might not be + */ + if(var_rdbmsDbParamName.val_len > sizeof(mib_idx->rdbmsDbParamName)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->rdbmsDbParamName, var_rdbmsDbParamName.val.string, var_rdbmsDbParamName.val_len); + mib_idx->rdbmsDbParamName_len = var_rdbmsDbParamName.val_len / sizeof(mib_idx->rdbmsDbParamName[0]); + } + mib_idx->rdbmsDbParamSubIndex = *((long *)var_rdbmsDbParamSubIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbParamTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a rdbmsDbParamTable_rowreq_ctx + */ +rdbmsDbParamTable_rowreq_ctx * +rdbmsDbParamTable_allocate_rowreq_ctx(void) +{ + rdbmsDbParamTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(rdbmsDbParamTable_rowreq_ctx); + + DEBUGMSGTL(("internal:rdbmsDbParamTable:rdbmsDbParamTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "rdbmsDbParamTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->rdbmsDbParamTable_data_list = NULL; + rowreq_ctx->rdbmsDbParamTable_reg = rdbmsDbParamTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* rdbmsDbParamTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a rdbmsDbParamTable_rowreq_ctx + */ +void +rdbmsDbParamTable_release_rowreq_ctx(rdbmsDbParamTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbParamTable:rdbmsDbParamTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* rdbmsDbParamTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbParamTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = rdbmsDbParamTable_pre_request(rdbmsDbParamTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbParamTable","error %d from " + "rdbmsDbParamTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbParamTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbParamTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbParamTable_rowreq_ctx *rowreq_ctx; + int rc = rdbmsDbParamTable_post_request(rdbmsDbParamTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbParamTable","error %d from " + "rdbmsDbParamTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(rdbmsDbParamTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(rdbmsDbParamTable_if_ctx.container, rowreq_ctx); + rdbmsDbParamTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbParamTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbParamTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbParamTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbParamTable:_mfd_rdbmsDbParamTable_object_lookup","called\n")); + + /* + * get our context from mfd + * rdbmsDbParamTable_interface_ctx *if_ctx = + * (rdbmsDbParamTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + rdbmsDbParamTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbParamTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbParamTable_get_column( rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbParamTable:_mfd_rdbmsDbParamTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbParamID(3)/AutonomousType/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h */ + case COLUMN_RDBMSDBPARAMID: + var->type = ASN_OBJECT_ID; +rc = rdbmsDbParamID_get(rowreq_ctx, (oid **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbParamCurrValue(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBPARAMCURRVALUE: + var->type = ASN_OCTET_STR; +rc = rdbmsDbParamCurrValue_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbParamComment(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBPARAMCOMMENT: + var->type = ASN_OCTET_STR; +rc = rdbmsDbParamComment_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbParamTable_get_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbParamTable_get_column */ + +int +_mfd_rdbmsDbParamTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbParamTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:rdbmsDbParamTable:_mfd_rdbmsDbParamTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbParamTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbParamTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:rdbmsDbParamTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for rdbmsDbParamTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return rdbmsDbParamTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(rdbmsDbParamTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:rdbmsDbParamTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + rdbmsDbParamTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:rdbmsDbParamTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in rdbmsDbParamTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + rdbmsDbParamTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_rdbmsDbParamTable_container_init(rdbmsDbParamTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbParamTable:_rdbmsDbParamTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + rdbmsDbParamTable_oid, + rdbmsDbParamTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for rdbmsDbParamTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + rdbmsDbParamTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("rdbmsDbParamTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "rdbmsDbParamTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _rdbmsDbParamTable_container_init */ + diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.h new file mode 100644 index 0000000..444939c --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_interface.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_interface.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_interface.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_INTERFACE_H +#define RDBMSDBPARAMTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "rdbmsDbParamTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _rdbmsDbParamTable_initialize_interface(rdbmsDbParamTable_registration_ptr user_ctx, + u_long flags); + + rdbmsDbParamTable_rowreq_ctx * rdbmsDbParamTable_allocate_rowreq_ctx(void); +void rdbmsDbParamTable_release_rowreq_ctx(rdbmsDbParamTable_rowreq_ctx *rowreq_ctx); + +int rdbmsDbParamTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbParamTable_mib_index *mib_idx); +int rdbmsDbParamTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbParamTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void rdbmsDbParamTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_INTERFACE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_oids.h b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_oids.h new file mode 100644 index 0000000..92c43de --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbParamTable/rdbmsDbParamTable_oids.h @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------- + * rdbmsDbParamTable_oids.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbParamTable_oids.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBPARAMTABLE_OIDS_H +#define RDBMSDBPARAMTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table rdbmsDbParamTable */ +#define RDBMSDBPARAMTABLE_OID 1,3,6,1,2,1,39,1,3 +#define COLUMN_RDBMSDBPARAMNAME 1 +#define COLUMN_RDBMSDBPARAMSUBINDEX 2 +#define COLUMN_RDBMSDBPARAMID 3 +#define COLUMN_RDBMSDBPARAMCURRVALUE 4 +#define COLUMN_RDBMSDBPARAMCOMMENT 5 + +#define RDBMSDBPARAMTABLE_MIN_COL COLUMN_RDBMSDBPARAMID +#define RDBMSDBPARAMTABLE_MAX_COL COLUMN_RDBMSDBPARAMCOMMENT + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBPARAMTABLE_OIDS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.c b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.c new file mode 100644 index 0000000..aac7c37 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.c @@ -0,0 +1,124 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbTable.h" +#include "rdbmsDbTable_interface.h" + +oid rdbmsDbTable_oid[] = { RDBMSDBTABLE_OID }; +int rdbmsDbTable_oid_size = OID_LENGTH(rdbmsDbTable_oid); + +void initialize_table_rdbmsDbTable(void); + + +/** + * Initializes the rdbmsDbTable module + */ +void +init_rdbmsDbTable(void) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:init_rdbmsDbTable","called\n")); + + /* + * TODO:300:o: Perform rdbmsDbTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("rdbmsDbTable")) + initialize_table_rdbmsDbTable(); + +} /* init_rdbmsDbTable */ + +/** + * Initialize the table rdbmsDbTable + * (Define its contents and how it's structured) + */ +void +initialize_table_rdbmsDbTable(void) +{ + rdbmsDbTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:rdbmsDbTable:initialize_table_rdbmsDbTable","called\n")); + + /* + * TODO:301:o: Perform rdbmsDbTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize rdbmsDbTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("rdbmsDbTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _rdbmsDbTable_initialize_interface(user_context, flags); +} /* initialize_table_rdbmsDbTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +rdbmsDbTable_pre_request(rdbmsDbTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform rdbmsDbTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +rdbmsDbTable_post_request(rdbmsDbTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_post_request","called\n")); + + /* + * TODO:511:o: Perform rdbmsDbTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsDbTable_post_request */ + + +/** @{ */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.h new file mode 100644 index 0000000..1dbdbe2 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable.h @@ -0,0 +1,220 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_H +#define RDBMSDBTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(RDBMS-MIB/rdbmsDbTable/rdbmsDbTable_interface); +config_require(RDBMS-MIB/rdbmsDbTable/rdbmsDbTable_data_access); +config_require(RDBMS-MIB/rdbmsDbTable/rdbmsDbTable_data_get); +config_require(RDBMS-MIB/rdbmsDbTable/rdbmsDbTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "rdbmsDbTable_oids.h" + +/* enum definions */ +#include "rdbmsDbTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_rdbmsDbTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review rdbmsDbTable registration context. + */ +typedef netsnmp_data_list * rdbmsDbTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review rdbmsDbTable data context structure. + * This structure is used to represent the data for rdbmsDbTable. + */ +/* + * This structure contains storage for all the columns defined in the + * rdbmsDbTable. + */ +typedef struct rdbmsDbTable_data_s { + + /* + * rdbmsDbPrivateMibOID(2)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h + */ + oid rdbmsDbPrivateMibOID[128]; +size_t rdbmsDbPrivateMibOID_len; /* # of oid elements, not bytes */ + + /* + * rdbmsDbVendorName(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char rdbmsDbVendorName[255]; +size_t rdbmsDbVendorName_len; /* # of char elements, not bytes */ + + /* + * rdbmsDbName(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char rdbmsDbName[255]; +size_t rdbmsDbName_len; /* # of char elements, not bytes */ + + /* + * rdbmsDbContact(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H + */ + char rdbmsDbContact[255]; +size_t rdbmsDbContact_len; /* # of char elements, not bytes */ + +} rdbmsDbTable_data; + + +/* ********************************************************************* + * TODO:115:o: |-> Review rdbmsDbTable undo context. + * We're just going to use the same data structure for our + * undo_context. If you want to do something more efficent, + * define your typedef here. + */ +typedef rdbmsDbTable_data rdbmsDbTable_undo_data; + +/* + * TODO:120:r: |-> Review rdbmsDbTable mib index. + * This structure is used to represent the index for rdbmsDbTable. + */ +typedef struct rdbmsDbTable_mib_index_s { + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + +} rdbmsDbTable_mib_index; + + /* + * TODO:121:r: | |-> Review rdbmsDbTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. +*/ +#define MAX_rdbmsDbTable_IDX_LEN 1 + + +/* ********************************************************************* + * TODO:130:o: |-> Review rdbmsDbTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * rdbmsDbTable_rowreq_ctx pointer. + */ +typedef struct rdbmsDbTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_rdbmsDbTable_IDX_LEN]; + + rdbmsDbTable_mib_index tbl_idx; + + rdbmsDbTable_data data; + rdbmsDbTable_undo_data * undo; + unsigned int column_set_flags; /* flags for set columns */ + + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + rdbmsDbTable_registration_ptr rdbmsDbTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to rdbmsDbTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *rdbmsDbTable_data_list; + +} rdbmsDbTable_rowreq_ctx; + +typedef struct rdbmsDbTable_ref_rowreq_ctx_s { + rdbmsDbTable_rowreq_ctx *rowreq_ctx; +} rdbmsDbTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int rdbmsDbTable_pre_request(rdbmsDbTable_registration_ptr user_context); + int rdbmsDbTable_post_request(rdbmsDbTable_registration_ptr user_context); + + int rdbmsDbTable_check_dependencies(rdbmsDbTable_rowreq_ctx * rowreq_ctx); + int rdbmsDbTable_commit(rdbmsDbTable_rowreq_ctx * rowreq_ctx); + + void initialize_table_rdbmsDbTable(void); + +extern oid rdbmsDbTable_oid[]; +extern int rdbmsDbTable_oid_size; + + +#include "rdbmsDbTable_interface.h" +#include "rdbmsDbTable_data_access.h" +#include "rdbmsDbTable_data_get.h" +#include "rdbmsDbTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.c b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.c new file mode 100644 index 0000000..d15c924 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.c @@ -0,0 +1,377 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_data_access.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_data_access.c,v 1.5 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbTable.h" +#include "rdbmsDbTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ + +/** + * initialization for rdbmsDbTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param rdbmsDbTable_reg + * Pointer to rdbmsDbTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +rdbmsDbTable_init_data(rdbmsDbTable_registration_ptr rdbmsDbTable_reg) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_init_data","called\n")); + + return MFD_SUCCESS; +} /* rdbmsDbTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +rdbmsDbTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to rdbmsDbTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up rdbmsDbTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = RDBMSDBTABLE_CACHE_TIMEOUT; /* seconds */ + + /* JWT-TODO: Initialize cache with cache->flags here */ +} /* rdbmsDbTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement rdbmsDbTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * rdbmsDbTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +rdbmsDbTable_cache_load(netsnmp_container *container) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx; + oid rdbmsDbPrivateMibOID[128] = { 1,3,6,1,4,1,27645 }; + int i, resultCount, errorcode = MFD_SUCCESS, tmpInt; + PGresult *pg_db_qry, *pgsnmpd_tbl_qry; + char *tmpString, *db_oid, *vendor_name, *contact_name; + int vendor_name_len, contact_name_len; + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_cache_load","called\n")); + + /* + * TODO:351:M: |-> Load/update data in the rdbmsDbTable container. + * loop over your rdbmsDbTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. */ + + if (PQstatus(dbconn) == CONNECTION_OK) + pg_db_qry = PQexec(dbconn, "SELECT oid, datname FROM pg_database"); + else { + snmp_log(LOG_ERR, "Can't get connected to the database"); + return MFD_RESOURCE_UNAVAILABLE; + } + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database"); + PQclear(pg_db_qry); + /*PQfinish(dbconn); */ + /* It's probably an error if I didn't find *any* databases */ + return MFD_RESOURCE_UNAVAILABLE; + } + + resultCount = PQntuples(pg_db_qry); + + for (i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new rdbmsDbTable rowreq context. + */ + rowreq_ctx = rdbmsDbTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + errorcode = MFD_RESOURCE_UNAVAILABLE; + break; + } + db_oid = PQgetvalue(pg_db_qry, i, 0); + if(MFD_SUCCESS != rdbmsDbTable_indexes_set(rowreq_ctx + ,atol(db_oid) + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "rdbmsDbTable cache.\n"); + rdbmsDbTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + + /* + * TODO:352:r: | |-> populate rdbmsDbTable data context. + * Populate data context here. (optionally, delay until row prep) + */ + + rowreq_ctx->data.rdbmsDbPrivateMibOID_len = 128; + rowreq_ctx->data.rdbmsDbVendorName_len = 255; + rowreq_ctx->data.rdbmsDbName_len = 255; + rowreq_ctx->data.rdbmsDbContact_len = 255; + + contact_name = NULL; + contact_name_len = 0; + vendor_name = NULL; + vendor_name_len = 0; + + /* Note that this queries pgsnmpd_rdbmsDbTable once per database. This could + * be more efficient by only querying once if it can't find the table (being + * sure that the table didn't exist, as opposed to simply an entry for that + * database not existing in the table). It could also be rewritten so that + * only one query is issued, joining pg_database and pgsnmpd_rdbmsDbTable, but + * that would have to be smart enough to know of the pgsnmpd table existed + * and not do the join if it didn't */ + pgsnmpd_tbl_qry = NULL; + tmpInt = sizeof("SELECT vendor_name, contact_name FROM pgsnmpd_rdbmsDbTable WHERE database_oid = ") + sizeof(*db_oid); + tmpString = calloc(tmpInt, sizeof(char*)); + if (tmpString == NULL) snmp_log(LOG_ERR, "Couldn't allocate memory to query pgsnmpd-specific database table\n"); + else { + snmp_log(LOG_INFO, "Gathering rdbmsDbTable information from pgsnmpd_rdbmsDbTable\n"); + snprintf(tmpString, sizeof(char*) * tmpInt, "SELECT vendor_name, contact_name FROM pgsnmpd_rdbmsDbTable WHERE database_oid = %s", db_oid); + pgsnmpd_tbl_qry = PQexec(dbconn, tmpString); + /* Ignore errors so that pgsnmpd will run without this table being available */ + if (PQresultStatus(pgsnmpd_tbl_qry) == PGRES_TUPLES_OK && PQntuples(pgsnmpd_tbl_qry) > 0) { + vendor_name = PQgetvalue(pgsnmpd_tbl_qry, 0, 0); + vendor_name_len = strlen(vendor_name); + contact_name = PQgetvalue(pgsnmpd_tbl_qry, 0, 1); + contact_name_len = strlen(contact_name); + } + /* Note that this error is INFO level, instead of something higher, because we're designed to work without this table */ + else snmp_log(LOG_INFO, "Unable to find relevant data in pgsnmpd_rdbmsDbTable\n"); + } + + /* + * TODO:246:r: |-> Define rdbmsDbPrivateMibOID mapping. + * Map values between raw/native values and MIB values + * + * if(MFD_SUCCESS != + * rdbmsDbPrivateMibOID_map(&rowreq_ctx->data.rdbmsDbPrivateMibOID, &rowreq_ctx->data.rdbmsDbPrivateMibOID_len, + * rdbmsDbPrivateMibOID, rdbmsDbPrivateMibOID_len, 0)) { + * return MFD_ERROR; + * } + */ + if ((NULL == rowreq_ctx->data.rdbmsDbPrivateMibOID) || + (rowreq_ctx->data.rdbmsDbPrivateMibOID_len < (1 * sizeof(rowreq_ctx->data.rdbmsDbPrivateMibOID[0])))) { + snmp_log(LOG_ERR,"not enough space for rdbmsDbTable.rdbmsDbPrivateMibOID value.\n"); + errorcode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbPrivateMibOID_len = 8; + rdbmsDbPrivateMibOID[7] = (oid) atoi(PQgetvalue(pg_db_qry, i, 0)); + memcpy( rowreq_ctx->data.rdbmsDbPrivateMibOID, rdbmsDbPrivateMibOID, 8 * sizeof(rdbmsDbPrivateMibOID[0])); + + /* + * TODO:246:r: |-> Define rdbmsDbVendorName mapping. + */ + if ((NULL == rowreq_ctx->data.rdbmsDbVendorName) || + (rowreq_ctx->data.rdbmsDbVendorName_len < (10 * sizeof(rowreq_ctx->data.rdbmsDbVendorName[0])))) { + snmp_log(LOG_ERR,"not enough space for rdbmsDbTable.rdbmsDbVendorName value\n"); + errorcode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbVendorName_len = vendor_name_len; + memcpy( rowreq_ctx->data.rdbmsDbVendorName, vendor_name, vendor_name_len); + + /* + * TODO:246:r: |-> Define rdbmsDbName mapping. + */ + if ((NULL == rowreq_ctx->data.rdbmsDbName) || + (rowreq_ctx->data.rdbmsDbName_len < (100 * sizeof(rowreq_ctx->data.rdbmsDbName[0])))) { + snmp_log(LOG_ERR,"not enough space for rdbmsDbTable.rdbmsDbName value\n"); + errorcode = MFD_ERROR; + break; + } + tmpString = PQgetvalue(pg_db_qry, i, 1); + rowreq_ctx->data.rdbmsDbName_len = strlen(tmpString) * sizeof(rowreq_ctx->data.rdbmsDbName[0]); + strncpy(rowreq_ctx->data.rdbmsDbName, tmpString, rowreq_ctx->data.rdbmsDbName_len); + + /* + * TODO:246:r: |-> Define rdbmsDbContact mapping. + */ + if ((NULL == rowreq_ctx->data.rdbmsDbContact) || + (rowreq_ctx->data.rdbmsDbContact_len < (100 * sizeof(rowreq_ctx->data.rdbmsDbContact[0])))) { + snmp_log(LOG_ERR,"not enough space for rdbmsDbTable.rdbmsDbContact value\n"); + errorcode = MFD_ERROR; + break; + } + rowreq_ctx->data.rdbmsDbContact_len = contact_name_len; + memcpy( rowreq_ctx->data.rdbmsDbContact, contact_name, contact_name_len); + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + + if (pgsnmpd_tbl_qry != NULL) PQclear(pgsnmpd_tbl_qry); + } + + DEBUGMSGT(("verbose:rdbmsDbTable:rdbmsDbTable_cache_load", + "inserted some records\n")); + + PQclear(pg_db_qry); + return errorcode; +} /* rdbmsDbTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +rdbmsDbTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_cache_free","called\n")); + + /* + * TODO:380:M: Free rdbmsDbTable cache. + */ +} /* rdbmsDbTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +rdbmsDbTable_row_prep( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* rdbmsDbTable_row_prep */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.h new file mode 100644 index 0000000..cdf1cac --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_access.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_data_access.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_data_access.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_DATA_ACCESS_H +#define RDBMSDBTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ + + + int rdbmsDbTable_init_data(rdbmsDbTable_registration_ptr rdbmsDbTable_reg); + + +/* + * TODO:180:o: Review rdbmsDbTable cache timeout. + * The number of seconds before the cache times out + */ +#define RDBMSDBTABLE_CACHE_TIMEOUT 60 + +void rdbmsDbTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int rdbmsDbTable_cache_load(netsnmp_container *container); +void rdbmsDbTable_cache_free(netsnmp_container *container); + +int rdbmsDbTable_row_prep( rdbmsDbTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_DATA_ACCESS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.c b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.c new file mode 100644 index 0000000..b6a7207 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.c @@ -0,0 +1,763 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_data_get.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_data_get.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement rdbmsDbTable get routines. + * TODO:240:M: Implement rdbmsDbTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement rdbmsDbTable data context functions. + */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbEntry.rdbmsDbIndex + * rdbmsDbIndex is subid 1 of rdbmsDbEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.2.1.39.1.1.1.1 + * Description: +A numeric index, unique among all the databases from all + products on this host. This value is a surrogate for the + conceptually unique key, which is {PrivateMibOID, + databasename} + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 0 + * settable 0 + * + * Ranges: 1 - 2147483647; + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + * + * + * + * NOTE: NODE rdbmsDbIndex IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbIndex.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbIndex_map(long *mib_rdbmsDbIndex_val_ptr, long raw_rdbmsDbIndex_val) +{ + netsnmp_assert(NULL != mib_rdbmsDbIndex_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbIndex_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsDbIndex mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsDbIndex_val_ptr) = raw_rdbmsDbIndex_val; + + return MFD_SUCCESS; +} /* rdbmsDbIndex_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +rdbmsDbTable_indexes_set_tbl_idx(rdbmsDbTable_mib_index *tbl_idx, long rdbmsDbIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_indexes_set_tbl_idx","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + + return MFD_SUCCESS; +} /* rdbmsDbTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +rdbmsDbTable_indexes_set(rdbmsDbTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_indexes_set","called\n")); + + if(MFD_SUCCESS != rdbmsDbTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , rdbmsDbIndex_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != rdbmsDbTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsDbTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbEntry.rdbmsDbPrivateMibOID + * rdbmsDbPrivateMibOID is subid 2 of rdbmsDbEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.1.1.2 + * Description: +The authoritative identification for the private MIB for + this database, presumably based on the vendor, e.g., { + enterprises 111 } for Oracle + databases, {enterprises 757 } for + Ingres databases, { enterprises 897 } for Sybase databases, etc. + + If no OBJECT IDENTIFIER exists for the private MIB, attempts + + to access this object will return noSuchName (SNMPv1) + or noSuchInstance (SNMPv2). + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is OBJECTID (based on perltype OBJECTID) + * The net-snmp type is ASN_OBJECT_ID. The C type decl is oid (oid) + * This data type requires a length. (Max 2147483647) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbPrivateMibOID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbPrivateMibOID_map(oid **mib_rdbmsDbPrivateMibOID_val_ptr_ptr, size_t *mib_rdbmsDbPrivateMibOID_val_ptr_len_ptr, + oid *raw_rdbmsDbPrivateMibOID_val_ptr, size_t raw_rdbmsDbPrivateMibOID_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbPrivateMibOID_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbPrivateMibOID_val_ptr_ptr) && (NULL != mib_rdbmsDbPrivateMibOID_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbPrivateMibOID_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbPrivateMibOID non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbPrivateMibOID_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbPrivateMibOID_val_ptr_ptr) || (*mib_rdbmsDbPrivateMibOID_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbPrivateMibOID_val_ptr_ptr = realloc( *mib_rdbmsDbPrivateMibOID_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbPrivateMibOID_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbPrivateMibOID_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbPrivateMibOID_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbPrivateMibOID_val_ptr_ptr, raw_rdbmsDbPrivateMibOID_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbPrivateMibOID_map */ + +/** + * Extract the current value of the rdbmsDbPrivateMibOID data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbPrivateMibOID_val_ptr_ptr + * Pointer to storage for a oid variable + * @param rdbmsDbPrivateMibOID_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbPrivateMibOID. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbPrivateMibOID_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbPrivateMibOID_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbPrivateMibOID_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, oid **rdbmsDbPrivateMibOID_val_ptr_ptr, size_t *rdbmsDbPrivateMibOID_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbPrivateMibOID_val_ptr_ptr) && (NULL != *rdbmsDbPrivateMibOID_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbPrivateMibOID_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbPrivateMibOID_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbPrivateMibOID data. + * set (* rdbmsDbPrivateMibOID_val_ptr_ptr ) and (* rdbmsDbPrivateMibOID_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbPrivateMibOID data + */ + if ((NULL == (* rdbmsDbPrivateMibOID_val_ptr_ptr )) || + ((* rdbmsDbPrivateMibOID_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbPrivateMibOID_len * sizeof((* rdbmsDbPrivateMibOID_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbPrivateMibOID data + */ + (* rdbmsDbPrivateMibOID_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbPrivateMibOID_len * sizeof((* rdbmsDbPrivateMibOID_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbPrivateMibOID_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbPrivateMibOID_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbPrivateMibOID_len * sizeof((* rdbmsDbPrivateMibOID_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbPrivateMibOID_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbPrivateMibOID, (* rdbmsDbPrivateMibOID_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbPrivateMibOID_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbEntry.rdbmsDbVendorName + * rdbmsDbVendorName is subid 3 of rdbmsDbEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.1.1.3 + * Description: +The name of the vendor whose RDBMS manages this database, + for informational purposes. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbVendorName.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbVendorName_map(char **mib_rdbmsDbVendorName_val_ptr_ptr, size_t *mib_rdbmsDbVendorName_val_ptr_len_ptr, char *raw_rdbmsDbVendorName_val_ptr, size_t raw_rdbmsDbVendorName_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbVendorName_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbVendorName_val_ptr_ptr) && (NULL != mib_rdbmsDbVendorName_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbVendorName_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbVendorName non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbVendorName_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbVendorName_val_ptr_ptr) || (*mib_rdbmsDbVendorName_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbVendorName_val_ptr_ptr = realloc( *mib_rdbmsDbVendorName_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbVendorName_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbVendorName_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbVendorName_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbVendorName_val_ptr_ptr, raw_rdbmsDbVendorName_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbVendorName_map */ + +/** + * Extract the current value of the rdbmsDbVendorName data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbVendorName_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbVendorName_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbVendorName. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbVendorName_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbVendorName_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbVendorName_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbVendorName_val_ptr_ptr, size_t *rdbmsDbVendorName_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbVendorName_val_ptr_ptr) && (NULL != *rdbmsDbVendorName_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbVendorName_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbVendorName_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbVendorName data. + * set (* rdbmsDbVendorName_val_ptr_ptr ) and (* rdbmsDbVendorName_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbVendorName data + */ + if ((NULL == (* rdbmsDbVendorName_val_ptr_ptr )) || + ((* rdbmsDbVendorName_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbVendorName_len * sizeof((* rdbmsDbVendorName_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbVendorName data + */ + (* rdbmsDbVendorName_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbVendorName_len * sizeof((* rdbmsDbVendorName_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbVendorName_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbVendorName_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbVendorName_len * sizeof((* rdbmsDbVendorName_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbVendorName_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbVendorName, (* rdbmsDbVendorName_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbVendorName_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbEntry.rdbmsDbName + * rdbmsDbName is subid 4 of rdbmsDbEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.1.1.4 + * Description: +The name of this database, in a product specific format. The + product may need to qualify the name in some way to resolve + conflicts if it is possible for a database name to be + duplicated on a host. It might be necessary to construct a + hierarchical name embedding the RDBMS instance/installation + on the host, and/or the owner of the database. For instance, + '/test-installation/database-owner/database-name'. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbName.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbName_map(char **mib_rdbmsDbName_val_ptr_ptr, size_t *mib_rdbmsDbName_val_ptr_len_ptr, char *raw_rdbmsDbName_val_ptr, size_t raw_rdbmsDbName_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbName_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbName_val_ptr_ptr) && (NULL != mib_rdbmsDbName_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbName_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbName non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbName_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbName_val_ptr_ptr) || (*mib_rdbmsDbName_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbName_val_ptr_ptr = realloc( *mib_rdbmsDbName_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbName_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbName_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbName_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbName_val_ptr_ptr, raw_rdbmsDbName_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbName_map */ + +/** + * Extract the current value of the rdbmsDbName data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbName_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbName_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbName. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbName_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbName_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbName_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbName_val_ptr_ptr, size_t *rdbmsDbName_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbName_val_ptr_ptr) && (NULL != *rdbmsDbName_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbName_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbName_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbName data. + * set (* rdbmsDbName_val_ptr_ptr ) and (* rdbmsDbName_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbName data + */ + if ((NULL == (* rdbmsDbName_val_ptr_ptr )) || + ((* rdbmsDbName_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbName_len * sizeof((* rdbmsDbName_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbName data + */ + (* rdbmsDbName_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbName_len * sizeof((* rdbmsDbName_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbName_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbName_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbName_len * sizeof((* rdbmsDbName_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbName_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbName, (* rdbmsDbName_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbName_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbEntry.rdbmsDbContact + * rdbmsDbContact is subid 5 of rdbmsDbEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.1.1.5 + * Description: +The textual identification of the contact person for this + managed database, together with information on how to contact + this person. + + Note: if there is no server associated with this database, an + agent may need to keep this in other persistent storage, + e.g., a configuration file. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsDbContact.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsDbContact_map(char **mib_rdbmsDbContact_val_ptr_ptr, size_t *mib_rdbmsDbContact_val_ptr_len_ptr, char *raw_rdbmsDbContact_val_ptr, size_t raw_rdbmsDbContact_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsDbContact_val_ptr); + netsnmp_assert((NULL != mib_rdbmsDbContact_val_ptr_ptr) && (NULL != mib_rdbmsDbContact_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbContact_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsDbContact non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsDbContact_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsDbContact_val_ptr_ptr) || (*mib_rdbmsDbContact_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsDbContact_val_ptr_ptr = realloc( *mib_rdbmsDbContact_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsDbContact_val_ptr_ptr)); + if(NULL == *mib_rdbmsDbContact_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsDbContact_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsDbContact_val_ptr_ptr, raw_rdbmsDbContact_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsDbContact_map */ + +/** + * Extract the current value of the rdbmsDbContact data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbContact_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsDbContact_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsDbContact. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsDbContact_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsDbContact_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsDbContact_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbContact_val_ptr_ptr, size_t *rdbmsDbContact_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsDbContact_val_ptr_ptr) && (NULL != *rdbmsDbContact_val_ptr_ptr)); + netsnmp_assert( NULL != rdbmsDbContact_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbContact_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsDbContact data. + * set (* rdbmsDbContact_val_ptr_ptr ) and (* rdbmsDbContact_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for rdbmsDbContact data + */ + if ((NULL == (* rdbmsDbContact_val_ptr_ptr )) || + ((* rdbmsDbContact_val_ptr_len_ptr ) < (rowreq_ctx->data.rdbmsDbContact_len * sizeof((* rdbmsDbContact_val_ptr_ptr )[0])))) { + /* + * allocate space for rdbmsDbContact data + */ + (* rdbmsDbContact_val_ptr_ptr ) = malloc(rowreq_ctx->data.rdbmsDbContact_len * sizeof((* rdbmsDbContact_val_ptr_ptr )[0])); + if(NULL == (* rdbmsDbContact_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* rdbmsDbContact_val_ptr_len_ptr ) = rowreq_ctx->data.rdbmsDbContact_len * sizeof((* rdbmsDbContact_val_ptr_ptr )[0]); + memcpy( (* rdbmsDbContact_val_ptr_ptr ), rowreq_ctx->data.rdbmsDbContact, (* rdbmsDbContact_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* rdbmsDbContact_get */ + + + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.h new file mode 100644 index 0000000..a4af810 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_get.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_data_get.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_data_get.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_DATA_GET_H +#define RDBMSDBTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ + /* + * indexes + */ + int rdbmsDbIndex_map(long *mib_rdbmsDbIndex_val_ptr, long raw_rdbmsDbIndex_val); + + int rdbmsDbPrivateMibOID_map(oid **mib_rdbmsDbPrivateMibOID_val_ptr_ptr, size_t *mib_rdbmsDbPrivateMibOID_val_ptr_len_ptr, oid *raw_rdbmsDbPrivateMibOID_val_ptr, size_t raw_rdbmsDbPrivateMibOID_val_ptr_len, int allow_realloc); + int rdbmsDbPrivateMibOID_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, oid **rdbmsDbPrivateMibOID_val_ptr_ptr, size_t *rdbmsDbPrivateMibOID_val_ptr_len_ptr ); + int rdbmsDbVendorName_map(char **mib_rdbmsDbVendorName_val_ptr_ptr, size_t *mib_rdbmsDbVendorName_val_ptr_len_ptr, char *raw_rdbmsDbVendorName_val_ptr, size_t raw_rdbmsDbVendorName_val_ptr_len, int allow_realloc); + int rdbmsDbVendorName_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbVendorName_val_ptr_ptr, size_t *rdbmsDbVendorName_val_ptr_len_ptr ); + int rdbmsDbName_map(char **mib_rdbmsDbName_val_ptr_ptr, size_t *mib_rdbmsDbName_val_ptr_len_ptr, char *raw_rdbmsDbName_val_ptr, size_t raw_rdbmsDbName_val_ptr_len, int allow_realloc); + int rdbmsDbName_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbName_val_ptr_ptr, size_t *rdbmsDbName_val_ptr_len_ptr ); + int rdbmsDbContact_map(char **mib_rdbmsDbContact_val_ptr_ptr, size_t *mib_rdbmsDbContact_val_ptr_len_ptr, char *raw_rdbmsDbContact_val_ptr, size_t raw_rdbmsDbContact_val_ptr_len, int allow_realloc); + int rdbmsDbContact_get( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char **rdbmsDbContact_val_ptr_ptr, size_t *rdbmsDbContact_val_ptr_len_ptr ); + + +int rdbmsDbTable_indexes_set_tbl_idx(rdbmsDbTable_mib_index *tbl_idx, long rdbmsDbIndex_val); +int rdbmsDbTable_indexes_set(rdbmsDbTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_DATA_GET_H */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.c b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.c new file mode 100644 index 0000000..5293811 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.c @@ -0,0 +1,517 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_data_set.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_data_set.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ + /* + * NOTE: if you update this chart, please update the versions in + * local/mib2c-conf.d/parent-set.m2i + * agent/mibgroup/helpers/baby_steps.c + * while you're at it. + */ + /* + *********************************************************************** + * Baby Steps Flow Chart (2004.06.05) * + * * + * +--------------+ +================+ U = unconditional path * + * |optional state| ||required state|| S = path for success * + * +--------------+ +================+ E = path for error * + *********************************************************************** + * + * +--------------+ + * | pre | + * | request | + * +--------------+ + * | U + * +==============+ + * +----------------|| object || + * | E || lookup || + * | +==============+ + * | | S + * | +==============+ + * | E || check || + * |<---------------|| values || + * | +==============+ + * | | S + * | +==============+ + * | +<-------|| undo || + * | | E || setup || + * | | +==============+ + * | | | S + * | | +==============+ + * | | || set ||-------------------------->+ + * | | || value || E | + * | | +==============+ | + * | | | S | + * | | +--------------+ | + * | | | check |-------------------------->| + * | | | consistency | E | + * | | +--------------+ | + * | | | S | + * | | +==============+ +==============+ | + * | | || commit ||-------->|| undo || | + * | | || || E || commit || | + * | | +==============+ +==============+ | + * | | | S U |<--------+ + * | | +--------------+ +==============+ + * | | | irreversible | || undo || + * | | | commit | || set || + * | | +--------------+ +==============+ + * | | | U U | + * | +-------------->|<------------------------+ + * | +==============+ + * | || undo || + * | || cleanup || + * | +==============+ + * +---------------------->| U + * +--------------+ + * | post | + * | request | + * +--------------+ + * + */ + +/** + * Setup up context with information needed to undo a set request. + * + * This function will be called before the individual node undo setup + * functions are called. If you need to do any undo setup that is not + * related to a specific column, you can do it here. + * + * Note that an individual node's undo_setup function will only be called + * if that node is being set to a new value. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in the node's undo_setup + * function, so it won't be done unless it is necessary. + * + * @param rowreq_ctx + * Pointer to the table context (rdbmsDbTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + */ +int +rdbmsDbTable_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_undo_setup","called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rowreq_ctx ); + + /* + * TODO:451:M: |-> Setup rdbmsDbTable undo. + * set up rdbmsDbTable undo information, in preparation for a set. + */ + + return rc; +} /* rdbmsDbTable_undo_setup */ + +/** + * Cleanup up context undo information. + * + * This function will be called after set/commit processing. If you + * allocated any resources in undo_setup, this is the place to release + * those resources. + * + * This function is called regardless of the success or failure of the set + * request. If you need to perform different steps for cleanup depending + * on success or failure, you can add a flag to the rowreq_ctx. + * + * @param rowreq_ctx + * Pointer to the table context (rdbmsDbTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +rdbmsDbTable_undo_cleanup( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_undo_cleanup","called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rowreq_ctx ); + + /* + * TODO:452:M: |-> Cleanup rdbmsDbTable undo. + */ + + return rc; +} /* rdbmsDbTable_undo_cleanup */ + +/** + * commit new values. + * + * At this point, you should have done everything you can to ensure that + * this commit will not fail. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the FLAG_* bits can be found in + * rdbmsDbTable_oids.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rdbmsDbTable_rowreq_ctx + * Pointer to the users context. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +rdbmsDbTable_commit( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + int rc = MFD_SUCCESS; + int save_flags; + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_commit","called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rowreq_ctx ); + + /* + * save flags, then clear until we actually do something + */ + save_flags = rowreq_ctx->column_set_flags; + rowreq_ctx->column_set_flags = 0; + + /* + * commit rdbmsDbTable data + * 1) check the column's flag in save_flags to see if it was set. + * 2) clear the flag when you handle that column + * 3) set the column's flag in column_set_flags if it needs undo + * processing in case of a failure. + */ + if (save_flags & FLAG_RDBMSDBCONTACT) { + save_flags &= ~FLAG_RDBMSDBCONTACT; /* clear rdbmsDbContact */ + /* + * TODO:482:o: |-> commit column rdbmsDbContact. + */ + rc = -1; + if(-1 == rc) { + snmp_log(LOG_ERR,"rdbmsDbTable column rdbmsDbContact commit failed\n"); + } + else { + /* + * set flag, in case we need to undo rdbmsDbContact + */ + rowreq_ctx->column_set_flags |= FLAG_RDBMSDBCONTACT; + } + } + + if (save_flags) { + snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags); + return MFD_ERROR; + } + + return rc; +} /* rdbmsDbTable_commit */ + +/** + * undo commit new values. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the FLAG_* bits can be found in + * rdbmsDbTable_oids.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @param rdbmsDbTable_rowreq_ctx + * Pointer to the users context. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error + */ +int +rdbmsDbTable_undo_commit( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_undo_commit","called\n")); + + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rowreq_ctx ); + + /* + * TODO:485:M: |-> Undo rdbmsDbTable commit. + * check the column's flag in rowreq_ctx->column_set_flags to see + * if it was set during commit, then undo it. + * + * eg: if (rowreq_ctx->column_set_flags & FLAG_) {} + */ + + return rc; +} /* rdbmsDbTable_undo_commit */ + +/* + * TODO:420:r: Implement rdbmsDbTable index validation. + */ +/* + * TODO:440:M: Implement rdbmsDbTable node value checks. + * TODO:450:M: Implement rdbmsDbTable undo functions. + * TODO:460:M: Implement rdbmsDbTable set functions. + * TODO:480:M: Implement rdbmsDbTable commit functions. + */ +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsDbEntry.rdbmsDbContact + * rdbmsDbContact is subid 5 of rdbmsDbEntry. + * Its status is Current, and its access level is ReadWrite. + * OID: .1.3.6.1.2.1.39.1.1.1.5 + * Description: +The textual identification of the contact person for this + managed database, together with information on how to contact + this person. + + Note: if there is no server associated with this database, an + agent may need to keep this in other persistent storage, + e.g., a configuration file. + + Note that a compliant agent does not need to + allow write access to this object. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 1 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * Check that the proposed new value is potentially valid. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsDbContact_val_ptr + * A char containing the new value. + * @param rdbmsDbContact_val_ptr_len + * The size (in bytes) of the data pointed to by rdbmsDbContact_val_ptr + * + * @retval MFD_SUCCESS : incoming value is legal + * @retval MFD_NOT_VALID_NOW : incoming value is not valid now + * @retval MFD_NOT_VALID_EVER : incoming value is never valid + * + * This is the place to check for requirements that are not + * expressed in the mib syntax (for example, a requirement that + * is detailed in the description for an object). + * + * You should check that the requested change between the undo value and the + * new value is legal (ie, the transistion from one value to another + * is legal). + * + *@note + * This check is only to determine if the new value + * is \b potentially valid. This is the first check of many, and + * is one of the simplest ones. + * + *@note + * this is not the place to do any checks for values + * which depend on some other value in the mib. Those + * types of checks should be done in the + * rdbmsDbTable_check_dependencies() function. + * + * The following checks have already been done for you: + * The syntax is ASN_OCTET_STR + * The length is in (one of) the range set(s): 0 - 255 + * + * If there a no other checks you need to do, simply return MFD_SUCCESS. + * + */ +int +rdbmsDbContact_check_value( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbContact_val_ptr, size_t rdbmsDbContact_val_ptr_len) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbContact_check_value","called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + netsnmp_assert(NULL != rdbmsDbContact_val_ptr); + + /* + * TODO:441:o: |-> Check for valid rdbmsDbContact value. + */ + + return MFD_SUCCESS; /* rdbmsDbContact value not illegal */ +} /* rdbmsDbContact_check_value */ + +/** + * Save old value information + * + * @param rowreq_ctx + * Pointer to the table context (rdbmsDbTable_rowreq_ctx) + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : error. set will fail. + * + * This function will be called after the table level undo setup function + * rdbmsDbTable_undo_setup has been called. + * + *@note + * this function will only be called if a new value is set for this column. + * + * If there is any setup specific to a particular column (e.g. allocating + * memory for a string), you should do that setup in this function, so it + * won't be done unless it is necessary. + */ +int +rdbmsDbContact_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbContact_undo_setup","called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:455:o: |-> Setup rdbmsDbContact undo. + */ + /* + * copy rdbmsDbContact and rdbmsDbContact_len data + * set rowreq_ctx->undo->rdbmsDbContact from rowreq_ctx->data.rdbmsDbContact + */ + memcpy( rowreq_ctx->undo->rdbmsDbContact, rowreq_ctx->data.rdbmsDbContact, + (rowreq_ctx->data.rdbmsDbContact_len * sizeof(rowreq_ctx->undo->rdbmsDbContact[0]))); + rowreq_ctx->undo->rdbmsDbContact_len = rowreq_ctx->data.rdbmsDbContact_len; + + + return MFD_SUCCESS; +} /* rdbmsDbContact_undo_setup */ + +/** + * Set the new value. + * + * @param rowreq_ctx + * Pointer to the users context. You should know how to + * manipulate the value from this object. + * @param rdbmsDbContact_val_ptr + * A char containing the new value. + * @param rdbmsDbContact_val_ptr_len + * The size (in bytes) of the data pointed to by rdbmsDbContact_val_ptr + */ +int +rdbmsDbContact_set( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbContact_val_ptr, size_t rdbmsDbContact_val_ptr_len ) +{ + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbContact_set","called\n")); + + /** should never get a NULL pointer */ + netsnmp_assert(NULL != rowreq_ctx); + netsnmp_assert(NULL != rdbmsDbContact_val_ptr); + +/* + * TODO:245:o: |-> Implement rdbmsDbContact reverse mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + /* + * TODO:461:M: |-> Set rdbmsDbContact value. + * set rdbmsDbContact value in rowreq_ctx->data + */ + memcpy( rowreq_ctx->data.rdbmsDbContact, rdbmsDbContact_val_ptr, rdbmsDbContact_val_ptr_len ); + rowreq_ctx->data.rdbmsDbContact_len = rdbmsDbContact_val_ptr_len / sizeof(rdbmsDbContact_val_ptr[0]); + + return MFD_SUCCESS; +} /* rdbmsDbContact_set */ + +/** + * undo the previous set. + * + * @param rowreq_ctx + * Pointer to the users context. + */ +int +rdbmsDbContact_undo( rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbContact_undo","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:456:o: |-> Clean up rdbmsDbContact undo. + */ + /* + * copy rdbmsDbContact and rdbmsDbContact_len data + * set rowreq_ctx->data.rdbmsDbContact from rowreq_ctx->undo->rdbmsDbContact + */ + memcpy( rowreq_ctx->data.rdbmsDbContact, rowreq_ctx->undo->rdbmsDbContact, + (rowreq_ctx->undo->rdbmsDbContact_len * sizeof(rowreq_ctx->data.rdbmsDbContact[0]))); + rowreq_ctx->data.rdbmsDbContact_len = rowreq_ctx->undo->rdbmsDbContact_len; + + + return MFD_SUCCESS; +} /* rdbmsDbContact_undo */ + +/** + * check dependencies + * + * This is useful for for tables which have dependencies between columns + * (or rows, or tables). For example, two columns allocating a percentage + * of something add up 100%. + * + * Should you need different behavior depending on which columns were + * set, rowreq_ctx->column_set_flags will indicate which writeable columns were + * set. The definitions for the FLAG_* bits can be found in + * rdbmsDbTable_oids.h. + * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. + * + * @retval MFD_SUCCESS all the changes to the row are legal + * @retval MFD_ERROR one or more changes are not legal + * + * (see README-table-rdbmsDbTable if you don't have dependencies) + */ +int +rdbmsDbTable_check_dependencies(rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + int rc = MFD_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbTable:rdbmsDbTable_check_dependencies","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:470:o: Check rdbmsDbTable row dependencies. + * check that all new value are legal and consistent with each other + */ + return rc; +} /* rdbmsDbTable_check_dependencies */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.h new file mode 100644 index 0000000..06cd026 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_data_set.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_data_set.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_data_set.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_DATA_SET_H +#define RDBMSDBTABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ +int rdbmsDbIndex_check_index( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); /* internal */ + + +int rdbmsDbTable_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx); +int rdbmsDbTable_undo_cleanup( rdbmsDbTable_rowreq_ctx *rowreq_ctx); +int rdbmsDbTable_commit( rdbmsDbTable_rowreq_ctx *rowreq_ctx); +int rdbmsDbTable_undo_commit( rdbmsDbTable_rowreq_ctx *rowreq_ctx); + + +int rdbmsDbPrivateMibOID_check_value( rdbmsDbTable_rowreq_ctx *rowreq_ctx, oid *rdbmsDbPrivateMibOID_val_ptr, size_t rdbmsDbPrivateMibOID_val_ptr_len); +int rdbmsDbPrivateMibOID_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); +int rdbmsDbPrivateMibOID_set( rdbmsDbTable_rowreq_ctx *rowreq_ctx, oid *rdbmsDbPrivateMibOID_val_ptr, size_t rdbmsDbPrivateMibOID_val_ptr_len ); +int rdbmsDbPrivateMibOID_undo( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); + +int rdbmsDbVendorName_check_value( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbVendorName_val_ptr, size_t rdbmsDbVendorName_val_ptr_len); +int rdbmsDbVendorName_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); +int rdbmsDbVendorName_set( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbVendorName_val_ptr, size_t rdbmsDbVendorName_val_ptr_len ); +int rdbmsDbVendorName_undo( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); + +int rdbmsDbName_check_value( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbName_val_ptr, size_t rdbmsDbName_val_ptr_len); +int rdbmsDbName_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); +int rdbmsDbName_set( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbName_val_ptr, size_t rdbmsDbName_val_ptr_len ); +int rdbmsDbName_undo( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); + +int rdbmsDbContact_check_value( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbContact_val_ptr, size_t rdbmsDbContact_val_ptr_len); +int rdbmsDbContact_undo_setup( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); +int rdbmsDbContact_set( rdbmsDbTable_rowreq_ctx *rowreq_ctx, char *rdbmsDbContact_val_ptr, size_t rdbmsDbContact_val_ptr_len ); +int rdbmsDbContact_undo( rdbmsDbTable_rowreq_ctx *rowreq_ctx ); + + +int rdbmsDbTable_check_dependencies(rdbmsDbTable_rowreq_ctx *ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_DATA_SET_H */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_enums.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_enums.h new file mode 100644 index 0000000..676d383 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_enums.h @@ -0,0 +1,47 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_enums.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_enums.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_ENUMS_H +#define RDBMSDBTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table rdbmsDbTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_ENUMS_H */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.c b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.c new file mode 100644 index 0000000..8711c2c --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.c @@ -0,0 +1,1238 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_interface.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_interface.c,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsDbTable.h" +#include "rdbmsDbTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsDbTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsDbTable is subid 1 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.1, length: 9 +*/ +typedef struct rdbmsDbTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + rdbmsDbTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} rdbmsDbTable_interface_ctx; + +static rdbmsDbTable_interface_ctx rdbmsDbTable_if_ctx; + +static void _rdbmsDbTable_container_init( + rdbmsDbTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_pre_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_post_request; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_object_lookup; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_get_values; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_check_objects; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_undo_setup; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_set_values; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_undo_cleanup; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_undo_values; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_commit; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_undo_commit; +static Netsnmp_Node_Handler _mfd_rdbmsDbTable_check_dependencies; + +NETSNMP_STATIC_INLINE int _rdbmsDbTable_undo_column( rdbmsDbTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ); + +rdbmsDbTable_data *rdbmsDbTable_allocate_data(void); +void rdbmsDbTable_release_data(rdbmsDbTable_data *data); + +/** + * @internal + * Initialize the table rdbmsDbTable + * (Define its contents and how it's structured) + */ +void +_rdbmsDbTable_initialize_interface(rdbmsDbTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &rdbmsDbTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &rdbmsDbTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:rdbmsDbTable:_rdbmsDbTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for rdbmsDbTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_INTEGER, /** index: rdbmsDbIndex */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = RDBMSDBTABLE_MIN_COL; + tbl_info->max_column = RDBMSDBTABLE_MAX_COL; + + /* + * save users context + */ + rdbmsDbTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + rdbmsDbTable_init_data(reg_ptr); + + /* + * set up the container + */ + _rdbmsDbTable_container_init(&rdbmsDbTable_if_ctx); + if (NULL == rdbmsDbTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for rdbmsDbTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_rdbmsDbTable_object_lookup; + access_multiplexer->get_values = _mfd_rdbmsDbTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_rdbmsDbTable_pre_request; + access_multiplexer->post_request = _mfd_rdbmsDbTable_post_request; + + + /* + * REQUIRED wrappers for set request handling + */ + access_multiplexer->object_syntax_checks = _mfd_rdbmsDbTable_check_objects; + access_multiplexer->undo_setup = _mfd_rdbmsDbTable_undo_setup; + access_multiplexer->undo_cleanup = _mfd_rdbmsDbTable_undo_cleanup; + access_multiplexer->set_values = _mfd_rdbmsDbTable_set_values; + access_multiplexer->undo_sets = _mfd_rdbmsDbTable_undo_values; + + /* + * no wrappers yet + */ + access_multiplexer->commit = _mfd_rdbmsDbTable_commit; + access_multiplexer->undo_commit = _mfd_rdbmsDbTable_undo_commit; + + /* + * REQUIRED for tables with dependencies + */ + access_multiplexer->consistency_checks = _mfd_rdbmsDbTable_check_dependencies; + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("rdbmsDbTable:init_rdbmsDbTable", + "Registering rdbmsDbTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("rdbmsDbTable", handler, + rdbmsDbTable_oid, + rdbmsDbTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RWRITE + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table rdbmsDbTable\n"); + return; + } + reginfo->my_reg_void = &rdbmsDbTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + rdbmsDbTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != rdbmsDbTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(rdbmsDbTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _rdbmsDbTable_initialize_interface */ + +void +rdbmsDbTable_valid_columns_set(netsnmp_column_info *vc) +{ + rdbmsDbTable_if_ctx.tbl_info.valid_columns = vc; +} /* rdbmsDbTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +rdbmsDbTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_index_to_oid","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_rdbmsDbIndex); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbTable_index_to_oid */ + +/** + * extract rdbmsDbTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +rdbmsDbTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_rdbmsDbIndex ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsDbTable_index_from_oid */ + + +/* + * rdbmsDbTable_allocate_data + * + * Purpose: create new rdbmsDbTable_data. + */ +rdbmsDbTable_data * +rdbmsDbTable_allocate_data(void) +{ + rdbmsDbTable_data *rtn = SNMP_MALLOC_TYPEDEF(rdbmsDbTable_data); + + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_allocate_data","called\n")); + + if(NULL == rtn) { + snmp_log(LOG_ERR, "unable to malloc memory for new " + "rdbmsDbTable_data.\n"); + } + + return rtn; +} /* rdbmsDbTable_allocate_data */ + +/* + * rdbmsDbTable_release_data + * + * Purpose: release rdbmsDbTable data. + */ +void +rdbmsDbTable_release_data(rdbmsDbTable_data *data) +{ + DEBUGMSGTL(("verbose:rdbmsDbTable:rdbmsDbTable_release_data","called\n")); + + free(data); +} /* rdbmsDbTable_release_data */ + +/* ********************************************************************* + * @internal + * allocate resources for a rdbmsDbTable_rowreq_ctx + */ +rdbmsDbTable_rowreq_ctx * +rdbmsDbTable_allocate_rowreq_ctx(void) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(rdbmsDbTable_rowreq_ctx); + + DEBUGMSGTL(("internal:rdbmsDbTable:rdbmsDbTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "rdbmsDbTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->rdbmsDbTable_data_list = NULL; + rowreq_ctx->rdbmsDbTable_reg = rdbmsDbTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* rdbmsDbTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a rdbmsDbTable_rowreq_ctx + */ +void +rdbmsDbTable_release_rowreq_ctx(rdbmsDbTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbTable:rdbmsDbTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + if(rowreq_ctx->undo) + rdbmsDbTable_release_data(rowreq_ctx->undo); + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* rdbmsDbTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = rdbmsDbTable_pre_request(rdbmsDbTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbTable","error %d from " + "rdbmsDbTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx; + int rc = rdbmsDbTable_post_request(rdbmsDbTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsDbTable","error %d from " + "rdbmsDbTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(rdbmsDbTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(rdbmsDbTable_if_ctx.container, rowreq_ctx); + rdbmsDbTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsDbTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_object_lookup","called\n")); + + /* + * get our context from mfd + * rdbmsDbTable_interface_ctx *if_ctx = + * (rdbmsDbTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + rdbmsDbTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbTable_get_column( rdbmsDbTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbPrivateMibOID(2)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h */ + case COLUMN_RDBMSDBPRIVATEMIBOID: + var->type = ASN_OBJECT_ID; +rc = rdbmsDbPrivateMibOID_get(rowreq_ctx, (oid **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbVendorName(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_RDBMSDBVENDORNAME: + var->type = ASN_OCTET_STR; +rc = rdbmsDbVendorName_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbName(4)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_RDBMSDBNAME: + var->type = ASN_OCTET_STR; +rc = rdbmsDbName_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + /* rdbmsDbContact(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBCONTACT: + var->type = ASN_OCTET_STR; +rc = rdbmsDbContact_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbTable_get_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbTable_get_column */ + +int +_mfd_rdbmsDbTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/*---------------------------------------------------------------------- + * + * SET: Syntax checks + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check the syntax for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbTable_check_column( rdbmsDbTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbTable:_rdbmsDbTable_check_column","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbContact(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBCONTACT: + rc = netsnmp_check_vb_type( var, ASN_OCTET_STR ); + if(SNMPERR_SUCCESS == rc) { + /* check that the value is in the defined range(s); inefficent + * but keeps rc value knowledge in libarary where it belongs. */ + if( 1 + && ((rc = netsnmp_check_vb_size_range(var, 0,255)) != SNMP_ERR_NOERROR) + ) { + ; /* rc set in condition */ + } + } + if(SNMPERR_SUCCESS == rc) { + rc = rdbmsDbContact_check_value( rowreq_ctx, (char *)var->val.string, var->val_len ); + if((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && + (MFD_NOT_VALID_NOW != rc)) { + snmp_log(LOG_ERR, "bad rc %d from rdbmsDbContact_check_value\n", rc); + rc = SNMP_ERR_GENERR; + } + } + break; + + default: /** We shouldn't get here */ + rc = SNMP_ERR_GENERR; + snmp_log(LOG_ERR, "unknown column %d in _rdbmsDbTable_check_column\n", column); + } + + return rc; +} /* _rdbmsDbTable_check_column */ + +int +_mfd_rdbmsDbTable_check_objects(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + int rc; + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_check_objects","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + + /* + * get column number from table request info, and check that column + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbTable_check_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + break; + } + + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_check_objects */ + + + +/*---------------------------------------------------------------------- + * + * SET: check dependencies + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Check dependencies wrapper + */ +static int +_mfd_rdbmsDbTable_check_dependencies(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_check_dependencies","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = rdbmsDbTable_check_dependencies(rowreq_ctx); + if(rc){ + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_check_dependencies\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_check_dependencies */ + +/*---------------------------------------------------------------------- + * + * SET: Undo setup + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbTable_undo_setup_column( rdbmsDbTable_rowreq_ctx *rowreq_ctx, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbTable:_rdbmsDbTable_undo_setup_column","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbContact(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBCONTACT: + rowreq_ctx->column_set_flags |= FLAG_RDBMSDBCONTACT; + rc = rdbmsDbContact_undo_setup(rowreq_ctx ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbTable_undo_setup_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbTable_undo_setup_column */ + + +/** + * @internal + * undo setup + */ +int +_mfd_rdbmsDbTable_undo_setup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_undo_setup","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * allocate undo context + */ + rowreq_ctx->undo = rdbmsDbTable_allocate_data(); + if(NULL == rowreq_ctx->undo) { + /** msg already logged */ + netsnmp_request_set_error_all(requests, SNMP_ERR_RESOURCEUNAVAILABLE); + return SNMP_ERR_NOERROR; + } + + /* + * row undo setup + */ + rowreq_ctx->column_set_flags = 0; + rc = rdbmsDbTable_undo_setup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_undo_setup\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + else { + /* + * column undo setup + */ + netsnmp_table_request_info * tri; + for(;requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbTable_undo_setup_column(rowreq_ctx, tri->colnum); + if(MFD_SUCCESS != rc) { + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_undo_setup_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_undo_setup */ + +/** + * @internal + * undo setup + */ +int +_mfd_rdbmsDbTable_undo_cleanup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + int rc; + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_undo_cleanup","called\n")); + + /* + * failed row create in early stages has no rowreq_ctx + */ + if (NULL == rowreq_ctx) + return MFD_SUCCESS; + + /* + * call user cleanup + */ + rc = rdbmsDbTable_undo_cleanup(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_undo_cleanup\n", rc)); + } + + /* + * release undo context, if needed + */ + if(rowreq_ctx->undo) { + rdbmsDbTable_release_data(rowreq_ctx->undo); + rowreq_ctx->undo = NULL; + } + + /* + * clear set flags + */ + rowreq_ctx->column_set_flags = 0; + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_undo_cleanup */ + +/*---------------------------------------------------------------------- + * + * SET: Set values + * + *---------------------------------------------------------------------*/ +/* + * @internal + * Set the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbTable_set_column( rdbmsDbTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbTable:_rdbmsDbTable_set_column","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbContact(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBCONTACT: + rowreq_ctx->column_set_flags |= FLAG_RDBMSDBCONTACT; + rc = rdbmsDbContact_set(rowreq_ctx, (char *)var->val.string, var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbTable_set_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbTable_set_column */ + +int +_mfd_rdbmsDbTable_set_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + int rc = SNMP_ERR_NOERROR; + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_set_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rowreq_ctx->column_set_flags = 0; + for(;requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbTable_set_column(rowreq_ctx, + requests->requestvb, tri->colnum); + if(MFD_SUCCESS != rc) { + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_set_column\n", rc)); + netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_set_values */ + +/*---------------------------------------------------------------------- + * + * SET: commit + * + *---------------------------------------------------------------------*/ +/** + * @internal + * commit the values + */ +int +_mfd_rdbmsDbTable_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_commit","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = rdbmsDbTable_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_commit\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} + +int +_mfd_rdbmsDbTable_undo_commit(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_undo_commit","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + rc = rdbmsDbTable_undo_commit(rowreq_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_undo_commit\n", rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_commit */ + +/*---------------------------------------------------------------------- + * + * SET: Undo + * + *---------------------------------------------------------------------*/ +/** + * @internal + * undo the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsDbTable_undo_column( rdbmsDbTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsDbTable:_rdbmsDbTable_undo_column","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsDbContact(5)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ + case COLUMN_RDBMSDBCONTACT: + rc = rdbmsDbContact_undo(rowreq_ctx); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsDbTable_undo_column\n", column); + break; + } + + return rc; +} /* _rdbmsDbTable_undo_column */ + +int +_mfd_rdbmsDbTable_undo_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc; + rdbmsDbTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + + DEBUGMSGTL(("internal:rdbmsDbTable:_mfd_rdbmsDbTable_undo_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * set column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsDbTable_undo_column(rowreq_ctx, requests->requestvb, + tri->colnum); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("verbose:rdbmsDbTable:mfd","error %d from " + "rdbmsDbTable_undo_column\n", rc)); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsDbTable_undo_values */ + +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:rdbmsDbTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for rdbmsDbTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return rdbmsDbTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(rdbmsDbTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:rdbmsDbTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + rdbmsDbTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:rdbmsDbTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in rdbmsDbTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + rdbmsDbTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_rdbmsDbTable_container_init(rdbmsDbTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:rdbmsDbTable:_rdbmsDbTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + rdbmsDbTable_oid, + rdbmsDbTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for rdbmsDbTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + rdbmsDbTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("rdbmsDbTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "rdbmsDbTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _rdbmsDbTable_container_init */ + diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.h new file mode 100644 index 0000000..2d74fdc --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_interface.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_interface.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_interface.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_INTERFACE_H +#define RDBMSDBTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "rdbmsDbTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _rdbmsDbTable_initialize_interface(rdbmsDbTable_registration_ptr user_ctx, + u_long flags); + + rdbmsDbTable_rowreq_ctx * rdbmsDbTable_allocate_rowreq_ctx(void); +void rdbmsDbTable_release_rowreq_ctx(rdbmsDbTable_rowreq_ctx *rowreq_ctx); + +int rdbmsDbTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsDbTable_mib_index *mib_idx); +int rdbmsDbTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsDbTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void rdbmsDbTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_INTERFACE_H */ diff --git a/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_oids.h b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_oids.h new file mode 100644 index 0000000..8d80497 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsDbTable/rdbmsDbTable_oids.h @@ -0,0 +1,46 @@ +/*------------------------------------------------------------------------- + * rdbmsDbTable_oids.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsDbTable_oids.h,v 1.2 2007/09/13 14:20:43 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSDBTABLE_OIDS_H +#define RDBMSDBTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table rdbmsDbTable */ +#define RDBMSDBTABLE_OID 1,3,6,1,2,1,39,1,1 +#define COLUMN_RDBMSDBINDEX 1 +#define COLUMN_RDBMSDBPRIVATEMIBOID 2 +#define COLUMN_RDBMSDBVENDORNAME 3 +#define COLUMN_RDBMSDBNAME 4 +#define COLUMN_RDBMSDBCONTACT 5 + +#define RDBMSDBTABLE_MIN_COL COLUMN_RDBMSDBPRIVATEMIBOID +#define RDBMSDBTABLE_MAX_COL COLUMN_RDBMSDBCONTACT + + /* + * change flags for writable columns + */ +#define FLAG_RDBMSDBCONTACT (0x1 << 0) + +#define FLAG_MAX_RDBMSDBTABLE 1 + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSDBTABLE_OIDS_H */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.c b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.c new file mode 100644 index 0000000..a911d5d --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.c @@ -0,0 +1,130 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable.c,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsRelTable.h" + +#include + +#include "rdbmsRelTable_interface.h" + +oid rdbmsRelTable_oid[] = { RDBMSRELTABLE_OID }; +int rdbmsRelTable_oid_size = OID_LENGTH(rdbmsRelTable_oid); + +void initialize_table_rdbmsRelTable(void); + + +/** + * Initializes the rdbmsRelTable module + */ +void +init_rdbmsRelTable(void) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:init_rdbmsRelTable","called\n")); + + /* + * TODO:300:o: Perform rdbmsRelTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("rdbmsRelTable")) + initialize_table_rdbmsRelTable(); + +} /* init_rdbmsRelTable */ + +/** + * Initialize the table rdbmsRelTable + * (Define its contents and how it's structured) + */ +void +initialize_table_rdbmsRelTable(void) +{ + rdbmsRelTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:rdbmsRelTable:initialize_table_rdbmsRelTable","called\n")); + + /* + * TODO:301:o: Perform rdbmsRelTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize rdbmsRelTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("rdbmsRelTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _rdbmsRelTable_initialize_interface(user_context, flags); +} /* initialize_table_rdbmsRelTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +rdbmsRelTable_pre_request(rdbmsRelTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform rdbmsRelTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsRelTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +rdbmsRelTable_post_request(rdbmsRelTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_post_request","called\n")); + + /* + * TODO:511:o: Perform rdbmsRelTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsRelTable_post_request */ + + +/** @{ */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.h new file mode 100644 index 0000000..1c44b8d --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable.h @@ -0,0 +1,205 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_H +#define RDBMSRELTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(RDBMS-MIB/rdbmsRelTable/rdbmsRelTable_interface); +config_require(RDBMS-MIB/rdbmsRelTable/rdbmsRelTable_data_access); +config_require(RDBMS-MIB/rdbmsRelTable/rdbmsRelTable_data_get); +config_require(RDBMS-MIB/rdbmsRelTable/rdbmsRelTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "rdbmsRelTable_oids.h" + +/* enum definions */ +#include "rdbmsRelTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_rdbmsRelTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsRelTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsRelTable is subid 9 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.9, length: 9 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review rdbmsRelTable registration context. + */ +typedef netsnmp_data_list * rdbmsRelTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review rdbmsRelTable data context structure. + * This structure is used to represent the data for rdbmsRelTable. + */ +/* + * This structure contains storage for all the columns defined in the + * rdbmsRelTable. + */ +typedef struct rdbmsRelTable_data_s { + + /* + * rdbmsRelState(1)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h + */ + u_long rdbmsRelState; + + /* + * rdbmsRelActiveTime(2)/DateAndTime/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + int activeTimeYear; + int activeTimeMonth; + int activeTimeDay; + int activeTimeHour; + int activeTimeMinutes; + int activeTimeSeconds; + int activeTimeDeciSeconds; + int activeTimeUtcOffsetDirection; + int activeTimeUtcOffsetHours; + int activeTimeUtcOffsetMinutes; + +} rdbmsRelTable_data; + + +/* + * TODO:120:r: |-> Review rdbmsRelTable mib index. + * This structure is used to represent the index for rdbmsRelTable. + */ +typedef struct rdbmsRelTable_mib_index_s { + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + /* + * applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long applIndex; + + +} rdbmsRelTable_mib_index; + + /* + * TODO:121:r: | |-> Review rdbmsRelTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. +*/ +#define MAX_rdbmsRelTable_IDX_LEN 2 + + +/* ********************************************************************* + * TODO:130:o: |-> Review rdbmsRelTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * rdbmsRelTable_rowreq_ctx pointer. + */ +typedef struct rdbmsRelTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_rdbmsRelTable_IDX_LEN]; + + rdbmsRelTable_mib_index tbl_idx; + + rdbmsRelTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + rdbmsRelTable_registration_ptr rdbmsRelTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to rdbmsRelTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *rdbmsRelTable_data_list; + +} rdbmsRelTable_rowreq_ctx; + +typedef struct rdbmsRelTable_ref_rowreq_ctx_s { + rdbmsRelTable_rowreq_ctx *rowreq_ctx; +} rdbmsRelTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int rdbmsRelTable_pre_request(rdbmsRelTable_registration_ptr user_context); + int rdbmsRelTable_post_request(rdbmsRelTable_registration_ptr user_context); + + +extern oid rdbmsRelTable_oid[]; +extern int rdbmsRelTable_oid_size; + + +#include "rdbmsRelTable_interface.h" +#include "rdbmsRelTable_data_access.h" +#include "rdbmsRelTable_data_get.h" +#include "rdbmsRelTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_H */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.c b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.c new file mode 100644 index 0000000..e2b6327 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.c @@ -0,0 +1,322 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_data_access.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_data_access.c,v 1.4 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsRelTable.h" +#include "rdbmsRelTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsRelTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsRelTable is subid 9 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.9, length: 9 +*/ + +/** + * initialization for rdbmsRelTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param rdbmsRelTable_reg + * Pointer to rdbmsRelTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +rdbmsRelTable_init_data(rdbmsRelTable_registration_ptr rdbmsRelTable_reg) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_init_data","called\n")); + + /* + * TODO:303:o: Initialize rdbmsRelTable data. + */ + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ + /* + * if you are the sole writer for the file, you could + * open it here. However, as stated earlier, we are assuming + * the worst case, which in this case means that the file is + * written to by someone else, and might not even exist when + * we start up. So we can't do anything here. + */ + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + + return MFD_SUCCESS; +} /* rdbmsRelTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +rdbmsRelTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to rdbmsRelTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up rdbmsRelTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = RDBMSRELTABLE_CACHE_TIMEOUT; /* seconds */ +} /* rdbmsRelTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement rdbmsRelTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * rdbmsRelTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +rdbmsRelTable_cache_load(netsnmp_container *container) +{ + rdbmsRelTable_rowreq_ctx *rowreq_ctx; + long applIndex = 1; + int resultCount, errorCode = MFD_SUCCESS, i, tmpInt, count = 0; + PGresult *pg_db_qry; + + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_cache_load","called\n")); + + /* + * TODO:351:M: |-> Load/update data in the rdbmsRelTable container. + * loop over your rdbmsRelTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + + if (PQstatus(dbconn) == CONNECTION_OK) + pg_db_qry = PQexec(dbconn, "SELECT datid, EXTRACT(YEAR FROM pg_postmaster_start_time()), EXTRACT(MONTH FROM pg_postmaster_start_time()), EXTRACT(DAY FROM pg_postmaster_start_time()), EXTRACT(HOUR FROM pg_postmaster_start_time()), EXTRACT(MINUTE FROM pg_postmaster_start_time()), EXTRACT(SECOND FROM pg_postmaster_start_time()), EXTRACT(MILLISECOND FROM pg_postmaster_start_time()), EXTRACT(TIMEZONE_HOUR FROM pg_postmaster_start_time()), EXTRACT(TIMEZONE_MINUTE FROM pg_postmaster_start_time()) FROM pg_stat_database"); + else { + snmp_log(LOG_ERR, "Can't get connected to the database"); + return MFD_RESOURCE_UNAVAILABLE; + } + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database"); + PQclear(pg_db_qry); + /*PQfinish(dbconn);*/ + /* It's probably an error if I didn't find *any* databases */ + return MFD_RESOURCE_UNAVAILABLE; + } + + resultCount = PQntuples(pg_db_qry); + + for(i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new rdbmsRelTable rowreq context. + */ + rowreq_ctx = rdbmsRelTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + errorCode = MFD_RESOURCE_UNAVAILABLE; + break; + } + tmpInt = atoi(PQgetvalue(pg_db_qry, i, 0)); + if(MFD_SUCCESS != rdbmsRelTable_indexes_set(rowreq_ctx + , tmpInt + , applIndex + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "rdbmsRelTable cache.\n"); + rdbmsRelTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + + /* + * TODO:352:r: | |-> populate rdbmsRelTable data context. + * Populate data context here. (optionally, delay until row prep) + */ + + /* All databases are active */ + if(MFD_SUCCESS != + rdbmsRelState_map(&rowreq_ctx->data.rdbmsRelState, INTERNAL_RDBMSRELSTATE_ACTIVE)) { + return MFD_ERROR; + } + + rowreq_ctx->data.activeTimeYear = atoi(PQgetvalue(pg_db_qry, i, 1)); + rowreq_ctx->data.activeTimeMonth = atoi(PQgetvalue(pg_db_qry, i, 2)); + rowreq_ctx->data.activeTimeDay = atoi(PQgetvalue(pg_db_qry, i, 3)); + rowreq_ctx->data.activeTimeHour = atoi(PQgetvalue(pg_db_qry, i, 4)); + rowreq_ctx->data.activeTimeMinutes = atoi(PQgetvalue(pg_db_qry, i, 5)); + rowreq_ctx->data.activeTimeSeconds = atoi(PQgetvalue(pg_db_qry, i, 6)); + rowreq_ctx->data.activeTimeDeciSeconds = atoi(PQgetvalue(pg_db_qry, i, 7)); + rowreq_ctx->data.activeTimeUtcOffsetHours = atoi(PQgetvalue(pg_db_qry, i, 8)); + rowreq_ctx->data.activeTimeUtcOffsetMinutes = atoi(PQgetvalue(pg_db_qry, i, 9)); + tmpInt = rowreq_ctx->data.activeTimeUtcOffsetHours * 60 + rowreq_ctx->data.activeTimeUtcOffsetMinutes; + if (tmpInt == 0) + rowreq_ctx->data.activeTimeUtcOffsetDirection = 0; + else + rowreq_ctx->data.activeTimeUtcOffsetDirection = (tmpInt > 0 ? 1 : -1); + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + DEBUGMSGT(("verbose:rdbmsRelTable:rdbmsRelTable_cache_load", + "inserted %d records\n", count)); + + PQclear(pg_db_qry); + + return errorCode; +} /* rdbmsRelTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +rdbmsRelTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_cache_free","called\n")); + + /* + * TODO:380:M: Free rdbmsRelTable cache. + */ +} /* rdbmsRelTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +rdbmsRelTable_row_prep( rdbmsRelTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* rdbmsRelTable_row_prep */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.h new file mode 100644 index 0000000..195fa5f --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_access.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_data_access.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_data_access.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_DATA_ACCESS_H +#define RDBMSRELTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsRelTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsRelTable is subid 9 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.9, length: 9 +*/ + + + int rdbmsRelTable_init_data(rdbmsRelTable_registration_ptr rdbmsRelTable_reg); + + +/* + * TODO:180:o: Review rdbmsRelTable cache timeout. + * The number of seconds before the cache times out + */ +#define RDBMSRELTABLE_CACHE_TIMEOUT 60 + +void rdbmsRelTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int rdbmsRelTable_cache_load(netsnmp_container *container); +void rdbmsRelTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int rdbmsRelTable_row_prep( rdbmsRelTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_DATA_ACCESS_H */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.c b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.c new file mode 100644 index 0000000..9895a63 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.c @@ -0,0 +1,378 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_data_get.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_data_get.c,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsRelTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement rdbmsRelTable get routines. + * TODO:240:M: Implement rdbmsRelTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsRelTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsRelTable is subid 9 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.9, length: 9 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement rdbmsRelTable data context functions. + */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +rdbmsRelTable_indexes_set_tbl_idx(rdbmsRelTable_mib_index *tbl_idx, long rdbmsDbIndex_val, long applIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_indexes_set_tbl_idx","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + /* applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->applIndex = applIndex_val; + + + return MFD_SUCCESS; +} /* rdbmsRelTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +rdbmsRelTable_indexes_set(rdbmsRelTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val, long applIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_indexes_set","called\n")); + + if(MFD_SUCCESS != rdbmsRelTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , rdbmsDbIndex_val + , applIndex_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != rdbmsRelTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsRelTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsRelEntry.rdbmsRelState + * rdbmsRelState is subid 1 of rdbmsRelEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.9.1.1 + * Description: +The state of this server's access to this database. + Active(2) means the server is actively using the database. + Available(3) means the server could use the database if + necessary. Restricted(4) means the database is in some + administratively determined state of less-than-complete + availability. Unavailable(5) means the database is not + available through this server. Other(1) means the + database/server is in some other condition, possibly + described in the vendor private MIB. + * + * Attributes: + * accessible 1 isscalar 0 enums 1 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * Enum range: 3/8. Values: other(1), active(2), available(3), restricted(4), unavailable(5) + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsRelState.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsRelState_map(u_long *mib_rdbmsRelState_val_ptr, u_long raw_rdbmsRelState_val) +{ + netsnmp_assert(NULL != mib_rdbmsRelState_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelState_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsRelState enum mapping. + * uses INTERNAL_* macros defined in the header files + */ + switch(raw_rdbmsRelState_val) { + case INTERNAL_RDBMSRELSTATE_OTHER: + *mib_rdbmsRelState_val_ptr = RDBMSRELSTATE_OTHER; + break; + + case INTERNAL_RDBMSRELSTATE_ACTIVE: + *mib_rdbmsRelState_val_ptr = RDBMSRELSTATE_ACTIVE; + break; + + case INTERNAL_RDBMSRELSTATE_AVAILABLE: + *mib_rdbmsRelState_val_ptr = RDBMSRELSTATE_AVAILABLE; + break; + + case INTERNAL_RDBMSRELSTATE_RESTRICTED: + *mib_rdbmsRelState_val_ptr = RDBMSRELSTATE_RESTRICTED; + break; + + case INTERNAL_RDBMSRELSTATE_UNAVAILABLE: + *mib_rdbmsRelState_val_ptr = RDBMSRELSTATE_UNAVAILABLE; + break; + + default: + snmp_log(LOG_ERR, "couldn't map value %ld for rdbmsRelState\n", raw_rdbmsRelState_val ); + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsRelState_map */ + +/** + * Extract the current value of the rdbmsRelState data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsRelState_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsRelState_get( rdbmsRelTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsRelState_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsRelState_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelState_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsRelState data. + * set (* rdbmsRelState_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsRelState_val_ptr ) = rowreq_ctx->data.rdbmsRelState; + + return MFD_SUCCESS; +} /* rdbmsRelState_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsRelEntry.rdbmsRelActiveTime + * rdbmsRelActiveTime is subid 2 of rdbmsRelEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.9.1.2 + * Description: +The time the database was made active by the server. If an + instance of rdbmsRelState is not active(1), then attempts to + access the corresponding instance of this object may result + in either noSuchName (SNMPv1) or noSuchInstance (SNMPv2) + being returned by the agent. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 2d-1d-1d,1d:1d:1d.1d,1a1d:1d + * + * Ranges: 8, 11; + * + * Its syntax is DateAndTime (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 11) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsRelActiveTime.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsRelActiveTime_map(char **mib_rdbmsRelActiveTime_val_ptr_ptr, size_t *mib_rdbmsRelActiveTime_val_ptr_len_ptr, char *raw_rdbmsRelActiveTime_val_ptr, size_t raw_rdbmsRelActiveTime_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsRelActiveTime_val_ptr); + netsnmp_assert((NULL != mib_rdbmsRelActiveTime_val_ptr_ptr) && (NULL != mib_rdbmsRelActiveTime_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelActiveTime_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsRelActiveTime non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsRelActiveTime_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsRelActiveTime_val_ptr_ptr) || (*mib_rdbmsRelActiveTime_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsRelActiveTime_val_ptr_ptr = realloc( *mib_rdbmsRelActiveTime_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsRelActiveTime_val_ptr_ptr)); + if(NULL == *mib_rdbmsRelActiveTime_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsRelActiveTime_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsRelActiveTime_val_ptr_ptr, raw_rdbmsRelActiveTime_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsRelActiveTime_map */ + +/** + * Extract the current value of the rdbmsRelActiveTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsRelActiveTime_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsRelActiveTime_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsRelActiveTime. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsRelActiveTime_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsRelActiveTime_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsRelActiveTime_get( rdbmsRelTable_rowreq_ctx *rowreq_ctx, char **rdbmsRelActiveTime_val_ptr_ptr, size_t *rdbmsRelActiveTime_val_ptr_len_ptr ) +{ + int rc; + /** we should have a pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsRelActiveTime_val_ptr_ptr) && (NULL != *rdbmsRelActiveTime_val_ptr_ptr)); + netsnmp_assert( (NULL != rdbmsRelActiveTime_val_ptr_len_ptr) && ((* rdbmsRelActiveTime_val_ptr_len_ptr) >= 11)); + + /* + * TODO:231:o: |-> copy rdbmsRelActiveTime data. + * get the date from your context pointer. + */ + + /* call convenience function to set data */ + rc = netsnmp_dateandtime_set_buf_from_vars((u_char *)*rdbmsRelActiveTime_val_ptr_ptr, rdbmsRelActiveTime_val_ptr_len_ptr, + rowreq_ctx->data.activeTimeYear, + rowreq_ctx->data.activeTimeMonth, + rowreq_ctx->data.activeTimeDay, + rowreq_ctx->data.activeTimeHour, + rowreq_ctx->data.activeTimeMinutes, + rowreq_ctx->data.activeTimeSeconds, + rowreq_ctx->data.activeTimeDeciSeconds, + rowreq_ctx->data.activeTimeUtcOffsetDirection, + rowreq_ctx->data.activeTimeUtcOffsetHours, + rowreq_ctx->data.activeTimeUtcOffsetMinutes); + if(rc != SNMP_ERR_NOERROR) + return rc; + + + return MFD_SUCCESS; +} /* rdbmsRelActiveTime_get */ + + + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.h new file mode 100644 index 0000000..2f86b58 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_get.h @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_data_get.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_data_get.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_DATA_GET_H +#define RDBMSRELTABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsRelTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsRelTable is subid 9 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.9, length: 9 +*/ + /* + * indexes + */ + int rdbmsDbIndex_map(long *mib_rdbmsDbIndex_val_ptr, long raw_rdbmsDbIndex_val); + int applIndex_map(long *mib_applIndex_val_ptr, long raw_applIndex_val); + + int rdbmsRelState_map(u_long *mib_rdbmsRelState_val_ptr, u_long raw_rdbmsRelState_val); + int rdbmsRelState_get( rdbmsRelTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsRelState_val_ptr ); + int rdbmsRelActiveTime_map(char **mib_rdbmsRelActiveTime_val_ptr_ptr, size_t *mib_rdbmsRelActiveTime_val_ptr_len_ptr, char *raw_rdbmsRelActiveTime_val_ptr, size_t raw_rdbmsRelActiveTime_val_ptr_len, int allow_realloc); + int rdbmsRelActiveTime_get( rdbmsRelTable_rowreq_ctx *rowreq_ctx, char **rdbmsRelActiveTime_val_ptr_ptr, size_t *rdbmsRelActiveTime_val_ptr_len_ptr ); + + +int rdbmsRelTable_indexes_set_tbl_idx(rdbmsRelTable_mib_index *tbl_idx, long rdbmsDbIndex_val, long applIndex_val); +int rdbmsRelTable_indexes_set(rdbmsRelTable_rowreq_ctx *rowreq_ctx, long rdbmsDbIndex_val, long applIndex_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_DATA_GET_H */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.c b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.c new file mode 100644 index 0000000..a2de409 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.c @@ -0,0 +1,30 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_data_set.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_data_set.c,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +/* standard Net-SNMP includes */ +#include +#include +#include + +/* include our parent header */ +#include "rdbmsRelTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.h new file mode 100644 index 0000000..3b62de5 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_data_set.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_data_set.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_data_set.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_DATA_SET_H +#define RDBMSRELTABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_DATA_SET_H */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_enums.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_enums.h new file mode 100644 index 0000000..7415b02 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_enums.h @@ -0,0 +1,76 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_enums.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_enums.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_ENUMS_H +#define RDBMSRELTABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table rdbmsRelTable + * + ************************************************************************* + *************************************************************************/ + +/************************************************************* + * constants for enums for the MIB node + * rdbmsRelState (INTEGER / ASN_INTEGER) + * + * since a Textual Convention may be referenced more than once in a + * MIB, protect againt redefinitions of the enum values. + */ +#ifndef RDBMSRELSTATE_ENUMS +#define RDBMSRELSTATE_ENUMS + +#define RDBMSRELSTATE_OTHER 1 +#define RDBMSRELSTATE_ACTIVE 2 +#define RDBMSRELSTATE_AVAILABLE 3 +#define RDBMSRELSTATE_RESTRICTED 4 +#define RDBMSRELSTATE_UNAVAILABLE 5 + + +#endif /* RDBMSRELSTATE_ENUMS */ + + /* + * TODO:140:o: Define interal representation of rdbmsRelState enums. + * (used for value mapping; see notes at top of file) + */ +#define INTERNAL_RDBMSRELSTATE_OTHER 1 +#define INTERNAL_RDBMSRELSTATE_ACTIVE 2 +#define INTERNAL_RDBMSRELSTATE_AVAILABLE 3 +#define INTERNAL_RDBMSRELSTATE_RESTRICTED 4 +#define INTERNAL_RDBMSRELSTATE_UNAVAILABLE 5 + + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_ENUMS_H */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.c b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.c new file mode 100644 index 0000000..6329fac --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.c @@ -0,0 +1,712 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_interface.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_interface.c,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsRelTable.h" + + +#include + +#include "rdbmsRelTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsRelTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsRelTable is subid 9 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.9, length: 9 +*/ +typedef struct rdbmsRelTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + rdbmsRelTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} rdbmsRelTable_interface_ctx; + +static rdbmsRelTable_interface_ctx rdbmsRelTable_if_ctx; + +static void _rdbmsRelTable_container_init( + rdbmsRelTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_rdbmsRelTable_pre_request; +static Netsnmp_Node_Handler _mfd_rdbmsRelTable_post_request; +static Netsnmp_Node_Handler _mfd_rdbmsRelTable_object_lookup; +static Netsnmp_Node_Handler _mfd_rdbmsRelTable_get_values; +/** + * @internal + * Initialize the table rdbmsRelTable + * (Define its contents and how it's structured) + */ +void +_rdbmsRelTable_initialize_interface(rdbmsRelTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &rdbmsRelTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &rdbmsRelTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:rdbmsRelTable:_rdbmsRelTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for rdbmsRelTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_INTEGER, /** index: rdbmsDbIndex */ + ASN_INTEGER, /** index: applIndex */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = RDBMSRELTABLE_MIN_COL; + tbl_info->max_column = RDBMSRELTABLE_MAX_COL; + + /* + * save users context + */ + rdbmsRelTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + rdbmsRelTable_init_data(reg_ptr); + + /* + * set up the container + */ + _rdbmsRelTable_container_init(&rdbmsRelTable_if_ctx); + if (NULL == rdbmsRelTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for rdbmsRelTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_rdbmsRelTable_object_lookup; + access_multiplexer->get_values = _mfd_rdbmsRelTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_rdbmsRelTable_pre_request; + access_multiplexer->post_request = _mfd_rdbmsRelTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("rdbmsRelTable:init_rdbmsRelTable", + "Registering rdbmsRelTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("rdbmsRelTable", handler, + rdbmsRelTable_oid, + rdbmsRelTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table rdbmsRelTable\n"); + return; + } + reginfo->my_reg_void = &rdbmsRelTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + rdbmsRelTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != rdbmsRelTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(rdbmsRelTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _rdbmsRelTable_initialize_interface */ + +void +rdbmsRelTable_valid_columns_set(netsnmp_column_info *vc) +{ + rdbmsRelTable_if_ctx.tbl_info.valid_columns = vc; +} /* rdbmsRelTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +rdbmsRelTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsRelTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_applIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_applIndex, 0x00, sizeof(var_applIndex) ); + var_applIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = &var_applIndex; var_applIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_index_to_oid","called\n")); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + /* applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_applIndex, (u_char*)&mib_idx->applIndex, + sizeof(mib_idx->applIndex)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_rdbmsDbIndex); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsRelTable_index_to_oid */ + +/** + * extract rdbmsRelTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +rdbmsRelTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsRelTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_applIndex; + + /* + * set up varbinds + */ + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_applIndex, 0x00, sizeof(var_applIndex) ); + var_applIndex.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_rdbmsDbIndex.next_variable = &var_applIndex; var_applIndex.next_variable = NULL; + + + DEBUGMSGTL(("verbose:rdbmsRelTable:rdbmsRelTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_rdbmsDbIndex ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + mib_idx->applIndex = *((long *)var_applIndex.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_rdbmsDbIndex ); + + return err; +} /* rdbmsRelTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a rdbmsRelTable_rowreq_ctx + */ +rdbmsRelTable_rowreq_ctx * +rdbmsRelTable_allocate_rowreq_ctx(void) +{ + rdbmsRelTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(rdbmsRelTable_rowreq_ctx); + + DEBUGMSGTL(("internal:rdbmsRelTable:rdbmsRelTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "rdbmsRelTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->rdbmsRelTable_data_list = NULL; + rowreq_ctx->rdbmsRelTable_reg = rdbmsRelTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* rdbmsRelTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a rdbmsRelTable_rowreq_ctx + */ +void +rdbmsRelTable_release_rowreq_ctx(rdbmsRelTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:rdbmsRelTable:rdbmsRelTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* rdbmsRelTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsRelTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = rdbmsRelTable_pre_request(rdbmsRelTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsRelTable","error %d from " + "rdbmsRelTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsRelTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsRelTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsRelTable_rowreq_ctx *rowreq_ctx; + int rc = rdbmsRelTable_post_request(rdbmsRelTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:rdbmsRelTable","error %d from " + "rdbmsRelTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(rdbmsRelTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(rdbmsRelTable_if_ctx.container, rowreq_ctx); + rdbmsRelTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsRelTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_rdbmsRelTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsRelTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:rdbmsRelTable:_mfd_rdbmsRelTable_object_lookup","called\n")); + + /* + * get our context from mfd + * rdbmsRelTable_interface_ctx *if_ctx = + * (rdbmsRelTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + rdbmsRelTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsRelTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_rdbmsRelTable_get_column( rdbmsRelTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:rdbmsRelTable:_mfd_rdbmsRelTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* rdbmsRelState(1)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h */ + case COLUMN_RDBMSRELSTATE: + var->val_len = sizeof(u_long); + var->type = ASN_INTEGER; +rc = rdbmsRelState_get(rowreq_ctx, (u_long *)var->val.string ); + break; + + /* rdbmsRelActiveTime(2)/DateAndTime/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_RDBMSRELACTIVETIME: + var->type = ASN_OCTET_STR; +rc = rdbmsRelActiveTime_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _rdbmsRelTable_get_column\n", column); + break; + } + + return rc; +} /* _rdbmsRelTable_get_column */ + +int +_mfd_rdbmsRelTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + rdbmsRelTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:rdbmsRelTable:_mfd_rdbmsRelTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _rdbmsRelTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_rdbmsRelTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:rdbmsRelTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for rdbmsRelTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return rdbmsRelTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(rdbmsRelTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:rdbmsRelTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + rdbmsRelTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:rdbmsRelTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in rdbmsRelTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + rdbmsRelTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_rdbmsRelTable_container_init(rdbmsRelTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:rdbmsRelTable:_rdbmsRelTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + rdbmsRelTable_oid, + rdbmsRelTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for rdbmsRelTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + rdbmsRelTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("rdbmsRelTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "rdbmsRelTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _rdbmsRelTable_container_init */ + diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.h new file mode 100644 index 0000000..148c92d --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_interface.h @@ -0,0 +1,50 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_interface.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_interface.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_INTERFACE_H +#define RDBMSRELTABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "rdbmsRelTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _rdbmsRelTable_initialize_interface(rdbmsRelTable_registration_ptr user_ctx, + u_long flags); + + rdbmsRelTable_rowreq_ctx * rdbmsRelTable_allocate_rowreq_ctx(void); +void rdbmsRelTable_release_rowreq_ctx(rdbmsRelTable_rowreq_ctx *rowreq_ctx); + +int rdbmsRelTable_index_to_oid(netsnmp_index *oid_idx, + rdbmsRelTable_mib_index *mib_idx); +int rdbmsRelTable_index_from_oid(netsnmp_index *oid_idx, + rdbmsRelTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void rdbmsRelTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_INTERFACE_H */ diff --git a/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_oids.h b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_oids.h new file mode 100644 index 0000000..371f101 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsRelTable/rdbmsRelTable_oids.h @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- + * rdbmsRelTable_oids.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsRelTable_oids.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSRELTABLE_OIDS_H +#define RDBMSRELTABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table rdbmsRelTable */ +#define RDBMSRELTABLE_OID 1,3,6,1,2,1,39,1,9 +#define COLUMN_RDBMSRELSTATE 1 +#define COLUMN_RDBMSRELACTIVETIME 2 + +#define RDBMSRELTABLE_MIN_COL COLUMN_RDBMSRELSTATE +#define RDBMSRELTABLE_MAX_COL COLUMN_RDBMSRELACTIVETIME + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSRELTABLE_OIDS_H */ diff --git a/RDBMS-MIB_src/rdbmsSrvInfoTable/README b/RDBMS-MIB_src/rdbmsSrvInfoTable/README new file mode 100644 index 0000000..d2cd2fe --- /dev/null +++ b/RDBMS-MIB_src/rdbmsSrvInfoTable/README @@ -0,0 +1 @@ +For PostgreSQL version 8.0.x, rdbmsSrvInfoStartupTime is not properly reported, because that information is unavailable. diff --git a/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.c b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.c new file mode 100644 index 0000000..264eb69 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.c @@ -0,0 +1,127 @@ +/*------------------------------------------------------------------------- + * rdbmsSrvInfoTable.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsSrvInfoTable.c,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsSrvInfoTable.h" + +/*#include */ + +#include "rdbmsSrvInfoTable_interface.h" + +oid rdbmsSrvInfoTable_oid[] = { RDBMSSRVINFOTABLE_OID }; +int rdbmsSrvInfoTable_oid_size = OID_LENGTH(rdbmsSrvInfoTable_oid); + +void initialize_table_rdbmsSrvInfoTable(void); + + +/** + * Initializes the rdbmsSrvInfoTable module + */ +void +init_rdbmsSrvInfoTable(void) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:init_rdbmsSrvInfoTable","called\n")); + + /* + * TODO:300:o: Perform rdbmsSrvInfoTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("rdbmsSrvInfoTable")) + initialize_table_rdbmsSrvInfoTable(); + +} /* init_rdbmsSrvInfoTable */ + +/** + * Initialize the table rdbmsSrvInfoTable + * (Define its contents and how it's structured) + */ +void +initialize_table_rdbmsSrvInfoTable(void) +{ + rdbmsSrvInfoTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:initialize_table_rdbmsSrvInfoTable","called\n")); + + /* + * TODO:301:o: Perform rdbmsSrvInfoTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize rdbmsSrvInfoTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("rdbmsSrvInfoTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _rdbmsSrvInfoTable_initialize_interface(user_context, flags); +} /* initialize_table_rdbmsSrvInfoTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +rdbmsSrvInfoTable_pre_request(rdbmsSrvInfoTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform rdbmsSrvInfoTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsSrvInfoTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +rdbmsSrvInfoTable_post_request(rdbmsSrvInfoTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_post_request","called\n")); + + /* + * TODO:511:o: Perform rdbmsSrvInfoTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* rdbmsSrvInfoTable_post_request */ + + +/** @{ */ diff --git a/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.h b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.h new file mode 100644 index 0000000..77389c6 --- /dev/null +++ b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable.h @@ -0,0 +1,262 @@ +/*------------------------------------------------------------------------- + * rdbmsSrvInfoTable.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsSrvInfoTable.h,v 1.2 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSSRVINFOTABLE_H +#define RDBMSSRVINFOTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(RDBMS-MIB/rdbmsSrvInfoTable/rdbmsSrvInfoTable_interface); +config_require(RDBMS-MIB/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access); +config_require(RDBMS-MIB/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get); +config_require(RDBMS-MIB/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "rdbmsSrvInfoTable_oids.h" + +/* enum definions */ +#include "rdbmsSrvInfoTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_rdbmsSrvInfoTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsSrvInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsSrvInfoTable is subid 6 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.6, length: 9 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review rdbmsSrvInfoTable registration context. + */ +typedef netsnmp_data_list * rdbmsSrvInfoTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review rdbmsSrvInfoTable data context structure. + * This structure is used to represent the data for rdbmsSrvInfoTable. + */ +/* + * This structure contains storage for all the columns defined in the + * rdbmsSrvInfoTable. + */ +typedef struct rdbmsSrvInfoTable_data_s { + + /* + * rdbmsSrvInfoStartupTime(1)/DateAndTime/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ +/* char rdbmsSrvInfoStartupTime[11]; +size_t rdbmsSrvInfoStartupTime_len; *//* # of char elements, not bytes */ + int startupYear; + int startupMonth; + int startupDay; + int startupHour; + int startupMinutes; + int startupSeconds; + int startupDeciSeconds; + int startupUtcOffsetDirection; + int startupUtcOffsetHours; + int startupUtcOffsetMinutes; + + /* + * rdbmsSrvInfoFinishedTransactions(2)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoFinishedTransactions; + + /* + * rdbmsSrvInfoDiskReads(3)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoDiskReads; + + /* + * rdbmsSrvInfoLogicalReads(4)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoLogicalReads; + + /* + * rdbmsSrvInfoDiskWrites(5)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoDiskWrites; + + /* + * rdbmsSrvInfoLogicalWrites(6)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoLogicalWrites; + + /* + * rdbmsSrvInfoPageReads(7)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoPageReads; + + /* + * rdbmsSrvInfoPageWrites(8)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoPageWrites; + + /* + * rdbmsSrvInfoDiskOutOfSpaces(9)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoDiskOutOfSpaces; + + /* + * rdbmsSrvInfoHandledRequests(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoHandledRequests; + + /* + * rdbmsSrvInfoRequestRecvs(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoRequestRecvs; + + /* + * rdbmsSrvInfoRequestSends(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoRequestSends; + + /* + * rdbmsSrvInfoHighwaterInboundAssociations(13)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h + */ + u_long rdbmsSrvInfoHighwaterInboundAssociations; + + /* + * rdbmsSrvInfoMaxInboundAssociations(14)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/W/e/r/d/h + */ + u_long rdbmsSrvInfoMaxInboundAssociations; + +} rdbmsSrvInfoTable_data; + + +/* + * TODO:120:r: |-> Review rdbmsSrvInfoTable mib index. + * This structure is used to represent the index for rdbmsSrvInfoTable. + */ +typedef struct rdbmsSrvInfoTable_mib_index_s { + + /* + * applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long applIndex; + + +} rdbmsSrvInfoTable_mib_index; + + /* + * TODO:121:r: | |-> Review rdbmsSrvInfoTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. +*/ +#define MAX_rdbmsSrvInfoTable_IDX_LEN 1 + + +/* ********************************************************************* + * TODO:130:o: |-> Review rdbmsSrvInfoTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * rdbmsSrvInfoTable_rowreq_ctx pointer. + */ +typedef struct rdbmsSrvInfoTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_rdbmsSrvInfoTable_IDX_LEN]; + + rdbmsSrvInfoTable_mib_index tbl_idx; + + rdbmsSrvInfoTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + rdbmsSrvInfoTable_registration_ptr rdbmsSrvInfoTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to rdbmsSrvInfoTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *rdbmsSrvInfoTable_data_list; + +} rdbmsSrvInfoTable_rowreq_ctx; + +typedef struct rdbmsSrvInfoTable_ref_rowreq_ctx_s { + rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx; +} rdbmsSrvInfoTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int rdbmsSrvInfoTable_pre_request(rdbmsSrvInfoTable_registration_ptr user_context); + int rdbmsSrvInfoTable_post_request(rdbmsSrvInfoTable_registration_ptr user_context); + + +extern oid rdbmsSrvInfoTable_oid[]; +extern int rdbmsSrvInfoTable_oid_size; + + +#include "rdbmsSrvInfoTable_interface.h" +#include "rdbmsSrvInfoTable_data_access.h" +#include "rdbmsSrvInfoTable_data_get.h" +#include "rdbmsSrvInfoTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSSRVINFOTABLE_H */ diff --git a/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.c b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.c new file mode 100644 index 0000000..af424be --- /dev/null +++ b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.c @@ -0,0 +1,340 @@ +/*------------------------------------------------------------------------- + * rdbmsSrvInfoTable_data_access.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsSrvInfoTable_data_access.c,v 1.7 2009/06/06 04:12:10 eggyknap Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsSrvInfoTable.h" + + +#include "rdbmsSrvInfoTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsSrvInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsSrvInfoTable is subid 6 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.6, length: 9 +*/ + +/** + * initialization for rdbmsSrvInfoTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param rdbmsSrvInfoTable_reg + * Pointer to rdbmsSrvInfoTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +rdbmsSrvInfoTable_init_data(rdbmsSrvInfoTable_registration_ptr rdbmsSrvInfoTable_reg) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_init_data","called\n")); + + return MFD_SUCCESS; +} /* rdbmsSrvInfoTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +rdbmsSrvInfoTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to rdbmsSrvInfoTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up rdbmsSrvInfoTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = RDBMSSRVINFOTABLE_CACHE_TIMEOUT; /* seconds */ +} /* rdbmsSrvInfoTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement rdbmsSrvInfoTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * rdbmsSrvInfoTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +rdbmsSrvInfoTable_cache_load(netsnmp_container *container) +{ + rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + PGresult *pg_db_qry; + static int maxAssociations = 0; + + long applIndex; + int resultCount, tmpInt, rdbmsSrvInfoMaxInboundAssociations = 0, i, errorCode = MFD_SUCCESS; + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_cache_load","called\n")); + + if (PQstatus(dbconn) == CONNECTION_OK) { + pg_db_qry = PQexec(dbconn, "SELECT setting FROM pg_settings WHERE name = 'max_connections'"); + if (PQresultStatus(pg_db_qry) == PGRES_TUPLES_OK) + rdbmsSrvInfoMaxInboundAssociations = atoi(PQgetvalue(pg_db_qry, 0, 0)); + PQclear(pg_db_qry); + pg_db_qry = PQexec(dbconn, "SELECT setting FROM pg_settings WHERE name = 'superuser_reserved_connections'"); + if (PQresultStatus(pg_db_qry) == PGRES_TUPLES_OK) + rdbmsSrvInfoMaxInboundAssociations -= atoi(PQgetvalue(pg_db_qry, 0, 0)); + PQclear(pg_db_qry); + pg_db_qry = PQexec(dbconn, "SELECT count(1) FROM pg_stat_activity"); + if (PQresultStatus(pg_db_qry) == PGRES_TUPLES_OK) { + tmpInt = atoi(PQgetvalue(pg_db_qry, 0, 0)); + maxAssociations = (tmpInt > maxAssociations) ? tmpInt : maxAssociations; + } + PQclear(pg_db_qry); + if (PQserverVersion(dbconn) < 80100) + pg_db_qry = PQexec(dbconn, "SELECT datid, EXTRACT(YEAR FROM now()), EXTRACT(MONTH FROM now()), EXTRACT(DAY FROM now()), EXTRACT(HOUR FROM now()), EXTRACT(MINUTE FROM now()), EXTRACT(SECOND FROM now()), EXTRACT(MILLISECOND FROM now()), EXTRACT(TIMEZONE_HOUR FROM now()), EXTRACT(TIMEZONE_MINUTE FROM now()), xact_commit, blks_read, blks_read + blks_hit FROM pg_stat_database"); + else + pg_db_qry = PQexec(dbconn, "SELECT datid, EXTRACT(YEAR FROM pg_postmaster_start_time()), EXTRACT(MONTH FROM pg_postmaster_start_time()), EXTRACT(DAY FROM pg_postmaster_start_time()), EXTRACT(HOUR FROM pg_postmaster_start_time()), EXTRACT(MINUTE FROM pg_postmaster_start_time()), EXTRACT(SECOND FROM pg_postmaster_start_time()), EXTRACT(MILLISECOND FROM pg_postmaster_start_time()), EXTRACT(TIMEZONE_HOUR FROM pg_postmaster_start_time()), EXTRACT(TIMEZONE_MINUTE FROM pg_postmaster_start_time()), xact_commit, blks_read, blks_read + blks_hit FROM pg_stat_database"); + } + else { + snmp_log(LOG_ERR, "Can't get connected to the database"); + return -1; + } + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database"); + PQclear(pg_db_qry); + /*PQfinish(dbconn);*/ + return -1; + } + + resultCount = PQntuples(pg_db_qry); + + /* + * TODO:351:M: |-> Load/update data in the rdbmsSrvInfoTable container. + * loop over your rdbmsSrvInfoTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new rdbmsSrvInfoTable rowreq context. + */ + rowreq_ctx = rdbmsSrvInfoTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + errorCode = MFD_RESOURCE_UNAVAILABLE; + break; + } + applIndex = atoi(PQgetvalue(pg_db_qry, i, 0)); + if(MFD_SUCCESS != rdbmsSrvInfoTable_indexes_set(rowreq_ctx + , applIndex + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "rdbmsSrvInfoTable cache.\n"); + rdbmsSrvInfoTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + + rowreq_ctx->data.startupYear = atoi(PQgetvalue(pg_db_qry, i, 1)); + rowreq_ctx->data.startupMonth = atoi(PQgetvalue(pg_db_qry, i, 2)); + rowreq_ctx->data.startupDay = atoi(PQgetvalue(pg_db_qry, i, 3)); + rowreq_ctx->data.startupHour = atoi(PQgetvalue(pg_db_qry, i, 4)); + rowreq_ctx->data.startupMinutes = atoi(PQgetvalue(pg_db_qry, i, 5)); + rowreq_ctx->data.startupSeconds = atoi(PQgetvalue(pg_db_qry, i, 6)); + rowreq_ctx->data.startupDeciSeconds = atoi(PQgetvalue(pg_db_qry, i, 7)); + rowreq_ctx->data.startupUtcOffsetHours = atoi(PQgetvalue(pg_db_qry, i, 8)); + rowreq_ctx->data.startupUtcOffsetMinutes = atoi(PQgetvalue(pg_db_qry, i, 9)); + tmpInt = rowreq_ctx->data.startupUtcOffsetHours * 60 + rowreq_ctx->data.startupUtcOffsetMinutes; + if (tmpInt == 0) + rowreq_ctx->data.startupUtcOffsetDirection = 0; + else + rowreq_ctx->data.startupUtcOffsetDirection = (tmpInt > 0 ? 1 : -1); + + rowreq_ctx->data.rdbmsSrvInfoFinishedTransactions = atoi(PQgetvalue(pg_db_qry, i, 10)); + + rowreq_ctx->data.rdbmsSrvInfoDiskReads = atoi(PQgetvalue(pg_db_qry, i, 11)); + + rowreq_ctx->data.rdbmsSrvInfoLogicalReads = atoi(PQgetvalue(pg_db_qry, i, 12)); + + /* Skip this unless someone comes up with a way to get these data */ + /*rowreq_ctx->data.rdbmsSrvInfoDiskWrites = rdbmsSrvInfoDiskWrites; + + rowreq_ctx->data.rdbmsSrvInfoLogicalWrites = rdbmsSrvInfoLogicalWrites; */ + + rowreq_ctx->data.rdbmsSrvInfoPageReads = rowreq_ctx->data.rdbmsSrvInfoDiskReads; + + /*rowreq_ctx->data.rdbmsSrvInfoPageWrites = rdbmsSrvInfoPageWrites; */ + + /* pgsql will have a fatal error if this happens, so the value must be 0 if we're connected to a db server */ + rowreq_ctx->data.rdbmsSrvInfoDiskOutOfSpaces = 0; + + /* rowreq_ctx->data.rdbmsSrvInfoHandledRequests = rdbmsSrvInfoHandledRequests; + + rowreq_ctx->data.rdbmsSrvInfoRequestRecvs = rdbmsSrvInfoRequestRecvs; + + rowreq_ctx->data.rdbmsSrvInfoRequestSends = rdbmsSrvInfoRequestSends; */ + + rowreq_ctx->data.rdbmsSrvInfoHighwaterInboundAssociations = maxAssociations; + + rowreq_ctx->data.rdbmsSrvInfoMaxInboundAssociations = rdbmsSrvInfoMaxInboundAssociations; + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + + DEBUGMSGT(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_cache_load", + "inserted %d records\n", count)); + + PQclear(pg_db_qry); + return errorCode; +} /* rdbmsSrvInfoTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +rdbmsSrvInfoTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_cache_free","called\n")); + + /* + * TODO:380:M: Free rdbmsSrvInfoTable cache. + */ +} /* rdbmsSrvInfoTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +rdbmsSrvInfoTable_row_prep( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* rdbmsSrvInfoTable_row_prep */ + +/** @} */ diff --git a/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.h b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.h new file mode 100644 index 0000000..51b463b --- /dev/null +++ b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_access.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * rdbmsSrvInfoTable_data_access.h + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsSrvInfoTable_data_access.h,v 1.3 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#ifndef RDBMSSRVINFOTABLE_DATA_ACCESS_H +#define RDBMSSRVINFOTABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsSrvInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsSrvInfoTable is subid 6 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.6, length: 9 +*/ + + + int rdbmsSrvInfoTable_init_data(rdbmsSrvInfoTable_registration_ptr rdbmsSrvInfoTable_reg); + + +/* + * TODO:180:o: Review rdbmsSrvInfoTable cache timeout. + * The number of seconds before the cache times out + */ +#define RDBMSSRVINFOTABLE_CACHE_TIMEOUT 10 + +void rdbmsSrvInfoTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int rdbmsSrvInfoTable_cache_load(netsnmp_container *container); +void rdbmsSrvInfoTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int rdbmsSrvInfoTable_row_prep( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* RDBMSSRVINFOTABLE_DATA_ACCESS_H */ diff --git a/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get.c b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get.c new file mode 100644 index 0000000..e0ff3bc --- /dev/null +++ b/RDBMS-MIB_src/rdbmsSrvInfoTable/rdbmsSrvInfoTable_data_get.c @@ -0,0 +1,1429 @@ +/*------------------------------------------------------------------------- + * rdbmsSrvInfoTable_data_get.c + * + * RDBMSMIB mib module. + * + * Copyright (c) 2004-2007, PostgreSQL Global Development Group + * Author: Joshua Tolley + * + * $Id: rdbmsSrvInfoTable_data_get.c,v 1.4 2007/09/13 14:20:44 h-saito Exp $ + * + *------------------------------------------------------------------------- + */ + +#include "pgsnmpd.h" + +/* include our parent header */ +#include "rdbmsSrvInfoTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement rdbmsSrvInfoTable get routines. + * TODO:240:M: Implement rdbmsSrvInfoTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table rdbmsSrvInfoTable + *** + ********************************************************************** + **********************************************************************/ +/* + * rdbmsSrvInfoTable is subid 6 of rdbmsObjects. + * Its status is Current. + * OID: .1.3.6.1.2.1.39.1.6, length: 9 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement rdbmsSrvInfoTable data context functions. + */ + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +rdbmsSrvInfoTable_indexes_set_tbl_idx(rdbmsSrvInfoTable_mib_index *tbl_idx, long applIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_indexes_set_tbl_idx","called\n")); + + /* applIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->applIndex = applIndex_val; + + + return MFD_SUCCESS; +} /* rdbmsSrvInfoTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +rdbmsSrvInfoTable_indexes_set(rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, long applIndex_val) +{ + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoTable_indexes_set","called\n")); + + if(MFD_SUCCESS != rdbmsSrvInfoTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , applIndex_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != rdbmsSrvInfoTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* rdbmsSrvInfoTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoStartupTime + * rdbmsSrvInfoStartupTime is subid 1 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.1 + * Description: +The date and time at which this server was last started. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 2d-1d-1d,1d:1d:1d.1d,1a1d:1d + * + * Ranges: 8, 11; + * + * Its syntax is DateAndTime (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 11) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoStartupTime.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoStartupTime_map(char **mib_rdbmsSrvInfoStartupTime_val_ptr_ptr, size_t *mib_rdbmsSrvInfoStartupTime_val_ptr_len_ptr, char *raw_rdbmsSrvInfoStartupTime_val_ptr, size_t raw_rdbmsSrvInfoStartupTime_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_rdbmsSrvInfoStartupTime_val_ptr); + netsnmp_assert((NULL != mib_rdbmsSrvInfoStartupTime_val_ptr_ptr) && (NULL != mib_rdbmsSrvInfoStartupTime_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoStartupTime_map","called\n")); + + /* + * TODO:241:r: |-> Implement rdbmsSrvInfoStartupTime non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_rdbmsSrvInfoStartupTime_val_ptr_len; /* assume equal */ + if((NULL == *mib_rdbmsSrvInfoStartupTime_val_ptr_ptr) || (*mib_rdbmsSrvInfoStartupTime_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_rdbmsSrvInfoStartupTime_val_ptr_ptr = realloc( *mib_rdbmsSrvInfoStartupTime_val_ptr_ptr, converted_len * sizeof(**mib_rdbmsSrvInfoStartupTime_val_ptr_ptr)); + if(NULL == *mib_rdbmsSrvInfoStartupTime_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_rdbmsSrvInfoStartupTime_val_ptr_len_ptr = converted_len; + memcpy( *mib_rdbmsSrvInfoStartupTime_val_ptr_ptr, raw_rdbmsSrvInfoStartupTime_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* rdbmsSrvInfoStartupTime_map */ + +/** + * Extract the current value of the rdbmsSrvInfoStartupTime data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoStartupTime_val_ptr_ptr + * Pointer to storage for a char variable + * @param rdbmsSrvInfoStartupTime_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by rdbmsSrvInfoStartupTime. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*rdbmsSrvInfoStartupTime_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update rdbmsSrvInfoStartupTime_val_ptr_ptr. + * DO NOT free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +rdbmsSrvInfoStartupTime_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, char **rdbmsSrvInfoStartupTime_val_ptr_ptr, size_t *rdbmsSrvInfoStartupTime_val_ptr_len_ptr ) +{ + int rc; + /** we should have a pointer and enough storage */ + netsnmp_assert( (NULL != rdbmsSrvInfoStartupTime_val_ptr_ptr) && (NULL != *rdbmsSrvInfoStartupTime_val_ptr_ptr)); + netsnmp_assert( (NULL != rdbmsSrvInfoStartupTime_val_ptr_len_ptr) && ((* rdbmsSrvInfoStartupTime_val_ptr_len_ptr) >= 11)); + + /* call convenience function to set data */ + rc = netsnmp_dateandtime_set_buf_from_vars((u_char *)*rdbmsSrvInfoStartupTime_val_ptr_ptr, rdbmsSrvInfoStartupTime_val_ptr_len_ptr, + rowreq_ctx->data.startupYear, + rowreq_ctx->data.startupMonth, + rowreq_ctx->data.startupDay, + rowreq_ctx->data.startupHour, + rowreq_ctx->data.startupMinutes, + rowreq_ctx->data.startupSeconds, + rowreq_ctx->data.startupDeciSeconds, + rowreq_ctx->data.startupUtcOffsetDirection, + rowreq_ctx->data.startupUtcOffsetHours, + rowreq_ctx->data.startupUtcOffsetMinutes); + if(rc != SNMP_ERR_NOERROR) + return rc; + + + return MFD_SUCCESS; +} /* rdbmsSrvInfoStartupTime_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoFinishedTransactions + * rdbmsSrvInfoFinishedTransactions is subid 2 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.2 + * Description: +The number of transactions visible to this server that have + been completed by either commit or abort. Some database + operations, such as read-only queries, may not result in the + creation of a transaction. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is GAUGE (based on perltype GAUGE) + * The net-snmp type is ASN_GAUGE. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoFinishedTransactions.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoFinishedTransactions_map(u_long *mib_rdbmsSrvInfoFinishedTransactions_val_ptr, u_long raw_rdbmsSrvInfoFinishedTransactions_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoFinishedTransactions_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoFinishedTransactions_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoFinishedTransactions mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoFinishedTransactions_val_ptr) = raw_rdbmsSrvInfoFinishedTransactions_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoFinishedTransactions_map */ + +/** + * Extract the current value of the rdbmsSrvInfoFinishedTransactions data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoFinishedTransactions_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoFinishedTransactions_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoFinishedTransactions_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoFinishedTransactions_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoFinishedTransactions_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoFinishedTransactions data. + * set (* rdbmsSrvInfoFinishedTransactions_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoFinishedTransactions_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoFinishedTransactions; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoFinishedTransactions_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoDiskReads + * rdbmsSrvInfoDiskReads is subid 3 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.3 + * Description: +The total number of reads of database files issued to the + operating system by this server since startup. Numbers are + not comparable between products. What constitutes a + readand how it is accounted is product-specific. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoDiskReads.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoDiskReads_map(u_long *mib_rdbmsSrvInfoDiskReads_val_ptr, u_long raw_rdbmsSrvInfoDiskReads_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoDiskReads_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoDiskReads_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoDiskReads mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoDiskReads_val_ptr) = raw_rdbmsSrvInfoDiskReads_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoDiskReads_map */ + +/** + * Extract the current value of the rdbmsSrvInfoDiskReads data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoDiskReads_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoDiskReads_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoDiskReads_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoDiskReads_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoDiskReads_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoDiskReads data. + * set (* rdbmsSrvInfoDiskReads_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoDiskReads_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoDiskReads; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoDiskReads_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoLogicalReads + * rdbmsSrvInfoLogicalReads is subid 4 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.4 + * Description: +The total number of logical reads of database files made + internally by this server since startup. The values of this + object and those of rdbmsSrvInfoDiskReads reveal the effect + of caching on read operation. Numbers are not comparable + between products, and may only be meaningful when aggregated + across all servers sharing a common cache. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoLogicalReads.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoLogicalReads_map(u_long *mib_rdbmsSrvInfoLogicalReads_val_ptr, u_long raw_rdbmsSrvInfoLogicalReads_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoLogicalReads_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoLogicalReads_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoLogicalReads mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoLogicalReads_val_ptr) = raw_rdbmsSrvInfoLogicalReads_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoLogicalReads_map */ + +/** + * Extract the current value of the rdbmsSrvInfoLogicalReads data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoLogicalReads_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoLogicalReads_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoLogicalReads_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoLogicalReads_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoLogicalReads_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoLogicalReads data. + * set (* rdbmsSrvInfoLogicalReads_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoLogicalReads_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoLogicalReads; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoLogicalReads_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoDiskWrites + * rdbmsSrvInfoDiskWrites is subid 5 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.5 + * Description: +The total number of writes to database files issued to the + operating system by this server since startup. Numbers are + not comparable between products. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoDiskWrites.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoDiskWrites_map(u_long *mib_rdbmsSrvInfoDiskWrites_val_ptr, u_long raw_rdbmsSrvInfoDiskWrites_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoDiskWrites_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoDiskWrites_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoDiskWrites mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoDiskWrites_val_ptr) = raw_rdbmsSrvInfoDiskWrites_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoDiskWrites_map */ + +/** + * Extract the current value of the rdbmsSrvInfoDiskWrites data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoDiskWrites_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoDiskWrites_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoDiskWrites_val_ptr ) +{ + return MFD_SKIP; + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoDiskWrites_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoDiskWrites_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoDiskWrites data. + * set (* rdbmsSrvInfoDiskWrites_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoDiskWrites_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoDiskWrites; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoDiskWrites_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoLogicalWrites + * rdbmsSrvInfoLogicalWrites is subid 6 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.6 + * Description: +The total number of times parts of the database files have + been marked 'dirty' and in need of writing to the disk. This + value and rdbmsSrvInfoDiskWrites give some indication of the + effect of 'write-behind' strategies in reducing the number of + disk writes compared to database operations. Because the + writes may be done by servers other than those marking the + parts of the database files dirty, these values may only be + meaningful when aggregated across all servers sharing a + common cache. Numbers are not comparable between products. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoLogicalWrites.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoLogicalWrites_map(u_long *mib_rdbmsSrvInfoLogicalWrites_val_ptr, u_long raw_rdbmsSrvInfoLogicalWrites_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoLogicalWrites_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoLogicalWrites_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoLogicalWrites mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoLogicalWrites_val_ptr) = raw_rdbmsSrvInfoLogicalWrites_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoLogicalWrites_map */ + +/** + * Extract the current value of the rdbmsSrvInfoLogicalWrites data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoLogicalWrites_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoLogicalWrites_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoLogicalWrites_val_ptr ) +{ + return MFD_SKIP; + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoLogicalWrites_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoLogicalWrites_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoLogicalWrites data. + * set (* rdbmsSrvInfoLogicalWrites_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoLogicalWrites_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoLogicalWrites; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoLogicalWrites_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoPageReads + * rdbmsSrvInfoPageReads is subid 7 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.7 + * Description: +The total number of pages in database files read by this + server since startup. 'Pages' are product specific units of + disk i/o operations. This value, along with + rdbmsSrvInfoDiskReads, reveals the effect of any grouping + read-ahead that may be used to enhance performance of some + queries, such as scans. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoPageReads.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoPageReads_map(u_long *mib_rdbmsSrvInfoPageReads_val_ptr, u_long raw_rdbmsSrvInfoPageReads_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoPageReads_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoPageReads_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoPageReads mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoPageReads_val_ptr) = raw_rdbmsSrvInfoPageReads_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoPageReads_map */ + +/** + * Extract the current value of the rdbmsSrvInfoPageReads data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoPageReads_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoPageReads_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoPageReads_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoPageReads_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoPageReads_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoPageReads data. + * set (* rdbmsSrvInfoPageReads_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoPageReads_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoPageReads; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoPageReads_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoPageWrites + * rdbmsSrvInfoPageWrites is subid 8 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.8 + * Description: +The total number of pages in database files written by this + server since startup. Pages are product-specific units of + disk I/O. This value, with rdbmsSrvInfoDiskWrites, shows the + effect of write strategies that collapse logical writes of + contiguous pages into single calls to the operating system. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoPageWrites.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoPageWrites_map(u_long *mib_rdbmsSrvInfoPageWrites_val_ptr, u_long raw_rdbmsSrvInfoPageWrites_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoPageWrites_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoPageWrites_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoPageWrites mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_rdbmsSrvInfoPageWrites_val_ptr) = raw_rdbmsSrvInfoPageWrites_val; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoPageWrites_map */ + +/** + * Extract the current value of the rdbmsSrvInfoPageWrites data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param rdbmsSrvInfoPageWrites_val_ptr + * Pointer to storage for a u_long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +rdbmsSrvInfoPageWrites_get( rdbmsSrvInfoTable_rowreq_ctx *rowreq_ctx, u_long * rdbmsSrvInfoPageWrites_val_ptr ) +{ + return MFD_SKIP; + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != rdbmsSrvInfoPageWrites_val_ptr ); + + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoPageWrites_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the rdbmsSrvInfoPageWrites data. + * set (* rdbmsSrvInfoPageWrites_val_ptr ) from rowreq_ctx->data + */ + (* rdbmsSrvInfoPageWrites_val_ptr ) = rowreq_ctx->data.rdbmsSrvInfoPageWrites; + + return MFD_SUCCESS; +} /* rdbmsSrvInfoPageWrites_get */ + +/*--------------------------------------------------------------------- + * RDBMS-MIB::rdbmsSrvInfoEntry.rdbmsSrvInfoDiskOutOfSpaces + * rdbmsSrvInfoDiskOutOfSpaces is subid 9 of rdbmsSrvInfoEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.2.1.39.1.6.1.9 + * Description: +The total number of times the server has been unable to + obtain disk space that it wanted, since server startup. This + would be inspected by an agent on receipt of an + rdbmsOutOfSpace trap. + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is COUNTER (based on perltype COUNTER) + * The net-snmp type is ASN_COUNTER. The C type decl is u_long (u_long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-rdbmsSrvInfoDiskOutOfSpaces.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +rdbmsSrvInfoDiskOutOfSpaces_map(u_long *mib_rdbmsSrvInfoDiskOutOfSpaces_val_ptr, u_long raw_rdbmsSrvInfoDiskOutOfSpaces_val) +{ + netsnmp_assert(NULL != mib_rdbmsSrvInfoDiskOutOfSpaces_val_ptr); + + DEBUGMSGTL(("verbose:rdbmsSrvInfoTable:rdbmsSrvInfoDiskOutOfSpaces_map","called\n")); + + /* + * TODO:241:o: |-> Implement rdbmsSrvInfoDiskOutOfSpaces mapping. + * If the values for your data type don