Following example shows the difference between uptime and snmpwalk commands.
# uptime
12:13:48 up 580 days, 51 min, 8 users, load average: 2.38, 1.70, 2.70
# snmpwalk -v2c -c public localhost .1.3.6.1.4.1.2021.10.1.5
UCD-SNMP-MIB::laLoadInt.1 = INTEGER: 243
UCD-SNMP-MIB::laLoadInt.2 = INTEGER: 172
UCD-SNMP-MIB::laLoadInt.3 = INTEGER: 270
# snmpwalk -v2c -c public localhost .1.3.6.1.4.1.2021.10.1.6
UCD-SNMP-MIB::laLoadFloat.1 = Opaque: Float: 2.240000
UCD-SNMP-MIB::laLoadFloat.2 = Opaque: Float: 1.690000
UCD-SNMP-MIB::laLoadFloat.3 = Opaque: Float: 2.680000
Snmp has 2 oids for load average, integer and floating point. The value of floating point is the same as uptime, To convert integer load average value from snmpwalk, simplely devide it by 100.
Wednesday, April 17, 2013
Retrieve system information with facter
The facter is a Ruby tool that provides system information in "key=>value" pairs. Following are some examples:
# facter
architecture => x86_64
...
is_virtual => false
...
memoryfree => 20.15 GB
...
netmask => 255.255.255.0
...
# facter timezone
EDT
# facter
architecture => x86_64
...
is_virtual => false
...
memoryfree => 20.15 GB
...
netmask => 255.255.255.0
...
# facter timezone
EDT
Thursday, April 11, 2013
Use Jenkiz to monitor Cron Job with hudson_wrapper
The easest way to use Jenkinz to monitor cron job is use hudson_wrapper as show below:
1. Put hudson_wrapper.sh, from https://github.com/joemiller/hudson_wrapper, on each server, and update the /etc/crontab as below:
0 * * * * root /path/hudson_wrapper.sh Jenkinz_URL name command
2. The wrapper will create the job on the Jekniz server if it is not exist. So no Jenkiz configuration needed.
1. Put hudson_wrapper.sh, from https://github.com/joemiller/hudson_wrapper, on each server, and update the /etc/crontab as below:
0 * * * * root /path/hudson_wrapper.sh Jenkinz_URL name command
2. The wrapper will create the job on the Jekniz server if it is not exist. So no Jenkiz configuration needed.
Top command issue on cron job
Use -b option to run top command through cron and extend script for snmp configuration, etc. Otherwise top will failed with "top: failed tty get" message.
top -b -n 1
top -b -n 1
Trick for SVN Folder defination in authz file
Don't put a slash at the end of a folder defination such as [/SYSTEMS/] instead of [/SYSTEMS]. The ending slash may cause access denied problem.
Saturday, March 30, 2013
Running script on remote systems
Instead of copying script to all systems, say 200, to run, following will make things easier.
1. Running script without argument on remote systems
ssh user@remote /bin/bash < scriptname.sh
2. Running script with arguments on remote systems.
runremote.sh user remote scriptname.sh -arguments
runremote.sh is shown below.
Details see http://backreference.org/2011/08/10/running-local-script-remotely-with-arguments/
1. Running script without argument on remote systems
ssh user@remote /bin/bash < scriptname.sh
2. Running script with arguments on remote systems.
runremote.sh user remote scriptname.sh -arguments
runremote.sh is shown below.
#!/bin/bash
# runremote.sh (revised, not dependent upon /dev/stdin)
# usage: runremote.sh remoteuser remotehost localscript arg1 arg2 ...
if [ $# -lt 3 ]; then
echo "Usage: $0 remoteuser remotehost localscript arg1 arg2 ..."
exit
fi
realscript=$3
user=$1
host=$2
shift 3
# escape the arguments
declare -a args
count=0
for arg in "$@"; do
args[count]=$(printf '%q' "$arg")
count=$((count+1))
done
{
printf '%s\n' "set -- ${args[*]}"
cat "$realscript"
} | ssh $user@$host "bash -s"Details see http://backreference.org/2011/08/10/running-local-script-remotely-with-arguments/
Friday, February 22, 2013
Install Jenkins Build System on Ubuntu 11
Install/setup Subversion
svn:x:1001:yourname"
Install Openssh:
- sudo apt-get update
- sudo apt-get install subversion
- cd /var
- sudo mkdir svn
- sudo svnadmin create /var/svn/repos
- sudo adduser svn
- sudo chown -R svn.svn svn
- sudo vigr
svn:x:1001:yourname"
Install Openssh:
- sudo apt-get install openssh-server
- svn co svn+ssh://pwong@localhost/var/svn/repos to make sure ssh is working
- chmod 0700 ~/.ssh
- chmod 0600 ~/.ssh/known_hosts
- sudo apt-get install libapache2-svn apache2
sudo vi /etc/apache2/mods-enabled/dav_svn.conf to remove comments for following lines:
DAV svn
SVNPath /var/svn/repos
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.authz
Require valid-user- sudo htpasswd -cb /etc/apache2/dav_svn.authz pwong password
- sudo /etc/init.d/apache2 force-reload, then check http://localhost/svn/
- sudo apt-get install trac python-setuptools libapache2-mod-python enscript
- sudo mkdir /var/www/trac
- sudo trac-admin /var/www/trac/repos initenv, accept defaults, and enter /var/svn/repos for repository.
- cd /var/www
- sudo chown -R www-data.svn trac
- cd /etc/apache2/mods-enabled/
- sudo vi python.conf to create w new config file
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.authz
Require valid-user
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /var/www/trac
PythonOption TracUriRoot /trac- sudo /etc/init.d/apache2 force-reload, then check http://localhost/trac/
- sudo apt-get install sun-java6-jdk
- sudo apt-get install tomcat6 tomcat6-admin
- sudo vi /usr/share/tomcat6/bin/startup.sh to add "export JAVA_HOME=/usr/lib/jvm/java-6-sun"
- sudo vi /usr/share/tomcat6/bin/shutdown.sh to add the some line to the file
- sudo vi /etc/init.d/tomcat6 to add the same line to the file
- sudo vi /etc/tomcat6/tomcat-users.xml to add "
" - sudo /etc/init.d/tomcat6 restart, then check http://localhost:8080
- sudo wget -q -o - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
- sudo vi /etc/apt/sources.list to append "ded http://pkg.jenkins-ci.org/debian binary/" to the file
- sudo apt-get update
- sudo apt-get install jenkinz
- sudo vi /etc/default/jenkinz to change the http port from 8080 to 8180. Otherwise, Jenkins won't be started at the default port 8080. Check http://locahost:8180 for Jenkins
- sudo /etc/init.d/jenkins start
- sudo apt-get install maven2 ant
- cd ~/MyProject
- mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=superapp
- cd superapp
- mvn package
- java -cp target/superapp-1.0-SNAPSHOT.jar com.mycompany.app.App
- mvn clean
- mkdir superapp-structure
- mv superapp-structure/ ..
- cd ..
- mv superapp superapp-structure/trunk
- mkdir superapp-structure/branches
- mkdir superapp-structure/tags
- sudo svn import superapp-structure file:///var/svn/repos/superapp-repository/superapp -m "First import.". The superapp-repository will be visible at http://localhost/trac/repos/browser
- svn co file:///var/svn/repos/superapp-repository/superapp/trunk superapp
SSH Login Without Password
A. Empty passphrase in keys:
1: On local host, create public and private keys using ssh-key-gen by pressing enter 3 times to either use default or without passphrase.
ssh-keygen
2: Copy public key to remote host with ssh-copy-id
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
Make sure .ssh/authorized_keys exist on remote host. From now on, the remote host shouldn't ask your password for login.
B. If there is passphrase in keys for any reason, following additional steps are needed.
1. Start up ssh-agent or put following line in ~/.bashrc to memorize the passphrase.
eval $(ssh-agent -s)
2. Add key to the agent. It needs to enter the passphrase to complete the step.
ssh-add ~/.ssh/id_rsa
3. Conform the key has been added.
ssh-add -l
No need to enter the passphrase to login to the remote host.
1: On local host, create public and private keys using ssh-key-gen by pressing enter 3 times to either use default or without passphrase.
ssh-keygen
2: Copy public key to remote host with ssh-copy-id
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
Make sure .ssh/authorized_keys exist on remote host. From now on, the remote host shouldn't ask your password for login.
B. If there is passphrase in keys for any reason, following additional steps are needed.
1. Start up ssh-agent or put following line in ~/.bashrc to memorize the passphrase.
eval $(ssh-agent -s)
2. Add key to the agent. It needs to enter the passphrase to complete the step.
ssh-add ~/.ssh/id_rsa
3. Conform the key has been added.
ssh-add -l
No need to enter the passphrase to login to the remote host.
Subscribe to:
Posts (Atom)