On 16.05.2011 17:50, Robert Story wrote:
>
RS> Yes, but having a working example of the code mean it would be
easier to stuff
RS> into an extension mib.
Ahok, so please find patches to hr_swrun.c and HOST-RESOURCES-MIB
attached to this mail.
> I think adding a Net-SNMP extension table to the hrSWRun table is the
way to
> go. We just have to get everyone to agree on the semantics for the
object.
Could you point me to an example? I looked throw the code, some examples
and tutorials but some how do not get the link to a clear defintion of
"Net-SNMP extension table" and/or its use.
Thanks
/a
--- HOST-RESOURCES-MIB.orig 2011-05-16 20:51:07.000000000 +0200
+++ HOST-RESOURCES-MIB 2011-05-16 20:53:04.000000000 +0200
@@ -1119,7 +1119,8 @@
hrSWRunPath InternationalDisplayString,
hrSWRunParameters InternationalDisplayString,
hrSWRunType INTEGER,
- hrSWRunStatus INTEGER
+ hrSWRunStatus INTEGER,
+ hrSWRunStartTime TimeTicks
}
hrSWRunIndex OBJECT-TYPE
@@ -1202,6 +1203,15 @@
other values are not valid."
::= { hrSWRunEntry 7 }
+hrSWRunStartTime OBJECT-TYPE
+ SYNTAX TimeTicks
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The start-time (in 1/100s since system start)
+ of this running piece of software."
+ ::= { hrSWRunEntry 8 }
+
-- The Host Resources Running Software Performance Group
--
-- The hrSWRunPerfTable contains an entry corresponding to
--- net-snmp-5.4.3.orig/agent/mibgroup/host/hr_swrun.c 2009-06-15 00:01:33.000000000 +0200
+++ net-snmp-5.4.3/agent/mibgroup/host/hr_swrun.c 2011-05-16 20:37:14.000000000 +0200
@@ -145,9 +145,10 @@
#define HRSWRUN_PARAMS 6
#define HRSWRUN_TYPE 7
#define HRSWRUN_STATUS 8
+#define HRSWRUN_STARTTIME 9
-#define HRSWRUNPERF_CPU 9
-#define HRSWRUNPERF_MEM 10
+#define HRSWRUNPERF_CPU 10
+#define HRSWRUNPERF_MEM 11
struct variable4 hrswrun_variables[] = {
{HRSWRUN_OSINDEX, ASN_INTEGER, RONLY, var_hrswrun, 1, {1}},
@@ -157,7 +158,8 @@
{HRSWRUN_PATH, ASN_OCTET_STR, RONLY, var_hrswrun, 3, {2, 1, 4}},
{HRSWRUN_PARAMS, ASN_OCTET_STR, RONLY, var_hrswrun, 3, {2, 1, 5}},
{HRSWRUN_TYPE, ASN_INTEGER, RONLY, var_hrswrun, 3, {2, 1, 6}},
- {HRSWRUN_STATUS, ASN_INTEGER, RONLY, var_hrswrun, 3, {2, 1, 7}}
+ {HRSWRUN_STATUS, ASN_INTEGER, RONLY, var_hrswrun, 3, {2, 1, 7}},
+ {HRSWRUN_STARTTIME, ASN_TIMETICKS, RONLY, var_hrswrun, 3, {2, 1, 8}}
};
struct variable4 hrswrunperf_variables[] = {
@@ -943,6 +945,7 @@
#endif
return (u_char *) & long_return;
case HRSWRUN_STATUS:
+ case HRSWRUN_STARTTIME:
#if defined(cygwin)
if (lowproc.process_state & PID_STOPPED)
long_return = 3; /* notRunnable */
@@ -1028,28 +1031,50 @@
if ((fp = fopen(string, "r")) != NULL) {
fgets(buf, sizeof(buf), fp);
cp = buf;
- for (i = 0; i < 2; ++i) { /* skip two fields */
+ int i_toSkip = -1;
+ switch(vp->magic) {
+ case HRSWRUN_STATUS:
+ i_toSkip = 2;
+ break;
+ case HRSWRUN_STARTTIME:
+ i_toSkip = 21;
+ break;
+ default:
+ break; /* should never get here */
+ }
+
+ for (i = 0; i < i_toSkip; ++i) { /* skip 'i_toSkip' fields */
while (*cp != ' ')
++cp;
++cp;
}
- switch (*cp) {
- case 'R':
- long_return = 1; /* running */
- break;
- case 'S':
- long_return = 2; /* runnable */
+ switch(vp->magic) {
+ case HRSWRUN_STATUS:
+ switch (*cp) {
+ case 'R':
+ long_return = 1; /* running */
+ break;
+ case 'S':
+ long_return = 2; /* runnable */
+ break;
+ case 'D':
+ case 'T':
+ long_return = 3; /* notRunnable */
+ break;
+ case 'Z':
+ default:
+ long_return = 4; /* invalid */
+ break;
+ }
break;
- case 'D':
- case 'T':
- long_return = 3; /* notRunnable */
+ case HRSWRUN_STARTTIME:
+ long_return = atol(cp);
break;
- case 'Z':
default:
- long_return = 4; /* invalid */
- break;
+ break; /* should never get here */
}
+
fclose(fp);
} else
long_return = 4; /* invalid */
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders