Posts Tagged ‘gentoo’

fish awesome auto complete and more

By Mark Davidson on February 26th, 2010

Ever since I started using Linux all those years ago I have always been on the look out for a different shell that would top bash. I had tried zsh and a few others but none of them really topped bash in a massive way. Recently a mate of mine told me about fish so I tried it out on my Gentoo dev box.

There are a lot of interesting features in fish most of them to do with the auto completion aspects.

The auto-completion of ls arguments is just a very basic example of how fish really improves on standard auto-complete functionality like in bash. As well as being able to complete the normal long arguments it can complete short ones as well plus giving an actual explanation to what the command does. I think this is absolutely great personally for two reasons. First of all if your new to Linux then it helps you learn. Second if your like me and your mind just falls apart some times as its to full other junk (mine being full of knowing every episode of The Simpsons in full word for word) its handy to get a bit of a prompt.

As well as the improvement of auto-completing arguments the auto-completion for programs is improved as well telling you what the program is where possible but at least telling you what the type of application or program is. The below screen shot is when listing a lot of programs which is output using a less type application if there is only a few it will be output like with the above ls auto-complete.

Next one of my personal favorite features of fish is the auto-completion of wildcards for example if I am at the top of my web directory and wanted to get the details of every PHP file in all the sub directories, I would need to do something like `find . -iname “*.php” -print0 | xargs -0 ls -la` while with fish you could just do `ls –la **.php` and get the same result.
Another example as follows is auto-completing on wild cards something that’s not possible with bash.

The last feature I would like to point out in this quick coverage of fish is a small one using the % symbol you can autocomplete for process IDs which can be really handy.

There are some more screen shots showing some other cool features on their website http://fishshell.org/screenshots.html and further detail on all the features on the documentation page http://fishshell.org/user_doc/index.html
Also if your interested checkout the possible features list http://fishshell.org/doc2/index.html#todo-possible think there is some cool ones coming up.

That’s it for now. I am going to continue using fish over the next few days then I will be putting together a bit of a cheat list which ill be posting up here, so if your interested check back soon.

Installing & Configuring Cacti Under Gentoo

By Mark Davidson on February 9th, 2010

Cacti is a front end to RRDTool, the purpose of which to provide an effective network graphing solution for monitoring devices within a Network. It can be used with SNMP to monitor various statistics about a device including but not limited to Load Average, Bandwidth, Disk Usage and Processes.

The following are the steps to install Cacti under Gentoo

  1. Modify your /etc/make.conf and modify your use flags adding “mysql xml sockets vhosts”, which should give you a line reading something similar to
    USE="symlink mmx sse sse2 bash-completion vhosts xml sockets snmp"
  2. Now emerge Apache, PHP, Cacti and webapp-config. You may already have some of these installed but it is important to rebuild them with the new use flags.
    sudo emerge apache php cacti webapp-config

    Once completed if everything has installed correctly procede to the next step if you get an error saying “Could not read settings from webapp-config” I found the easiest way to solve this was to unmerege webapp-config and reinstalled it.

  3. Update your /etc/ config files if required
    sudo etc-update
  4. Create a vhost if you don’t already have one and then run the following. Then install cacti to the vhost using webapp-config. Remember to change the -h option to reflect the name of your vhost and that you may need to set a different cacti version number if cacti has been updated since I posted this article.
    sudo webapp-config -I -h yourdomain.com -d cacti cacti 0.8.7e-r1
  5. Its now time to setup the database that Cacti will be using.
    mysqladmin -p --user=root create cacti
    mysql -p --user=root cacti < /var/www/yourdomain.com/htdocs/cacti/cacti.sql # Remember to change this to reflect the path to your cacti install.
    mysql -p --user=root mysql
    GRANT ALL ON cacti.* TO [email protected] IDENTIFIED BY  'somepassword'; # Just a note I like to use apg to generate my passwords.
    flush privileges;
  6. Now that the database has been created your need to set the database settings in cacti. Modify /var/www/yourdomain.com/htdocs/cacti/include/config.php if your installing with a local database and only changed the password above that’s all you need to update in the config file.
  7. The last step of the install is to add a cron entry to your tab to get Cacti to update. Add the following entry to your crontab updating the path as needed.
    */5 * * * * apache /usr/bin/php  /var/www/yourdomain.com/htdocs/cacti/poller.php > /dev/null  2>&1
  8. That should be it for Cacti base install visit http://yourdomain.com/cacti and you should be meet with a login screen use admin as the username and admin as the password. You should now see the Cacti inteface.
  9. Click on the Graphs tab accross the top and after a while once data starts coming in your should see the graphs start to be drawn. At the moment these graphs will display localhost data.

Thats all for now in the next post I will cover setting up net-snmpd on a host and then configuring Cacti to monitor it.

Gentoo & Nagios Configuration for Basic Remote Host Monitoring

By Mark Davidson on February 7th, 2010

Nagios is a very powerful monitoring solution that can be used to monitor the status of hosts and servers. This post is going to cover a basic setup of Nagios under Gentoo and configuring it to monitor the status of remote hosts.

First Add these lines to /etc/portage/package.use

net-analyzer/nagios-plugins nagios-dns nagios-ping nagios-ssh
net-analyzer/nagios-core vim-syntax
media-libs/gd jpeg png # You may need this line as well if your GD isn't already compiled with jpeg and png support.

Then emerge nagios

sudo emerge nagios
sudo chmod +x /etc/nagios/ # You don't have to do this but lets you ls the dir because permissions are a bit strict by default

now that nagios has been installed the next step is to enable it under apache. Edit /etc/conf.d/apache2 and add “-D NAGIOS” to the apache2 opts

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D SECURITY -D PHP5 -D STATUS -D INFO -D NAGIOS"

After doing so create a new .htaccess file in /usr/share/nagios/htdocs/ containing the following

AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/auth.users
Require valid-user

make a copy of the file to /usr/lib/nagios/cgi-bin/.htaccess

sudo cp /usr/share/nagios/htdocs/.htaccess /usr/lib/nagios/cgi-bin/.htaccess

next create the htpasswd fileĀ  and restart apache

sudo htpasswd2 -c /etc/nagios/auth.users nagiosadmin
sudo apache2ctl restart

Now nagios should be configured and monitoring localhost with a number of checks, to check its working simply vist http://yourdomain.com/nagios/ and click the service details link on the menu providing everything is working you should see some service details and other status details about the localhost.

Providing everything went well we can now start monitoring some hosts remotely. There are many ways of doing so with Nagios I will cover some of these in a later tutorial but for now I will simply explain how to set up a check for PING, SSH and HTTP against a host.

Edit the /etc/nagios/nagios.cfg file and add this line any where below the log_file line.

cfg_dir=/etc/nagios/servers

next you need to create the dir /etc/nagios/servers and set it to be owned by nagios.

sudo mkdir /etc/nagios/servers
sudo chown nagios:nagios /etc/nagios/servers

now create a new .cfg named yourdomain.com.cfg and begin editing it. Add the following to the file save and exit.

define host{
    use                     linux-server
    host_name           server01.example.co.uk ; Change this to yourdomain
    address               83.XXX.XXX.XXX ; Change this to the IP of your domain
}

define service {
    use                     generic-service
    host_name               server01.example.co.uk ; Change this to your domain as above
    service_description     PING
    is_volatile             0
    check_period            24x7
    max_check_attempts      3
    normal_check_interval   5
    retry_check_interval    1
    notification_interval   240
    notification_period     24x7
    notification_options    w,u,c,r
    check_command           check_ping!100.0,20%!500.0,60%
}

define service {
    use                     generic-service
    host_name               server01.example.co.uk ; Change this to your domain as above
    service_description     SSH
    check_command           check_ssh
    notifications_enabled   0
}

define service {
    use                     generic-service
    host_name               server01.example.co.uk ; Change this to your domain as above
    service_description     HTTP
    check_command           check_http
    notifications_enabled   0
}

repeat this step for each of your hosts then restart nagios

sudo /etc/init.d/nagios restart

finally visit http://yourdomain.com/nagios/ click on the service details link again and you should see all your servers with status reports for the PING, HTTP and SSH monitoring.

Thats it for now any problems or questsions let me know I plan on covering the subject in more detail in a future post.

In the mean time some more details can be found at http://www.gentoo.org/doc/en/nagios-guide.xml and http://www.debian-administration.org/article/Using_Nagios_to_Monitor_Networks