diff options
Diffstat (limited to 'lib/os_mon')
-rw-r--r-- | lib/os_mon/c_src/Makefile.in | 8 | ||||
-rw-r--r-- | lib/os_mon/c_src/memsup.c | 71 | ||||
-rw-r--r-- | lib/os_mon/src/memsup.erl | 4 | ||||
-rw-r--r-- | lib/os_mon/src/os_mon.erl | 6 | ||||
-rw-r--r-- | lib/os_mon/test/Makefile | 1 | ||||
-rw-r--r-- | lib/os_mon/test/os_mon.spec | 1 | ||||
-rw-r--r-- | lib/os_mon/test/os_mon_mib_SUITE.cfg | 8 | ||||
-rw-r--r-- | lib/os_mon/test/os_mon_mib_SUITE.erl | 147 |
8 files changed, 54 insertions, 192 deletions
diff --git a/lib/os_mon/c_src/Makefile.in b/lib/os_mon/c_src/Makefile.in index 2b16789a14..e728e43a09 100644 --- a/lib/os_mon/c_src/Makefile.in +++ b/lib/os_mon/c_src/Makefile.in @@ -63,14 +63,10 @@ ENTRY_OBJ=$(ERL_TOP)/erts/obj/$(TARGET)/port_entry.o PORT_ENTRY_POINT=erl_port_entry ENTRY_LDFLAGS=-entry:$(PORT_ENTRY_POINT) else -ifeq ($(findstring vxworks_simso,$(TARGET)),vxworks_simso) -PROGRAMS = -else PROGRAMS = \ memsup @os_mon_programs@ C_FILES= $(PROGRAMS:%=%.c) endif -endif TARGET_FILES= $(PROGRAMS:%=$(BINDIR)/%) @@ -127,14 +123,10 @@ $(OBJDIR)/memsup.o: memsup.h # ---------------------------------------------------- include $(ERL_TOP)/make/otp_release_targets.mk -ifeq ($(findstring vxworks_simso,$(TARGET)),vxworks_simso) -release_spec: -else release_spec: opt $(INSTALL_DIR) "$(RELSYSDIR)/src" $(INSTALL_DATA) $(C_FILES) "$(RELSYSDIR)/src" $(INSTALL_DIR) "$(RELSYSDIR)/priv/bin" $(INSTALL_PROGRAM) $(TARGET_FILES) "$(RELSYSDIR)/priv/bin" -endif release_docs_spec: diff --git a/lib/os_mon/c_src/memsup.c b/lib/os_mon/c_src/memsup.c index 593a066f98..3a1a8e9444 100644 --- a/lib/os_mon/c_src/memsup.c +++ b/lib/os_mon/c_src/memsup.c @@ -31,7 +31,7 @@ * * This program is started from Erlang as follows, * - * Port = open_port({spawn, 'memsup'}, [{packet,1}]) for UNIX and VxWorks + * Port = open_port({spawn, 'memsup'}, [{packet,1}]) for UNIX * * Erlang sends one of the request condes defined in memsup.h and this program * answers in one of two ways: @@ -75,10 +75,6 @@ * that there is no process at the other end of the connection * having the connection open for writing (end-of-file). * - * COMPILING - * - * When the target is VxWorks the identifier VXWORKS must be defined for - * the preprocessor (usually by a -D option). */ #if defined(sgi) || defined(__sgi) || defined(__sgi__) @@ -90,9 +86,7 @@ #include <stddef.h> #include <stdlib.h> -#ifndef VXWORKS #include <unistd.h> -#endif #if (defined(__unix__) || defined(unix)) && !defined(USG) #include <sys/param.h> @@ -104,12 +98,6 @@ #include <time.h> #include <errno.h> -#ifdef VXWORKS -#include <vxWorks.h> -#include <ioLib.h> -#include <memLib.h> -#endif - #ifdef BSD4_4 #include <sys/types.h> #include <sys/sysctl.h> @@ -143,20 +131,8 @@ /* prototypes */ static void print_error(const char *,...); -#ifdef VXWORKS -extern int erl_mem_info_get(MEM_PART_STATS *); -#endif - -#ifdef VXWORKS -#define MAIN memsup -static MEM_PART_STATS latest; -static unsigned long latest_system_total; /* does not fit in the struct */ - -#else #define MAIN main -#endif - /* * example, we want procfs information, now give them something equivalent: @@ -282,16 +258,6 @@ send_tag(int value){ } } - -#ifdef VXWORKS -static void load_statistics(void){ - if(memPartInfoGet(memSysPartId,&latest) != OK) - memset(&latest,0,sizeof(latest)); - latest_system_total = latest.numBytesFree + latest.numBytesAlloc; - erl_mem_info_get(&latest); /* if it fails, latest is untouched */ -} -#endif - #ifdef BSD4_4 static int get_vmtotal(struct vmtotal *vt) { @@ -358,19 +324,6 @@ get_mem_procfs(memory_ext *me){ /* arch specific functions */ -#if defined(VXWORKS) -static int -get_extended_mem_vxwork(memory_ext *me) { - load_statistics(); - me->total = (latest.numBytesFree + latest.numBytesAlloc); - me->free = latest.numBytesFree; - me->pagesize = 1; - me->flag = F_MEM_TOTAL | F_MEM_FREE; - return 1; -} -#endif - - #if defined(__linux__) /* ifdef SYSINFO */ /* sysinfo does not include cached memory which is a problem. */ static int @@ -442,12 +395,8 @@ get_extended_mem_sgi(memory_ext *me) { static void get_extended_mem(memory_ext *me) { -/* vxworks */ -#if defined(VXWORKS) - if (get_extended_mem_vxworks(me)) return; - /* linux */ -#elif defined(__linux__) +#if defined(__linux__) if (get_mem_procfs(me)) return; if (get_extended_mem_sysinfo(me)) return; @@ -477,12 +426,7 @@ get_extended_mem(memory_ext *me) { static void get_basic_mem(unsigned long *tot, unsigned long *used, unsigned long *pagesize){ -#if defined(VXWORKS) - load_statistics(); - *tot = (latest.numBytesFree + latest.numBytesAlloc); - *used = latest.numBytesAlloc; - *pagesize = 1; -#elif defined(_SC_AVPHYS_PAGES) /* Does this exist on others than Solaris2? */ +#if defined(_SC_AVPHYS_PAGES) /* Does this exist on others than Solaris2? */ unsigned long avPhys, phys, pgSz; phys = sysconf(_SC_PHYS_PAGES); @@ -557,17 +501,8 @@ extended_show_mem(void){ if (me.flag & F_SWAP_TOTAL) { send_tag(SWAP_TOTAL); send(me.total_swap, ps); } if (me.flag & F_SWAP_FREE) { send_tag(SWAP_FREE); send(me.free_swap, ps); } -#ifdef VXWORKS - send_tag(SM_SYSTEM_TOTAL); - send(latest_system_total, 1); - send_tag(SM_LARGEST_FREE); - send(latest.maxBlockSizeFree, 1); - send_tag(SM_NUMBER_OF_FREE); - send(latest.numBlocksFree, 1); -#else /* total is system total*/ if (me.flag & F_MEM_TOTAL) { send_tag(MEM_SYSTEM_TOTAL); send(me.total, ps); } -#endif send_tag(SHOW_SYSTEM_MEM_END); } diff --git a/lib/os_mon/src/memsup.erl b/lib/os_mon/src/memsup.erl index 54771b4703..a1b8591c8c 100644 --- a/lib/os_mon/src/memsup.erl +++ b/lib/os_mon/src/memsup.erl @@ -185,7 +185,6 @@ init([]) -> {unix, irix} -> true; {unix, sunos} -> true; {win32, _OSname} -> false; - vxworks -> true; _ -> exit({unsupported_os, OS}) end, @@ -617,8 +616,7 @@ code_change(Vsn, PrevState, "1.8") -> {unix, openbsd} -> true; {unix, netbsd} -> true; {unix, sunos} -> true; - {win32, _OSname} -> false; - vxworks -> true + {win32, _OSname} -> false end, Pid = if PortMode -> spawn_link(fun() -> port_init() end); diff --git a/lib/os_mon/src/os_mon.erl b/lib/os_mon/src/os_mon.erl index 2b6cd7c498..19acae9f0e 100644 --- a/lib/os_mon/src/os_mon.erl +++ b/lib/os_mon/src/os_mon.erl @@ -176,11 +176,7 @@ services({unix, sunos}) -> services({unix, _}) -> % Other unix. [cpu_sup, disksup, memsup]; services({win32, _}) -> - [disksup, memsup, os_sup, sysinfo]; -services(vxworks) -> - [memsup]; -services(_) -> - []. + [disksup, memsup, os_sup, sysinfo]. server_name(cpu_sup) -> cpu_sup; server_name(disksup) -> disksup; diff --git a/lib/os_mon/test/Makefile b/lib/os_mon/test/Makefile index 9c5f2c1820..461bebc102 100644 --- a/lib/os_mon/test/Makefile +++ b/lib/os_mon/test/Makefile @@ -86,6 +86,7 @@ release_spec: release_tests_spec: make_emakefile $(INSTALL_DIR) "$(RELSYSDIR)" $(INSTALL_DATA) os_mon.spec os_mon.cover $(EMAKEFILE) $(SOURCE) "$(RELSYSDIR)" + $(INSTALL_DATA) os_mon_mib_SUITE.cfg "$(RELSYSDIR)" ## tar chf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -) diff --git a/lib/os_mon/test/os_mon.spec b/lib/os_mon/test/os_mon.spec index d292b258f3..4b4286b313 100644 --- a/lib/os_mon/test/os_mon.spec +++ b/lib/os_mon/test/os_mon.spec @@ -1 +1,2 @@ {suites,"../os_mon_test",all}. +{config,"os_mon_mib_SUITE.cfg"}.
\ No newline at end of file diff --git a/lib/os_mon/test/os_mon_mib_SUITE.cfg b/lib/os_mon/test/os_mon_mib_SUITE.cfg new file mode 100644 index 0000000000..a33c23530b --- /dev/null +++ b/lib/os_mon/test/os_mon_mib_SUITE.cfg @@ -0,0 +1,8 @@ +%% -*- erlang -*- +{snmp, [{start_agent,true}, + {users,[{os_mon_mib_test,[snmpm_user_default,[]]}]}, + {managed_agents,[{os_mon_mib_test, + [os_mon_mib_test, {127,0,0,1}, 4000, []]}]}, + {agent_sysname,"Test os_mon_mibs"}, + {mgr_port,5001} + ]}. diff --git a/lib/os_mon/test/os_mon_mib_SUITE.erl b/lib/os_mon/test/os_mon_mib_SUITE.erl index a137efc441..08f5532d50 100644 --- a/lib/os_mon/test/os_mon_mib_SUITE.erl +++ b/lib/os_mon/test/os_mon_mib_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2004-2011. All Rights Reserved. +%% Copyright Ericsson AB 2004-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -18,16 +18,20 @@ %% -module(os_mon_mib_SUITE). -%-define(STANDALONE,1). +%%----------------------------------------------------------------- +%% This suite can no longer be executed standalone, i.e. it must be +%% executed with common test. The reason is that ct_snmp is used +%% instead of the snmp application directly. The suite requires a +%% config file, os_mon_mib_SUITE.cfg, found in the same directory as +%% the suite. +%% +%% Execute with: +%% > ct_run -suite os_mon_mib_SUITE -config os_mon_mib_SUITE.cfg +%%----------------------------------------------------------------- --ifdef(STANDALONE). --define(line,erlang:display({line,?LINE}),). --define(config(A,B), config(A,B)). --else. -include_lib("test_server/include/test_server.hrl"). -include_lib("os_mon/include/OTP-OS-MON-MIB.hrl"). -include_lib("snmp/include/snmp_types.hrl"). --endif. % Test server specific exports -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, @@ -60,15 +64,6 @@ -define(MGR_PORT, 5001). %%--------------------------------------------------------------------- --ifdef(STANDALONE). --export([run/0]). -run() -> - catch init_per_suite([]), - Ret = (catch update_load_table([])), - catch end_per_suite([]), - Ret. --else. - init_per_testcase(_Case, Config) when is_list(Config) -> Dog = test_server:timetrap(test_server:minutes(6)), [{watchdog, Dog}|Config]. @@ -78,7 +73,8 @@ end_per_testcase(_Case, Config) when is_list(Config) -> test_server:timetrap_cancel(Dog), Config. -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> [{ct_hooks,[ts_install_cth]}, + {require, snmp_mgr_agent, snmp}]. all() -> [load_unload, get_mem_sys_mark, get_mem_proc_mark, @@ -104,8 +100,6 @@ end_per_group(_GroupName, Config) -> Config. - --endif. %%--------------------------------------------------------------------- %%-------------------------------------------------------------------- %% Function: init_per_suite(Config) -> Config @@ -121,50 +115,13 @@ init_per_suite(Config) -> ?line application:start(mnesia), ?line application:start(os_mon), - %% Create initial configuration data for the snmp application - ?line PrivDir = ?config(priv_dir, Config), - ?line ConfDir = filename:join(PrivDir, "conf"), - ?line DbDir = filename:join(PrivDir,"db"), - ?line MgrDir = filename:join(PrivDir,"mgr"), - - ?line file:make_dir(ConfDir), - ?line file:make_dir(DbDir), - ?line file:make_dir(MgrDir), - - {ok, HostName} = inet:gethostname(), - {ok, Addr} = inet:getaddr(HostName, inet), - - ?line snmp_config:write_agent_snmp_files(ConfDir, ?CONF_FILE_VER, - tuple_to_list(Addr), ?TRAP_UDP, - tuple_to_list(Addr), - ?AGENT_UDP, ?SYS_NAME), - - ?line snmp_config:write_manager_snmp_files(MgrDir, tuple_to_list(Addr), - ?MGR_PORT, ?MAX_MSG_SIZE, - ?ENGINE_ID, [], [], []), - - %% To make sure application:set_env is not overwritten by any - %% app-file settings. - ?line ok = application:load(snmp), - - ?line application:set_env(snmp, agent, [{db_dir, DbDir}, - {config, [{dir, ConfDir}]}, - {agent_type, master}, - {agent_verbosity, trace}, - {net_if, [{verbosity, trace}]}]), - ?line application:set_env(snmp, manager, [{config, [{dir, MgrDir}, - {db_dir, MgrDir}, - {verbosity, trace}]}, - {server, [{verbosity, trace}]}, - {net_if, [{verbosity, trace}]}, - {versions, [v1, v2, v3]}]), - application:start(snmp), + ok = ct_snmp:start(Config,snmp_mgr_agent), %% Load the mibs that should be tested otp_mib:load(snmp_master_agent), os_mon_mib:load(snmp_master_agent), - [{agent_ip, Addr}| Config]. + Config. %%-------------------------------------------------------------------- %% Function: end_per_suite(Config) -> _ %% Config - [tuple()] @@ -197,7 +154,7 @@ end_per_suite(Config) -> load_unload(doc) -> ["Test to unload and the reload the OTP.mib "]; load_unload(suite) -> []; -load_unload(Config) when list(Config) -> +load_unload(Config) when is_list(Config) -> ?line os_mon_mib:unload(snmp_master_agent), ?line os_mon_mib:load(snmp_master_agent), ok. @@ -424,7 +381,7 @@ cpu_load(doc) -> []; cpu_load(suite) -> []; -cpu_load(Config) when list(Config) -> +cpu_load(Config) when is_list(Config) -> ?line [{[?loadCpuLoad, Len | NodeStr], Load}] = os_mon_mib:load_table(get_next,[], [?loadCpuLoad]), ?line Len = length(NodeStr), @@ -640,32 +597,24 @@ disk_capacity(Config) when is_list(Config) -> %%--------------------------------------------------------------------- real_snmp_request(doc) -> - ["Starts an snmp manager and sends a real snmp-reques. i.e. " + ["Starts an snmp manager and sends a real snmp-request. i.e. " "sends a udp message on the correct format."]; real_snmp_request(suite) -> []; -real_snmp_request(Config) when list(Config) -> - Agent_ip = ?config(agent_ip, Config), - - ?line ok = snmpm:register_user(os_mon_mib_test, snmpm_user_default, []), - ?line ok = snmpm:register_agent(os_mon_mib_test, Agent_ip, ?AGENT_UDP), - +real_snmp_request(Config) when is_list(Config) -> NodStr = atom_to_list(node()), Len = length(NodStr), {_, _, {Pid, _}} = memsup:get_memory_data(), PidStr = lists:flatten(io_lib:format("~w", [Pid])), io:format("FOO: ~p~n", [PidStr]), - ?line ok = snmp_get(Agent_ip, - [?loadEntry ++ + ?line ok = snmp_get([?loadEntry ++ [?loadLargestErlProcess, Len | NodStr]], PidStr), - ?line ok = snmp_get_next(Agent_ip, - [?loadEntry ++ + ?line ok = snmp_get_next([?loadEntry ++ [?loadSystemUsedMemory, Len | NodStr]], ?loadEntry ++ [?loadSystemUsedMemory + 1, Len | NodStr], PidStr), - ?line ok = snmp_set(Agent_ip, [?loadEntry ++ - [?loadLargestErlProcess, Len | NodStr]], - s, "<0.101.0>"), + ?line ok = snmp_set([?loadEntry ++ [?loadLargestErlProcess, Len | NodStr]], + s, "<0.101.0>", Config), ok. otp_7441(doc) -> @@ -674,34 +623,17 @@ otp_7441(doc) -> otp_7441(suite) -> []; otp_7441(Config) when is_list(Config) -> - Agent_ip = ?config(agent_ip, Config), - - NodStr = atom_to_list(node()), Len = length(NodStr), Oids = [Oid|_] = [?loadEntry ++ [?loadSystemTotalMemory, Len | NodStr]], - ?line { ok, {noError,0,[#varbind{oid = Oid, variabletype = 'Unsigned32'}]}, _} = - snmpm:g(os_mon_mib_test, Agent_ip, ?AGENT_UDP, Oids), + {noError,0,[#varbind{oid = Oid, variabletype = 'Unsigned32'}]} = + ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), ok. %%--------------------------------------------------------------------- %% Internal functions %%--------------------------------------------------------------------- --ifdef(STANDALONE). -config(priv_dir,_) -> - "/tmp". - -start_node() -> - Host = hd(tl(string:tokens(atom_to_list(node()),"@"))), - {ok,Node} = slave:start(Host,testnisse), - net_adm:ping(testnisse), - Node. - - -stop_node(Node) -> - rpc:call(Node,erlang,halt,[]). --else. start_node() -> ?line Pa = filename:dirname(code:which(?MODULE)), ?line {ok,Node} = test_server:start_node(testnisse, slave, @@ -711,8 +643,6 @@ start_node() -> stop_node(Node) -> test_server:stop_node(Node). --endif. - del_dir(Dir) -> io:format("Deleting: ~s~n",[Dir]), {ok, Files} = file:list_dir(Dir), @@ -722,21 +652,22 @@ del_dir(Dir) -> file:del_dir(Dir). %%--------------------------------------------------------------------- -snmp_get(Agent_ip, Oids = [Oid |_], Result) -> - ?line {ok,{noError,0,[#varbind{oid = Oid, - variabletype = 'OCTET STRING', - value = Result}]}, _} = - snmpm:g(os_mon_mib_test, Agent_ip, ?AGENT_UDP, Oids), +snmp_get(Oids = [Oid |_], Result) -> + {noError,0,[#varbind{oid = Oid, + variabletype = 'OCTET STRING', + value = Result}]} = + ct_snmp:get_values(os_mon_mib_test, Oids, snmp_mgr_agent), ok. -snmp_get_next(Agent_ip, Oids, NextOid, Result) -> - ?line {ok,{noError,0,[#varbind{oid = NextOid, - variabletype = 'OCTET STRING', - value = Result}]},_} = - snmpm:gn(os_mon_mib_test, Agent_ip, ?AGENT_UDP, Oids), +snmp_get_next(Oids, NextOid, Result) -> + {noError,0,[#varbind{oid = NextOid, + variabletype = 'OCTET STRING', + value = Result}]} = + ct_snmp:get_next_values(os_mon_mib_test, Oids, snmp_mgr_agent), ok. -snmp_set(Agent_ip, Oid, ValuType, Value) -> - ?line {ok, {notWritable, _, _}, _} = - snmpm:s(os_mon_mib_test,Agent_ip,?AGENT_UDP,[{Oid, ValuType, Value}]), +snmp_set(Oid, ValuType, Value, Config) -> + {notWritable, _, _} = + ct_snmp:set_values(os_mon_mib_test, [{Oid, ValuType, Value}], + snmp_mgr_agent, Config), ok. |