[Orca-dev] State column patch for orcallator.se 1.30b1

Rusty Carruth rcarruth at tempe.tt.slb.com
Wed Oct 10 17:18:50 PDT 2001


Blair Zajac <blair at orcaware.com> wrote:
> Rusty Carruth wrote:
> > 
> > Blair Zajac <blair at orcaware.com> wrote:
> > > Rusty,
> > >
> > > Would you mind sending me a new patch for your new states columns so it can
> > > go into the next orcallator.se?
> > 
> > Sure.  When do you want to have it done by?

How about today   ;-)  (for part of it, anyway)

Here is a -u diff for just orcallator.se:

diff -u orcallator.se-1.30b1 orcallator.se.out
--- orcallator.se-1.30b1        Wed Oct 10 16:40:56 2001
+++ orcallator.se.out   Wed Oct 10 16:40:58 2001
@@ -1210,31 +1210,69 @@
   }
 }
 
+/* state as a digit */
+int state_dig(int state) {
+  switch(state) {
+    case ST_WHITE: return '0'; /* OK states are zero */
+    case ST_BLUE:  return '0';
+    case ST_GREEN: return '0';
+    case ST_AMBER: return '1';/* bad states have a non-zero value.
+    case ST_RED:   return '2';
+    case ST_BLACK: return '4';
+    default: return '9';       /* invalid state */
+  }
+}
+
 measure_misc(long now, tm_t tm_now)
 {
   long   uptime;
   char   states[12];
   char   tm_buf[16];
+  char sum_states[24];
+  int statetmp;
 
   uptime = now - boot_time;
+  sum_states = "0 0 0 0 0 0 0 0 0 0 0";
   states = "wwwwwwwwwww";
   strftime(tm_buf, sizeof(tm_buf), "%T", tm_now);
 
-  states[0] = state_char(lr_disk$dr.state);
-  states[1] = state_char(lr_net$nr.state);
-  states[2] = state_char(lr_rpcclient$r.state);
-  states[3] = state_char(lr_swapspace$s.state);
-  states[4] = state_char(lr_ram$ram.state);
-  states[5] = state_char(lr_kmem$kmem.state);
-  states[6] = state_char(lr_cpu$cpu.state);
-  states[7] = state_char(lr_mutex$m.state);
-  states[8] = state_char(lr_dnlc$dnlc.state);
-  states[9] = state_char(lr_inode$inode.state);
-  states[10]= state_char(lr_tcp$tcp.state);
+  statetmp = lr_disk$dr.state;
+  states[0] = state_char(statetmp);    sum_states[0] = state_dig(statetmp);
+
+  statetmp = lr_net$nr.state;
+  states[1] = state_char(statetmp);    sum_states[2] = state_dig(statetmp);
+
+  statetmp = lr_rpcclient$r.state;
+  states[2] = state_char(statetmp);    sum_states[4] = state_dig(statetmp);
+
+  statetmp = lr_swapspace$s.state;
+  states[3] = state_char(statetmp);    sum_states[6] = state_dig(statetmp);
+
+  statetmp = lr_ram$ram.state;
+  states[4] = state_char(statetmp);    sum_states[8] = state_dig(statetmp);
+
+  statetmp = lr_kmem$kmem.state;
+  states[5] = state_char(statetmp);    sum_states[10] = state_dig(statetmp);
+
+  statetmp = lr_cpu$cpu.state;
+  states[6] = state_char(statetmp);    sum_states[12] = state_dig(statetmp);
+
+  statetmp = lr_mutex$m.state;
+  states[7] = state_char(statetmp);    sum_states[14] = state_dig(statetmp);
+
+  statetmp = lr_dnlc$dnlc.state;
+  states[8] = state_char(statetmp);    sum_states[16] = state_dig(statetmp);
+
+  statetmp = lr_inode$inode.state;
+  states[9] = state_char(statetmp);    sum_states[18] = state_dig(statetmp);
+
+  statetmp = lr_tcp$tcp.state;
+  states[10]= state_char(statetmp);    sum_states[20]= state_dig(statetmp);
 
   put_output(" timestamp",  sprintf("%10d", now));
   put_output("locltime",    tm_buf);
   put_output("DNnsrkcmdit", states);
+  put_output(" State_D State_N State_n State_s State_r State_k State_c State_m State_d State_i State_t", sum_states);
   put_output("  uptime",    sprintf("%8d", uptime));
 }
 
Hmm.  That last line is really long.  Here's an alternate version of it:

+  put_output(" State_D State_N State_n State_s State_r State_k State_c "
+	"State_m State_d State_i State_t", sum_states);

But I don't know if se can handle broken lines like that...

The other files I'll get out here hopefully by this time next week (probably
sooner, but I'm not making any promises ;-)

(Blair, I'm sure YOU realize this, but in case anyone ELSE wonders,
I'll say that I did that 'statetmp'  thingy because the state gets 
reset upon read, so I had to save it to use it twice (and I did not
like any of the other hacks that went through my head momentarily ;-)

rc


Rusty E. Carruth       Email:     rcarruth at Tempe.tt.slb.com or rcarruth at slb.com
Voice: (480) 345-3621  SnailMail: Schlumberger ATE                   ___
FAX:   (480) 345-8793             7855 S. River Parkway, Suite 116   \e/
Ham: N7IKQ @ 146.82+,pl 162.2     Tempe, AZ 85284-1825                V
ICBM: 33 20' 44"N   111 53' 47"W  http://tuxedo.org/~esr/ecsl/index.html
"Why would anyone choose a tool that is the primary virus vector of the known universe?" - me



More information about the Orca-dev mailing list