Editing Ubstat system call

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 19: Line 19:
 
The system call description is
 
The system call description is
  
<source lang="c">
+
<pre>
 
long ubstat(int func, unsigned long luid, void *notif, void *buf, int size);
 
long ubstat(int func, unsigned long luid, void *notif, void *buf, int size);
</source>
+
</pre>
  
 
The macros and data typed used are declared in <code>include/ub/ub_stat.h</code> file.
 
The macros and data typed used are declared in <code>include/ub/ub_stat.h</code> file.
Line 49: Line 49:
  
 
'''1. <code>UBSTAT_READ_ONE</code>''' format is
 
'''1. <code>UBSTAT_READ_ONE</code>''' format is
<source lang="c">
+
<pre>
 
         typedef unsigned long ubstattime_t;
 
         typedef unsigned long ubstattime_t;
  
Line 62: Line 62:
 
                 ubstatparm_t    param[1];
 
                 ubstatparm_t    param[1];
 
         }
 
         }
</source>
+
</pre>
  
 
It contains the time period for which the stats are returned and the <code>maxheld</code> and <code>failcnt</code> for the resource.
 
It contains the time period for which the stats are returned and the <code>maxheld</code> and <code>failcnt</code> for the resource.
  
 
'''2. <code>UBSTAT_READ_ALL</code>''' format is
 
'''2. <code>UBSTAT_READ_ALL</code>''' format is
<source lang="c">
+
<pre>
 
         typedef unsigned long ubstattime_t;
 
         typedef unsigned long ubstattime_t;
  
Line 80: Line 80:
 
                 ubstatparm_t    param[UB_RESOURCES];
 
                 ubstatparm_t    param[UB_RESOURCES];
 
         }
 
         }
</source>
+
</pre>
  
 
It contains the same info as the <code>UBSTAT_READ_ONE</code> does, but for all the resources.
 
It contains the same info as the <code>UBSTAT_READ_ONE</code> does, but for all the resources.
  
 
'''3. <code>UBSTAT_READ_FULL</code>''' format is
 
'''3. <code>UBSTAT_READ_FULL</code>''' format is
<source lang="c">
+
<pre>
 
         typedef unsigned long ubstattime_t;
 
         typedef unsigned long ubstattime_t;
  
Line 104: Line 104:
 
                 ubstatparmf_t    param[UB_RESOURCES];
 
                 ubstatparmf_t    param[UB_RESOURCES];
 
         }
 
         }
</source>
+
</pre>
  
 
It contains the extended info for all the resources.
 
It contains the extended info for all the resources.
Line 113: Line 113:
  
 
'''6. UBSTAT_GETTIME''' format is
 
'''6. UBSTAT_GETTIME''' format is
<source lang="c">
+
<pre>
 
         typedef unsigned long ubstattime_t;
 
         typedef unsigned long ubstattime_t;
  
Line 121: Line 121:
 
                 ubstattime_t    cur_time;
 
                 ubstattime_t    cur_time;
 
         };
 
         };
</source>
+
</pre>
  
 
It returns the time interval within which the stats are collected and the current time.
 
It returns the time interval within which the stats are collected and the current time.
Line 131: Line 131:
  
 
The <code>notif</code> should point to
 
The <code>notif</code> should point to
<source lang="c">
+
<pre>
 
         typedef struct {
 
         typedef struct {
 
                 long            maxinterval;
 
                 long            maxinterval;
 
                 int            signum;
 
                 int            signum;
 
         } ubnotifrq_t;
 
         } ubnotifrq_t;
</source>
+
</pre>
  
 
The <code>maxinterval</code> is the time after which the notification will be delivered. It should be more than 1 (second).
 
The <code>maxinterval</code> is the time after which the notification will be delivered. It should be more than 1 (second).
Line 147: Line 147:
 
== Demo ==
 
== Demo ==
 
The following program demonstrates how you can (but not should) use the described API. This example is deliberately made very stupid and simple to demonstrate the main idea and will only work on x86_64.
 
The following program demonstrates how you can (but not should) use the described API. This example is deliberately made very stupid and simple to demonstrate the main idea and will only work on x86_64.
<source lang="c">
+
<pre>
 
#include <stdio.h>
 
#include <stdio.h>
 
#include <unistd.h>
 
#include <unistd.h>
Line 285: Line 285:
 
return 0;
 
return 0;
 
}
 
}
</source>
+
</pre>
  
 
== Implementation constraints ==
 
== Implementation constraints ==

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)