Skip to contentSkip to conversation

/proc/updike -- uptime histogram

PATCH In review Sean Neakums 1 participant 2 messages Dec 25, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 /proc/updike -- uptime histogram

If you don't find the notion of represting uptime with an ASCII phallus amusing on any level at all, then this patch is not for you. Please, just skip to the next message.

Of course this is better done in userspace, but /proc/updike is funnier.

alias updike='/usr/bin/uptime | perl -ne "/(\d+) d/;print 8,q(=)x\$1,\"D\n\""'

I believe the above was found in someone's signature on Slashdot (figures, mutter the people who really shouldn't have bothered to read this far).

fs/Kconfig +8 -0
diff -urN --exclude '*~' S0/fs/Kconfig hack-S0/fs/Kconfig
@@ -760,6 +760,14 @@
 	  This option will enlarge your kernel by about 67 KB. Several
 	  programs depend on this, so everyone should say Y here.
 
+config PROC_UPDIKE
+	bool "visual uptime reporting support"
+	depends on PROC_FS
+	help
+	  A dynamic commentary on the nature of uptime contests, drawing on
+	  principles of the visual display of quantitative information
+	  espoused by Ed Tufte.
+
 config PROC_KCORE
 	bool
 	default y if !ARM
fs/proc/proc_misc.c +25 -0
diff -urN --exclude '*~' S0/fs/proc/proc_misc.c hack-S0/fs/proc/proc_misc.c
@@ -153,6 +153,28 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_PROC_UPDIKE
+static int updike_read_proc(char *page, char**start, off_t off,
+				int count, int *eof, void *data)
+{
+	struct timespec uptime;
+	int days;
+	int i = 0;
+
+	do_posix_clock_monotonic_gettime(&uptime);
+	days = uptime.tv_sec / (3600 * 24);
+	page[0] = '8';
+	while ((i < days) && (i <= PAGE_SIZE - 4)) {
+		page[++i] = '=';
+	}
+	page[i + 1] = 'D';
+	page[i + 2] = '\n';
+	page[i + 3] = '\0';
+
+	return proc_calc_metrics(page, start, off, count, eof, i + 3);
+}
+#endif
+
 static int meminfo_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
@@ -647,6 +669,9 @@
 	} *p, simple_ones[] = {
 		{"loadavg",     loadavg_read_proc},
 		{"uptime",	uptime_read_proc},
+#ifdef CONFIG_PROC_UPDIKE
+		{"updike",	updike_read_proc},
+#endif
 		{"meminfo",	meminfo_read_proc},
 		{"version",	version_read_proc},
 #ifdef CONFIG_PROC_HARDWARE
#1 lore raw
Quoted 2 lines · Sean Neakums

If you don't find the notion of represting uptime with an ASCII phallus amusing on any level at all, then this patch is not for you.

Also applies to this message.

Below is a /proc/updike patch for legacy Linux 2.4:

(Boy, 2.5's kconfig sure is nice.)

Documentation/Configure.help +6 -0
diff -urN --exclude '*~' linux-2.4.23/Documentation/Configure.help edited/Documentation/Configure.help
@@ -16703,6 +16703,12 @@
   This option will enlarge your kernel by about 67 KB. Several
   programs depend on this, so everyone should say Y here.
 
+visual uptime reporting support
+CONFIG_PROC_UPDIKE
+  A dynamic commentary on the nature of uptime contests, drawing on               
+  principles of the visual display of quantitative information                    
+  espoused by Ed Tufte.                                                           
+
 Support for PReP Residual Data
 CONFIG_PREP_RESIDUAL
   Some PReP systems have residual data passed to the kernel by the
fs/Config.in +1 -0
diff -urN --exclude '*~' linux-2.4.23/fs/Config.in edited/fs/Config.in
@@ -71,6 +71,7 @@
 tristate 'OS/2 HPFS file system support' CONFIG_HPFS_FS
 
 bool '/proc file system support' CONFIG_PROC_FS
+dep_bool 'visual uptime reporting support' CONFIG_PROC_UPDIKE $CONFIG_PROC_FS
 
 # For some reason devfs corrupts memory badly on x86-64. Disable it 
 # for now.
fs/proc/proc_misc.c +25 -0
diff -urN --exclude '*~' linux-2.4.23/fs/proc/proc_misc.c edited/fs/proc/proc_misc.c
@@ -152,6 +152,28 @@
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
+#ifdef CONFIG_PROC_UPDIKE
+static int updike_read_proc(char *page, char**start, off_t off,
+				int count, int *eof, void *data)
+{
+	struct timespec uptime;
+	int days;
+	int i = 0;
+
+	do_posix_clock_monotonic_gettime(&uptime);
+	days = uptime.tv_sec / (3600 * 24);
+	page[0] = '8';
+	while ((i < days) && (i <= PAGE_SIZE - 4)) {
+		page[++i] = '=';
+	}
+	page[i + 1] = 'D';
+	page[i + 2] = '\n';
+	page[i + 3] = '\0';
+
+	return proc_calc_metrics(page, start, off, count, eof, i + 3);
+}
+#endif
+
 static int meminfo_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
@@ -596,6 +618,9 @@
 	} *p, simple_ones[] = {
 		{"loadavg",     loadavg_read_proc},
 		{"uptime",	uptime_read_proc},
+#ifdef CONFIG_PROC_UPDIKE
+		{"updike",	updike_read_proc},
+#endif
 		{"meminfo",	meminfo_read_proc},
 		{"version",	version_read_proc},
 #ifdef CONFIG_PROC_HARDWARE