PHP EditDNS Updater for Linux
Dec 18, 2008 Code, Linux, Software
This is a simple PHP script which will update your dynamic DNS records using EditDNS.
Features:
- You can configure as many records as you want.
- Supports HTTP and HTTPS.
- For PHP 4x and higher compiled with sockets.
- Simple validation.
Here is the code: (editdns.php)
#!/usr/bin/php -q <? $port = 443; // use 80 if you dont wanna use SSL // add as many arrays as you want, first element is the record // and the second is the password // $data[] = array('myrecord1.domain.com','mypass1'); // $data[] = array('myrecord2.domain.com','mypass2'); // ... etc etc etc ;) $data[] = array('somerecord.resolveme.com','blahblah123'); $sleep = 1; // seconds we should sleep before updating another record // main loop if (!is_array($data)) die("Nothing to do\n"); foreach ($data as $v) { echo "Updating $v[0] ... "; if(_send($port,"p=$v[1]&r=$v[0]")) echo "[OK]\n"; sleep($sleep); } function _send($port=443,$args="") { if ($port == 443) $proto = "ssl"; else $proto = "http"; $fp = fsockopen("$proto://dyndns.editdns.net",$port,$errno,$errstr,10); if (!$fp) die("\nCouldn't establish connection\n"); $out = "POST /api/dynLinux.php HTTP/1.0\r\n"; $out .= "Host: dyndns.editdns.net\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Content-Length: ".strlen($args)."\r\n"; $out .= "Connection: Close\r\n\r\n"; $out .= $args; //echo $out; fwrite($fp, $out); while (!feof($fp)) { $res .= fgets($fp,1024); } fclose($fp); $parts = explode("\r\n\r\n",trim($res)); //print_r($parts); // checking output if (preg_match("/record has been updated|record already exists/i",$parts[1])) return 1; // anything else should be an error echo "[ERROR]\n\t$parts[1]\n"; return 0; } ?>
Save it, chmod +x and play with it.
Old sources:
http://forums.nerdie.net/showthread.php?t=616
http://xux.in/blog/post/ip-updater-for-editdnsnet/
ADS!!!
Ensim’s (aka Parallels Pro Control Panel X for Linux) alternative ChangePasswdVirtUser
Nov 24, 2008 Code, Ensim, Linux, Lost+Found, Software
Ensim former Parallels Pro Control Panel X for Linux has a command line interface scripts as you SHOULD know
which allows you to do several administrative tasks without login to the appliance. The other day I started to write an API in order to admin N Ensim servers with only 1 interface which is a lot of work/code but hell, I’ll post some screenshots later
… So one of the biggest problems I had was the script ChangePasswdVirtUser (located in /usr/local/bin), which allows you to change a virtual user’s password asking for the new password 2 times and I didn’t want to ruin my weekend and decided to hack that script and make it work like this: ChangePasswdVirtUser domain.com user newpassword
That’s so insecure! I know and I’ll come later with a more secure alternative don’t worry
in the meantime you can play with it:
File: /usr/local/bin/ChangePasswdVirtUser1
#!/usr/bin/ensim-python # # Usage: # # ChangePasswdVirtUser <domainname> <username> <passwd> # # Example: # # AddVirtUser myco.com joe doe import getopt import getpass import sys import traceback from vh3 import virthost from vh3 import virtutil from vh3.modules import users import string import be_vherrordisp if (len(sys.argv) < 4) or (sys.argv[1] == "--help"): print "usage: ChangePasswdVirtUser1 <domainname> <username> <passwd>" sys.exit(0) else: # checks to see if we are in maintenance mode virthost.checkMaintenance() status = be_vherrordisp.CLIError.SUCCESS status_obj = be_vherrordisp.CLIError() options, args = getopt.getopt(sys.argv[1:],"") siteindex = virthost.get_site_from_anything(string.lower(args[0])) username = string.lower(args[1]) passwd1 = args[2] if not siteindex: print "Domain %s does not exist on this server."% string.lower(args[0]) sys.exit(1) ret = [] try: virthost.edit_user(ret, siteindex, username, None, passwd1, None, None) status = virthost.cli_display_status_list(ret) except: status = be_vherrordisp.CLIError.ERROR print traceback.print_exc() sys.exit(status)
cpanel 535 Incorrect authentication data
Nov 24, 2008 Code, Linux, Lost+Found, Software
I ran into a small issue when migrating some sites to a cPanel server, tried a few “tricks” (/scripts/* –force hehe) without luck till I found a great post which pointed me the solution, and it is as simple as that!
Since I’m a very lazy guy, I wrote a tiny script which does what Jerry (from cPanel forums) said/explained. Copy the code, save it and execute it. By default it won’t do anything but show the directories and files current state and how they should be. If you see something is not as it should be then you should change the $debug var to false in order to allow the script to do the job. After that everything should be fixed and if not don’t blame me, you can always do that manually
#!/usr/bin/php -q <? // file: fix_auth_perms.php // turn it off if you want to fix them // based on http://forums.cpanel.net/showpost.php?p=323248&postcount=3 $debug = true; $maps = file("/etc/domainusers"); if (!is_array($maps)) die("No users found!\n"); foreach ($maps as $map) { list($user,$domain) = explode(": ",trim($map)); if (!$user || !$domain) continue; echo "\nChecking $domain ...\n"; _file_fix("/home/$user/etc",$user,"mail"); _file_fix("/home/$user/etc/$domain",$user,"mail"); _file_fix("/home/$user/etc/$domain/shadow","","mail","0640"); //exit; } // $file = full dir/file path // $nuser = desired user name // $ngroup = desired group name // $perms = desired permissions in octal mode (0640) function _file_fix($file="",$nuser="",$ngroup="",$perms="") { global $debug; $uname_array = posix_getpwuid(fileowner($file)); $gname_array = posix_getgrgid(filegroup($file)); $file_perms = substr(sprintf('%o', fileperms($file)), -4); echo " $file owned by $uname_array[name].$gname_array[name] ($file_perms)\n"; //wrong ownership, fixing it now! if (!$debug) { if ($nuser && $nuser != $uname_array[name]) { if (!chown($file, $uname_array[name])) echo " couldn't change file owner to $nuser\n"; else echo " changed file owner to $nuser\n"; } if ($ngroup && $ngroup != $gname_array[name]) { if (!chgrp($file, $gname_array[name])) echo " couldn't change group owner to $ngroup\n"; else echo " changed group owner to $ngroup\n"; } } if ($perms && $perms != $file_perms) { if (!$debug) { if (!chmod($file,octdec($perms))) echo " couldn't change file mode to $perms\n"; else echo " changed file mode to $perms\n"; } } //making a nice output :P if (!$nuser) $nuser = $uname_array[name]; if (!$ngroup) $ngroup = $gname_array[name]; if (!$perms) $perms = $file_perms; echo " $file should now be owned by $nuser.$ngroup ($perms)\n"; } ?>
Quick Ensim Backup
Oct 23, 2008 Code, Ensim, Linux
Nothing but an easy to use backup script for Ensim (4.X-10.X) which uses vhexport, so yeah, it’s not fast, but I wrote it because sometimes you just need to backup 1 or a few sites and drop them somewhere
You just need to type this:
./backupsingle.php /path/to/backup domain1.com domain2.com ...domainN.com
And you’ll see something like this:
Building site's structure... found NN sites Building backup for N site(s) Starting backup for domain domain1.com (site1)... [OK] Starting backup for domain domain2.com (site2)... [OK] Starting backup for domain domainN.com (siteN)... [OK]
Can’t be easier
copy the code, save it and chmod +x that’s all
#!/usr/bin/php -q <? // dirty code, no comments ;) $vhexport = '/usr/local/bin/vhexport'; $sitelookup = '/usr/local/bin/sitelookup'; if (count($argv) <= 2) die("Usage: $argv[0] /backup/path domain1 domain2 ...domainN\n"); $path = $argv[1]; $limit = (count($argv)-1); if (!is_dir($path)) die("$path doesn't exist, creat it first!\n"); if (preg_match("/\/$/",$path)) $path = substr($path,0,-1); echo "Building site's structure... "; sleep(1); $ds = explode("\n",trim(`$sitelookup -a site_handle,domain`)); if (!is_array($ds)) die("Server is empty!\n"); foreach ($ds as $dlines) { $tmpparts = explode(",",trim($dlines)); if (!is_array($tmpparts)) continue; $domains[$tmpparts[1]] = $tmpparts[0]; } echo "found ".count($ds)." sites\n"; sleep(1); echo "Building backup for ".($limit-1)." site(s)\n\n"; for ($i=2;$i<=$limit;$i++) { $bdomain = $argv[$i]; $bsite = $domains[$bdomain]; if (!$bsite) { echo "Looks like $bdomain has not a valid site_handle, aborting...\n"; continue; } echo "Starting backup for domain $bdomain ($bsite)... "; $cmd = $vhexport . ' -s ' . $bsite . ' -U "file://' . $path . '/%(type)-%(name)" -z'; //echo "\n[debug] $cmd\n"; `$cmd`; echo "[OK]\n"; } ?>
Duplicated uid’s causing quotas issues on Ensim
Sep 28, 2008 Code, Ensim, Linux, Lost+Found
I’ve found some interesting error on some Ensim servers, some users having issues with their quotas and if you remove it and add it again you get the same quota issues. So, after a few minutes I noticed that the users UID’s with issues were duplicated on other sites and that’s a BIG problem.
Ensim uses a postgres database called “appldb” and a table inside “free_uids” (with fields ‘uid’, ‘site_id’) where it stores UID’s and their relation with site’s numbers, so when a user is deleted the field “site_id” is set to nothing and becomes available for the next user.
I did a small/dirty php script in 10 minutes, it’s very simple but effective. It checks if some UID is duplicated. Check the source:
* Create a file somewhere called “check_uids.php”
* Open it and paste the following code:
#!/usr/bin/php -q <? echo "Checking your system for duplicated id's...n"; $lines = explode("n",`/bin/cat /home/virtual/site*/fst/etc/passwd`); if (!is_array($lines)) die("No duplicated UID's found!"); foreach($lines as $k => $v) { $parts = explode(":",$v); if ($parts[2] < 22000) continue; if ($uids[$parts[2]]) { $uids[$parts[2]] .= ",$parts[3]"; $winners[$parts[2]] = true; } else $uids[$parts[2]] = $parts[3]; } if (!is_array($winners)) { echo "Your system has no duplicated entries :)n"; exit; } foreach ($winners as $k => $v) echo "Duplicated UID : $k on GID's: ".$uids[$k]."n"; ?>
* chmod +x check_uids.php
* execute it: ./check_uids.php
If you see a “Duplicated UID…..” then that means you have the same issue I had.
How can I solve that issue?
I’ve found a primitive way to do it, if you have a better one let me know
* Case: UID 220001 is in group 503 (site1) and 504 (site2)
* BACKUP ALL YOUR INFORMATION!
* Go to site2 and remove the user with the UID (normally you can find the username at /home/virtual/site1/fst/etc/passwd)
* Browse your pgsql, appldb -> free_uids and search for the UID at the field “uid” (if you are not a pgsql geek get the latest webmin, install it and have fun)
* Edit the pgsql “site_id” field (which should be empty) and put the value “1″ (which corresponds to the site1)
* Add the user from the site2 again
* Run the script again, if you are lucky you are out of danger
NOTE: In the worse scenario I’ve seen the same UID on 5 different groups… that’d need an extra coffee
Add/Remove multiple DNS zones for Ensim 4.x
Sep 22, 2008 Code, Ensim, Linux
I wrote this small script a few years ago (2005). This script allows you to add/delete 1 or more DNS zones and trust me, when you need to add 300 domains to your Ensim box you’ll come back to thank me
Basicly, the script asks you for 2 options:
What do you want to do? [1] Add zone(s) [2] Delete zone(s)
Then, you’ll need to write the domain(s) separated by spaces and also the IP address and that’s all. By default it uses Ensim’s DNS zone template but you can change it to whatever you want.
File: mdns.php
#!/usr/bin/php -q <? // This settings should be OK! // Add more if you need ;) define('DEBUG',true); // make it 'false' if you want to see it work define('DPATH','/usr/lib/opcenter/bind/'); define('ADD',DPATH.'add_zone'); define('REM',DPATH.'remove_zone'); define('AA',DPATH.'add_a'); define('AMX',DPATH.'add_mx'); main_menu(); function main_menu() { ?> What do you want to do? [1] Add zone(s) [2] Delete zone(s) Option: <? $option = get_line(); switch ($option) { case "1": $__domains = option_domains(); $__ip = option_ip(); option_confirm(); add_domains($__domains,$__ip); break; case "2": $__domains = option_domains(); option_confirm(); rem_domains($__domains); break; default: main_menu(); } } function add_domains($domains=array(),$ip="") { if (!$domains[0] || !$ip) { print_out("\nThere are no domain(s) or ip, please start again <ENTER>\n"); get_line(); main_menu(); return; } foreach ($domains as $k => $v) { print_out("\nAdding Zone $v ...\n"); ecmd(ADD." -f ".$v); print_out("\nAdding A (www,ftp,mail) and MX records ...\n"); ecmd(AA." -u $v $ip"); ecmd(AA." -z $v www $ip"); ecmd(AA." -z $v ftp $ip"); ecmd(AA." -z $v mail $ip"); ecmd(AMX." $v mail.".$v." 10"); } } function rem_domains($domains=array()) { if (!$domains[0]) { print_out("\nThere are no domain(s), please start again <ENTER>\n"); get_line(); main_menu(); return; } foreach ($domains as $k => $v) { print_out("\nRemoving Zone $v ...\n"); ecmd(REM." ".$v); } } function ecmd($cmd="") { if (!$cmd) { echo "Nothing to execute!\n"; return; } $cmd = escapeshellcmd($cmd); print_out("\t$cmd\n"); if (!DEBUG) { $out = `$cmd 2>&1`; } } function option_domains() { print_out("\nEnter domain or domains separated by spaces or comas:\n"); $line = get_line(); $domains = preg_split('/\s+|,/',$line,-1,PREG_SPLIT_NO_EMPTY); if (!$domains[0]) { print_out("\nYou need to enter at least one domain name, press any key to continue..."); get_line(); main_menu(); } print_out("\nCheck your information submitted: "); $i = 1; foreach ($domains as $k => $v) { echo "($i)$v "; $i++; } print_out("\n"); return $domains; } function option_ip() { print_out("\nEnter the IP: "); $line = get_line(); if (!$line) { print_out("\nYou need to enter an IP, press any key to continue..."); get_line(); main_menu(); } print_out("\nCheck your information submitted: $line\n"); return $line; } function option_confirm($info="") { print_out("\nIs this information correct?\n$info\n"); print_out("Type 'return' to start over again, 'exit' to quit this application or any other key to continue..."); $line = get_line(); if (preg_match('/return/i',$line)) main_menu(); elseif (preg_match('/exit|quit|bye/i',$line)) exit; else return; } function print_out($line="") { if (!$line) return; echo "$line"; } function get_line() { $fh = fopen("php://stdin","r"); $stdin = trim(fgets($fh)); fclose($fh); return $stdin; } ?>
Perl IRC Bot (Goki) + ChanOp plugin
Sep 1, 2008 Code, Linux, Software
Goki is an IRC Bot written in perl, very easy to install, use and develop. One of the best things about Goki is it doesn’t require any additional modules, just give it a try http://goki.sf.net.
Since Goki has no authentication yet, I did a small plugin which will handle a very primitive user’s access list and a few basic channel operator’s commands, nothing more but what you are reading
Follow the instructions:
- Create a file plugin/chanop.pm (or whatever you want)
- Paste the following code:
package chanop; #use warnings; # we don't need warnings, we know it's dirty code ;) # Module wide variables # add as many nicks as you want, and remember, in order to authenticate # you need to have the same nick name (not case sensitive) my %chanops = ( 'xUx' => '12345', 'demonick' => 'demopass', 'nick2' => 'somethinghere' ); # careful, moving things here could make the bot crash :) my %chdata = (); # hash that will hold all data foreach $key (sort keys %chanops) { %{$chdata{lc($key)}} = ('nick' => lc($key), 'pass' => $chanops{$key}); } # Module load functions. Set default values here. BEGIN { our $VERSION = 0.4; $irc = main::IRC; # private events $irc->add_handler('privcmd auth','do_auth'); $irc->add_handler('privcmd who','do_who'); $irc->add_handler('privcmd join','do_join'); $irc->add_handler('privcmd part','do_part'); $irc->add_handler('privcmd kick','do_kick'); $irc->add_handler('privcmd ban','do_ban'); $irc->add_handler('privcmd voice','do_voice'); $irc->add_handler('privcmd devoice','do_devoice'); $irc->add_handler('privcmd op','do_op'); $irc->add_handler('privcmd deop','do_deop'); $irc->add_handler('privcmd sh','do_sh'); $irc->add_handler('privcmd say','do_say'); } sub do_say { my ( $nick, $hostmask, $text ) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); my $msg = join(" ",@args[1 .. scalar(@args)-1]); main::plog "Message sent from $nick to $args[0]\n"; $irc->say($args[0],$msg); } sub do_sh { my ( $nick, $hostmask, $text ) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } main::plog "Exec attempt by $nick\n"; my @output = `$text`; my $line; foreach $line (@output) { $irc->say($nick, $line); } } sub do_deop { # deop #channel nick my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } main::plog "Deop on $args[0] to $args[1] by $nick\n"; $irc->deop($args[0],$args[1]); } sub do_op { # op #channel nick my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } main::plog "Op on $args[0] to $args[1] by $nick\n"; $irc->op($args[0],$args[1]); } sub do_devoice { # devoice #channel nick my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } $irc->devoice($args[0],$args[1]); } sub do_voice { # voice #channel nick my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } main::plog "Voice on $args[0] to $args[1] by $nick\n"; $irc->voice($args[0],$args[1]); } sub do_ban { # ban #channel nick|hostmask my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } main::plog "Ban on $args[0] to $args[1] by $nick\n"; $irc->mode($args[0],"+b",$args[1]); } sub do_kick { # kick #channel nick reason my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } my $reason = join(" ",@args[2 .. scalar(@args)-1]) || $args[1]; main::plog "Kick on $args[0] to $args[1] ($reason) by $nick\n"; $irc->kick($args[0],$args[1],$reason); } sub do_part { # part #channel my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } main::plog "Parting $args[0] by $nick\n"; $irc->part($args[0]); } sub do_join { # join #channel my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } my @args = split(" ",$text); if ($args[0] !~ /^\#/) { $args[0] = "#" . $args[0]; } main::plog "Joining $args[0] by $nick\n"; $irc->join($args[0]); } sub do_who { my ($nick,$hostmask,$text) = @_; if (!&do_auth_check($nick,$hostmask)) { return; } foreach my $key (sort keys %chdata) { if (exists($chdata{$key}{'hostmask'})) { $irc->say($nick, $chdata{$key}{'nick'} . " (". $chdata{$key}{'hostmask'}.")"); } } return; } sub do_auth_check { my ($nick,$hostmask) = @_; my $tmphostmask = (split("\!",$hostmask))[1]; if (!exists($chdata{lc($nick)}{'hostmask'})) { main::plog "Unauthorized access from $hostmask\n"; return 0; } if ($chdata{lc($nick)}{'hostmask'} eq $tmphostmask) { return 1; } return 0; } sub do_auth { my ($nick,$hostmask,$text) = @_; my $tmphostmask = (split("\!",$hostmask))[1]; if (!exists($chdata{lc($nick)})) { main::plog "Invalid user tried to AUTH: $nick ($tmphostmask)\n"; return; } my @args = split(" ",$text); if ($chdata{lc($nick)}{'pass'} ne $args[0]) { main::plog "Invalid Login attemp from $nick ($tmphostmask)\n"; $irc->notice($nick,"Invalid Password, attemp logged!"); return; } if (exists($chdata{lc($nick)}{'hostmask'})) { main::plog "RE-AUTH from $nick from ".$chdata{lc($nick)}{'hostmask'}." to $tmphostmask\n"; } else { main::plog "AUTH from $nick from $tmphostmask\n"; } $chdata{lc($nick)}{'hostmask'} = $tmphostmask; $irc->notice($nick, "Authentication Succesful!"); } return 1; # Module unload functions, free memory and close open filehandles here END { # Does not currently work, but is here for future compatibility # $irc->del_handler( '', '' ); }
- Edit file conf/plugin.conf and make it load your plugin by adding a line with the word “chanop” (or the first part of your thanemayoupicked.pm)
- Start your bot and have fun
For future reference and user’s comments go to http://sourceforge.net/forum/forum.php?thread_id=2185241&forum_id=621728
PHP Generate Random Passwords
Mar 26, 2008 Code, Linux, Software
This is a small script written in PHP which will help you to generate N passwords of N length in less than 1ms
Make sure you have PHP installed, then copy this code to a file called randompass.php
#!/usr/bin/php -q <? // no i,l,o keep passwords easy $chars = "abcdefghjkmnpqrstuvwxyz0123456789"; $passlen = (intval($argv[1])? intval($argv[1]):6); $passnum = (intval($argv[2])? intval($argv[2]):1); echo "Generating $passnum passwords of $passlen letters/numbers\n"; // feed the random God :P srand(((int)((double)microtime()*1000003))); for ($i=1;$i<=$passnum;$i++) _gen_pass(); function _gen_pass() { global $chars, $passlen; $cnt = 1; while ($cnt <= $passlen) { $myrand = rand() % 33; $tmp = substr($chars, $myrand, 1); if (rand(0,1)) $tmp = strtoupper($tmp); $pass = $pass . $tmp; $cnt++; } echo $pass . "\n"; } ?>
Now you have the file don’t forget to make it executable:
chmod +x randompass.phpHow it works? See some examples:
Usage: ./randompass.php [password_length] [password_number] # The default execution will drop 1 password of 6 letters/numbers ./randompass.php Generating 1 passwords of 6 letters/numbers 9hBEq1 # want 5 passwords of 12 letters/numbers ? ./randompass.php 12 5 Generating 5 passwords of 12 letters/numbers ug5Tj8fP3w26 Tn9fnSjy2PmJ NRqC6m8J0svn YFQ6g3WnHH8r ds56SnQvsBEq
That’s all, use it for what you need, don’t try to break it or find stupid bugs
Easy RRDtool Install (1.2.27)
Mar 26, 2008 Code, Ensim, Linux, Software
As you should know RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, TCL or PHP bindings.
This post will guide you to setup RRDtool 1.2.27 on your Linux server without pain
I have tested this configuration on CentOS 4,5, RHEL 3,4
Before you start make sure you install the following apps:
- libart_lgpl-2.3.16-3
- libart_lgpl-devel-2.3.16-3
- zlib-1.2.1.2-1.2
- zlib-devel-1.2.1.2-1.2
- freetype-2.1.9-6.el4
- freetype-devel-2.1.9-6.el4
- libpng-1.2.7-3.el4_5.1
- libpng-devel-1.2.7-3.el4_5.1
Use the power of yum to get them on your system… if you ran into trouble then you shouldn’t continue unless you get someone to fix your mess
Now, you need to download and install RRDtool
cd /usr/local/src wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.27.tar.gz tar -zxf rrdtool-1.2.27.tar.gz cd rrdtool-1.2.27 ./configure --disable-tcl # if you get an error while configuring make sure you read # what caused that, and try to fix it make make install ln -s /usr/local/rrdtool-1.2.27/bin/rrdtool /usr/bin/rrdtool ln -s /usr/local/rrdtool-1.2.27/bin/rrdupdate /usr/bin/rrdupdate ln -s /usr/local/rrdtool-1.2.27/bin/rrdcgi /usr/bin/rrdcgi
Was that hard? I don’t think so, actually it was pretty easy and now you can start coding your own graphs
You need to start diggin’ the Tutorials, Documentation and Wiki provided by Tobias Oetiker in order to start with your own cool graphs, and remember, RRDtool is FREE and if it helps you and saves you time/money you should really consider make Tobi happy
I’ll be posting later some basic examples for RRDtool graphs and other scripts, be patient
IP updater for EditDNS.net
Mar 24, 2008 Code, Linux, Software
As anyone know (and should know) EditDNS it’s the best alternative for DNS Management and the best of all it is FREE
Here I wrote/adapted some code which will allow you to update your dynamic IP through EditDNS’s API.
Requirements:
- You need to register first! (duh)
- Donations are optional, but if it makes your life easier you should consider it and you’ll also get more services.
- Perl!
File: editdns.pl
#!/usr/bin/perl use strict; ## Configure ONLY this 2 variables my $editdns_pass = "a"; # put your password my $editdns_record = "b"; # put the record you wish to update ## ############### ## Nothing else should be changed unless you know what to do ## ############### my $host = "DynDNS.EditDNS.net"; my $port = 80; my $editdns_post = "p=$editdns_pass&r=$editdns_record"; my $editdns_req = join("", "POST /api/dynLinux.php HTTP/1.0\r\n", "Host: $host:$port\r\n", "User-Agent: EditDNS Browser 0.1\r\n", "Referer: http://www.editdns.net\r\n", "Content-Type: application/x-www-form-urlencoded\r\n", "Content-Length: ".length($editdns_post)."\r\n\r\n", "$editdns_post\n" ); my $hostaddr = (gethostbyname($host))[4] || &error("Couldn't get IP for $host"); my $remotehost= pack('S n a4 x8',2,$port,$hostaddr); socket(S,2,1,6) || &error("Couldn't create socket"); connect(S,$remotehost) || &error("Couldn't connect to $host:$port"); select((select(S),$|=1)[0]); print S $editdns_req; vec(my $rin='',fileno(S),1)= 1 ; select($rin,undef,undef,60) || &error("No response from $host:$port"); undef($/); close(S); print "[DONE]\n"; exit; sub error { print "[ERROR] $_[0]\n"; exit; }
Next and once you have configured the script:
chmod +x editdns.pl pico /etc/crontab # Add editdns.pl to execute every 15 minutes */15 * * * * root /path/editdns.pl > /dev/null 2>&1
Do not set intervals lower than 15 minutes, since it can be considered as an abuse and you’ll get banned.
Part of this code was taken from James Marshal, happy coding!
*** If you are looking for SSL support and multiple records you might want to check http://xux.in/blog/post/php-editdns-updater-for-linux/
