[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature requests: trunc and maybe cmddiff
From: |
Rafal Maszkowski |
Subject: |
feature requests: trunc and maybe cmddiff |
Date: |
Tue, 10 Mar 2009 13:19:50 +0100 |
User-agent: |
Mutt/1.5.9i |
I wonder if a wrapper around the system trunc(3) call could be included
into coreutils. It could be a separate command like:
trunc my_file 234M
(I have made such for myself) or maybe an extension to the touch
comand syntax. The command can shorten an existing file or create a
sparse new file.
If you do not like it in coreutils I CC to the moreutils author.
There is another command (script) I created some 10 years ago and I used
to use it frequently. The main purpose of it is estimating the ending
time of big and slow file copying. It can base the estimate on a number
contained in some row and field of e.g. du or df output. The output
of the traced command is saved every time cmddiff is called. The
output is kept in an RCS file in $HOME. The consecutive runs of cmddiff
can check different fields of the same traced command. This one is
probably more suitable for moreutils.
address@hidden:/tmp,0# cmddiff -h
cmddiff - command output tracer
example:
cmddiff -f 2 -e 137000 -p -r 1.6 'wc -l addr.resolved'
-f 1 compare 1st field in 1st line; general form: line.field
-e 137000 calculate when the field is going to reach this value
-p do not append path to the characteristic command string
-r 1.6 compare with revision 1.6, default: 0 == 1.1, -1 means the
previous one
'wc ...' the command
Somewhat artificial example:
Just df, not estimating anything yet:
address@hidden:/tmp,0# cmddiff df
first version:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 489992 360999 103693 78% /
/dev/mapper/sys-tmp 2031440 68908 1857676 4% /tmp
/dev/mapper/sys-var 8125880 5016364 2690100 66% /var
/dev/mapper/sys-usr 5078656 1357396 3459116 29% /usr
/dev/mapper/sys-home 11173104 8909572 1686908 85% /home
/dev/mapper/sys-www 75164744 60372928 10912776 85% /www
tmpfs 1037824 0 1037824 0% /dev/shm
tmpfs 16384 0 16384 0% /var/spool/MIMEDefang
sunsite:/local/majordomo/lists
6196236 4916832 1217440 81% /sunsite/majordomo/lists
sunsite:/recesja 123378104 42310704 81067400 35% /www2
The RCS file:
address@hidden:/tmp,0# lt ~/.cmddiff/
total 2
-r--r--r-- 1 root root 920 Mar 10 13:11 f1eddd11eb190a1271fde939bfc86883,v
df again, still no options used:
address@hidden:/tmp,0# cmddiff df
df
--- f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:11:45 1.1
+++ f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:11:52
@@ -1,7 +1,7 @@
Filesystem 1K-blocks Used Available Use% Mounted on
-/dev/sda1 489992 360999 103693 78% /
+/dev/sda1 489992 361000 103692 78% /
/dev/mapper/sys-tmp 2031440 68908 1857676 4% /tmp
-/dev/mapper/sys-var 8125880 5016364 2690100 66% /var
+/dev/mapper/sys-var 8125880 5016372 2690092 66% /var
/dev/mapper/sys-usr 5078656 1357396 3459116 29% /usr
/dev/mapper/sys-home 11173104 8909572 1686908 85% /home
/dev/mapper/sys-www 75164744 60372928 10912776 85% /www
Now we would like to see when there will be 0 KB available in /var if it
is used at current speed (beginning from the first cmddif use):
address@hidden:/tmp,0# cmddiff -f 4.4 -e 0 df
df
--- f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:11:45 1.1
+++ f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:12:50
@@ -1,7 +1,7 @@
Filesystem 1K-blocks Used Available Use% Mounted on
-/dev/sda1 489992 360999 103693 78% /
+/dev/sda1 489992 361001 103691 78% /
/dev/mapper/sys-tmp 2031440 68908 1857676 4% /tmp
-/dev/mapper/sys-var 8125880 5016364 2690100 66% /var
+/dev/mapper/sys-var 8125880 5016412 2690052 66% /var
/dev/mapper/sys-usr 5078656 1357396 3459116 29% /usr
/dev/mapper/sys-home 11173104 8909572 1686908 85% /home
/dev/mapper/sys-www 75164744 60372928 10912776 85% /www
change: -.73846153846153846153 per second, ends: Tue Apr 21 18:05:49 MEST 2009
After few minutes the estimate is more precise:
address@hidden:/tmp,0# cmddiff -f 4.4 -e 0 df
df
--- f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:11:45 1.1
+++ f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:17:10
@@ -1,12 +1,12 @@
Filesystem 1K-blocks Used Available Use% Mounted on
-/dev/sda1 489992 360999 103693 78% /
+/dev/sda1 489992 361001 103691 78% /
/dev/mapper/sys-tmp 2031440 68908 1857676 4% /tmp
-/dev/mapper/sys-var 8125880 5016364 2690100 66% /var
+/dev/mapper/sys-var 8125880 5016948 2689516 66% /var
/dev/mapper/sys-usr 5078656 1357396 3459116 29% /usr
-/dev/mapper/sys-home 11173104 8909572 1686908 85% /home
-/dev/mapper/sys-www 75164744 60372928 10912776 85% /www
+/dev/mapper/sys-home 11173104 8909556 1686924 85% /home
+/dev/mapper/sys-www 75164744 60376004 10909700 85% /www
tmpfs 1037824 0 1037824 0% /dev/shm
tmpfs 16384 0 16384 0% /var/spool/MIMEDefang
sunsite:/local/majordomo/lists
- 6196236 4916832 1217440 81%
/sunsite/majordomo/lists
+ 6196236 4916828 1217444 81%
/sunsite/majordomo/lists
sunsite:/recesja 123378104 42310704 81067400 35% /www2
change: -1.79692307692307692307 per second, ends: Fri Mar 27 21:02:44 MET 2009
We can use the 2nd run data instead of 1st run, note different time and
version 1.2:
address@hidden:/tmp,0# cmddiff -f 4.4 -e 0 -r 1.2 df
df
--- f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:11:52 1.2
+++ f1eddd11eb190a1271fde939bfc86883 2009/03/10 12:17:51
@@ -1,12 +1,12 @@
Filesystem 1K-blocks Used Available Use% Mounted on
-/dev/sda1 489992 361000 103692 78% /
+/dev/sda1 489992 361001 103691 78% /
/dev/mapper/sys-tmp 2031440 68908 1857676 4% /tmp
-/dev/mapper/sys-var 8125880 5016372 2690092 66% /var
+/dev/mapper/sys-var 8125880 5016976 2689488 66% /var
/dev/mapper/sys-usr 5078656 1357396 3459116 29% /usr
-/dev/mapper/sys-home 11173104 8909572 1686908 85% /home
-/dev/mapper/sys-www 75164744 60372928 10912776 85% /www
+/dev/mapper/sys-home 11173104 8909556 1686924 85% /home
+/dev/mapper/sys-www 75164744 60377028 10908676 85% /www
tmpfs 1037824 0 1037824 0% /dev/shm
tmpfs 16384 0 16384 0% /var/spool/MIMEDefang
sunsite:/local/majordomo/lists
- 6196236 4916832 1217440 81%
/sunsite/majordomo/lists
+ 6196236 4916828 1217444 81%
/sunsite/majordomo/lists
sunsite:/recesja 123378104 42310704 81067400 35% /www2
change: -1.68245125348189415041 per second, ends: Sun Mar 29 01:20:24 MET 2009
R.
--
Jeżeli upadnie cywilizacja zachodnia, to będzie szansa na odbudowę cywilizacji
chrześcijańskiej. (dr Stanisław Krajski, Radio Maryja, 10 X 2001)
- feature requests: trunc and maybe cmddiff,
Rafal Maszkowski <=