NCBI C Toolkit Cross Reference

C/connect/ncbi_host_info.h


  1 #ifndef CONNECT___NCBI_HOST_INFO__H
  2 #define CONNECT___NCBI_HOST_INFO__H
  3 
  4 /* $Id: ncbi_host_info.h,v 6.11 2009/09/30 20:24:38 kazimird Exp $
  5  * ===========================================================================
  6  *
  7  *                            PUBLIC DOMAIN NOTICE
  8  *               National Center for Biotechnology Information
  9  *
 10  *  This software/database is a "United States Government Work" under the
 11  *  terms of the United States Copyright Act.  It was written as part of
 12  *  the author's official duties as a United States Government employee and
 13  *  thus cannot be copyrighted.  This software/database is freely available
 14  *  to the public for use. The National Library of Medicine and the U.S.
 15  *  Government have not placed any restriction on its use or reproduction.
 16  *
 17  *  Although all reasonable efforts have been taken to ensure the accuracy
 18  *  and reliability of the software and data, the NLM and the U.S.
 19  *  Government do not and cannot warrant the performance or results that
 20  *  may be obtained by using this software or data. The NLM and the U.S.
 21  *  Government disclaim all warranties, express or implied, including
 22  *  warranties of performance, merchantability or fitness for any particular
 23  *  purpose.
 24  *
 25  *  Please cite the author in any work or product based on this material.
 26  *
 27  * ===========================================================================
 28  *
 29  * Author:  Anton Lavrentiev
 30  *
 31  * File Description:
 32  *   NCBI host info getters
 33  *
 34  *   Host information handle becomes available from SERV_Get[Next]InfoEx()
 35  *   calls of the service mapper (ncbi_service.c) and remains valid until
 36  *   destructed by passing into free(). All API functions declared below
 37  *   accept NULL as 'host_info' parameter, and as the result return a failure
 38  *   status as described individually for each API call.
 39  *
 40  */
 41 
 42 #include <connect/connect_export.h>
 43 #include <connect/ncbi_types.h>
 44 
 45 
 46 /** @addtogroup ServiceSupport
 47  *
 48  * @{
 49  */
 50 
 51 
 52 #ifdef __cplusplus
 53 extern "C" {
 54 #endif
 55 
 56 
 57 struct SHostInfoTag;  /*forward declaration of an opaque private structure*/
 58 typedef struct SHostInfoTag* HOST_INFO; /*handle for the user code use*/
 59 
 60 
 61 /* Return official host address or 0 if unknown.
 62  */
 63 extern NCBI_XCONNECT_EXPORT
 64 unsigned int HINFO_HostAddr(const HOST_INFO host_info);
 65 
 66 
 67 /* Return CPU count or -1 if an error occurred.
 68  */
 69 extern NCBI_XCONNECT_EXPORT
 70 int HINFO_CpuCount(const HOST_INFO host_info);
 71 
 72 
 73 /* Return number of actual CPU units, 0 if the number cannot
 74  * be determined, or -1 if an error occurred.
 75  */
 76 extern NCBI_XCONNECT_EXPORT
 77 int HINFO_CpuUnits(const HOST_INFO host_info);
 78 
 79 
 80 /* Return CPU clock rate (in MHz) or 0 if an error occurred.
 81  */
 82 extern NCBI_XCONNECT_EXPORT
 83 double HINFO_CpuClock(const HOST_INFO host_info);
 84 
 85 
 86 /* Return task count or -1 if an error occurred.
 87  */
 88 extern NCBI_XCONNECT_EXPORT
 89 int HINFO_TaskCount(const HOST_INFO host_info);
 90 
 91 
 92 /* Return non-zero on success and store memory usage (in MB
 93  * at the provided array "memusage" in the following layout:
 94  * index 0 = total RAM, MB;
 95  * index 1 = discardable RAM (cached), MB;
 96  * index 2 = free RAM, MB;
 97  * index 3 = total swap, MB;
 98  * index 4 = free swap, MB.
 99  * Return 0 if an error occurred.
100  */
101 extern NCBI_XCONNECT_EXPORT
102 int/*bool*/ HINFO_Memusage(const HOST_INFO host_info, double memusage[5]);
103 
104 
105 typedef struct {
106     int                arch;    /* architecture ID, 0=unknown */
107     int                ostype;  /* OS type ID,      0=unknown */
108     struct {
109         unsigned short major;
110         unsigned short minor;
111         unsigned short patch;
112     } kernel;                   /* kernel/OS version #, if available         */
113     unsigned short     bits;    /* platform bitness, 32/64/0=unknown         */
114     size_t             pgsize;  /* hardware page size in bytes, if available */
115     TNCBI_Time         bootup;  /* boot time, time_t-compatible              */
116     TNCBI_Time         start;   /* LB start time, time_t-compatible          */
117     struct {
118         short          major;
119         short          minor;
120         short          patch;
121     } daemon;                   /* LBSMD version */
122     unsigned short     pad;     /* MBZ */
123 } SHINFO_Params;
124 
125 extern NCBI_XCONNECT_EXPORT
126 int/*bool*/ HINFO_MachineParams(const HOST_INFO host_info, SHINFO_Params* p);
127 
128 
129 /* Return non-zero on success and store load averages in the
130  * provided array "lavg", with the standard load average for last
131  * minute stored at index [0], and instant load average
132  * (aka BLAST) stored at index [1].  Return 0 on error.
133  */
134 extern NCBI_XCONNECT_EXPORT
135 int/*bool*/ HINFO_LoadAverage(const HOST_INFO host_info, double lavg[2]);
136 
137 
138 /* Return non-zero on success and store host status coefficients in
139  * the provided array "status", with status based on the standard
140  * load average stored at index [0], and that based on instant load
141  * average stored at index [1]. Status may return as 0 if the host
142  * does not provide such information.  Return 0 on error.
143  */
144 extern NCBI_XCONNECT_EXPORT
145 int/*bool*/ HINFO_Status(const HOST_INFO host_info, double status[2]);
146 
147 
148 /* Obtain and return host environment.  The host environment is the
149  * sequence of lines (separated by \n), all having the form "name=value",
150  * which are provided to load-balancing service mapping daemon (LBSMD)
151  * in the configuration file on that host.  Return 0 if the host
152  * environment cannot be obtained.  If completed successfully, the
153  * host environment remains valid until the handle 'host_info' deleted
154  * in the application program.
155  */
156 extern NCBI_XCONNECT_EXPORT
157 const char* HINFO_Environment(const HOST_INFO host_info);
158 
159 
160 /* Obtain affinity argument and value that has keyed the service
161  * selection (if affinities have been used at all).  NULL gets returned
162  * as argument if no affinity has been found (in this case the value
163  * will be returned NULL as well).  Otherwise, NULL gets returned as
164  * the value if there was no particular value matched but the argument
165  * played alone; "" is the value has been used empty, or any other
166  * substring from the host environment that keyed the selection decision.
167  */
168 extern NCBI_XCONNECT_EXPORT
169 const char* HINFO_AffinityArgument(const HOST_INFO host_info);
170 
171 extern NCBI_XCONNECT_EXPORT
172 const char* HINFO_AffinityArgvalue(const HOST_INFO host_info);
173 
174 
175 #ifdef __cplusplus
176 }  /* extern "C" */
177 #endif
178 
179 
180 /* @} */
181 
182 #endif /* CONNECT___NCBI_HOST_INFO__H */
183 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.