View previous topic :: View next topic |
Author |
Message |
tacker Tux's lil' helper
Joined: 22 Jul 2004 Posts: 85 Location: Offenbach, Germany
|
Posted: Wed Jun 22, 2005 10:16 am Post subject: View emerge -uD output of multiple machines online (PHP5) |
|
|
Hoi all,
I've written a PHP client script which parses the output of emerge -uDpq into XML
and sends it to a server script where it is stored in a database.
On the server side is a browser script which lists all clients with their packages to be updated.
This seems more usefull to me, than receiving emails every day from my machines.
This is merely a rough draft but nonetheless working.
See screenshot.
Source code can be fetched via SVN: http://versions.tacker.org/svn/emerge-update-xml/trunk/ |
|
Back to top |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Wed Jun 22, 2005 3:36 pm Post subject: |
|
|
is there some kind of documentation except some comments in the source?
Rei _________________ Please stand by - The mailer daemon is busy burning your messages in hell... |
|
Back to top |
|
|
ansient Guru
Joined: 22 Jan 2005 Posts: 445 Location: Argentina
|
Posted: Wed Jun 22, 2005 4:00 pm Post subject: |
|
|
Dude...
Code: | #!/bin/bash
for SERVER in server1 server2 server3 server4 server5 server6; do
echo -n "Packages for $SERVER at "
ssh $USER@$SERVER '/sbin/ifconfig eth0 2>&1 | grep "inet addr" | awk "{print \$2}" | cut -c 6-;
/usr/bin/emerge -uDNpv world | grep /'
done |
The ifconfig...grep..awk to get the IP address isn't necessary; I just find it useful
Last edited by ansient on Wed Jun 22, 2005 4:16 pm; edited 1 time in total |
|
Back to top |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Wed Jun 22, 2005 4:14 pm Post subject: |
|
|
the more elegant way for that in combination with ssh keys @ ansient
Code: |
#!/bin/bash
#
#
# Filename: cx
# Usage ./cx [target-group] [command]
HOME="\
box1.example.com \
box2.example.com \
...
"
WORK="\
box3.example.com \
box4.example.com \
...
"
MISC="\
box5.example.com \
box6.example.com \
...
"
if [ -z "$1" -a -z "$2" ] ; then echo "Usage: cx (all|home|work|misc) command" ; exit 1 ; fi
case $1 in
"all")
tmp=( ${HOME[@]} ${WORK[@]} ${MISC[@]} )
;;
"home")
tmp=${HOME[@]}
;;
"work")
tmp=${WORK[@]}
;;
"misc")
tmp=${MISC[@]}
;;
esac
for host in ${tmp[@]}; do
echo "Running command on: ${host}"
ssh -l root ${host} -t $2
done
|
or clusterssh and simmilar programs - if on linux
Sometimes, especially at work or at school there might be no linux box avaliable, so a browser-accessible tool is a good job. Imagine a firewall that blocks 22... disturbing, euh? So I think this program can be some help
Rei _________________ Please stand by - The mailer daemon is busy burning your messages in hell... |
|
Back to top |
|
|
djh-world Apprentice
Joined: 04 Jan 2004 Posts: 281 Location: Nottingham, UK
|
|
Back to top |
|
|
ansient Guru
Joined: 22 Jan 2005 Posts: 445 Location: Argentina
|
Posted: Wed Jun 22, 2005 4:21 pm Post subject: |
|
|
If a linux box isn't available, the first thing I do is ssh to one.... http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
Otherwise why would it be useful to see what packages need updating (via a web interface) if you can't do anything about it?! |
|
Back to top |
|
|
ToeiRei Veteran
Joined: 03 Jan 2005 Posts: 1191 Location: Austria
|
Posted: Wed Jun 22, 2005 4:35 pm Post subject: |
|
|
my script can also be used for the update too or sending some commands to all of the hosts (./ cx all "emerge -uD world"). You might want to try out putty with a secured proxy and port 22 blocked - It does not work. With the php script here you know what would be updated and you can check out the changelogs of the package - you know: some updates are just bugfixes, some are just new versions.
Rei _________________ Please stand by - The mailer daemon is busy burning your messages in hell... |
|
Back to top |
|
|
tacker Tux's lil' helper
Joined: 22 Jul 2004 Posts: 85 Location: Offenbach, Germany
|
Posted: Wed Jun 22, 2005 4:57 pm Post subject: |
|
|
ToeiRei wrote: | is there some kind of documentation except some comments in the source? |
Not yet. You may PN me if you like.
ToeiRei wrote: | you can check out the changelogs of the package |
I just added that feature.
ansient wrote: | Otherwise why would it be useful to see what packages need updating (via a web interface) if you can't do anything about it?! |
It's IMHO more convenient especially if the number of your boxes is even greater. |
|
Back to top |
|
|
|