home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume34 / netuse / part05 < prev    next >
Encoding:
Text File  |  1993-01-09  |  50.2 KB  |  1,443 lines

  1. Newsgroups: comp.sources.misc
  2. From: amber@engin.umich.edu (Lee Liming)
  3. Subject: v34i103:  netuse - A Network Host Usage Monitoring System, Part05/06
  4. Message-ID: <1993Jan11.023832.25587@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5596b0fe1715b63d234510153297ea3f
  6. Date: Mon, 11 Jan 1993 02:38:32 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: amber@engin.umich.edu (Lee Liming)
  10. Posting-number: Volume 34, Issue 103
  11. Archive-name: netuse/part05
  12. Environment: UNIX, MS-DOS, OS/2, INET, MSC
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  netuse/clients/getmach.1 netuse/clients/getmach.c
  19. #   netuse/clients/hostinfo.1 netuse/clients/netuseadmin.1
  20. #   netuse/daemons/getdisk.c netuse/daemons/getusers.c
  21. #   netuse/daemons/netuse.8 netuse/daemons/netused.8
  22. #   netuse/lib/config.h netuse/lib/netadmin.c netuse/lib/variable.h
  23. # Wrapped by kent@sparky on Sun Jan 10 20:28:37 1993
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 5 (of 6)."'
  27. if test -f 'netuse/clients/getmach.1' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'netuse/clients/getmach.1'\"
  29. else
  30.   echo shar: Extracting \"'netuse/clients/getmach.1'\" \(3373 characters\)
  31.   sed "s/^X//" >'netuse/clients/getmach.1' <<'END_OF_FILE'
  32. X.TH getmach 1 "June 6, 1992" "" "CAEN - The University of Michigan"
  33. X.UC 4
  34. X.SH NAME
  35. Xgetmach \- NETUSE Host Selection utility
  36. X.SH SYNOPSIS
  37. X.B getmach [
  38. X.BR specifications
  39. X.B ]
  40. X.SH DESCRIPTION
  41. X.I getmach
  42. Xis a tool for selecting a network host which meets specific usage criteria.
  43. XThe
  44. X.I getmach
  45. Xclient consults the
  46. X.I netuse
  47. Xserver, which maintains a list of network hosts
  48. Xwhich periodically report their status.  The
  49. X.I netuse
  50. Xserver returns a host which meets the specification given on the command line,
  51. Xand
  52. X.I getmach
  53. Xprints this hostname on the terminal.
  54. X.PP
  55. XA particular hostname will only be returned once to any client on the network
  56. Xduring a given two minute period.  Thus, successive
  57. X.I getmach
  58. Xcommands are guaranteed to return unique hostnames, so long as additional
  59. Xhosts which meet the specifications are available.  The complete listing of
  60. Xhosts reporting to the
  61. X.I netuse
  62. Xserver can be displayed using the
  63. X.IR hostinfo (1)
  64. Xcommand.
  65. X.PP
  66. XIf no machines meet the given specifications, or if all matching machines have
  67. Xbeen given out within the past two minutes,
  68. X.I getmach
  69. Xwill produce no output, and the return code will be set to 1.
  70. X.PP
  71. XWith no options specified, an arbitrary hostname will be returned.  As
  72. Xadditional specifications are made, only hosts which meet the specifications
  73. Xwill be returned.
  74. X.SH OPTIONS
  75. XThe following options may be used with the
  76. X.I hostinfo
  77. Xcommand to specify criteria for selecting hosts.
  78. X.TP 16
  79. X-help
  80. XList the available specifications.
  81. X.TP 16
  82. X-sun
  83. XRequest only Suns.
  84. X.TP 16
  85. X-ibm
  86. XRequest only IBM RS/6000s.
  87. X.TP 16
  88. X-dec
  89. XRequest only DECstations.
  90. X.TP 16
  91. X-hp
  92. XRequest only HP9000s.
  93. X.TP 16
  94. X-model <model>
  95. XSpecify a model type to be matched.  Model types are those listed by the 
  96. Xhostinfo(1) command when the -models flag is used.
  97. X.TP 16
  98. X-l1 <load>
  99. XSpecify the maximum 1-minute load average.
  100. X.TP 16
  101. X-l2 <load>
  102. XSpecify the maximum 5-minute load average.
  103. X.TP 16
  104. X-l3 <load>
  105. XSpecify the maximum 15-minute load average.
  106. X.TP 16
  107. X-users <nusers>
  108. XSpecify the maximum number of login sessions.
  109. X.TP 16
  110. X-console
  111. XSpecify no one logged into the display.
  112. X.TP 16
  113. X-tmp <kbytes>
  114. XSpecify the minimum free space on /tmp.
  115. X.SH COPYRIGHT
  116. XCopyright (C) 1992 by the Regents of the University of Michigan.
  117. X.PP
  118. XUser agrees to reproduce said copyright notice on all copies of the software
  119. Xmade by the recipient.  
  120. X.PP
  121. XAll Rights Reserved. Permission is hereby granted for the recipient to make
  122. Xcopies and use this software for its own internal purposes only. Recipient of
  123. Xthis software may re-distribute this software outside of their own
  124. Xinstitution. Permission to market this software commercially, to include this
  125. Xproduct as part of a commercial product, or to make a derivative work for
  126. Xcommercial purposes, is explicitly prohibited.  All other uses are also
  127. Xprohibited unless authorized in writing by the Regents of the University of
  128. XMichigan.
  129. X.PP
  130. XThis software is offered without warranty. The Regents of the University of
  131. XMichigan disclaim all warranties, express or implied, including but not
  132. Xlimited to the implied warranties of merchantability and fitness for any
  133. Xparticular purpose. In no event shall the Regents of the University of
  134. XMichigan be liable for loss or damage of any kind, including but not limited
  135. Xto incidental, indirect, consequential, or special damages. 
  136. X.SH SEE ALSO
  137. Xhostinfo(1), netuse(8), netused(8),
  138. X.I Monitoring Hosts with NETUSE
  139. X
  140. END_OF_FILE
  141.   if test 3373 -ne `wc -c <'netuse/clients/getmach.1'`; then
  142.     echo shar: \"'netuse/clients/getmach.1'\" unpacked with wrong size!
  143.   fi
  144.   # end of 'netuse/clients/getmach.1'
  145. fi
  146. if test -f 'netuse/clients/getmach.c' -a "${1}" != "-c" ; then 
  147.   echo shar: Will not clobber existing file \"'netuse/clients/getmach.c'\"
  148. else
  149.   echo shar: Extracting \"'netuse/clients/getmach.c'\" \(5893 characters\)
  150.   sed "s/^X//" >'netuse/clients/getmach.c' <<'END_OF_FILE'
  151. X/******************************************************************************
  152. X GETMACH.C - Network Host Use Monitor Machine Selection Utility
  153. X
  154. X This program contacts the NETUSE server and returns the hostname of a
  155. X specific host on the network which meets given criteria.  If no host meets
  156. X the criteria, no output is produced.  The -help option lists the possible
  157. X selection criteria.
  158. X
  159. X Lee Liming and Michael Neil, The Computer Aided Engineering Network
  160. X The University of Michigan
  161. X
  162. X Copyright (C) 1990, 1991, 1992 by the Regents of the University of Michigan.
  163. X
  164. X User agrees to reproduce said copyright notice on all copies of the software
  165. X made by the recipient.  
  166. X
  167. X All Rights Reserved. Permission is hereby granted for the recipient to make
  168. X copies and use this software for its own internal purposes only. Recipient of
  169. X this software may re-distribute this software outside of their own
  170. X institution. Permission to market this software commercially, to include this
  171. X product as part of a commercial product, or to make a derivative work for
  172. X commercial purposes, is explicitly prohibited.  All other uses are also
  173. X prohibited unless authorized in writing by the Regents of the University of
  174. X Michigan.
  175. X
  176. X This software is offered without warranty. The Regents of the University of
  177. X Michigan disclaim all warranties, express or implied, including but not
  178. X limited to the implied warranties of merchantability and fitness for any
  179. X particular purpose. In no event shall the Regents of the University of
  180. X Michigan be liable for loss or damage of any kind, including but not limited
  181. X to incidental, indirect, consequential, or special damages. 
  182. X******************************************************************************/
  183. X
  184. X#include <stdio.h>
  185. X#include <sys/types.h>
  186. X#include <netuse.h>
  187. X
  188. X
  189. X#ifdef __STDC__
  190. Xmain(int argc,char *argv[])
  191. X#else
  192. Xmain(argc,argv)
  193. Xint argc;
  194. Xchar *argv[];
  195. X#endif
  196. X{
  197. X     double l1,l2,l3;
  198. X     int users,console,i,modellist=0;
  199. X     long tmp;
  200. X     u_char machtype,modtype;
  201. X     char mname[132],buffer[512];
  202. X
  203. X     l1=100.0; l2=100.0; l3=100.0;
  204. X     users=100; console=100;
  205. X     tmp=0;
  206. X     machtype=0; modtype=0;
  207. X     for (i=1; i<argc; i++) {
  208. X          strcpy(buffer,argv[i]);
  209. X          stoupper(buffer);
  210. X          if (!strcmp(buffer,"-L1")) {
  211. X               i++;
  212. X               if (sscanf(argv[i],"%lf",&l1)!=1) {
  213. X                    printf("Bad argument value (%s,%s).\n",argv[i-1],argv[i]);
  214. X                    --i;
  215. X               }
  216. X               continue;
  217. X          }
  218. X          if (!strcmp(buffer,"-L2")) {
  219. X               i++;
  220. X               if (sscanf(argv[i],"%lf",&l2)!=1) {
  221. X                    printf("Bad argument value (%s,%s).\n",argv[i-1],argv[i]);
  222. X                    --i;
  223. X               }
  224. X               continue;
  225. X          }
  226. X          if (!strcmp(buffer,"-L3")) {
  227. X               i++;
  228. X               if (sscanf(argv[i],"%lf",&l3)!=1) {
  229. X                    printf("Bad argument value (%s,%s).\n",argv[i-1],argv[i]);
  230. X                    --i;
  231. X               }
  232. X               continue;
  233. X          }
  234. X          if (!strcmp(buffer,"-USERS")) {
  235. X               i++;
  236. X               if (sscanf(argv[i],"%d",&users)!=1) {
  237. X                    printf("Bad argument value (%s,%s).\n",argv[i-1],argv[i]);
  238. X                    --i;
  239. X               }
  240. X               continue;
  241. X          }
  242. X          if (!strcmp(buffer,"-MODEL")) {
  243. X               i++;
  244. X               if (!(modtype=netStrToModel(argv[i]))) {
  245. X                    printf("Unknown model specifier (%s,%s).\n",argv[i-1],argv[i]);
  246. X                    --i;
  247. X               }
  248. X               continue;
  249. X          }
  250. X          if (!strcmp(buffer,"-TMP")) {
  251. X               i++;
  252. X               if (sscanf(argv[i],"%ld",&tmp)!=1) {
  253. X                    printf("Bad argument value (%s,%s).\n",argv[i-1],argv[i]);
  254. X                    --i;
  255. X               }
  256. X               continue;
  257. X          }
  258. X          if (!strcmp(buffer,"-CONSOLE")) {
  259. X               console=0;
  260. X               continue;
  261. X          }
  262. X          if (!strcmp(buffer,"-SUN")) {
  263. X               machtype=MACH_SUN;
  264. X               continue;
  265. X          }
  266. X          if (!strcmp(buffer,"-IBM")) {
  267. X               machtype=MACH_IBM_RS6000;
  268. X               continue;
  269. X          }
  270. X          if (!strcmp(buffer,"-APOLLO")) {
  271. X               machtype=MACH_APOLLO;
  272. X               continue;
  273. X          }
  274. X          if (!strcmp(buffer,"-DEC")) {
  275. X               machtype=MACH_DEC;
  276. X               continue;
  277. X          }
  278. X          if (!strcmp(buffer,"-HP")) {
  279. X               machtype=MACH_HP;
  280. X               continue;
  281. X          }
  282. X          if (!strcmp(buffer,"-HELP")) {
  283. X               printf("\nUsage: getmach [options]\n\n");
  284. X               printf("Options: -l1 <load>       Specify maximum 1-min load average\n");
  285. X               printf("         -l2 <load>       Specify maximum 5-min load average\n");
  286. X               printf("         -l3 <load>       Specify maximum 15-min load average\n");
  287. X               printf("         -users <nusers>  Specify maximum number of login sessions\n");
  288. X               printf("         -console         Specify no one logged into the display\n");
  289. X               printf("         -tmp <kbytes>    Specify minimum free space on /tmp\n");
  290. X               printf("         -model <model>   Specify model type\n");
  291. X               printf("         -sun             Request only Sun SparcStations\n");
  292. X               printf("         -ibm             Request only IBM RS/6000s\n");
  293. X               printf("         -dec             Request only DECstations\n");
  294. X               printf("         -apollo          Request only Apollos\n");
  295. X               printf("         -hp              Request only HP9000s\n\n");
  296. X               exit(0);
  297. X          }
  298. X     }
  299. X     netSetup();
  300. X     netuseFind(mname,l1,l2,l3,users,console,tmp,machtype,modtype);
  301. X     netShutdown();
  302. X     if (strlen(mname)) {
  303. X          printf("%s\n",mname);
  304. X          exit(0);
  305. X     }
  306. X     else exit(1);
  307. X}
  308. END_OF_FILE
  309.   if test 5893 -ne `wc -c <'netuse/clients/getmach.c'`; then
  310.     echo shar: \"'netuse/clients/getmach.c'\" unpacked with wrong size!
  311.   fi
  312.   # end of 'netuse/clients/getmach.c'
  313. fi
  314. if test -f 'netuse/clients/hostinfo.1' -a "${1}" != "-c" ; then 
  315.   echo shar: Will not clobber existing file \"'netuse/clients/hostinfo.1'\"
  316. else
  317.   echo shar: Extracting \"'netuse/clients/hostinfo.1'\" \(3527 characters\)
  318.   sed "s/^X//" >'netuse/clients/hostinfo.1' <<'END_OF_FILE'
  319. X.TH hostinfo 1 "June 6, 1992" "" "CAEN - The University of Michigan"
  320. X.UC 4
  321. X.SH NAME
  322. Xhostinfo \- Network Host Information listing utility
  323. X.SH SYNOPSIS
  324. X.B hostinfo [
  325. X.BR options
  326. X.B ]
  327. X.SH DESCRIPTION
  328. X.I hostinfo
  329. Xis a tool for listing available hosts on the Internet.  The
  330. X.I hostinfo
  331. Xclient consults the
  332. X.I netuse
  333. Xserver, which maintains a list of network hosts
  334. Xwhich periodically report their status.  The
  335. X.I netuse
  336. Xserver transfers the list
  337. Xof hosts to the
  338. X.I hostinfo
  339. Xclient, which displays the list on the terminal.
  340. X.PP
  341. XThe host listing is given in order of least use (machines reporting a low
  342. Xcurrent usage will be displayed first).  Machines with users logged into the
  343. Xconsole will always be listed after machines with no one logged into the
  344. Xconsole.
  345. X.PP
  346. XWith no options specified, the listing will include machines of all types.
  347. XOnly the ten least-used machines will be listed.  Currently, the only types of
  348. Xmachines supported are DECstation 3100 and 5000s, Sun 4s (SparcStation and
  349. XSparcStation+), Apollos (all models), HP9000 700 series, and IBM RS/6000s.
  350. XHosts that have not reported recently (within the last 15 minutes) will not be
  351. Xincluded.
  352. X.PP
  353. XThe information for each host includes the following: hostname, type, load
  354. Xaverages over the past 1, 5, and 15 minutes, number of current login sessions,
  355. Xstatus of the display (login or nologin), time of last report, and the number
  356. Xof kilobytes of free space on the /tmp filesystem.
  357. X.PP
  358. XIf the -models flag is used, the listing format is modified to include a wider
  359. Xtype field, including the model as well as the vendor.  With this type of
  360. Xlisting, the time of last report is not displayed.
  361. X.SH OPTIONS
  362. XThe following options may be used with the
  363. X.I hostinfo
  364. Xcommand to modify the types of machines listed.
  365. X.TP 16
  366. X-help
  367. XList the available options.
  368. X.TP 16
  369. X-sun
  370. XInclude only Suns in the listing.
  371. X.TP 16
  372. X-dec
  373. XInclude only DECstations in the listing.
  374. X.TP 16
  375. X-ibm
  376. XInclude only IBM RS/6000s in the listing.
  377. X.TP 16
  378. X-hp
  379. XInclude only HP9000s in the listing.
  380. X.TP 16
  381. X-any
  382. XInclude any type of machine in the listing.
  383. X.TP 16
  384. X-model <model>
  385. XInclude only machines of the specified model.
  386. X.TP 16
  387. X-all
  388. XList all known hosts.
  389. X.TP 16
  390. X-down
  391. XList machines that have NOT reported in the last 15 minutes.
  392. X.TP 16
  393. X-models
  394. XList models rather than last report time.
  395. X.SH COPYRIGHT
  396. XCopyright (C) 1992 by the Regents of the University of Michigan.
  397. X.PP
  398. XUser agrees to reproduce said copyright notice on all copies of the software
  399. Xmade by the recipient.  
  400. X.PP
  401. XAll Rights Reserved. Permission is hereby granted for the recipient to make
  402. Xcopies and use this software for its own internal purposes only. Recipient of
  403. Xthis software may re-distribute this software outside of their own
  404. Xinstitution. Permission to market this software commercially, to include this
  405. Xproduct as part of a commercial product, or to make a derivative work for
  406. Xcommercial purposes, is explicitly prohibited.  All other uses are also
  407. Xprohibited unless authorized in writing by the Regents of the University of
  408. XMichigan.
  409. X.PP
  410. XThis software is offered without warranty. The Regents of the University of
  411. XMichigan disclaim all warranties, express or implied, including but not
  412. Xlimited to the implied warranties of merchantability and fitness for any
  413. Xparticular purpose. In no event shall the Regents of the University of
  414. XMichigan be liable for loss or damage of any kind, including but not limited
  415. Xto incidental, indirect, consequential, or special damages. 
  416. X.SH SEE ALSO
  417. Xgetmach(1), netuse(8), netused(8),
  418. X.I Monitoring Hosts with NETUSE
  419. X
  420. END_OF_FILE
  421.   if test 3527 -ne `wc -c <'netuse/clients/hostinfo.1'`; then
  422.     echo shar: \"'netuse/clients/hostinfo.1'\" unpacked with wrong size!
  423.   fi
  424.   # end of 'netuse/clients/hostinfo.1'
  425. fi
  426. if test -f 'netuse/clients/netuseadmin.1' -a "${1}" != "-c" ; then 
  427.   echo shar: Will not clobber existing file \"'netuse/clients/netuseadmin.1'\"
  428. else
  429.   echo shar: Extracting \"'netuse/clients/netuseadmin.1'\" \(3243 characters\)
  430.   sed "s/^X//" >'netuse/clients/netuseadmin.1' <<'END_OF_FILE'
  431. X.TH netuseadmin 1 "November 29, 1992" "" "CAEN - The University of Michigan"
  432. X.UC 4
  433. X.SH NAME
  434. Xnetuseadmin \- NETUSE administration utility
  435. X.SH SYNOPSIS
  436. X.B netuseadmin
  437. X.SH DESCRIPTION
  438. X.I netuseadmin
  439. Xis an interface to the functions of the netuse master daemon.  The
  440. X.I netuse(8)
  441. Xdaemon receives periodic reports from clients running the 
  442. X.I netused(8)
  443. Xdaemon and requests from the 
  444. X.I hostinfo(1)
  445. Xand 
  446. X.I getmach(1)
  447. Xclient applications.  
  448. X.I netuseadmin
  449. Xallows the network administrator to add and delete hosts from the NETUSE
  450. Xdatabase, and to control the daemon's basic operations, including saving
  451. Xstate and quitting.
  452. X.PP
  453. X.I netuseadmin
  454. Xis an interactive utility.  Commands are given within the program at the
  455. X"netuseadmin>" prompt.
  456. X.PP
  457. XThe "help" command will generate a list of the available commands and their
  458. Xarguments.  They are also listed below.
  459. X.TP 16
  460. Xadd
  461. XAdd a host to the database.  The 
  462. X.I netuse
  463. Xdaemon will add the host (listing it as down until it receives a report from
  464. Xthe host), and eventually attempt to start the host's 
  465. X.I netused
  466. Xdaemon if remote wakeup functionality has been enabled (see the installation
  467. Xguide, 
  468. X.I Monitoring Hosts with NETUSE).
  469. X.TP 16
  470. Xdelete
  471. XRemove a host from the NETUSE database.  Note that this does not kill the 
  472. X.I netused
  473. Xdaemon on the named host.  Unless this is done, the host will continue sending
  474. Xreports to the
  475. X.I netuse
  476. Xmaster daemon, and will be added back into the database.
  477. X.TP 16
  478. Xlist
  479. XProduce a list of the database contents similar to the output of "hostinfo
  480. X-all".  
  481. X.TP 16
  482. Xreload
  483. XReload the host database from the state-save file.
  484. X.TP 16
  485. Xsavestate
  486. XForce the server to save its database state in the state-save file.  This is
  487. Xautomatically done periodically by the master daemon, but it may be necessary
  488. Xat times to force a dump at a specific time (before shutting down the server, 
  489. Xfor example).
  490. X.TP 16 
  491. Xuse
  492. XRead subsequent commands from a file, as if they were typed at the command
  493. Xprompt.
  494. X.TP 16
  495. Xquit
  496. XExit the
  497. X.I netuseadmin
  498. Xprogram.
  499. X.SH COPYRIGHT
  500. XCopyright (C) 1992 by the Regents of the University of Michigan.
  501. X.PP
  502. XUser agrees to reproduce said copyright notice on all copies of the software
  503. Xmade by the recipient.  
  504. X.PP
  505. XAll Rights Reserved. Permission is hereby granted for the recipient to make
  506. Xcopies and use this software for its own internal purposes only. Recipient of
  507. Xthis software may re-distribute this software outside of their own
  508. Xinstitution. Permission to market this software commercially, to include this
  509. Xproduct as part of a commercial product, or to make a derivative work for
  510. Xcommercial purposes, is explicitly prohibited.  All other uses are also
  511. Xprohibited unless authorized in writing by the Regents of the University of
  512. XMichigan.
  513. X.PP
  514. XThis software is offered without warranty. The Regents of the University of
  515. XMichigan disclaim all warranties, express or implied, including but not
  516. Xlimited to the implied warranties of merchantability and fitness for any
  517. Xparticular purpose. In no event shall the Regents of the University of
  518. XMichigan be liable for loss or damage of any kind, including but not limited
  519. Xto incidental, indirect, consequential, or special damages. 
  520. X.SH SEE ALSO
  521. Xnetuse(8), netused(8), getmach(1), hostinfo(1),
  522. X.I Monitoring Hosts with NETUSE
  523. END_OF_FILE
  524.   if test 3243 -ne `wc -c <'netuse/clients/netuseadmin.1'`; then
  525.     echo shar: \"'netuse/clients/netuseadmin.1'\" unpacked with wrong size!
  526.   fi
  527.   # end of 'netuse/clients/netuseadmin.1'
  528. fi
  529. if test -f 'netuse/daemons/getdisk.c' -a "${1}" != "-c" ; then 
  530.   echo shar: Will not clobber existing file \"'netuse/daemons/getdisk.c'\"
  531. else
  532.   echo shar: Extracting \"'netuse/daemons/getdisk.c'\" \(3505 characters\)
  533.   sed "s/^X//" >'netuse/daemons/getdisk.c' <<'END_OF_FILE'
  534. X/******************************************************************************
  535. X This code gets the disk usage for /tmp for a DEC or a SUN.  (See below for
  536. X extensions to other platforms.)
  537. X
  538. X define mips for DEC
  539. X define sun for SUN
  540. X define testing for a compileable program with main
  541. X define DEBUG for debugging output
  542. X
  543. X Hacked up by: Mike Neil on Oct 11, 1990.
  544. X
  545. X Copyright (C) 1990, 1991, 1992 by the Regents of the University of Michigan.
  546. X
  547. X User agrees to reproduce said copyright notice on all copies of the software
  548. X made by the recipient.  
  549. X
  550. X All Rights Reserved. Permission is hereby granted for the recipient to make
  551. X copies and use this software for its own internal purposes only. Recipient of
  552. X this software may re-distribute this software outside of their own
  553. X institution. Permission to market this software commercially, to include this
  554. X product as part of a commercial product, or to make a derivative work for
  555. X commercial purposes, is explicitly prohibited.  All other uses are also
  556. X prohibited unless authorized in writing by the Regents of the University of
  557. X Michigan.
  558. X
  559. X This software is offered without warranty. The Regents of the University of
  560. X Michigan disclaim all warranties, express or implied, including but not
  561. X limited to the implied warranties of merchantability and fitness for any
  562. X particular purpose. In no event shall the Regents of the University of
  563. X Michigan be liable for loss or damage of any kind, including but not limited
  564. X to incidental, indirect, consequential, or special damages. 
  565. X******************************************************************************/
  566. X
  567. X#include <stdio.h>
  568. X
  569. X
  570. X#ifdef mips
  571. X#include <sys/types.h>
  572. X#include <sys/param.h>
  573. X#include <sys/mount.h>
  574. X
  575. X
  576. X#ifdef __STDC__
  577. Xlong getdisk(void)
  578. X#else
  579. Xlong getdisk()
  580. X#endif
  581. X{
  582. X    struct fs_data tempspace;
  583. X    
  584. X    if (statfs("/tmp", &tempspace) != 1)
  585. X        if (statfs("/tmp", &tempspace) != 1)
  586. X            tempspace.fd_req.bfreen = 0;
  587. X    
  588. X    if (tempspace.fd_req.bfreen < 0)
  589. X      tempspace.fd_req.bfreen = 0;
  590. X      
  591. X#ifdef DEBUG
  592. X      printf("%d  %d\n", tempspace.fd_req.btot, tempspace.fd_req.bfreen);
  593. X                 /*        TotalSpace^     Available User Space */
  594. X#endif
  595. X    
  596. X    return((long)tempspace.fd_req.bfreen);
  597. X}
  598. X#endif
  599. X
  600. X
  601. X#if (defined(sun) || defined(_AIX) || defined(hpux))
  602. X
  603. X#include <sys/types.h>
  604. X#if (defined(_AIX))
  605. X#include <sys/statfs.h>
  606. X#else
  607. X#include <sys/vfs.h>
  608. X#endif
  609. X
  610. X#ifdef __STDC__
  611. Xlong getdisk(void)
  612. X#else
  613. Xlong getdisk()
  614. X#endif
  615. X{
  616. X    struct statfs tempspace;
  617. X    long num;
  618. X    
  619. X    if (statfs("/tmp", &tempspace) != 0)
  620. X      if (statfs("/tmp", &tempspace) != 0)
  621. X        tempspace.f_bavail = 0;
  622. X        
  623. X    if (tempspace.f_bavail < 0)
  624. X      tempspace.f_bavail = 0;
  625. X          
  626. X#ifdef DEBUG
  627. X      printf("%d  %d\n", tempspace.f_bsize, tempspace.f_bavail);
  628. X    /*                 BlockSize^     Available User Space in blocks */
  629. X#endif
  630. X    
  631. X    num = (tempspace.f_bsize * tempspace.f_bavail) / 1024;
  632. X    return(num);
  633. X}
  634. X
  635. X#endif
  636. X
  637. X#ifdef apollo
  638. X
  639. X#include <sys/types.h>
  640. X#include <sys/statfs.h>
  641. X
  642. X#ifdef __STDC__
  643. Xlong getdisk(void)
  644. X#else
  645. Xlong getdisk()
  646. X#endif
  647. X{
  648. X    struct statfs tempspace;
  649. X    long num;
  650. X    
  651. X    if (statfs("/tmp", &tempspace,sizeof(tempspace),0) != 0)
  652. X      if (statfs("/tmp", &tempspace,sizeof(tempspace),0) != 0)
  653. X        tempspace.f_bfree = 0;
  654. X        
  655. X    if (tempspace.f_bfree < 0)
  656. X      tempspace.f_bfree = 0;
  657. X          
  658. X#ifdef DEBUG
  659. X      printf("%d  %d\n", tempspace.f_bsize, tempspace.f_bfree);
  660. X    /*                 BlockSize^     Available User Space in blocks */
  661. X#endif
  662. X    
  663. X    num = (tempspace.f_bfree);
  664. X    return(num);
  665. X}
  666. X
  667. X#endif
  668. X
  669. X#ifdef testing
  670. Xmain()
  671. X{
  672. X  printf("%d",getdisk());
  673. X}
  674. X#endif
  675. END_OF_FILE
  676.   if test 3505 -ne `wc -c <'netuse/daemons/getdisk.c'`; then
  677.     echo shar: \"'netuse/daemons/getdisk.c'\" unpacked with wrong size!
  678.   fi
  679.   # end of 'netuse/daemons/getdisk.c'
  680. fi
  681. if test -f 'netuse/daemons/getusers.c' -a "${1}" != "-c" ; then 
  682.   echo shar: Will not clobber existing file \"'netuse/daemons/getusers.c'\"
  683. else
  684.   echo shar: Extracting \"'netuse/daemons/getusers.c'\" \(3215 characters\)
  685.   sed "s/^X//" >'netuse/daemons/getusers.c' <<'END_OF_FILE'
  686. X/******************************************************************************
  687. X This code gets the user list.
  688. X
  689. X Hacked up by: Mike Neil.
  690. X
  691. X Copyright (C) 1990, 1991, 1992 by the Regents of the University of Michigan.
  692. X
  693. X User agrees to reproduce said copyright notice on all copies of the software
  694. X made by the recipient.  
  695. X
  696. X All Rights Reserved. Permission is hereby granted for the recipient to make
  697. X copies and use this software for its own internal purposes only. Recipient of
  698. X this software may re-distribute this software outside of their own
  699. X institution. Permission to market this software commercially, to include this
  700. X product as part of a commercial product, or to make a derivative work for
  701. X commercial purposes, is explicitly prohibited.  All other uses are also
  702. X prohibited unless authorized in writing by the Regents of the University of
  703. X Michigan.
  704. X
  705. X This software is offered without warranty. The Regents of the University of
  706. X Michigan disclaim all warranties, express or implied, including but not
  707. X limited to the implied warranties of merchantability and fitness for any
  708. X particular purpose. In no event shall the Regents of the University of
  709. X Michigan be liable for loss or damage of any kind, including but not limited
  710. X to incidental, indirect, consequential, or special damages. 
  711. X******************************************************************************/
  712. X#include <stdio.h>
  713. X#include <sys/types.h>
  714. X#include <utmp.h>
  715. X
  716. X#if (defined(mips) || defined(sun) || defined(hpux))
  717. X#include <sys/types.h>
  718. X#include <sys/stat.h>
  719. X#endif
  720. X
  721. X
  722. X#ifdef __STDC__
  723. Xint getusers(int *users,int *console)
  724. X#else
  725. Xint getusers(users,console)
  726. Xint *users;
  727. Xint *console;
  728. X#endif
  729. X{
  730. X    struct utmp user;
  731. X#ifdef hpux
  732. X        struct utmp *utptr;
  733. X#endif
  734. X#if (defined(mips) || defined(sun) || defined(hpux))
  735. X    struct stat buf;
  736. X#endif
  737. X    int etcutmp;
  738. X    int eof = 1;
  739. X    char line[9], name[9], host[17];
  740. X    
  741. X        *users=0;
  742. X        *console=0;
  743. X#if (defined(mips) || defined (sun) || defined(hpux))
  744. X    stat ("/dev/console" , &buf);
  745. X    if (buf.st_uid != 0) ++(*console);
  746. X#endif
  747. X
  748. X#ifdef hpux
  749. X        while (utptr=getutent()) {
  750. X                memcpy((char *)&user,(char *)utptr,sizeof(user));
  751. X                if (user.ut_type!=USER_PROCESS) continue;
  752. X        strncpy(name, user.ut_user, 8);
  753. X#else
  754. X    etcutmp = open("/etc/utmp", 0);
  755. X    while(read (etcutmp, (char *)&user, sizeof(struct utmp))) {
  756. X#if !(defined(sun) || defined(mips))
  757. X                if (user.ut_type!=USER_PROCESS) continue;
  758. X#endif
  759. X        strncpy(name, user.ut_name, 8);
  760. X#endif
  761. X        name[8] = '\0';
  762. X        strncpy(line, user.ut_line, 8);
  763. X        line[8] = '\0';
  764. X        strncpy(host, user.ut_host, 16);
  765. X        host[16] = '\0';
  766. X#ifdef testing
  767. X                printf("name= \"%s\"  line=\"%s\"  host=\"%s\"\n",
  768. X                       name,line,host);
  769. X#endif
  770. X        if (strlen(name)) {
  771. X            ++(*users);
  772. X#if (!defined(mips) && !defined(sun) && !defined(hpux))
  773. X            if (!strcmp(line,"console") || !strcmp(host,":0.0") ||
  774. X                            !strcmp(line,"display"))
  775. X            {
  776. X                ++(*console);
  777. X            }
  778. X#endif
  779. X        }
  780. X    }
  781. X#ifdef hpux
  782. X        endutent();
  783. X#else    
  784. X    close(etcutmp);
  785. X#endif      
  786. X        return(*users);
  787. X}
  788. X
  789. X
  790. X#ifdef testing
  791. Xmain()
  792. X{
  793. X     int u,c,rv;
  794. X
  795. X     rv=getusers(&u,&c);
  796. X     printf("Results:  rv=%d u=%d c=%d\n",rv,u,c);
  797. X}
  798. X#endif
  799. END_OF_FILE
  800.   if test 3215 -ne `wc -c <'netuse/daemons/getusers.c'`; then
  801.     echo shar: \"'netuse/daemons/getusers.c'\" unpacked with wrong size!
  802.   fi
  803.   # end of 'netuse/daemons/getusers.c'
  804. fi
  805. if test -f 'netuse/daemons/netuse.8' -a "${1}" != "-c" ; then 
  806.   echo shar: Will not clobber existing file \"'netuse/daemons/netuse.8'\"
  807. else
  808.   echo shar: Extracting \"'netuse/daemons/netuse.8'\" \(1935 characters\)
  809.   sed "s/^X//" >'netuse/daemons/netuse.8' <<'END_OF_FILE'
  810. X.TH netuse 8 "November 29, 1992" "" "CAEN - The University of Michigan"
  811. X.UC 4
  812. X.SH NAME
  813. Xnetuse \- NETUSE Host Monitor master daemon
  814. X.SH SYNOPSIS
  815. X.B netuse 
  816. X.SH DESCRIPTION
  817. X.I netuse
  818. Xis the master daemon which receives reports from all hosts running the 
  819. X.I netused
  820. Xdaemon at a given site.  It stores the reports from each monitored host, and
  821. Xresponds to requests for information from NETUSE clients (such as
  822. X.I getmach(1)
  823. Xand 
  824. X.I hostinfo(1).
  825. X.PP
  826. XThis daemon should run on only one machine at each site using NETUSE.  There
  827. Xare no features for redundancy or fallback servers.
  828. X.PP
  829. XThe 
  830. X.I netuseadmin(1)
  831. Xprogram is used to administer the
  832. X.I netuse
  833. Xdaemon remotely while it is running.
  834. X.SH COPYRIGHT
  835. XCopyright (C) 1992 by the Regents of the University of Michigan.
  836. X.PP
  837. XUser agrees to reproduce said copyright notice on all copies of the software
  838. Xmade by the recipient.  
  839. X.PP
  840. XAll Rights Reserved. Permission is hereby granted for the recipient to make
  841. Xcopies and use this software for its own internal purposes only. Recipient of
  842. Xthis software may re-distribute this software outside of their own
  843. Xinstitution. Permission to market this software commercially, to include this
  844. Xproduct as part of a commercial product, or to make a derivative work for
  845. Xcommercial purposes, is explicitly prohibited.  All other uses are also
  846. Xprohibited unless authorized in writing by the Regents of the University of
  847. XMichigan.
  848. X.PP
  849. XThis software is offered without warranty. The Regents of the University of
  850. XMichigan disclaim all warranties, express or implied, including but not
  851. Xlimited to the implied warranties of merchantability and fitness for any
  852. Xparticular purpose. In no event shall the Regents of the University of
  853. XMichigan be liable for loss or damage of any kind, including but not limited
  854. Xto incidental, indirect, consequential, or special damages. 
  855. X.SH SEE ALSO
  856. Xgetmach(1), hostinfo(1), netuseadmin(1), netused(8),
  857. X.I Monitoring Hosts with NETUSE
  858. END_OF_FILE
  859.   if test 1935 -ne `wc -c <'netuse/daemons/netuse.8'`; then
  860.     echo shar: \"'netuse/daemons/netuse.8'\" unpacked with wrong size!
  861.   fi
  862.   # end of 'netuse/daemons/netuse.8'
  863. fi
  864. if test -f 'netuse/daemons/netused.8' -a "${1}" != "-c" ; then 
  865.   echo shar: Will not clobber existing file \"'netuse/daemons/netused.8'\"
  866. else
  867.   echo shar: Extracting \"'netuse/daemons/netused.8'\" \(2757 characters\)
  868.   sed "s/^X//" >'netuse/daemons/netused.8' <<'END_OF_FILE'
  869. X.TH netused 8 "November 29, 1992" "" "CAEN - The University of Michigan"
  870. X.UC 4
  871. X.SH NAME
  872. Xnetused \- NETUSE Host Monitor monitoring/reporting daemon
  873. X.SH SYNOPSIS
  874. X.B netused [
  875. X.BR options
  876. X.B ]
  877. X.SH DESCRIPTION
  878. X.I netused
  879. Xis a daemon which runs on a host and periodically determines the status of the
  880. Xhost's usage and reports it to the NETUSE master daemon 
  881. X.I netuse(8).
  882. X.PP
  883. XWithout any options, 
  884. X.I netused
  885. Xruns as a perpetual daemon, exactly as described above.  The default periods
  886. Xfor checking the hosts's status and for reporting to the master daemon are
  887. Xdefined at compile time, but may be set using the -wakeup and -report options. 
  888. X.SH OPTIONS
  889. XThe following options may be used with the
  890. X.I netused
  891. Xcommand to specify variations on the daemon's usual operation.
  892. X.TP 16
  893. X-once
  894. XReport once to the server, then quit.  This is useful for adding the current
  895. Xhost to the NETUSE database.
  896. X.TP 16
  897. X-force
  898. XForce 
  899. X.I netused
  900. Xto run, even if it determines that it shouldn't because of other causes.  (See
  901. Xthe installation guide 
  902. X.I Monitoring Hosts with NETUSE).
  903. X.TP 16
  904. X-wakeup
  905. XSet the period (in seconds) between status checks.
  906. X.TP 16
  907. X-report
  908. XSet the time period (in seconds) between reports to the master daemon.  This
  909. Xshould be a multiple of the wakeup period.
  910. X.TP 16
  911. X-inetd
  912. XObsolete option informing 
  913. X.I netused 
  914. Xthat it is being run from the 
  915. X.I inetd(8) 
  916. Xdaemon.
  917. X.SH BUGS
  918. X.I netused
  919. Xcurrently doesn't seem to like RS/6000 load average computation under AIX 3.2.
  920. XThe load averages are computed correctly for AIX 3.1 versions.
  921. X.SH COPYRIGHT
  922. XCopyright (C) 1992 by the Regents of the University of Michigan.
  923. X.PP
  924. XUser agrees to reproduce said copyright notice on all copies of the software
  925. Xmade by the recipient.  
  926. X.PP
  927. XAll Rights Reserved. Permission is hereby granted for the recipient to make
  928. Xcopies and use this software for its own internal purposes only. Recipient of
  929. Xthis software may re-distribute this software outside of their own
  930. Xinstitution. Permission to market this software commercially, to include this
  931. Xproduct as part of a commercial product, or to make a derivative work for
  932. Xcommercial purposes, is explicitly prohibited.  All other uses are also
  933. Xprohibited unless authorized in writing by the Regents of the University of
  934. XMichigan.
  935. X.PP
  936. XThis software is offered without warranty. The Regents of the University of
  937. XMichigan disclaim all warranties, express or implied, including but not
  938. Xlimited to the implied warranties of merchantability and fitness for any
  939. Xparticular purpose. In no event shall the Regents of the University of
  940. XMichigan be liable for loss or damage of any kind, including but not limited
  941. Xto incidental, indirect, consequential, or special damages. 
  942. X.SH SEE ALSO
  943. Xgetmach(1), hostinfo(1), netuse(8), 
  944. X.I Monitoring Hosts with NETUSE
  945. END_OF_FILE
  946.   if test 2757 -ne `wc -c <'netuse/daemons/netused.8'`; then
  947.     echo shar: \"'netuse/daemons/netused.8'\" unpacked with wrong size!
  948.   fi
  949.   # end of 'netuse/daemons/netused.8'
  950. fi
  951. if test -f 'netuse/lib/config.h' -a "${1}" != "-c" ; then 
  952.   echo shar: Will not clobber existing file \"'netuse/lib/config.h'\"
  953. else
  954.   echo shar: Extracting \"'netuse/lib/config.h'\" \(4265 characters\)
  955.   sed "s/^X//" >'netuse/lib/config.h' <<'END_OF_FILE'
  956. X/******************************************************************************
  957. X CONFIG.H - NETUSE customization header file
  958. X
  959. X This header file defines site-dependent customizations.
  960. X
  961. X Lee Liming, Computer Aided Engineering Network
  962. X The University of Michigan
  963. X
  964. X Copyright (C) 1992 by the Regents of the University of Michigan.
  965. X
  966. X User agrees to reproduce said copyright notice on all copies of the software
  967. X made by the recipient.  
  968. X
  969. X All Rights Reserved. Permission is hereby granted for the recipient to make
  970. X copies and use this software for its own internal purposes only. Recipient of
  971. X this software may re-distribute this software outside of their own
  972. X institution. Permission to market this software commercially, to include this
  973. X product as part of a commercial product, or to make a derivative work for
  974. X commercial purposes, is explicitly prohibited.  All other uses are also
  975. X prohibited unless authorized in writing by the Regents of the University of
  976. X Michigan.
  977. X
  978. X This software is offered without warranty. The Regents of the University of
  979. X Michigan disclaim all warranties, express or implied, including but not
  980. X limited to the implied warranties of merchantability and fitness for any
  981. X particular purpose. In no event shall the Regents of the University of
  982. X Michigan be liable for loss or damage of any kind, including but not limited
  983. X to incidental, indirect, consequential, or special damages. 
  984. X******************************************************************************/
  985. X
  986. X#ifndef _CONFIG_INCLUDED_
  987. X#define _CONFIG_INCLUDED_
  988. X
  989. X
  990. X/*  The NETUSE_SERVER macro should expand to the IP hostname of the machine  */
  991. X/*  on which the netuse daemon for your site runs.                           */
  992. X
  993. X#define NETUSE_SERVER   "myhost.some.where"
  994. X
  995. X/*  At CAEN, we have some unusual ways of determining whether or not the     */
  996. X/*  netused daemon should run on a given host.  The existence of USE_CAENLAB */
  997. X/*  says that netused will use those CAEN-specific heuristics.  Other sites  */
  998. X/*  should not use this.                                                     */
  999. X
  1000. X/* #define USE_CAENLAB */
  1001. X
  1002. X/*  The name of the file in which the netused daemon stores problem reports. */
  1003. X
  1004. X#define NETUSEDLOG      "/tmp/netused.log"
  1005. X
  1006. X/*  The name of the file in which the netuse daemon stores log messages.     */
  1007. X
  1008. X#define NETUSELOG       "/usr/adm/netuse-req.log"
  1009. X
  1010. X/*  The name of the file in which the netuse daemon stores host information. */
  1011. X
  1012. X#define NETUSEHOSTFILE  "/usr/adm/netuse.hosts"
  1013. X
  1014. X/* The types of log messages that routinely get logged by the netuse daemon. */
  1015. X/* E.g., to log all NETUSE requests, uncomment LOGREQUESTS.  To log all      */
  1016. X/* wakeup calls sent by netuse, uncomment LOGWAKEUPS.  These log files can   */
  1017. X/* get pretty big, though...                                                 */
  1018. X
  1019. X/* #define LOGWAKEUPS */
  1020. X#define LOGREQUESTS
  1021. X
  1022. X/* The default port numbers and service names used by netuse and netused.    */
  1023. X
  1024. X#define NETUSED_PORT    1689           /* Used if /etc/services doesn't know */
  1025. X#define NETUSE_PORT     1690           /* Used if /etc/services doesn't know */
  1026. X#define NETUSED_SERVICE "netused"    /* Inet service name for client daemons */
  1027. X#define NETUSE_SERVICE  "netuse"      /* Inet service name for NETUSE server */
  1028. X
  1029. X/* The number of hosts to be listed by netuse if -all is not specified.      */
  1030. X
  1031. X#define MAXLSTLEN         10
  1032. X
  1033. X/* Number of minutes without a report from a node before netuse considers    */
  1034. X/* the node "down".                                                          */
  1035. X
  1036. X#define DOWNTIME          15
  1037. X
  1038. X/* Number of minutes without a report from a node before netuse deletes the  */
  1039. X/* node from its database.                                                   */ 
  1040. X
  1041. X#define GIVEUPTIME     10080
  1042. X
  1043. X/* Default period (in seconds) between reports by netused.                   */
  1044. X/* Note that AIX load averaging requires that netused wake up around once    */
  1045. X/* every 15 seconds, but it still reports once every 8 wakeups (2 min.)      */
  1046. X
  1047. X#ifdef _AIX
  1048. X#define DEFAULT_PERIOD    15           /* Period between wakeups for netused */
  1049. X#define REPORT_CYCLE       8       /* Number of wakeups in each report cycle */
  1050. X#else
  1051. X#define DEFAULT_PERIOD   120
  1052. X#define REPORT_CYCLE       1
  1053. X#endif
  1054. X
  1055. X
  1056. X#endif /* _CONFIG_INCLUDED_ */
  1057. END_OF_FILE
  1058.   if test 4265 -ne `wc -c <'netuse/lib/config.h'`; then
  1059.     echo shar: \"'netuse/lib/config.h'\" unpacked with wrong size!
  1060.   fi
  1061.   # end of 'netuse/lib/config.h'
  1062. fi
  1063. if test -f 'netuse/lib/netadmin.c' -a "${1}" != "-c" ; then 
  1064.   echo shar: Will not clobber existing file \"'netuse/lib/netadmin.c'\"
  1065. else
  1066.   echo shar: Extracting \"'netuse/lib/netadmin.c'\" \(6078 characters\)
  1067.   sed "s/^X//" >'netuse/lib/netadmin.c' <<'END_OF_FILE'
  1068. X/******************************************************************************
  1069. X NETADMIN.C - NETUSE Administration Client Library Routines
  1070. X
  1071. X The functions included here are for making administrative server requests.
  1072. X They are fairly powerful, and could be used to deny service to other clients,
  1073. X and are included in the library out of pure naivity (and because it wouldn't
  1074. X make any difference if they weren't).
  1075. X
  1076. X Lee Liming, The Computer Aided Engineering Network
  1077. X The University of Michigan
  1078. X
  1079. X Copyright (C) 1990, 1991, 1992 by the Regents of the University of Michigan.
  1080. X
  1081. X User agrees to reproduce said copyright notice on all copies of the software
  1082. X made by the recipient.  
  1083. X
  1084. X All Rights Reserved. Permission is hereby granted for the recipient to make
  1085. X copies and use this software for its own internal purposes only. Recipient of
  1086. X this software may re-distribute this software outside of their own
  1087. X institution. Permission to market this software commercially, to include this
  1088. X product as part of a commercial product, or to make a derivative work for
  1089. X commercial purposes, is explicitly prohibited.  All other uses are also
  1090. X prohibited unless authorized in writing by the Regents of the University of
  1091. X Michigan.
  1092. X
  1093. X This software is offered without warranty. The Regents of the University of
  1094. X Michigan disclaim all warranties, express or implied, including but not
  1095. X limited to the implied warranties of merchantability and fitness for any
  1096. X particular purpose. In no event shall the Regents of the University of
  1097. X Michigan be liable for loss or damage of any kind, including but not limited
  1098. X to incidental, indirect, consequential, or special damages. 
  1099. X******************************************************************************/
  1100. X
  1101. X#include <stdio.h>
  1102. X#include <sys/types.h>
  1103. X#ifdef IBMTCPIP
  1104. X#include <types.h>
  1105. X#endif
  1106. X#include <sys/socket.h>
  1107. X#include <netinet/in.h>
  1108. X#include <netdb.h>
  1109. X#include "network.h"
  1110. X#include "protocol.h"
  1111. X#include "netuse.h"
  1112. X
  1113. X
  1114. X/******************************************************************************
  1115. X int netuseAddName(char *name,u_short type,u_short model)
  1116. X
  1117. X This function adds a host given by name (internet hostname or an ASCII
  1118. X equivalent of the IP address) to the server's host list.  If no IP address
  1119. X for the host can be found, RV_NOMATCH is returned.  All other errors are
  1120. X passed directly back to the caller.  The host's vendor type should be given
  1121. X by the type parameter.
  1122. X******************************************************************************/
  1123. X
  1124. X#ifdef __STDC__
  1125. Xint netuseAddName(char *name,u_char type,u_char model)
  1126. X#else
  1127. Xint netuseAddName(name,type,model)
  1128. Xchar *name;
  1129. Xu_char type,model;
  1130. X#endif
  1131. X{
  1132. X     USEREC msg;
  1133. X     int rv;
  1134. X
  1135. X     msg.opcode=OP_ADDHOST;
  1136. X     msg.machine=type;
  1137. X     msg.model=model;
  1138. X     if (!(msg.ipaddr=netGetAddress(name))) return(RV_NOMATCH);
  1139. X#if (defined(MSDOS) || defined(OS2))
  1140. X     msg.uid=0;
  1141. X#else
  1142. X     msg.uid=getuid();
  1143. X#endif
  1144. X     if ((rv=packetSend(&msg))!=RV_nOK) return(rv);
  1145. X     if ((rv=packetReceive(&msg))!=RV_nOK) return(rv);
  1146. X     else return(msg.retcode);
  1147. X}
  1148. X
  1149. X
  1150. X/******************************************************************************
  1151. X int netuseAddIP(u_long ip_addr,u_short type)
  1152. X
  1153. X This function adds a host to the NETUSE server's host list using the numeric
  1154. X IP address instead of the hostname.  Again, the machine type should be given
  1155. X in the type parameter.  All errors are passed back to the caller.
  1156. X******************************************************************************/
  1157. X
  1158. X#ifdef __STDC__
  1159. Xint netuseAddIP(u_long ip_addr,u_short type)
  1160. X#else
  1161. Xint netuseAddIP(ip_addr,type)
  1162. Xu_long ip_addr;
  1163. Xu_short type;
  1164. X#endif
  1165. X{
  1166. X     USEREC msg;
  1167. X     int rv;
  1168. X
  1169. X     msg.opcode=OP_ADDHOST;
  1170. X     msg.machine=type;
  1171. X     msg.ipaddr=ip_addr;
  1172. X#if (defined(MSDOS) || defined(OS2))
  1173. X     msg.uid=0;
  1174. X#else
  1175. X     msg.uid=getuid();
  1176. X#endif
  1177. X     if ((rv=packetSend(&msg))!=RV_nOK) return(rv);
  1178. X     if ((rv=packetReceive(&msg))!=RV_nOK) return(rv);
  1179. X     else return(msg.retcode);
  1180. X}
  1181. X
  1182. X
  1183. X/******************************************************************************
  1184. X int netuseDelName(char *name)
  1185. X
  1186. X The host represented by the hostname given in name (or the IP address in text
  1187. X format in name) is removed from the NETUSE server's host list.
  1188. X******************************************************************************/
  1189. X
  1190. X#ifdef __STDC__
  1191. Xint netuseDelName(char *name)
  1192. X#else
  1193. Xint netuseDelName(name)
  1194. Xchar *name;
  1195. X#endif
  1196. X{
  1197. X     USEREC msg;
  1198. X     int rv;
  1199. X
  1200. X     msg.opcode=OP_DELHOST;
  1201. X     if (!(msg.ipaddr=netGetAddress(name))) return(RV_NOMATCH);
  1202. X#if (defined(MSDOS) || defined(OS2))
  1203. X     msg.uid=0;
  1204. X#else
  1205. X     msg.uid=getuid();
  1206. X#endif
  1207. X     if ((rv=packetSend(&msg))!=RV_nOK) return(rv);
  1208. X     if ((rv=packetReceive(&msg))!=RV_nOK) return(rv);
  1209. X     else return(msg.retcode);
  1210. X}
  1211. X
  1212. X
  1213. X/******************************************************************************
  1214. X int netuseSaveState(void)
  1215. X
  1216. X This function requests that the server save it's hostlist into the static
  1217. X host file.
  1218. X******************************************************************************/
  1219. X
  1220. X#ifdef __STDC__
  1221. Xint netuseSaveState(void)
  1222. X#else
  1223. Xint netuseSaveState()
  1224. X#endif
  1225. X{
  1226. X     USEREC msg;
  1227. X     int rv;
  1228. X
  1229. X     msg.opcode=OP_SAVESTATE;
  1230. X#if (defined(MSDOS) || defined(OS2))
  1231. X     msg.uid=0;
  1232. X#else
  1233. X     msg.uid=getuid();
  1234. X#endif
  1235. X     if ((rv=packetSend(&msg))!=RV_nOK) return(rv);
  1236. X     if ((rv=packetReceive(&msg))!=RV_nOK) return(rv);
  1237. X     else return(msg.retcode);
  1238. X}
  1239. X
  1240. X
  1241. X/******************************************************************************
  1242. X int netuseLoadHosts(void)
  1243. X
  1244. X This function requests the server to throw away all of the hosts in it's
  1245. X hostlist and load a new hostlist from the static host file.
  1246. X******************************************************************************/
  1247. X
  1248. X#ifdef __STDC__
  1249. Xint netuseLoadHosts(void)
  1250. X#else
  1251. Xint netuseLoadHosts()
  1252. X#endif
  1253. X{
  1254. X     USEREC msg;
  1255. X     int rv;
  1256. X
  1257. X     msg.opcode=OP_LOADHOSTS;
  1258. X#if (defined(MSDOS) || defined(OS2))
  1259. X     msg.uid=0;
  1260. X#else
  1261. X     msg.uid=getuid();
  1262. X#endif
  1263. X     if ((rv=packetSend(&msg))!=RV_nOK) return(rv);
  1264. X     if ((rv=packetReceive(&msg))!=RV_nOK) return(rv);
  1265. X     else return(msg.retcode);
  1266. X}
  1267. END_OF_FILE
  1268.   if test 6078 -ne `wc -c <'netuse/lib/netadmin.c'`; then
  1269.     echo shar: \"'netuse/lib/netadmin.c'\" unpacked with wrong size!
  1270.   fi
  1271.   # end of 'netuse/lib/netadmin.c'
  1272. fi
  1273. if test -f 'netuse/lib/variable.h' -a "${1}" != "-c" ; then 
  1274.   echo shar: Will not clobber existing file \"'netuse/lib/variable.h'\"
  1275. else
  1276.   echo shar: Extracting \"'netuse/lib/variable.h'\" \(5615 characters\)
  1277.   sed "s/^X//" >'netuse/lib/variable.h' <<'END_OF_FILE'
  1278. X/*****************************************************************************
  1279. X VARIABLE.H - The variable management module's header file
  1280. X
  1281. X Defines: typedef   VARENTRY
  1282. X          typedef   VARTABLE
  1283. X          int       varHashName(u_long name);
  1284. X          VARENTRY *varAllocate(void);
  1285. X          void      varFreeTable(void);
  1286. X          void      varSet(VARENTRY *var);
  1287. X          VARENTRY *varFindMatch(VARENTRY *template);
  1288. X          VARENTRY *varFind(u_long ip_addr);
  1289. X          int       varSaveState(void);
  1290. X          int       varLoadHosts(void);
  1291. X          void      varInit();
  1292. X          void      varDumpTable(char *fname);
  1293. X          void      treeInsert(TREE **tptr,VARENTRY *vptr);
  1294. X          void      treeBuild(u_char machtype);
  1295. X          void      treePrintHost(FILE *outf,TREE *tptr);
  1296. X          void      treeDump(FILE *outf,TREE *tptr,u_char opcode,int *i);
  1297. X          void      treePrintList(FILE *outf,u_char machtype,u_char opcode);
  1298. X
  1299. X Copyright (C) 1990, 1991, 1992 by the Regents of the University of Michigan.
  1300. X
  1301. X User agrees to reproduce said copyright notice on all copies of the software
  1302. X made by the recipient.  
  1303. X
  1304. X All Rights Reserved. Permission is hereby granted for the recipient to make
  1305. X copies and use this software for its own internal purposes only. Recipient of
  1306. X this software may re-distribute this software outside of their own
  1307. X institution. Permission to market this software commercially, to include this
  1308. X product as part of a commercial product, or to make a derivative work for
  1309. X commercial purposes, is explicitly prohibited.  All other uses are also
  1310. X prohibited unless authorized in writing by the Regents of the University of
  1311. X Michigan.
  1312. X
  1313. X This software is offered without warranty. The Regents of the University of
  1314. X Michigan disclaim all warranties, express or implied, including but not
  1315. X limited to the implied warranties of merchantability and fitness for any
  1316. X particular purpose. In no event shall the Regents of the University of
  1317. X Michigan be liable for loss or damage of any kind, including but not limited
  1318. X to incidental, indirect, consequential, or special damages. 
  1319. X******************************************************************************/
  1320. X
  1321. X#ifndef _VARIABLE_INCLUDED_
  1322. X
  1323. X#define _VARIABLE_INCLUDED_
  1324. X
  1325. X
  1326. X#define VAR_ENTRIES   113            /* Number of entries in the hash table */
  1327. X
  1328. X
  1329. Xtypedef struct _user {
  1330. X             char         *name;
  1331. X             char         *tty;
  1332. X             struct _user *next;
  1333. X        } USER,*USERLIST;
  1334. X
  1335. Xtypedef struct _varentry {
  1336. X             char             *name;                 /* The variable's name */
  1337. X             u_long            ip_addr;                       /* IP address */
  1338. X             char             *class;                        /* Entry class */
  1339. X             float             l1,l2,l3;             /* Load average values */
  1340. X             u_long            tmp;                      /* kb free on /tmp */
  1341. X             u_char            machine;                  /* Type of machine */
  1342. X             u_char            model;               /* Machine's model type */
  1343. X             long              lastused;        /* Time of entry's last use */
  1344. X             long              logtime;              /* Time of last update */
  1345. X             int               users;      /* How many users are logged in? */
  1346. X             int               console;        /* Is anyone on the console? */
  1347. X             USERLIST          userFirst;               /* Who is logged in */
  1348. X             struct _varentry *next;    /* Link to next entry in hash chain */
  1349. X        } VARENTRY;
  1350. Xtypedef VARENTRY *VARTABLE[VAR_ENTRIES];         /* The variable hash table */
  1351. X
  1352. Xtypedef struct _nodetree {
  1353. X             VARENTRY         *data;
  1354. X             struct _nodetree *left,*right;
  1355. X        } TREE;
  1356. X
  1357. X
  1358. X#ifdef __STDC__
  1359. X
  1360. Xint       varHashName(u_long name);
  1361. XUSER     *userAllocate(void);
  1362. Xvoid      userFree(USER *uptr);
  1363. Xvoid      userFreeList(USER *uptr);
  1364. XVARENTRY *varAllocate(void);
  1365. Xvoid      varFree(VARENTRY *vptr);
  1366. Xvoid      varFreeTable(void);
  1367. Xvoid      varSet(VARENTRY *var);
  1368. XVARENTRY *varFindMatch(VARENTRY *template);
  1369. XVARENTRY *varFind(u_long ip_addr);
  1370. Xvoid      varDumpTable(char *fname);
  1371. Xvoid      varDumpTableWithModels(char *fname);
  1372. Xint       varSaveState(void);
  1373. Xint       varLoadHosts(void);
  1374. Xvoid      varInit(void);
  1375. Xvoid      treeInsert(TREE **tptr,VARENTRY *vptr);
  1376. Xvoid      treeBuild(u_char machtype,u_char modeltype);
  1377. Xvoid      treePrintHost(FILE *outf,TREE *tptr);
  1378. Xvoid      treeDump(FILE *outf,TREE *tptr,u_char opcode,int *i);
  1379. Xvoid      treePrintList(FILE *outf,u_char machtype,u_char modeltype,
  1380. X                        u_char opcode);
  1381. Xvoid      treePrintHostWithModels(FILE *outf,TREE *tptr);
  1382. Xvoid      treeDumpWithModels(FILE *outf,TREE *tptr,u_char opcode,int *i);
  1383. Xvoid      treePrintListWithModels(FILE *outf,u_char machtype,u_char modeltype,
  1384. X                                  u_char opcode);
  1385. X
  1386. X#else  /* ifndef __STDC__ */
  1387. X
  1388. Xint       varHashName();
  1389. XUSER     *userAllocate();
  1390. Xvoid      userFree();
  1391. Xvoid      userFreeList();
  1392. XVARENTRY *varAllocate();
  1393. Xvoid      varFree();
  1394. Xvoid      varFreeTable();
  1395. Xvoid      varSet();
  1396. XVARENTRY *varFindMatch();
  1397. XVARENTRY *varGetValue();
  1398. Xint       varSaveState();
  1399. Xint       varLoadHosts();
  1400. Xvoid      varInit();
  1401. Xvoid      varDumpTable();
  1402. Xvoid      varDumpTableWithModels();
  1403. Xint       varSaveState();
  1404. Xint       varLoadHosts();
  1405. Xvoid      varInit();
  1406. Xvoid      treeInsert();
  1407. Xvoid      treeBuild();
  1408. Xvoid      treePrintHost();
  1409. Xvoid      treeDump();
  1410. Xvoid      treePrintList();
  1411. Xvoid      treePrintHostWithModels();
  1412. Xvoid      treeDumpWithModels();
  1413. Xvoid      treePrintListWithModels();
  1414. X
  1415. X#endif
  1416. X
  1417. X#endif  /* _VARIABLE_INCLUDED_ */
  1418. END_OF_FILE
  1419.   if test 5615 -ne `wc -c <'netuse/lib/variable.h'`; then
  1420.     echo shar: \"'netuse/lib/variable.h'\" unpacked with wrong size!
  1421.   fi
  1422.   # end of 'netuse/lib/variable.h'
  1423. fi
  1424. echo shar: End of archive 5 \(of 6\).
  1425. cp /dev/null ark5isdone
  1426. MISSING=""
  1427. for I in 1 2 3 4 5 6 ; do
  1428.     if test ! -f ark${I}isdone ; then
  1429.     MISSING="${MISSING} ${I}"
  1430.     fi
  1431. done
  1432. if test "${MISSING}" = "" ; then
  1433.     echo You have unpacked all 6 archives.
  1434.     rm -f ark[1-9]isdone
  1435. else
  1436.     echo You still must unpack the following archives:
  1437.     echo "        " ${MISSING}
  1438. fi
  1439. exit 0
  1440. exit 0 # Just in case...
  1441.