View previous topic :: View next topic |
Author |
Message |
ChevyBowtie n00b
Joined: 10 Nov 2002 Posts: 36 Location: Arlington, Texas
|
Posted: Tue Jan 07, 2003 1:54 am Post subject: uptime .signature for email - brag on Gentoo's Stability! |
|
|
I wanted to be able to tell which of my Gentoo boxes my email was sent from by including the name of the machine in each email signature. Then I got carried away...why not the uptime (I've seen that before...I like it), hey let's add the kernel version also!
I pieced this script together after a little 'googling'. I am sure this is not the only way to do this, but it works well for me.
This actually requires 2 files:
.signature-org - this is the part of your signature that does not change
sig-uptime - this is the dynamic creating part
Here is my .signature-org file:
Code: |
Paul Sturm
Arlington, Texas
My Project: http://www.speeddot.com
***********************************
"I can't give you a brain,
so I'll give you a diploma" - The Great Oz
***********************************
|
Here is my sig-uptime file:
Code: |
##
# sig-uptime
#
# Adds 'uptime' data to my .signature file
# Launched by cron every hour
#
cat .signature-org > .signature
echo "Uptime: `uptime`" >> .signature
# hostname
echo " `uname -n`" >> .signature
# Add Kernel Version
echo " Gentoo Linux - Kernel `uname -r`" >> .signature
|
This will create a signature that updates every hour with the uptime of your machine, machine name, and kernel version - like this:
Code: |
Paul Sturm
Arlington, Texas
My Project: http://www.speeddot.com
***********************************
"I can't give you a brain,
so I'll give you a diploma" - The Great Oz
***********************************
Uptime: 04:24:35 up 3:36, 2 users, load average: 1.22, 1.44, 0.95
dell500.paulsturm.net
Gentoo Linux - Kernel 2.4.20
|
Don't forget to tell your mail program to use the ~/.signature file for new messages. In Mozilla mail & news: click 'Edit','Mail & Newsgroup Account Settings' and check off the 'Attach this signature' then browse to your .signature file.
A link in your cron.hourly directory that points to sig-uptime (I keep my in my home folder) will update your sig every hour and keep your stats current:
Code: | ln -s /root/sig-uptime /etc/cron.hourly/rootsig.cron |
Don't forget to set the permissions on your sig-uptime file: Code: | chmod 755 ./sig-uptime |
BTW: Don't tell me about running root! It's my box, I'll break it at will - After all, I've earned it!
(edit) May 4th, 2003 - modified script to use uname command to get hostname, kernel version etc...
Last edited by ChevyBowtie on Sun May 04, 2003 2:35 am; edited 1 time in total |
|
Back to top |
|
|
Carlos Guru
Joined: 07 Aug 2002 Posts: 458 Location: Providence, RI
|
Posted: Tue Jan 07, 2003 2:52 am Post subject: |
|
|
I use mutt, which can handle using a shell script's output instead of a text file, so I don't have to run cron. Here's my ~/.signature.py (which needs to be chmodded +x):
Code: | #!/usr/bin/env python
import os
print """Yuji Carlos Kosugi <yuji@np.catv.ne.jp>,<carlos@pubbawup.net>
GPG KeyID 93EFE7A7
Fingerprint: 08A7 075B C954 E798 5D00 DFB6 F503 F82D 93EF E7A7
flogiston.dyndns.org""", os.popen("uptime|gawk '{ print $2, $3, $4, $5 }' -").read()[0:-2] |
Which looks like:
Code: |
Yuji Carlos Kosugi <yuji@np.catv.ne.jp>,<carlos@pubbawup.net>
GPG KeyID 93EFE7A7
Fingerprint: 08A7 075B C954 E798 5D00 DFB6 F503 F82D 93EF E7A7
flogiston.dyndns.org up 2 days, 22:25 |
My name, e-mail addresses, GPG junk, and uptime, all within the 70x4 limit! All I need to have mutt use that is Code: | set signature="~/.signature.py|" | in my .muttrc.
I used Python just because I'm used to the way it processes strings; I wanted to get the right string from uptime so it would result in a sentence that would make sense.
EDIT: The traditional limit is 70x4 characters, not 80x4, as I had originally typed.
EDIT again: 'Doh, my muttrc example was wrong.
last EDIT, I promise: the script needs to be chmodded +x. _________________ Man must shape his tools lest they shape him.
Last edited by Carlos on Tue Jan 07, 2003 1:40 pm; edited 3 times in total |
|
Back to top |
|
|
heijs Apprentice
Joined: 12 Jun 2002 Posts: 174 Location: Groningen
|
Posted: Tue Jan 07, 2003 11:23 am Post subject: |
|
|
This looks very cool Carlos, but unfortunately I can't make it work.
My signature is just the contents of the python script
Code: |
heijs@rugth38 heijs $ cat .muttrc
set signature="~/.signature.py"
|
Can you tell me what I did wrong? |
|
Back to top |
|
|
idl Retired Dev
Joined: 24 Dec 2002 Posts: 1728 Location: Nottingham, UK
|
Posted: Tue Jan 07, 2003 12:35 pm Post subject: |
|
|
heijs, chmod +x ~/.signature.py ? |
|
Back to top |
|
|
Carlos Guru
Joined: 07 Aug 2002 Posts: 458 Location: Providence, RI
|
Posted: Tue Jan 07, 2003 1:26 pm Post subject: |
|
|
heijs wrote: | This looks very cool Carlos, but unfortunately I can't make it work.
My signature is just the contents of the python script
Code: |
heijs@rugth38 heijs $ cat .muttrc
set signature="~/.signature.py"
|
Can you tell me what I did wrong? | A thousand apologies! You need to put a pipe after the signature filename, e.g. Code: |
set signature="~/.signature.py|"
| I totally forgot about it when posting the thing, sorry.
EDIT: Just checked, you also need to chmod +x the script file. _________________ Man must shape his tools lest they shape him. |
|
Back to top |
|
|
heijs Apprentice
Joined: 12 Jun 2002 Posts: 174 Location: Groningen
|
Posted: Tue Jan 07, 2003 4:45 pm Post subject: |
|
|
Of course I did a chmod +x!
OK, thanks for the pipe |
|
Back to top |
|
|
hhaamu Apprentice
Joined: 23 Aug 2002 Posts: 253 Location: Finland
|
Posted: Wed Jan 08, 2003 2:05 pm Post subject: |
|
|
You might also want to try this perl script:
Code: |
#!/usr/bin/perl
chdir;
$FIFO = '.signature';
while (1) {
unless (-p $FIFO) {
unlink $FIFO;
system('mknod', $FIFO, 'p') && die "can't mknod $FIFO: $!";
}
open (FIFO, "> $FIFO") or die "can't write $FIFO: $!";
print FIFO "Put your static things here\n", `uname; uptime; fortune -s`;
close FIFO;
sleep 1;
} |
Put that in your .bashrc, and it creates a device node in ~/.signature every time you log in.
You might want to reduce the commands there are, or else the sig might be a bit too long |
|
Back to top |
|
|
Oo.et.oO Apprentice
Joined: 23 Apr 2002 Posts: 291 Location: burlington
|
Posted: Sat Jan 18, 2003 4:28 pm Post subject: evolution can use the output of a script for a signature |
|
|
Tools -> settings
Composer Preferences
Signatures tab
hit the "Add Script" button
here is mine:
Code: |
#!/bin/sh
fortune -s
|
one could add all sorts of echo statments in there, uname, uptime, whatever.
i don't like to give away info on my system to who knows...
anyway, this way is cool cuz it gets run when you write the mail. that way i get a random fortune each time. the -s option is to keep them short.
i used to have cron change my .sig every 5 mins. but this is superior and works in evolution 1.2.1
[/code] |
|
Back to top |
|
|
dattaway n00b
Joined: 25 Jan 2003 Posts: 29 Location: Kansas Citeeeee, Missoureeeee
|
Posted: Sat Jan 25, 2003 2:25 am Post subject: uptime |
|
|
I'd love to put my uptime in my signature, but I have this problem...
20:18:27 up 24 days, 4:13, 6 users, load average: 0.13, 0.30, 0.28
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root vc/2 - 8Dec02 24days 0.18s 0.08s -bash
root vc/6 - 8Oct02 1:26m 1.28s 1.16s -bash
root pts/0 satellite 17Jan03 1.00s 3.80s 0.17s w
dattaway pts/2 satellite 17Jan03 17:41 1:48 1:48 pine
Note the uptime and a few of the login dates. Uptime seems to roll over about every 45 days. A few calculations with /proc/uptime tells me the system was started in September, which is correct. I can't seem to find out why "w" fails to calculate the correct uptime. Any idea where I can poke around and look for clues? |
|
Back to top |
|
|
Carlos Guru
Joined: 07 Aug 2002 Posts: 458 Location: Providence, RI
|
Posted: Sun Jan 26, 2003 4:55 am Post subject: Re: uptime |
|
|
dattaway wrote: | Note the uptime and a few of the login dates. Uptime seems to roll over about every 45 days. A few calculations with /proc/uptime tells me the system was started in September, which is correct. I can't seem to find out why "w" fails to calculate the correct uptime. Any idea where I can poke around and look for clues? | It's the jiffies in the kernel; if you set them to 1000, then the upper limit on uptime becomes something like 45 days, which appears to be what you're experiencing. I haven't looked into the problem, though, because my desktop (which I also use as a server) is never up that long, what with my finding new kernels to play with and stuff. I do recall hearing that there isn't any really good solution, but this may have changed. _________________ Man must shape his tools lest they shape him. |
|
Back to top |
|
|
DooBeDooBeDo Apprentice
Joined: 21 Aug 2002 Posts: 220 Location: UK
|
|
Back to top |
|
|
kollega Tux's lil' helper
Joined: 19 Jul 2002 Posts: 127 Location: Munich, Germany
|
Posted: Sat May 24, 2003 11:21 am Post subject: |
|
|
hey guys
i found another easy way for that signature-stuff. you only need linux_logo.
here is my sig-uptime
Code: |
##
# sig-uptime
#
# Adds 'uptime' data to my .signature file
# Launched by cron every hour
#
cat .signature-org > .signature
echo "`linux_logo -a -g -u -y`" >> .signature
|
i just tried a littlebit with linux_logo and so i found that out!
bye |
|
Back to top |
|
|
maw Apprentice
Joined: 25 Aug 2002 Posts: 175 Location: Nottingham, UK
|
Posted: Sun May 25, 2003 11:14 pm Post subject: |
|
|
It's a shame that Evolution-mail segfaults on me when I hit 'add new signature'... (1.2.4) these are all very nice ideas.
Edit: got around that (didn't read instructions right) but it ignores newlines _________________ Your Gentoo woll sle me sodenly!
I may the beaute of it not sustene
(to misquote Chaucer) |
|
Back to top |
|
|
Konsti l33t
Joined: 10 Dec 2002 Posts: 691
|
Posted: Sat May 31, 2003 12:02 pm Post subject: |
|
|
Well, I am a python dumb, but I like the signature.py.
But how is it possible to put the output of uname -r into it?
I fiddled around a bit, but I did not get it...
Konsti |
|
Back to top |
|
|
GenKiller n00b
Joined: 04 Mar 2003 Posts: 66 Location: United States of America
|
Posted: Sat May 31, 2003 12:11 pm Post subject: |
|
|
Konsti wrote: | Well, I am a python dumb, but I like the signature.py.
But how is it possible to put the output of uname -r into it?
I fiddled around a bit, but I did not get it... |
Code: | import os
os.system("/bin/uname -r") |
Enjoy _________________ http://www.digital-drip.com |
|
Back to top |
|
|
Konsti l33t
Joined: 10 Dec 2002 Posts: 691
|
Posted: Sat May 31, 2003 12:32 pm Post subject: |
|
|
Well, I wanted it well formatted near the uptime output of theexisting script additionally.
When I add the line, there is an unwanted 0:
Code: |
2.5.70-mm3
0
Konstantin Kletschke <konsti@ludenkalle.de>, <konsti@ku-gbr.de>
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E A080 1E69 3FDA EF62 FCEF
keulator.homelinux.org up 1:00, 18 users
|
|
|
Back to top |
|
|
GenKiller n00b
Joined: 04 Mar 2003 Posts: 66 Location: United States of America
|
Posted: Sat May 31, 2003 12:52 pm Post subject: |
|
|
Konsti wrote: | Well, I wanted it well formatted near the uptime output of theexisting script additionally.
When I add the line, there is an unwanted 0: |
Code: | #!/usr/bin/env python
import os
os.system("/bin/uname -r")
print """Konstantin Kletschke <konsti@ludenkalle.de>, <konsti@ku-gbr.de>
GPG KeyID EF62FCEF
Fingerprint: 13C9 B16B 9844 EC15 CC2E A080 1E69 3FDA EF62 FCEF
keulator.homelinux.org""", os.popen("uptime|gawk '{ print $2, $3, $4, $5 }' -").read()[0:-2] |
I'm assuming you are using the print statement for the uname -r line. Don't, as this will give you that zero. The above code works fine for me here _________________ http://www.digital-drip.com |
|
Back to top |
|
|
Konsti l33t
Joined: 10 Dec 2002 Posts: 691
|
Posted: Sat May 31, 2003 1:30 pm Post subject: |
|
|
Ah! *slapshimself*
To stupid |
|
Back to top |
|
|
Sp4rky n00b
Joined: 10 Jul 2002 Posts: 15
|
Posted: Wed Jun 04, 2003 8:16 am Post subject: updated signature using a named pipe |
|
|
Few years back I ran into this script (so I didn't make it, credits where credits due, sort off a disclaimer as well
Make a named pipe:
Run the following script in the background
Code: |
while [ 1 ]; do
( echo "Gentoo User http://www.gentoo.org"
echo "Using kernel $(uname -r)"
echo "$(uptime)"
) > .signature;
sleep 1;
done
|
Now the .signature is updated only when it is needed, no Cron lines |
|
Back to top |
|
|
|