[Orca-dev] orcallator.se patch to dynamically count oracle connections
Blair Zajac
blair at orcaware.com
Thu May 27 21:42:27 PDT 2004
Dmitry Berezin wrote:
> Here is another patch for orcallator.se that _might_ be useful. This
> patch allows orcallator.se find all running Oracle Databases and count
> connections to them by counting all oracle<SID> processes. It will count
> local and remote connections separately.
>
>
>
> The only new functionality that this patch provides comparing to the
> workload patch that I have posted earlier today is that there is no need
> to specify which Oracle instances to look for on the servers, so the
> same version of orcallator.se can be installed on multiple systems.
> There are some drawbacks that I have listed here:
>
> http://www.orcaware.com/pipermail/orca-dev/2004-May/000459.html
Will orcallator.se work with both this patch and the workload patch
installed? Can this patch be integrated into the functionality of the
other?
Here are some comments on the patch.
Please fit the lines to 80 characters. I still use 6 80 character wide
putty's :)
diff -Naur orcallator-1.37/orcallator.se orcallator-oracle/orcallator.se
--- orcallator-1.37/orcallator.se 2004-05-24 16:45:37.000000000 -0400
+++ orcallator-oracle/orcallator.se 2004-05-25 16:06:28.424021000 -0400
@@ -346,6 +346,12 @@
#include <tcp_class.se>
#include <tcp_rules.se>
+#ifdef WATCH_ORACLE
+#include <proc.se>
+#include <fcntl.se>
+#include <process_class.se>
+#endif
+
It would be good to have all includes included once. Right now proc.se
and fcntl.se are already included. It would be good to have a single
test like this:
#if WATCH_CPU || WATCH_ORACLE || WATCH_WEB
#include <proc.se>
to include it.
+ if (init_done == 0) { // Initialize proc_class_t variable
+ refresh$(pp);
Is there any point to calling refresh$(pp); here given that it is called
just after this if test?
+ init_done = 1;
+ }
+
+ refresh$(pp); // Get new snapshot of all processes
+ for (i=0; i<ndbs; i++) { // Reset counters
Just a style nit, but I like the ++ and -- before the variable. Not in
these circumstances, but the compiler can optimize ++i better, because
i++ may require the compiler to keep the old value of i around after i
is incremented.
+ while (pp.index$ != -1) { // For all processes...
+ if (pp.args =~ "^oracle") { // For all oracleXXXX processes...
+ db_name = strtok(pp.args," "); // Extract SID
Space after the ,
+ pt = ((pointer_t) &db_name) + 6;
+ db_name = ((string) pt);
+ for (i=0; i<ndbs; i++) { // Find db_name in the database list
+ if (dbproc[i].name == db_name) {
+ break;
+ }
+ }
+ if (i == ndbs) { // db_name is not found in the database list
+ if (ndbs == max_ndbs) { // Need to expand database list array
+ max_ndbs += 10;
+ dbproc = renew dbproc[max_ndbs];
+ }
+ for (i=ndbs++; i>0; i--) { // Simple bubble sort to make orca happy
How about using the qsort that is in stdlib.se?
+ if ( db_name < dbproc[i-1].name) {
Remove space before db_name.
Otherwise it looks good.
Best
Blair
More information about the Orca-dev
mailing list