Tuesday 28 March 2017

ev3dev - Windows 7 ssh

Connect Robot to Windows 7, it downloads and installs the cdc gadget driver and will display ev3dev+ev3dev

open putty

connect via ssh to robot@ev3dev.local with the password maker

ev3dev - connecting to macbook 10.12.2

Need a cdc gadget driver

Connect to the robot via bluetooth or wifi




Reboot your ev3dev robot

once rebooted - goto All network connections - set "Wired" to connect 
Once "connected" you will get a IP Address

open SSH or iTerm and connect to the address using robot@IPADDRESS


Thursday 9 March 2017

Nagios - change opening page to tactical page

goto /usr/local/nagios/share/  or just locate "index.php"

vi index.php

At the top you'll find $url = ' main.php'

Change this to $url = ' cgi-bin/tac.cgi'

Restart Nagios








Tuesday 28 February 2017

Nagios 4.2 errors Error: Invalid max_check_attempts value for host


Error: Invalid max_check_attempts value for host 


Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Invalid max_check_attempts value for host 'N-Claassen'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/samsung.cfg', starting on line 24)
   Error processing object config files!


***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data defintions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.

_________________________________________________________________________________

/objects/samsung.cfg

define host{
        use             Samsung-Phones  ; Inherit default values from a template
        host_name       N-Claassen      ; The name we're giving to this host
        alias           N-Claassen      ; A longer name associated with the host
        address         192.168.0.104   ; IP address of the host
        }

define hostgroup{
        hostgroup_name  Samsung-Phones  ; The name of the hostgroup
        alias           Samsung-Phones  ; Long name of the group
        members         N-Claassen
}


/templates.cfg

#Samsung Voip Phones

define host{
        name                    Samsung-Phones  ; The name of this host template
        use                     generic-host    ; Inherit default values from the generic-host template
        check_period            24x7            ; By default, Windows servers are monitored round the clock
        check_interval          5               ; Actively check the server every 5 minutes
        retry_interval          1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts      5              ; Check each server 10 times (max)
        check_command           check-host-alive        ; Default command to check if servers are "alive"
        notification_period     24x7            ; Send notification out at any time - day or night
        notification_interval   30              ; Resend notifications every 30 minutes
        notification_options    d,r             ; Only send notifications for specific host states
        contact_groups          admins          ; Notifications get sent to the admins by default
        hostgroups              Samsung-Phones ; Host groups that Windows servers should be a member of
        register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
        }


Nagios 4.2 - Reminder how it all work......

Add new hostgroups/hosts

/usr/local/nagios/etc/objects/

Add the new group to the list of groups to be displayed
templates.cfg
nagios.cfg


Recheck config
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

restarting nagiog service
sudo /etc/init.d/servicename restart


Restart service

Finding a file
grep -r "filename"

Winscp
"Permission denied"

checking Nagios log files
tail -f /usr/local/nagios/var/nagios.log

FTP

service vsftpd restart














Monday 27 February 2017

Installing Nagios on Ubuntu 14.04

sudo -i

Restarting Apache & Nagios in Ubuntu 14.04

update-rc.d <service> enable

https://assets.nagios.com/downloads/nagioscore/docs/Installing_Nagios_Core_From_Source.pdf

Equivalent to chkconfig

update-rc.d nagios enable

starting Apache at startup

sudo /etc/init.d/apache2 start

Restarting Apache   service apache restart

Verifying nagios config

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
tail -f /var/log/syslog  (checking log file)
https://support.nagios.com/kb/article.php?id=515
sudo ufw reload
NRPE 5666


NRPE STATUS
sudo start nrpe
sudo stop nrpe
sudo restart nrpe
sudo status nrpe

checking 
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load


Restarting Nagios
/etc/init.d/nagios



Tuesday 21 February 2017

Nagios Installation 4.4.2 (updated 23 Nov 2018)

Nagios installation


Install Ubuntu with LAMP & postfix & Build essentials.
sudo apt-get install build-essential libgd2-xpm-dev apache2-utils unzip

Nagios User Setup

useradd -m -s /bin/bash nagios
passwd nagios
usermod -G nagios nagios
groupadd nagcmd
usermod -a -G nagcmd nagios

Download And Unzip Nagios And Nagios Plugins

mkdir downloads
cd /downloads
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.2.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -zxf nagios-4.4.2.tar.gz
tar -zxf nagios-plugins-2.2.1.tar.gz



Install Nagios


cd /downloads/nagios-4.4.2
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

make install-classicui


Nagios Password


This is the password you will need to look at the nagios pages. If you install Nagios to a different directory please change this command to where the Nagios etc. folder will be.


htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Enter your password when prompted.  Phoenix0
Now we will restart Apache to make sure all of the changes take effect:


/etc/init.d/apache2 restart


Nagios Plugins



cd /downloads/nagios-plugins-2.2.1.tar.gz/


make all
make install
make install-init
make install-commandmode

Now we need to make Nagios start at bootup:


ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios


Change Default Email Address For Nagios Admin


Open your favorite editor and open /usr/local/nagios/etc/objects/contacts.cfg . (change to J's email)

Once you have saved your changes to the contacts.cfg we need to verify that there are no errors in the configuration of Nagios.


/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Now we are going to start nagios:

service nagios start
/etc/init.d/nagios start




Postfix Configuration For A Smarthost Relay


postconf -e 'relayhost=yourmailserver.com'

postconf -e 'smtp_sasl_auth_enabled = yes'

postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'


postconf -e 'smtp_sasl_security_options ='


echo "mail.gmail.com emailusername:scanning@xxxxx.org:Password84" > /etc/postfix/sasl_passwd

Now we will need to change the password file attributes so only root has access to read it.


chown root:root /etc/postfix/sasl_passwd


chmod 600 /etc/postfix/sasl_passwd


postmap /etc/postfix/sasl_passwd





Now we are going to set the map that will change your outbound messages from nagios to your email server username/email address.


echo "nagios scanning@xxxxxx.org" /etc/postfix/canonical


echo "canonical_maps = hash:/etc/postfix/canonical" >> /etc/postfix/main.cf


postmap /etc/postfix/canonical (failed)


/etc/init.d/postfix restart

Now that this all has been completed you can restart your system.
Once your system has come back up you will be able to login to the website and look at your first Nagios installation.


http://yourserver/nagios/


Changing nagios startup screen to tactical view

cd /usr/local/nagios/share
vi index.php
<replace line 2:
  $url = 'main.php';
with
  $url = '/nagios/cgi-bin/tac.cgi';
<save file>


Adding an IP range

hen, Edit file /etc/apache2/sites-enabled/nagios.conf,
sudo nano /etc/apache2/sites-enabled/nagios.conf
And edit the following lines if you want to access nagios administrative console from a particular IP series.
Here, I want to allow nagios administrative access from 192.168.1.0/24 series only. So, I edited this file as shown below.
[...]
## Comment the following lines ##
#   Order allow,deny
#   Allow from all

## Uncomment and Change lines as shown below ##
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24
[...]


source: http://www.howtoforge.com/nagios-installation-on-ubuntu-10.04-lucid-lynx-p3

source: https://support.nagios.com/forum/viewtopic.php?f=7&t=29198
source: https://www.unixmen.com/how-to-install-nagios-core-4-1-1-in-ubuntu-15-10/