Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
uptime .signature for email - brag on Gentoo's Stability!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
ChevyBowtie
n00b
n00b


Joined: 10 Nov 2002
Posts: 36
Location: Arlington, Texas

PostPosted: Tue Jan 07, 2003 1:54 am    Post subject: uptime .signature for email - brag on Gentoo's Stability! Reply with quote

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! :wink:

:idea: (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
View user's profile Send private message
Carlos
Guru
Guru


Joined: 07 Aug 2002
Posts: 458
Location: Providence, RI

PostPosted: Tue Jan 07, 2003 2:52 am    Post subject: Reply with quote

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! :P 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
View user's profile Send private message
heijs
Apprentice
Apprentice


Joined: 12 Jun 2002
Posts: 174
Location: Groningen

PostPosted: Tue Jan 07, 2003 11:23 am    Post subject: Reply with quote

This looks very cool Carlos, but unfortunately I can't make it work.
My signature is just the contents of the python script :cry:
Code:

heijs@rugth38 heijs $ cat .muttrc
set signature="~/.signature.py"

Can you tell me what I did wrong?
Back to top
View user's profile Send private message
idl
Retired Dev
Retired Dev


Joined: 24 Dec 2002
Posts: 1728
Location: Nottingham, UK

PostPosted: Tue Jan 07, 2003 12:35 pm    Post subject: Reply with quote

heijs, chmod +x ~/.signature.py ?
Back to top
View user's profile Send private message
Carlos
Guru
Guru


Joined: 07 Aug 2002
Posts: 458
Location: Providence, RI

PostPosted: Tue Jan 07, 2003 1:26 pm    Post subject: Reply with quote

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 :cry:
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. :oops:

EDIT: Just checked, you also need to chmod +x the script file.
_________________
Man must shape his tools lest they shape him.
Back to top
View user's profile Send private message
heijs
Apprentice
Apprentice


Joined: 12 Jun 2002
Posts: 174
Location: Groningen

PostPosted: Tue Jan 07, 2003 4:45 pm    Post subject: Reply with quote

Of course I did a chmod +x!

OK, thanks for the pipe :)
Back to top
View user's profile Send private message
hhaamu
Apprentice
Apprentice


Joined: 23 Aug 2002
Posts: 253
Location: Finland

PostPosted: Wed Jan 08, 2003 2:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
Oo.et.oO
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 291
Location: burlington

PostPosted: Sat Jan 18, 2003 4:28 pm    Post subject: evolution can use the output of a script for a signature Reply with quote

Tools -> settings
Composer Preferences
Signatures tab
hit the "Add Script" button

:D 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
View user's profile Send private message
dattaway
n00b
n00b


Joined: 25 Jan 2003
Posts: 29
Location: Kansas Citeeeee, Missoureeeee

PostPosted: Sat Jan 25, 2003 2:25 am    Post subject: uptime Reply with quote

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
View user's profile Send private message
Carlos
Guru
Guru


Joined: 07 Aug 2002
Posts: 458
Location: Providence, RI

PostPosted: Sun Jan 26, 2003 4:55 am    Post subject: Re: uptime Reply with quote

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
View user's profile Send private message
DooBeDooBeDo
Apprentice
Apprentice


Joined: 21 Aug 2002
Posts: 220
Location: UK

PostPosted: Sun Jan 26, 2003 1:11 pm    Post subject: Reply with quote

There's a full explanation here: http://kerneltrap.org/node.php?id=464
Back to top
View user's profile Send private message
kollega
Tux's lil' helper
Tux's lil' helper


Joined: 19 Jul 2002
Posts: 127
Location: Munich, Germany

PostPosted: Sat May 24, 2003 11:21 am    Post subject: Reply with quote

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
View user's profile Send private message
maw
Apprentice
Apprentice


Joined: 25 Aug 2002
Posts: 175
Location: Nottingham, UK

PostPosted: Sun May 25, 2003 11:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
Konsti
l33t
l33t


Joined: 10 Dec 2002
Posts: 691

PostPosted: Sat May 31, 2003 12:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
GenKiller
n00b
n00b


Joined: 04 Mar 2003
Posts: 66
Location: United States of America

PostPosted: Sat May 31, 2003 12:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
Konsti
l33t
l33t


Joined: 10 Dec 2002
Posts: 691

PostPosted: Sat May 31, 2003 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
GenKiller
n00b
n00b


Joined: 04 Mar 2003
Posts: 66
Location: United States of America

PostPosted: Sat May 31, 2003 12:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Konsti
l33t
l33t


Joined: 10 Dec 2002
Posts: 691

PostPosted: Sat May 31, 2003 1:30 pm    Post subject: Reply with quote

Ah! *slapshimself*
To stupid 8O
Back to top
View user's profile Send private message
Sp4rky
n00b
n00b


Joined: 10 Jul 2002
Posts: 15

PostPosted: Wed Jun 04, 2003 8:16 am    Post subject: updated signature using a named pipe Reply with quote

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:

Code:

mkfifo .signature


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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum