Sigx

We are the future in the past.
It is currently Mon Jun 05, 2023 3:07 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 68 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Ok all you Linux and Mac fans. here you go.
PostPosted: Wed Mar 03, 2004 9:35 pm 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
I asked my friend to code this perl script for all you people who dont have windows machine.

This perl script which runs on Linux and Mac OSX supports the following:

CPUNAME
MHZ
BOGOMIPS
OS
Ram Used
Diskspace
Screen Res


i know there are a lot of perl scripts for linux which report on statistcs
about your computer, so you can find one and modify it to fit your needs.

i have not tested it, so i would like you guys to test it.

my friend did show me that it works.

get it:
from http://sigx.yuriy.net/dist/sigx.pl (original)

from http://sigx.yuriy.net/dist/sigxv1.pl (my minor modification)
i added better way to comment out lines and uptime.

you need curl installed on your machine.
and libwww-perl



all you need to do is change the

Code:
my $username = "a";
my $password = "a";



i know if you run linux you probably know what a cronjob is, because that is what you have to do to keep it updated periodically.

i would suggest doing 1.5 - 2 minutes.

mac users good luck, i dont know mac, but i do that MacOS X does have cronjob which is same as linux.

also if you want some stuff to be removed or moved in different place, just mess with the code.

i know there are a few perl experts here, so if you feel like modifying this or making improvements, submit to us your fixes and make it better for others.


we dont offer support for this because its a contribution, but ask anyway. im sure someone will know something.


Last edited by admin on Thu Mar 04, 2004 12:28 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 11:04 pm 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
after installing on my Debian linux machine, it seems like i needed libwww-perl and then sigx.pl worked fine.


Last edited by admin on Fri Mar 05, 2004 5:50 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 9:38 am 
Offline

Joined: Fri Mar 05, 2004 9:32 am
Posts: 2
ok i modifed it a lil bit, im on SuSE and got the perl script to work beloq is my sigx.pl code (it may be a lil messy implemented but i cut up a netstat.pl from x-chat and made it show upload and download b/w..

Code:
#!/usr/bin/perl

# Credits     : This script was created by and is currently maintained
#               by Victor Igumnov [lamer0@lamer0.com].
#
# Legal Info  : Copyright (C) 2003, Victor Igumnov [lamer0@lamer0.com]
#
#               This program is free software. You may redistribute it
#               and/or modify it under the terms of the GNU General
#               Public License as published by the Free Software
#               Foundation; either version 2 of the License, or
#               (at your option) any later version.
#
#               This program is distributed in the hope that it will be
#               useful, but WITHOUT ANY WARRANTY; without even the
#               implied warranty of MERCHANTABILITY or FITNESS FOR A
#               PARTICULAR PURPOSE.  See the GNU General Public License
#               for more details.
#
$|=1;
## --added code -- ##

#Config

$LIMIT            = 3000;         #// When should it change from Bytes to K ?
$MULTIPLIER   = 1024;         #// Divide by 1000 or 1024? Eternally mysterious

#$CAT = "ssh 127.0.0.1 cat /proc/net/dev";      #// Command to acces /proc/net/dev - I ssh in to get it!
#DEV = "eth0";                        #// Device to be read

$DEV = "eth0";                        #// Workstations has fewer netcards :)
$CAT = "cat /proc/net/dev";               #// A local version

$DOWNSTREAM   = 52000;               #// Max downstream in bytes;
$UPSTREAM      = 52000;               #// Max upstream in bytes;


####################################################################################
####################################################################################

#DO leave this part alone :)

$FirstTime      = time();
($FirstNetIn,  $FirstNetOut) = getNetTraffic();

sub getNetTraffic
{
   $str = `$CAT | grep $DEV`;
   ($in, $out) = ($str =~ m/^\s\s$DEV:(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+) .*/);
   return ($in, $out);
}

sub display_net
{
   ($netIn, $netOut) = getNetTraffic();
#   $LastTime = time();
#   $Time   = $LastTime - $FirstTime;
#   $in      = int( ($netIn - $FirstNetIn) /$Time);
#   $out   = int( ($netOut - $FirstNetOut) /$Time);
   $in      = int( $netIn );
   $out   = int( $netOut );
   $strOut = ($out > $LIMIT)? sprintf("%.2fMB", (($out/$MULTIPLIER)/$MULTIPLIER)) : "".$out." Bytes";
   $strIn = ($in > $LIMIT)? sprintf("%.2fMb", (($in/$MULTIPLIER)/$MULTIPLIER)) : "".$in." Bytes";

   $FINALNET = "Uploaded: " . $strOut . " Downloaded: " . $strIn;

#   $FirstTime = $LastTime;
#   $FirstNetIn = $netIn;
#   $FirstNetOut = $netOut;

   return $FINALNET;
}

$imitiator = display_net;

##--end added code --##
use CGI;
use URI::URL;
use LWP::UserAgent;

#Set These
my $CPU='temp3';
my $MOBO='temp2';
my $FAN='fan2';

$MYUPTIME = `/usr/bin/uptime`;

$CPUNAME=`cat /proc/cpuinfo | grep '^model name' | head -1 | sed -e 's/^.*: //'`;
($CPUNAME)=$CPUNAME=~/^\s*(.*?)\s*$/;  # trim head/tail at same time

$CPUSPEED=`cat /proc/cpuinfo | grep 'cpu MHz' | head -1 | sed -e 's/^.*: //'`;
$BOGOMIPS=`cat /proc/cpuinfo  | grep 'bogomips' |  head -1 | sed -e 's/^.*: //'`;
$UNAME = `uname -ms`;

#--PERCENTAGE OF MEMORY FREE--#
$MEMPERCENT = `free | grep Mem | awk '{print (( \$3 -(\$6 + \$7) )/\$2)*100}'`;
chop ($MEMPERCENT);
$MEMPERCENT = sprintf('%.2f', $MEMPERCENT);


#--MEMORY FREE--#
$MEMFREE = `free | grep Mem | awk '{printf (\"%.0fg\", ( \$3 -(\$6 + \$7) )/1000)}'`;
chop ($MEMFREE);

#--TOTAL MEMORY--#
$MEMTOTAL = `free | grep Mem | awk '{printf (\"%dMb\", \$2/1000 )}'`;
chop ($MEMTOTAL);

#--SCREEN RESOLUTION--#
$RES = `xdpyinfo | grep dimensions | awk '{print \$2}'`;
chop ($RES);

#--DISKSPACE--#
$HDD = `df | awk '{ sum+=\$2/1024^2 }; END { printf (\"%dGb\", sum )}'`;
chop ($HDD);

#--DISKSPACE FREE--#
$HDDFREE = `df | awk '{ sum+=\$4/1024^2 }; END { printf (\"%dGb\", sum )}'`;
chop ($HDDFREE);

#--SCREEN RESOLUTION--#
$RES = `xdpyinfo | grep dimensions | awk '{print \$2}'`;
chop ($RES);

chop($UNAME);
chop($CPUNAME);
chop($CPUSPEED);
chop($BOGOMIPS);
$RAMLEFT=$MEMTOTAL-$MEMFREE;

$query = new CGI;
$query->import_names('webform');

my $username = "nihaopaul";
my $password = "mypassword";

$DATA_2_SEND = "Uptime: $MYUPTIME *<*";
$DATA_2_SEND .= "CPU: $CPUNAME | MHZ: $CPUSPEED *<*";
$DATA_2_SEND .= "IRC: irc.street-creed.com | NET: $FINALNET *<*";
$DATA_2_SEND .= "OS: SuSE 9.0 $UNAME *<*";
$DATA_2_SEND .= "$MEMPERCENT% Ram Used | Total RAM = $MEMTOTAL | Diskspace: $HDD Free: $HDDFREE *<*";
# $DATA_2_SEND .= "Screen Res: $RES";





my %form = ();

%form =('username' => $username,
   'password' => $password,
   'data'      => $DATA_2_SEND,
   'Submit'   => '');

my $ua = new LWP::UserAgent;
my $curl = url("http:"); 
my $req = new HTTP::Request 'POST','http://sigx.yuriy.net/update.php';
$req->content_type('application/x-www-form-urlencoded');
$req->content($curl->equery);
$curl->query_form(%form);
$req->content($curl->equery);
my $response= $ua->request($req)->as_string;



Image


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 10:37 am 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
so whats new in your code? btw the last *<* is what giving you that space at the bottom.


i like the idea of cutting up existing perl scripts which get alot of data like current song, and alot more and implementing it here. its just a copy/paste away :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 4:56 pm 
Offline

Joined: Fri Mar 05, 2004 9:32 am
Posts: 2
thanks i removed the extra *<* donno if you saw but i put in net usage into the script, and as i mod'd it i thought i'd return the mod. hacking up x-chat script wasn't an easy one it showed cps but that was a little boring so i showed total b/w in and out

oh for linux nubs who don't know how to crontab what i do is add a line to a file like cronjob.conf.. following line is for sigx..
Code:
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * /dir/to/sigx.pl >/dev/null 2>&1

will run every 2 minutes

then exit and type: crontab cronjob.conf

it'll replace any other cronjobs you have, thats why i just keep one file for cronjobs at user level.

paul

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 06, 2004 10:24 am 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
if you want current playing song on iTunes on your mac using this script, you need to get Mac::Glue..

here is an article: http://www.perl.com/lpt/a/2004/01/23/macglue.html

and here is a piece of code which you can cut and paste and modify to get it to work with sigx.pl.

Code:
#!/usr/bin/perl

use Mac::Apps::Launch;
use Mac::Glue ':all';
use Socket;
 
my $itunes = new Mac::Glue 'iTunes';
 
if (IsRunning($itunes->{ID})) {
    my $status = $itunes->get( $itunes->prop('player state') );
    if ($status eq 'playing') {
        my $track = $itunes->prop('current track');
 
        my %info;
        for my $prop (qw(name artist album)) {
            $info{$prop} = $itunes->get( $itunes->prop($prop => $track) );
        }
        $nowPlaying = "Now Playing: $info{name} - $info{artist}";
    }
}


then add the $nowPlaying to one of the lines where it sends the data over.


i am not a perl expert and i dont have a mac, i dont know if this will wok, but give it a try and tell others.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 06, 2004 3:37 pm 
Offline

Joined: Sat Mar 06, 2004 3:36 pm
Posts: 1
what about xmms?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 06, 2004 3:47 pm 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
google for it. im sure its there.

alot of scrips which do alot of things for xmms
http://www.xmms.org/plugins.php?category=misc


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 4:57 pm 
Offline

Joined: Mon Mar 08, 2004 4:50 pm
Posts: 3
Or for the cron job you can just do:

*/2 * * * * /dir/to/sigx.pl >/dev/null 2>&1


HTH :D


ocbeta

_________________
Linux? Whats that.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 5:00 pm 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
ya that is a crazy cron job the guy wrote up there


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 8:37 pm 
Offline

Joined: Mon Mar 08, 2004 4:50 pm
Posts: 3
Thats ok though, I am sure I am kinda crazy too :D


ocbeta

_________________
Linux? Whats that.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 10:23 pm 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
but i think you should tell people how to actually get to the place where to place that line to.. please.


Top
 Profile  
 
 Post subject: Almost have XMMS working
PostPosted: Mon Mar 15, 2004 9:15 am 
Offline

Joined: Mon Mar 15, 2004 9:09 am
Posts: 8
Location: USA
OK, I almost have XMMS working with SigX, but I've run into a problem. I'm a C++ programmer, and I know precisely Jack Squat about Perl. I've been playing around with an XMMS plugin called "xmms-infopipe" that will spit out a text file to /tmp/xmms-info that contains current XMMS info, as shown below:

Code:
XMMS protocol version: 2467
InfoPipe Plugin version: 1.3
Status: Playing
Tunes in playlist: 112
Currently playing: 12
uSecPosition: 153752
Position: 2:33
uSecTime: 299676
Time: 4:59
Current bitrate: 192000
Samping Frequency: 44100
Channels: 2
Title: Bloodhound Gang - Hell Yeah
File: /home/honkeykong/files/Bloodhound Gang - Hell Yeah.mp3


And since I don't know a whole lot about Perl, I have no idea how to parse this file and send the relevant info. If anybody could post up some info about parsing text files, I could update the script and post a new one, along with all the info you need to run it.

Peace -
Honkey Kong

EDIT -- I got the XMMS script working with SigX. Check the next page for the code. ;)

_________________
Image


Last edited by honkeykong on Mon Mar 15, 2004 12:00 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 9:45 am 
Offline
Site Admin

Joined: Thu Jul 03, 2003 1:59 pm
Posts: 454
Location: Los Angeles
i probably said this before, but there are scripts for IRC that get all that data like XMMS and other fun stuff. so just find that and play around with that code


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 10:05 am 
Offline

Joined: Mon Mar 15, 2004 9:09 am
Posts: 8
Location: USA
admin wrote:
i probably said this before, but there are scripts for IRC that get all that data like XMMS and other fun stuff. so just find that and play around with that code


Xmms-Infopipe is one of the plugins that IRC users display their info with. I'm simply trying to get it to work with SigX. As soon as I figure out how to read this text file in perl, I'm gonna post all the stuff to make it work. I'm looking through my Perl book right now to try and figure it out. ;)

The plugin comes with Perl scripts to output to IRC and websites, but the web script requires Apache and some other stuff like Ogginfo. I don't have Apache or ogginfo installed on my system, and I doubt some of the other Linux users do either, so I'm simply trying to have it read this info from the text file so that the user doesn't have to install a whole bunch of other stuff that they aren't going to use other than for their sig. Hopefully this clears up what I'm trying to do. 8)

EDIT: I believe the file that needs to be edited to add this as a cronjob is this one:

/etc/crontab

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Fatal: Not able to open ./cache/data_global.php