1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 2004-2012. All Rights Reserved. 5: %% 6: %% The contents of this file are subject to the Erlang Public License, 7: %% Version 1.1, (the "License"); you may not use this file except in 8: %% compliance with the License. You should have received a copy of the 9: %% Erlang Public License along with this software. If not, it can be 10: %% retrieved online at http://www.erlang.org/. 11: %% 12: %% Software distributed under the License is distributed on an "AS IS" 13: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 14: %% the License for the specific language governing rights and limitations 15: %% under the License. 16: %% 17: %% %CopyrightEnd% 18: %% 19: -module(os_mon_mib_SUITE). 20: 21: %%----------------------------------------------------------------- 22: %% This suite can no longer be executed standalone, i.e. it must be 23: %% executed with common test. The reason is that ct_snmp is used 24: %% instead of the snmp application directly. The suite requires a 25: %% config file, os_mon_mib_SUITE.cfg, found in the same directory as 26: %% the suite. 27: %% 28: %% Execute with: 29: %% > ct_run -suite os_mon_mib_SUITE -config os_mon_mib_SUITE.cfg 30: %%----------------------------------------------------------------- 31: 32: -include_lib("test_server/include/test_server.hrl"). 33: -include_lib("os_mon/include/OTP-OS-MON-MIB.hrl"). 34: -include_lib("snmp/include/snmp_types.hrl"). 35: 36: % Test server specific exports 37: -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, 38: init_per_suite/1, end_per_suite/1, 39: init_per_testcase/2, end_per_testcase/2]). 40: 41: 42: % Test cases must be exported. 43: -export([update_load_table/1]). 44: 45: -export([get_mem_sys_mark/1, get_mem_proc_mark/1, get_disk_threshold/1, 46: get_load_table/1, get_disk_table/1, 47: real_snmp_request/1, load_unload/1]). 48: 49: -export([sys_tot_mem/1, sys_used_mem/1, large_erl_process/1, 50: large_erl_process_mem/1, cpu_load/1, cpu_load5/1, cpu_load15/1, 51: os_wordsize/1, sys_tot_mem64/1, sys_used_mem64/1, 52: large_erl_process_mem64/1, disk_descr/1, disk_kbytes/1, 53: disk_capacity/1]). 54: 55: -export([]). 56: -export([otp_6351/1, otp_7441/1]). 57: 58: -define(TRAP_UDP, 5000). 59: -define(AGENT_UDP, 4000). 60: -define(CONF_FILE_VER, [v2]). 61: -define(SYS_NAME, "Test os_mon_mibs"). 62: -define(MAX_MSG_SIZE, 484). 63: -define(ENGINE_ID, "mgrEngine"). 64: -define(MGR_PORT, 5001). 65: 66: %%--------------------------------------------------------------------- 67: init_per_testcase(_Case, Config) when is_list(Config) -> 68: Dog = test_server:timetrap(test_server:minutes(6)), 69: [{watchdog, Dog}|Config]. 70: 71: end_per_testcase(_Case, Config) when is_list(Config) -> 72: Dog = ?config(watchdog, Config), 73: test_server:timetrap_cancel(Dog), 74: Config. 75: 76: suite() -> [{ct_hooks,[ts_install_cth]}, 77: {require, snmp_mgr_agent, snmp}]. 78: 79: all() -> 80: [load_unload, get_mem_sys_mark, get_mem_proc_mark, 81: get_disk_threshold, get_load_table, 82: {group, get_next_load_table}, get_disk_table, 83: {group, get_next_disk_table}, real_snmp_request, 84: update_load_table, {group, tickets}]. 85: 86: groups() -> 87: [{tickets, [], [otp_6351, otp_7441]}, 88: {get_next_load_table, [], 89: [sys_tot_mem, sys_used_mem, large_erl_process, 90: large_erl_process_mem, cpu_load, cpu_load5, cpu_load15, 91: os_wordsize, sys_tot_mem64, sys_used_mem64, 92: large_erl_process_mem64]}, 93: {get_next_disk_table, [], 94: [disk_descr, disk_kbytes, disk_capacity]}]. 95: 96: init_per_group(_GroupName, Config) -> 97: Config. 98: 99: end_per_group(_GroupName, Config) -> 100: Config. 101: 102: 103: %%--------------------------------------------------------------------- 104: %%-------------------------------------------------------------------- 105: %% Function: init_per_suite(Config) -> Config 106: %% Config - [tuple()] 107: %% A list of key/value pairs, holding the test case configuration. 108: %% Description: Initiation before the whole suite 109: %% 110: %% Note: This function is free to add any key/value pairs to the Config 111: %% variable, but should NOT alter/remove any existing entries. 112: %%-------------------------------------------------------------------- 113: init_per_suite(Config) -> 114: ?line application:start(sasl), 115: ?line application:start(mnesia), 116: ?line application:start(os_mon), 117: 118: ok = ct_snmp:start(Config,snmp_mgr_agent), 119: 120: %% Load the mibs that should be tested 121: otp_mib:load(snmp_master_agent), 122: os_mon_mib:load(snmp_master_agent), 123: 124: Config. 125: %%-------------------------------------------------------------------- 126: %% Function: end_per_suite(Config) -> _ 127: %% Config - [tuple()] 128: %% A list of key/value pairs, holding the test case configuration. 129: %% Description: Cleanup after the whole suite 130: %%-------------------------------------------------------------------- 131: end_per_suite(Config) -> 132: PrivDir = ?config(priv_dir, Config), 133: ConfDir = filename:join(PrivDir,"conf"), 134: DbDir = filename:join(PrivDir,"db"), 135: MgrDir = filename:join(PrivDir, "mgr"), 136: 137: %% Uload mibs 138: snmpa:unload_mibs(snmp_master_agent,["OTP-OS-MON-MIB"]), 139: otp_mib:unload(snmp_master_agent), 140: 141: %% Clean up 142: application:stop(snmp), 143: application:stop(mnesia), 144: application:stop(os_mon), 145: 146: del_dir(ConfDir), 147: del_dir(DbDir), 148: (catch del_dir(MgrDir)), 149: ok. 150: 151: %%--------------------------------------------------------------------- 152: %% Test cases 153: %%--------------------------------------------------------------------- 154: load_unload(doc) -> 155: ["Test to unload and the reload the OTP.mib "]; 156: load_unload(suite) -> []; 157: load_unload(Config) when is_list(Config) -> 158: ?line os_mon_mib:unload(snmp_master_agent), 159: ?line os_mon_mib:load(snmp_master_agent), 160: ok. 161: %%--------------------------------------------------------------------- 162: 163: update_load_table(doc) -> 164: ["check os_mon_mib:update_load_table error handling"]; 165: update_load_table(suite) -> 166: []; 167: update_load_table(Config) when is_list(Config) -> 168: ?line Node = start_node(), 169: ?line ok = rpc:call(Node,application,start,[sasl]), 170: ?line ok = rpc:call(Node,application,start,[os_mon]), 171: ?line ok = os_mon_mib:update_load_table(), 172: ?line rpc:call(Node,application,stop,[os_mon]), 173: ?line ok = os_mon_mib:update_load_table(), 174: ?line stop_node(Node), 175: ok. 176: 177: otp_6351(doc) -> 178: ["like update_load_table, when memsup_system_only==true"]; 179: otp_6351(suite) -> 180: []; 181: otp_6351(Config) when is_list(Config) -> 182: ?line Node = start_node(), 183: ?line ok = rpc:call(Node,application,start,[sasl]), 184: ?line ok = rpc:call(Node,application,load,[os_mon]), 185: ?line ok = rpc:call(Node,application,set_env, 186: [os_mon,memsup_system_only,true]), 187: ?line ok = rpc:call(Node,application,start,[os_mon]), 188: ?line Res = rpc:call(Node,os_mon_mib,get_load,[Node]), 189: if 190: is_tuple(Res), element(1, Res)==loadTable -> 191: ?line ok; 192: true -> 193: ?line ?t:fail(Res) 194: end, 195: ?line rpc:call(Node,application,stop,[os_mon]), 196: ?line stop_node(Node), 197: ok. 198: 199: 200: 201: 202: %%--------------------------------------------------------------------- 203: get_mem_sys_mark(doc) -> 204: ["Simulates a get call to test the instrumentation function " 205: "for the loadMemorySystemWatermark variable."]; 206: get_mem_sys_mark(suite) -> 207: []; 208: get_mem_sys_mark(Config) when is_list(Config) -> 209: case os_mon_mib:mem_sys_mark(get) of 210: {value, SysMark} when is_integer(SysMark) -> 211: ok; 212: _ -> 213: ?line test_server:fail(sys_mark_value_not_integer) 214: end. 215: %%--------------------------------------------------------------------- 216: get_mem_proc_mark(doc) -> 217: ["Simulates a get call to test the instrumentation function " 218: "for the loadMemoryErlProcWatermark variable."]; 219: get_mem_proc_mark(suite) -> 220: []; 221: get_mem_proc_mark(Config) when is_list(Config) -> 222: case os_mon_mib:mem_proc_mark(get) of 223: {value, ProcMark} when is_integer(ProcMark) -> 224: ok; 225: _ -> 226: ?line test_server:fail(proc_mark_value_not_integer) 227: end. 228: %%--------------------------------------------------------------------- 229: get_disk_threshold(doc) -> 230: ["Simulates a get call to test the instrumentation function " 231: "for the diskAlmostFullThreshold variable."]; 232: get_disk_threshold(suite) -> 233: []; 234: get_disk_threshold(Config) when is_list(Config) -> 235: case os_mon_mib:disk_threshold(get) of 236: {value, ProcMark} when is_integer(ProcMark) -> 237: ok; 238: _ -> 239: ?line test_server:fail(disk_threshold_value_not_integer) 240: end. 241: %%--------------------------------------------------------------------- 242: 243: %%% Note that when we have a string key, as in loadTable, the 244: %%% instrumentation will deal with the [length(String), String]. We 245: %%% have to know about this, when short cutting SNMP and calling 246: %%% instrumentation functions directly as done in most test cases in 247: %%% this test suite 248: 249: get_load_table(doc) -> 250: ["Simulates get calls to test the instrumentation function " 251: "for the loadTable"]; 252: get_load_table(suite) -> 253: []; 254: get_load_table(Config) when is_list(Config) -> 255: 256: NodeStr = atom_to_list(node()), 257: NodeLen = length(NodeStr), 258: 259: {_, _, {Pid, _}} = memsup:get_memory_data(), 260: PidStr = lists:flatten(io_lib:format("~w", [Pid])), 261: ?line [{value, NodeStr},{value, PidStr}] = 262: os_mon_mib:load_table(get, [NodeLen | NodeStr], 263: [?loadErlNodeName, ?loadLargestErlProcess]), 264: 265: ?line Values = os_mon_mib:load_table(get, [NodeLen | NodeStr] , 266: [?loadSystemTotalMemory, 267: ?loadSystemUsedMemory, 268: ?loadLargestErlProcessUsedMemory, 269: ?loadCpuLoad, 270: ?loadCpuLoad5, 271: ?loadCpuLoad15, 272: ?loadOsWordsize, 273: ?loadSystemTotalMemory64, 274: ?loadSystemUsedMemory64, 275: ?loadLargestErlProcessUsedMemory64]), 276: 277: IsInt = fun({value, Val}) when is_integer(Val) -> 278: true; 279: (_) -> 280: false 281: end, 282: 283: NewValues = lists:filter(IsInt, Values), 284: 285: case length(NewValues) of 286: 10 -> 287: ok; 288: _ -> 289: ?line test_server:fail(value_not_integer) 290: end, 291: 292: ?line [{noValue,noSuchInstance}, {noValue,noSuchInstance}, 293: {noValue,noSuchInstance}, {noValue,noSuchInstance}, 294: {noValue,noSuchInstance}, {noValue,noSuchInstance}, 295: {noValue,noSuchInstance}, {noValue,noSuchInstance}, 296: {noValue,noSuchInstance}, {noValue,noSuchInstance}, 297: {noValue,noSuchInstance}, {noValue,noSuchInstance}] = 298: os_mon_mib:load_table(get, [3, 102, 111, 111], 299: [?loadErlNodeName, 300: ?loadSystemTotalMemory, 301: ?loadSystemUsedMemory, 302: ?loadLargestErlProcess, 303: ?loadLargestErlProcessUsedMemory, 304: ?loadCpuLoad, 305: ?loadCpuLoad5, 306: ?loadCpuLoad15, 307: ?loadOsWordsize, 308: ?loadSystemTotalMemory64, 309: ?loadSystemUsedMemory64, 310: ?loadLargestErlProcessUsedMemory64]), 311: 312: ok. 313: %%--------------------------------------------------------------------- 314: 315: sys_tot_mem(doc) -> 316: []; 317: sys_tot_mem(suite) -> 318: []; 319: sys_tot_mem(Config) when is_list(Config) -> 320: ?line [{[?loadSystemTotalMemory, Len | NodeStr], Mem}] = 321: os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory]), 322: ?line Len = length(NodeStr), 323: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 324: 325: case Mem of 326: Mem when is_integer(Mem) -> 327: ok; 328: _ -> 329: ?line test_server:fail(sys_tot_mem_value_not_integer) 330: end. 331: 332: sys_used_mem(doc) -> 333: []; 334: sys_used_mem(suite) -> []; 335: sys_used_mem(Config) when is_list(Config) -> 336: ?line [{[?loadSystemUsedMemory, Len | NodeStr], Mem}] = 337: os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory]), 338: ?line Len = length(NodeStr), 339: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 340: 341: case Mem of 342: Mem when is_integer(Mem) -> 343: ok; 344: _ -> 345: ?line test_server:fail(sys_used_mem_value_not_integer) 346: end. 347: 348: large_erl_process(doc) -> 349: []; 350: large_erl_process(suite) -> 351: []; 352: large_erl_process(Config) when is_list(Config) -> 353: {_, _, {Pid, _}} = memsup:get_memory_data(), 354: PidStr = lists:flatten(io_lib:format("~w", [Pid])), 355: ?line [{[?loadLargestErlProcess, Len | NodeStr], PidStr}] = 356: os_mon_mib:load_table(get_next,[], [?loadLargestErlProcess]), 357: ?line Len = length(NodeStr), 358: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 359: ok. 360: 361: large_erl_process_mem(doc) -> 362: []; 363: large_erl_process_mem(suite) -> 364: []; 365: large_erl_process_mem(Config) when is_list(Config) -> 366: 367: ?line [{[?loadLargestErlProcessUsedMemory, Len | NodeStr], Mem}] = 368: os_mon_mib:load_table(get_next,[], 369: [?loadLargestErlProcessUsedMemory]), 370: ?line Len = length(NodeStr), 371: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 372: 373: case Mem of 374: Mem when is_integer(Mem) -> 375: ok; 376: _ -> 377: ?line test_server:fail(erl_pid_mem_value_not_integer) 378: end. 379: 380: cpu_load(doc) -> 381: []; 382: cpu_load(suite) -> 383: []; 384: cpu_load(Config) when is_list(Config) -> 385: ?line [{[?loadCpuLoad, Len | NodeStr], Load}] = 386: os_mon_mib:load_table(get_next,[], [?loadCpuLoad]), 387: ?line Len = length(NodeStr), 388: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 389: 390: case Load of 391: Load when is_integer(Load) -> 392: ok; 393: _ -> 394: ?line test_server:fail(cpu_load_value_not_integer) 395: end. 396: 397: cpu_load5(doc) -> 398: []; 399: cpu_load5(suite) -> 400: []; 401: cpu_load5(Config) when is_list(Config) -> 402: ?line [{[?loadCpuLoad5, Len | NodeStr], Load}] = 403: os_mon_mib:load_table(get_next,[], [?loadCpuLoad5]), 404: ?line Len = length(NodeStr), 405: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 406: 407: case Load of 408: Load when is_integer(Load) -> 409: ok; 410: _ -> 411: ?line test_server:fail(cpu_load5_value_not_integer) 412: end. 413: 414: cpu_load15(doc) -> 415: []; 416: cpu_load15(suite) -> 417: []; 418: cpu_load15(Config) when is_list(Config) -> 419: ?line [{[?loadCpuLoad15, Len | NodeStr], Load}] = 420: os_mon_mib:load_table(get_next,[], [?loadCpuLoad15]), 421: ?line Len = length(NodeStr), 422: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 423: 424: case Load of 425: Load when is_integer(Load) -> 426: ok; 427: _ -> 428: ?line test_server:fail(cpu_load15_value_not_integer) 429: end. 430: 431: os_wordsize(doc) -> 432: []; 433: os_wordsize(suite) -> 434: []; 435: os_wordsize(Config) when is_list(Config) -> 436: ?line [{[?loadOsWordsize, Len | NodeStr], Wordsize}] = 437: os_mon_mib:load_table(get_next,[], [?loadOsWordsize]), 438: ?line Len = length(NodeStr), 439: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 440: 441: case Wordsize of 442: Wordsize when is_integer(Wordsize) -> 443: ok; 444: _ -> 445: ?line test_server:fail(os_wordsize_value_not_integer) 446: end. 447: 448: sys_tot_mem64(doc) -> 449: []; 450: sys_tot_mem64(suite) -> 451: []; 452: sys_tot_mem64(Config) when is_list(Config) -> 453: ?line [{[?loadSystemTotalMemory64, Len | NodeStr], Mem}] = 454: os_mon_mib:load_table(get_next, [], [?loadSystemTotalMemory64]), 455: ?line Len = length(NodeStr), 456: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 457: 458: case Mem of 459: Mem when is_integer(Mem) -> 460: ok; 461: _ -> 462: ?line test_server:fail(sys_tot_mem_value_not_integer) 463: end. 464: 465: sys_used_mem64(doc) -> 466: []; 467: sys_used_mem64(suite) -> []; 468: sys_used_mem64(Config) when is_list(Config) -> 469: ?line [{[?loadSystemUsedMemory64, Len | NodeStr], Mem}] = 470: os_mon_mib:load_table(get_next,[], [?loadSystemUsedMemory64]), 471: ?line Len = length(NodeStr), 472: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 473: 474: case Mem of 475: Mem when is_integer(Mem) -> 476: ok; 477: _ -> 478: ?line test_server:fail(sys_used_mem_value_not_integer) 479: end. 480: 481: large_erl_process_mem64(doc) -> 482: []; 483: large_erl_process_mem64(suite) -> 484: []; 485: large_erl_process_mem64(Config) when is_list(Config) -> 486: 487: ?line [{[?loadLargestErlProcessUsedMemory64, Len | NodeStr], Mem}] = 488: os_mon_mib:load_table(get_next,[], 489: [?loadLargestErlProcessUsedMemory64]), 490: ?line Len = length(NodeStr), 491: ?line true = lists:member(list_to_atom(NodeStr), [node() | nodes()]), 492: 493: case Mem of 494: Mem when is_integer(Mem) -> 495: ok; 496: _ -> 497: ?line test_server:fail(erl_pid_mem_value_not_integer) 498: end. 499: %%--------------------------------------------------------------------- 500: get_disk_table(doc) -> 501: ["Simulates get calls to test the instrumentation function " 502: "for the diskTable."]; 503: get_disk_table(suite) -> 504: []; 505: get_disk_table(Config) when is_list(Config) -> 506: 507: DiskData = disksup:get_disk_data(), 508: DiskDataLen = length(DiskData), 509: 510: if 511: DiskDataLen > 0 -> 512: ?line [{value, Value}] = 513: os_mon_mib:disk_table(get, [1,1], [?diskDescr]), 514: 515: case is_list(Value) of 516: true -> 517: ok; 518: false -> 519: ?line test_server:fail(value_not_a_string) 520: end, 521: 522: ?line Values = os_mon_mib:disk_table(get, [1,1], 523: [?diskId, 524: ?diskKBytes, 525: ?diskCapacity]), 526: 527: IsInt = fun({value, Val}) when is_integer(Val) -> 528: true; 529: (_) -> 530: false 531: end, 532: 533: NewValues = lists:filter(IsInt, Values), 534: 535: case length(NewValues) of 536: 3 -> 537: ok; 538: _ -> 539: ?line test_server:fail(value_not_integer) 540: end 541: end, 542: 543: ?line [{noValue,noSuchInstance}, {noValue,noSuchInstance}, 544: {noValue,noSuchInstance}, {noValue,noSuchInstance}] = 545: os_mon_mib:disk_table(get, [1, DiskDataLen + 1], [?diskId, 546: ?diskDescr, 547: ?diskKBytes, 548: ?diskCapacity]), 549: 550: ok. 551: 552: %%--------------------------------------------------------------------- 553: 554: disk_descr(doc) -> 555: []; 556: disk_descr(suite) -> 557: []; 558: disk_descr(Config) when is_list(Config) -> 559: ?line [{[?diskDescr, 1,1], Descr}] = 560: os_mon_mib:disk_table(get_next, [], [?diskDescr]), 561: 562: case Descr of 563: Descr when is_list(Descr) -> 564: ok; 565: _ -> 566: ?line test_server:fail(disk_descr_value_not_a_string) 567: end. 568: 569: disk_kbytes(doc) -> 570: []; 571: disk_kbytes(suite) -> []; 572: disk_kbytes(Config) when is_list(Config) -> 573: ?line [{[?diskKBytes, 1,1], Kbytes}] = 574: os_mon_mib:disk_table(get_next,[], [?diskKBytes]), 575: 576: case Kbytes of 577: Kbytes when is_integer(Kbytes) -> 578: ok; 579: _ -> 580: ?line test_server:fail(disk_kbytes_value_not_integer) 581: end. 582: 583: 584: disk_capacity(doc) -> 585: []; 586: disk_capacity(suite) -> []; 587: disk_capacity(Config) when is_list(Config) -> 588: ?line [{[?diskCapacity, 1,1], Capacity}] = 589: os_mon_mib:disk_table(get_next,[], [?diskCapacity]), 590: 591: case Capacity of 592: Capacity when is_integer(Capacity) -> 593: ok; 594: _ -> 595: ?line test_server:fail(disk_capacity_value_not_integer) 596: end. 597: 598: %%--------------------------------------------------------------------- 599: real_snmp_request(doc) -> 600: ["Starts an snmp manager and sends a real snmp-request. i.e. " 601: "sends a udp message on the correct format."]; 602: real_snmp_request(suite) -> []; 603: real_snmp_request(Config) when is_list(Config) -> 604: NodStr = atom_to_list(node()), 605: Len = length(NodStr), 606: {_, _, {Pid, _}} = memsup:get_memory_data(), 607: PidStr = lists:flatten(io_lib:format("~w", [Pid])), 608: io:format("FOO: ~p~n", [PidStr]), 609: ?line ok = snmp_get([?loadEntry ++ 610: [?loadLargestErlProcess, Len | NodStr]], 611: PidStr), 612: ?line ok = snmp_get_next([?loadEntry ++ 613: [?loadSystemUsedMemory, Len | NodStr]], 614: ?loadEntry ++ [?loadSystemUsedMemory + 1, Len 615: | NodStr], PidStr), 616: ?line ok = snmp_set([?loadEntry ++ [?loadLargestErlProcess, Len | NodStr]], 617: s, "<0.101.0>", Config), 618: ok. 619: 620: otp_7441(doc) -> 621: ["Starts an snmp manager and requests total memory. Was previously 622: integer32 which was errornous on 64 bit machines."]; 623: otp_7441(suite) -> 624: []; 625: otp_7441(Config) when is_list(Config) -> 626: NodStr = atom_to_list(node()), 627: Len = length(NodStr), 628: Oids = [Oid|_] = [?loadEntry ++ [?loadSystemTotalMemory, Len | NodStr]], 629: {noError,0,[#varbind{oid = Oid, variabletype = 'Unsigned32'}]} = 630: ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), 631: 632: ok. 633: 634: %%--------------------------------------------------------------------- 635: %% Internal functions 636: %%--------------------------------------------------------------------- 637: start_node() -> 638: ?line Pa = filename:dirname(code:which(?MODULE)), 639: ?line {ok,Node} = test_server:start_node(testnisse, slave, 640: [{args, " -pa " ++ Pa}]), 641: Node. 642: 643: stop_node(Node) -> 644: test_server:stop_node(Node). 645: 646: del_dir(Dir) -> 647: io:format("Deleting: ~s~n",[Dir]), 648: {ok, Files} = file:list_dir(Dir), 649: FullPathFiles = lists:map(fun(File) -> filename:join(Dir, File) end, 650: Files), 651: lists:foreach(fun file:delete/1, FullPathFiles), 652: file:del_dir(Dir). 653: 654: %%--------------------------------------------------------------------- 655: snmp_get(Oids = [Oid |_], Result) -> 656: {noError,0,[#varbind{oid = Oid, 657: variabletype = 'OCTET STRING', 658: value = Result}]} = 659: ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), 660: ok. 661: 662: snmp_get_next(Oids, NextOid, Result) -> 663: {noError,0,[#varbind{oid = NextOid, 664: variabletype = 'OCTET STRING', 665: value = Result}]} = 666: ct_snmp:get_next_values(os_mon_mib_test, Oids, snmp_mgr_agent), 667: ok. 668: 669: snmp_set(Oid, ValuType, Value, Config) -> 670: {notWritable, _, _} = 671: ct_snmp:set_values(os_mon_mib_test, [{Oid, ValuType, Value}], 672: snmp_mgr_agent, Config), 673: ok.