#include <"netmgt/netmgt.h"> |
13.1.2 Static and Dynamic Linking
You can link your application with libnetmgt_db
and libnetmgt either statically or dynamically. Dynamically
is preferable and recommended for the following reasons:
If you have installed the Solaris 1.1.1 version of this product:
If you have installed the Solaris 2.4 version of this product:
NOTE - If you link with the libnetmgt_db.so library, the libnetmgt.so library must also be used, wit hlibnetmgt_db.so being listed before libnetmgt.so in the command line. The libnetmgt.so library may be used without the libnetmgt_db.so library.
host% cc myprog.c -o myprog -R /opt/SUNWconn/snm/lib -L /opt/SUNWconn/snm/lib -lnetmgt_db |
13.1.2.3 Dynamic Linking for the Solaris 1.1 Environment
To dynamically link your application with the libraries
provided with the Solaris 1.1.1 version of this product, follow this format:
host% cc myprog.c -o myprog -L /usr/snm/lib -lnetmgt_db -lnetmgt -lnsl |
13.1.3 Static Linking
When you statically link your program, you can include the
following libnetmgt libraries:
NOTE - If you link with the libnetmgt_db.a library, the libnetmgt.a library must also be used, wit hlibnetmgt_db.a being listed before libnetmgt.a in the command line. The libnetmgt.a library may be used without the libnetmgt_db.a library.
host% cc myprog.c -o myprog -L /opt/SUNWconn/snm/lib -Bstatic -lnetmgt_db -lnetmgt -lnsl |
If you use the static method, you must specifically link in libdl.
13.1.3.2 Static Linking for the Solaris 1.1.1 Environment
To statically link your application with the
libraries provided for the Solaris 1.1.1 version of this product, follow
this format:
host% cc myprog.c -o myprog -L /usr/snm/lib -Bstatic -lnetmgt_db -lnetmgt -lnsl |
If you use the static method, you must specifically link in libdl.
13.1.4 API Differences from the 2.0 Release
Two API functions in the SunNet Manager 2.1 and later
releases differ from the SunNet Manager 2.0 release. Arguments to the
reap and shutdown functions, specified as arguments to
the netmgt_init_rpc_agent() function, have been simplified, as
shown in the definitions below.
SunNet Manager 2.0 reap function:
SunNet Manager 2.1, 2.2, 2.2.3, and 2.3 reap
function:
SunNet Manager 2.0 shutdown function:
SunNet Manager 2.1, 2.2, 2.2.3, and 2.3 shutdown
function:
shutdown_agent (sig)
|
int sig; /* signal caught */
|
13.1.9 Assign an Agent Name
To communicate with an agent, Site/SunNet/Domain Manager
services map the agent name to a unique RPC program number. Given the agent
RPC program number and the name of the host where the agent resides, a Site/SunNet/Domain
Manager application can send requests directly to the agent.
host% ypcat rpc.bynumber | grep <my-agent-name> |
If NIS is not running, type the following:
host% grep <my-agent-name> /etc/rpc |
If you don't see a match, your name is unique.
13.1.10 Register the Agent RPC Program Number
Once you have a name for your agent, assign your agent
an RPC program number. While you are developing your agent, you can use a
temporary RPC program number, which must be unique within your rpc.bynumber
map (or the rpc file). You should assign a number from the range
intended for debugging new programs, which extends from 0x20000000 to 0x3fffffff.
Before picking your temporary RPC number, verify its
uniqueness:
host% ypcat rpc.bynumber | grep <my-RPC-number> |
or if you are not running NIS, enter the following:
host% grep <my-RPC-number> /etc/rpc |
Again, if you don't see a match, your number is unique.
host% /usr/snm/agents/na.logger |
If you've installed this product on a Solaris 2.x machine,
the command would be the following:
host% /opt/SUNWconn/snm/agents/na.logger |
13.2.1 snm_cmd
snm_cmd is a generic manager for Site/SunNet/Domain
Manager agents. You can test agents without having to write a dedicated manager
or running the Console.
host% myagent -d 3 |
13.2.2 Verifying the Agent Schema
Once you have written your agent schema, use the
-v option of snm_cmd to verify the group and attribute
names and values defined in the agent schema match those in your agent:
host% snm_cmd -v -f myagent.schema |
13.2.3 Test the Agent
The verification check done by snm_cmd
-v can give you a high degree of confidence that your agent and schema
match, and that your agent is at least reporting information. However, there
are several tests you should do yourself. Use snm_cmd to do your
testing. These are recommended tests, and may be done in any order.
Count |
Interval |
Interpretation |
13.3.1 Install the Agent
For each system where you want your agent to
run,
na.<my-agent-name> 0 |
na.<agent-name>/10 tli rpc/udp wait root <agent program absolute pathname> <agent-name> <arguments> |
na.hostmem/10 tli rpc/udp wait root /opt/SUNWconn/snm/agents/na.iproutes na.iproutes |
host% kill -HUP <inetd's process ID> |