pkgsrc/sysutils/tload/patches/patch-aa
hubertf febf6efb1c Update to 2.0.6nb1:
Add hostname, time and date to the top line
Patch send back to the maintainers @redhat.com
2001-05-22 02:59:25 +00:00

70 lines
1.5 KiB
Text

$NetBSD: patch-aa,v 1.2 2001/05/22 02:59:25 hubertf Exp $
--- tload.c.orig Tue Sep 2 18:02:19 1997
+++ tload.c
@@ -34,6 +34,25 @@
extern int optind;
extern char *optarg;
+#ifdef __NetBSD__
+void
+display_version(void)
+{
+ printf("procps 2.0.6, NetBSD port\n");
+}
+
+
+int
+loadavg(double *l0, double *l1, double *l2)
+{
+ double l[3];
+ getloadavg(l, 3);
+ *l0 = l[0];
+ *l1 = l[1];
+ *l2 = l[2];
+}
+#endif
+
void alrm(int n)
{
signal(SIGALRM, alrm);
@@ -74,6 +93,11 @@
double av[3];
static double max_scale, scale_fact;
char *scale_arg = NULL;
+ static char hostname[256];
+ static char date[256];
+ time_t datet;
+ static char headl[256], headr[256];
+ int lenl, lenr;
while ((opt = getopt(argc, argv, "s:d:V")) != -1)
switch (opt) {
@@ -94,6 +118,11 @@
setsize(0);
+ if (gethostname(hostname, sizeof(hostname)) < 0) {
+ perror(argv[optind]);
+ exit(1);
+ }
+
if (scale_arg)
max_scale = atof(scale_arg);
else
@@ -144,8 +173,13 @@
for(row = nrows-2; row >= 0; --row)
*(screen + row * ncols + col) = ' ';
}
- i = sprintf(screen, " %.2f, %.2f, %.2f",
- av[0], av[1], av[2]);
+ datet = time(NULL);
+ strftime(date, sizeof(date), "%c", localtime(&datet));
+ lenr = sprintf(headr, "%s %s", hostname, date);
+ lenl = sprintf(headl, " %.2f, %.2f, %.2f",
+ av[0], av[1], av[2]);
+ i = sprintf(screen, "%s %*.s %s", headl,
+ ncols - lenl - lenr - 2, "", headr);
if (i>0)
screen[i] = ' ';