home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / condor40.zip / CONDOR / src / util_lib / status.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  3KB  |  138 lines

  1. /* 
  2. ** Copyright 1986, 1987, 1988, 1989 University of Wisconsin
  3. ** 
  4. ** Permission to use, copy, modify, and distribute this software and its
  5. ** documentation for any purpose and without fee is hereby granted,
  6. ** provided that the above copyright notice appear in all copies and that
  7. ** both that copyright notice and this permission notice appear in
  8. ** supporting documentation, and that the name of the University of
  9. ** Wisconsin not be used in advertising or publicity pertaining to
  10. ** distribution of the software without specific, written prior
  11. ** permission.  The University of Wisconsin makes no representations about
  12. ** the suitability of this software for any purpose.  It is provided "as
  13. ** is" without express or implied warranty.
  14. ** 
  15. ** THE UNIVERSITY OF WISCONSIN DISCLAIMS ALL WARRANTIES WITH REGARD TO
  16. ** THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17. ** FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF WISCONSIN  BE LIABLE FOR
  18. ** ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19. ** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  20. ** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  21. ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22. ** 
  23. ** Authors:  Allan Bricker and Michael J. Litzkow,
  24. **              University of Wisconsin, Computer Sciences Dept.
  25. ** 
  26. */ 
  27.  
  28.  
  29. #include <stdio.h>
  30. #include <sys/types.h>
  31. #include <netinet/in.h>
  32. #include "expr.h"
  33. #include "manager.h"
  34. #include "except.h"
  35.  
  36. #ifndef LINT
  37. static char *_FileName_ = __FILE__;        /* Used by EXCEPT (see except.h)     */
  38. #endif LINT
  39.  
  40. char    *index();
  41.  
  42.  
  43. display_status_line( line )
  44. STATUS_LINE    *line;
  45. {
  46.     char    *shorten();
  47.     char    *ptr;
  48.  
  49.     
  50.     if( ptr=index(line->name,'.') ) {
  51.         *ptr = '\0';
  52.     }
  53.     printf( "%-14s ", line->name );
  54.     printf( "%3d ", line->run );
  55.     printf( "%4d ", line->tot);
  56.  
  57.     if( line->prio < -9999 ) {
  58.         line->prio = -9999;
  59.     } else if( line->prio > 9999 ) {
  60.         line->prio = 9999;
  61.     }
  62.     printf( "%5d ", line->prio );
  63.  
  64.     printf( "%-6.6s ", shorten(line->state) );
  65.     printf( "%-6.2f ", line->load_avg );
  66.  
  67.     if( line->kbd_idle > 9999 ) {
  68.         line->kbd_idle = 9999;
  69.     }
  70.     printf( "%4d ", line->kbd_idle );
  71.     printf( "%-7.7s ", line->arch );
  72.     printf( "%-8.8s ", line->op_sys );
  73.  
  74.     printf( "\n" );
  75. }
  76.  
  77. char *
  78. shorten( state )
  79. char    *state;
  80. {
  81.     if( stricmp(state,"Running") == 0 ) {
  82.         return "Run";
  83.     }
  84.     if( stricmp(state,"Suspended") == 0 ) {
  85.         return "Susp";
  86.     }
  87.     if( stricmp(state,"Killed") == 0 ) {
  88.         return "Kill";
  89.     }
  90.     if( stricmp(state,"Checkpointing") == 0 ) {
  91.         return "Ckpt";
  92.     }
  93.     if( stricmp(state,"NoJob") == 0 ) {
  94.         return "NoJob";
  95.     }
  96.     if( stricmp(state,"(Down)") == 0 ) {
  97.         return "Down";
  98.     }
  99.     return "(???)";
  100. }
  101.  
  102. free_status_line( line )
  103. STATUS_LINE    *line;
  104. {
  105.     if( line->name ) {
  106.         free( line->name );
  107.     }
  108.  
  109.     if( line->state ) {
  110.         free( line->state );
  111.     }
  112.  
  113.     if( line->arch ) {
  114.         free( line->arch );
  115.     }
  116.  
  117.     if( line->op_sys ) {
  118.         free( line->op_sys );
  119.     }
  120.  
  121.     free( (char *)line );
  122. }
  123.  
  124. print_header()
  125. {
  126.  
  127.     printf( "%-14s ", "Name" );
  128.     printf( "%-3s ", "Run" );
  129.     printf( "%4.4s ", "Tot" );
  130.     printf( "%5s ", "Prio" );
  131.     printf( "%-6s ", "State" );
  132.     printf( "%-6s ", "LdAvg" );
  133.     printf( "%-4s ", "Idle" );
  134.     printf( "%-7s ", "Arch" );
  135.     printf( "%-8s ", "OpSys" );
  136.     printf( "\n" );
  137. }
  138.