Sigx

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

All times are UTC - 8 hours




Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: Fri Apr 16, 2004 5:31 pm 
Offline

Joined: Fri Apr 16, 2004 5:22 pm
Posts: 7
Location: UK
I wrote a bit of code within the original perl script to include uptime on a Sig.

You can get it from http://markphelan.net/downloads/sigx2.txt.

Not the most amazing bit of code in the world, but it works. Should give you something like this:

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 4:07 am 
Offline

Joined: Sun Apr 18, 2004 3:49 am
Posts: 3
How to get it set up and run it? is there an instruction? I'm using Slackware.

Thank you. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 8:05 am 
Offline

Joined: Fri Apr 16, 2004 5:22 pm
Posts: 7
Location: UK
Earlier in this thread, someone posted how to add a cronjob:

Quote:
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.


I personally used Webmin to set it up, and just pointed it to the sigx.pl file. I also had to chmod the file to make it executable. You can test it before adding it as a cronjob, by just typing ./sigx.pl in the folder containing the file. I've since tweaked it a little bit since I submitted it to the forum, but the latest version is here:

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;

use CGI;
use URI::URL;
use LWP::UserAgent;

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

$CPUNAME=`cat /proc/cpuinfo | grep '^model name' | head -1 | sed -e 's/^.*: //'`;
$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 -sr`;

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

#--UPTIME--#
$UPTIMEDAYS = `uptime | awk '{printf (\$3)}'`;
$UPTIMEHOURS = `uptime | awk '{printf(\$5)}' | awk -F ':' '{printf(\$1)}'`;
$UPTIMEMINS = `uptime | awk '{printf(\$5)}' | awk -F ':' '{printf(\$2)}' | head -c 2`;

$UPTIME = "$UPTIMEDAYS Days $UPTIMEHOURS Hours $UPTIMEMINS Mins";

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

#--TOTAL MEMORY--#
$MEMTOTAL = `free | grep Mem | awk '{printf (\"%d\", \$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 = "a";
my $password = "a";
$DATA_2_SEND="OS: Debian $UNAME *<*System Uptime: $UPTIME *<*$MEMPERCENT% Ram Used | Total RAM = $MEMTOTAL MB | Available RAM = $RAMLEFT MB*<*CPU: $CPUNAME @ $CPUSPEED MHz, $BOGOMIPS BOGOMIPS*<*";
printf $MEMTOTAL;
print $DATA_2_SEND;





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;


Hope this helps!

(Dont forget to install the libraries mentioned at the beginning of the thread)

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 4:09 pm 
Offline

Joined: Wed Mar 17, 2004 8:21 am
Posts: 13
i=a total n00b with linux
i got rh9 runnin on a PC..i dont use it for anything...its just on..store files.. etc

i dont understand how im suppose to get it to work with linux
we were all n00bs at one time.. so help a newbert out
detailed instructions :oops:

all i really want is uptime to be displayed


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2004 11:48 pm 
Offline

Joined: Fri Apr 16, 2004 5:22 pm
Posts: 7
Location: UK
OK, unfortunately installations vary between distributions of Linux. I run Debian, mainly because apt and aptitude make it easy to install libraries and applications.

If you're a 'newbie' to Linux, I'd suggest installing Webmin - it's a good way to start out learning commands, and makes the cronjob a bit easier to set up.

First off, you'll need to copy the code in my last post in to a file, and save it on your hard drive. I think I put mine in /etc/cron once I'd got it working.

You'll need to chmod it to the correct setting to make it executable. For this I used 'chmod 755 sigx.pl' - whether that's the best setting to use or not, I dont know - but it worked.

You'll need to check you have the 2 libraries installed that yuriy mentioned at the start of this thread. RedHat is fairly feature-rich from installation, so you might find you have them already. Like I said, I use Debian - which starts off with the bare minimum installed, and so I had to use aptitude to get the packages. Have a Google round for the two package names if you get in trouble - I'm sure they're out there somewhere for download.

The cronjob I mentioned at the beginning is equivalent to a Scheduled Task in Windows. I used Webmin (http://www.webmin.com/) to get this sorted out, as it gives me a graphical interface for configuring the schedule. All you have to do is select the times you want the task to run (I selected every other minute, all hours, all days...) to give me a 2 minute update of my sigx.

Sorry I can't give more step-by-step instructions, but different distro's do things differently. Hope this is of some help.

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 9:35 am 
Offline

Joined: Wed Mar 17, 2004 8:21 am
Posts: 13
blah.. forget it
everytime i go to install an rpm(webmin) it asks for the root pass.. then thats the last i see of it

ill just try to get http://phpsysinfo.sourceforge.net/ working, like thatll ever happen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 9:58 am 
Offline

Joined: Wed Mar 17, 2004 8:21 am
Posts: 13
maybe i should install XP.. ive see people go 43 days or so with XP
i mean the PC with linux has been on for like 20 days but i guess a reboot wouldnt kill it
plus i wont be doing anything on it.. just idleing it


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 12:02 pm 
Offline

Joined: Fri Apr 16, 2004 5:22 pm
Posts: 7
Location: UK
I've lost count of the number of times I've tried Linux, then got annoyed and gone back to Windows. It's perfect for my server, and although was a bit tricky to get going - it works fantastically well now!
Windows has come a long way, and although still flawed, does work pretty well. It all comes down to what you use your PC for I guess.

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 12:46 pm 
Offline

Joined: Mon Mar 15, 2004 1:48 pm
Posts: 1397
Location: Los Angeles
i only use linux as a server. my personal pc's are always windows. i tried linux and i couldnt stand using it. i just cant get the same stuff done with linux as i could with my Windows machine with such ease.

i had so much trouble even changing the resolution... so i just gave up 2 years ago.

_________________
Image

Image

Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 7:18 pm 
Offline

Joined: Sun Apr 18, 2004 3:49 am
Posts: 3
Howdy Markp

I got the libwww-perl installed today, and downloaded the webmin, and even copy and saved that code that ya pasted onto the board in your post.

Now, I'm trying to figure out how to use webmin etc to make the sigx to work or something.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 9:32 pm 
Offline

Joined: Mon Mar 15, 2004 1:48 pm
Posts: 1397
Location: Los Angeles
cronjobs

_________________
Image

Image

Image


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 11:36 pm 
Offline

Joined: Fri Apr 16, 2004 5:22 pm
Posts: 7
Location: UK
My install of Webmin (v0.94) has a System tab. I go there, and then select Scheduled Cronjobs. Once there, you'll need to create a new scheduled job, and the rest is pretty straight-forward. Just point it at your sigx.pl (ensuring you've chmod'd it to make it executable - ie. it'll run from the shell) and ta-da! (hopefully) :)

PS: Oh to use webmin - go to https://localhost:10000

_________________
Image
Image


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 2:01 am 
Offline

Joined: Sun Apr 18, 2004 3:49 am
Posts: 3
boy this is getting confused...

ok, here i go, well for the code I saved it onto KWrite, named that file sigx.PL

now, erm created new directory /etc/cron
next thing i did is to put sigx.pl in to that directory.

then on shell-konsole

root@Pisces:~# /etc/cron
-bash: /etc/cron: is a directory
root@Pisces:~# chmod 755 sigx.pl
chmod: failed to get attributes of `sigx.pl': No such file or directory

Any suggestions? i'm happy to start it over again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 11:03 am 
Offline

Joined: Mon Apr 05, 2004 8:37 pm
Posts: 335
Location: /home/chair/sitting down/
you're not in the directory

you have to navigate to the dir with konsole

also, i'm not sure, but I don't think you have to create the folder

_________________
Image
My Site: www.dh5.us
I'll kill you Brian Anderson


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 02, 2004 12:20 pm 
Offline

Joined: Sun May 02, 2004 12:04 pm
Posts: 2
Where do I put the peral script?

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  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