Sunday, December 17, 2017

Powershell 101: Process Start Time

Ever wondered how you check the process start time in Windows ?

 Use Powershell !

 Command:

 Get-Process | select name, starttime

Thursday, October 26, 2017

OSX Tips and Trick : Telnet

Told myself I would eventually try out this system and voila. I’m in the bandwagon of MacOS X: High Sierra. The transition between operating system is easy for me without much hiccup except the UNIX file system and the number of application available. I must say as compared to Windows, OSX is built around the user interface and user experience. Fluidity is one thing that was lacking in Windows and they are trying to catch up in Windows 10, it’s definitely a long gap since Windows Longhorn. Now I have Windows 10 as my workhorse and Mac for my content creation and development. One reason for my transition was also about Citrix VDI or virtual desktop which sounds super cool haha. Let’s straight to the point. I’ve seen people asking or complaining about the removal of telnet from MacOS in High Sierra. Removal of telnet was chaos for system administrator but no worries because there’s an alternative for it. NetCat, I bet a lot of people never use it and it was really good. Yes, start using nc and stop complaining the removal of telnet. The removal was likely due to the transition of OS to 64-it based and I don’t think they will put it back even if there’s petition or complaints since nc does everything telnet do and better in all sort of way.

Thursday, October 19, 2017

IT Infrastructure Monitor with Nagios

Difficulty Level : 4 out of 5 
Ever heard of Nagios, Zabbix, Cacti or even Icinga? If I name it, you probably heard it. These are the famous monitoring tools for IT Infrastructure today and, majority of them are built for one intention, to monitor your infrastructure be it Servers, Network Switches and Routers or even printers. They are really famous out there because they are actually free or licensed under GPL/GNU GPL which means you can actually study, share or even improve it should you have the capability to do so.

The topic I cover today would be Nagios Core IV, do not get confused with another product Nagios XI, in fact both of them are by the same developer and one is intended for enterprise that pays and it is not cheap though. It is ever important skill for an IT professionals to learn about the implementation of these tool into their existing system, remember that the monitoring can always be automated in any day now but the implementation will be not at any time now.

 Have a look at the link below should you want to know more about what Nagios XI offers. https://www.nagios.org/downloads/nagios-core/



 I would say Nagios Core itself is suffice for majority of the system administrator out there and Nagios XI would be the icing on top of the cake as it provides better interfaces and report functionality and of course the support.

I have made this guide into 7 steps, the topic will covers the installation of Nagios CORE, Nagios Plugin (the library of feature for the CORE) and NRPE plugins (the plugin used for monitoring).


Step 1 :
Prepare your server you want Nagios CORE to be installed with. Make sure the server come ready with LAMP (Linux, Apache, MySQL, PHP). You can install of of them by using yum install for Red-Hat/Centos or apt-get for Debian/Ubuntu.
i. Create a user 'nagios'
- sudo useradd nagios
ii. Create a group 'nagcmd'
- sudo groupadd nagcmd
iii. Make the user part of the group created

- sudo usermod -a -G nagcmd nagios

* For learners, I suggest you to build the LAMP stack on your own local machine. Should you need any guidance in it please write in to me and I will try to help you out. You may run it in virtual machine as well with VMWare Workstation Player.

Step 2 :
Before we go for Nagios installation, make sure we have all the dependencies needed for NagiosCore (NC). The usual requirement for NC is as follow :
build-essential libgd2-xpm-dev openssl libssl-dev xinetd apache2-utils unzip
- You can use yum or apt-get to install them
* Some people may experience problem running yum or apt-get. Do not worry, it is likely that your network is blocked with a firewall or even your school or company is blocking them. Try to use proxy instead and do Google it out. 

Step 3 :
Installing NagiosCORE. Start by downloading NagiosCORE from the link below :
Just get any latest version you can find and of course like all Linux admin does, choose the [Stable] one.
Extract the NagiosCore in a directory (temporary for installation use)
- tar xvf nagios-*.tar.gz
Change to the directory
- cd nagios-*

Set up Email server before using Nagios
You can use PostFix / EXIM or SMTP  servers. I recommend you use PostFix (/usr/bin/mail) for the ease of mind. Same thing you can install it by using yum install mailutils or apt-get install mailutils.

Lets build the configuration file by running the command below, you can see I added a parameter '--with-mail=/usr/sbin/sendmail' because i wanted to use PostFix, remove it or change it if you wanna use the other one.

- ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-mail=/usr/sbin/sendmail

After configuration is done the script actually generates some file inside this directory with all the configuration specified. You can run this next to compile them.

- make all

This will compile the NagiosCore. Next we need to initiate all the Nagios script by running the command below :
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
sudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf
Depending on your apache group and user. You will next need to set the apache user to the group of nagios by running the following :

- sudo usermod -G nagcmd
www-datawww-data is for my vanilla Apache2 ... It might be different in your environment and do check them out. 

Step 4 :
Installing Nagios Plugin
Just like step 3, we download the Nagios Plugin this time round. You can use curl -L -O or wget. Its up to you.
Extract it
- tar xvf nagios-plugins-*.tar.gz
Change to the directory
- cd nagios-plugins-*
Configure the plugin
- ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
(This will configure the nagios plugin with the nagios user and their group)
Compile it
- make
Install It
- sudo make install 
Its done for plugin, PLUGIN is not for monitoring yet. Plugin is just the library for the NagiosCORE. Next we talk about NRPE or the monitoring part..

Step 5
Installing NRPE
NRPE is the part used by NagiosCore for monitoring the server. In this scenario, we will setup the NC to monitor ourself (localhost). Just like Step 3 and Step 4, download the NRPE from the link in a temporary directory u want.

 Same thing, lets get the latest and stable

Extract it
- tar xvf nrpe-*.tar.gz
Change to Directory
- cd nrpe-*

Configure it
- ./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

Build and Compile
make all
sudo make install
sudo make install-xinetd
sudo make install-daemon-config

Let's modify the xinetd file after that, you might need to install xinetd yourself in case you dont see one. Can be done with yum or apt-get. Xinetd should be at the following path :
sudo nano /etc/xinetd.d/nrpe

Look for the portion "only_from = [IP Address]
modify it by adding your own IP address into this section wiith (comma ,) if you want more IP.
Remember to Save and Exit it.

Restart xinetd service now with sudo service xinetd restart (systemctl might be needed if your on RHEL 7.x)

Now Nagios 4 Core , Plugin, NRPE is installed !

Step 6
Configuring Nagios now with our server environment.
Open your Nagios Configuration file for editing.
- sudo nano /usr/local/nagios/etc/nagios.cfg
Locate this section
#cfg_dir=/usr/local/nagios/etc/servers
* This is actually the path to your configuration file for Nagios to know where can I read the server configuration. Uncomment it so that nagios will be ready to use this config file. Remember to Save and Exit.
Now create a directory based on the config file path you set above. In this case :
- sudo mkdir /usr/local/nagios/etc/servers
* Remember how Exabytes set each server a config file, its for this purpose.
Next, you will configure the Contact Email for your NC
- sudo nano /usr/local/nagios/etc/objects/contacts.cfg
* Look for the section email and change it to your Email Address (default is nagios@localhost)
Next, configure the check_nrpe.
This is useful in order to check your NRPE version (the monitoring plugin). One of the service we want to monitor. You can of course ignore it if you want to.
Edit the file : - sudo nano /usr/local/nagios/etc/objects/commands.cfg
Add in the following at the end :
define command{       
command_name check_nrpe       
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
Save and Exit

Configure Apache
Yes, its lengthy process but Apache will need to be setup as well since we are using the web interface to view Nagios. (eg. www.pikachuben.com/nagios). Make sure Apache rewrite and cgi is enabled.
- sudo a2enmod rewrite
- sudo a2enmod cgi

Create a user you want to use for nagios monitoring, in my case nagiosadmin

- sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
(Put a password you can remember when it prompts you and please remember it)
 Take note if you want to use other user, you will need to modify every section in the file /usr/local/nagios/etc/cgi.cfg)

Create a symbolic link for nagios.conf to the site-enabled directory. ( This is for debian/ubuntu since the Apache works a bit different) Skip this part if your on Redhat/Centos
- sudo ln -s /etc/apache2/sites-available/nagios.conf /etc/apache2/sites-enabled/

Lets start nagios and restart apache to take effect !
- sudo service nagios start
- sudo service apache2 restart

To setup NAgios to start when boot
_ sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Basically your Nagios is ready to kick now, you can access to pikachuben.com/nagios and try to login now !

For Redhat / Centos
- You do not need to make site-available symbolic link actually since Apache works differently in Centos/Redhat. Just run the following :

- sudo systemctl daemon-reload
- sudo systemctl start nagios.service
- sudo systemctl restart httpd.service

To make nagios start during boot
- sudo chkconfig nagios on

Done for RedHat !

Step 7
Monitoring a remote Host
Go to the server  you want to monitor. Install both the following with yum or apt-get
- nagios-plugins
- nagios-nrpe-server

Modify the following file after the installation above.
sudo nano /etc/nagios/nrpe.cfg
Find this section "allowed_host"
Add in the IP address of your remote server like this allowed_hosts=127.0.0.1,[Your_NAGIOSCORE_IP_ADDRESS]
Save and Exit
Now lets try to monitor the disk !
type this
- df -h /
You will see your disk name most likely /dev/vda or /dev/sda or others.
Open up this file /etc/nagios/nrpe.cfg
Look for these section : server_address / allowed_hosts / command[check_hda1]
Change the /dev/hda1 to the disk name above where u see ur actual disk name is. Do not change the front part [check_hda1].
Change the server_address to your own server IP address (your current server IP not the nagios core server)
Change the allowed_hosts to your NAGIOS CORE server IP address.
 After that, restart the NRPE by using
sudo service nagios-nre-server restart
You probably ask what are you doing now. To make it simple to understand, you are actually creating a NRPE plugin for the server right now. This command can then be called from the main NAGIOS core server which will be explained next. Some feature do not need these custom call at all. PING is special you don't need to set it up. Others yes like HTTPD, EXIM etc etc.

NOW you will need to go to your NAGIOS Core server and setup the monitoring based on what you have done in the host server (host = the server you want to monitor and the NRPE you just setup there)
- Go to the following path :
/usr/local/nagios/etc/servers/
* Remember this path we created early on for the preparation of any future server? Now you will use it.
Create a cfg file here, use the server name which you are monitoring for more convenient, you can use anything though. In my case, theorionsbelt.cfg
Add the following into it
define host {
use                             linux-server       
host_name                       [Your_remoteserver_name]     
alias                           [Just a name for your remote server]     
address                         [Remote server IP Address]       
max_check_attempts              5       
check_period                    24x7       
notification_interval           30       
notification_period             24x7
}

This portion is needed because it will define which is the remote host you wanna monitor. Look at the parameter. You need to modify it based on what the remote server is.
Take note that the notification interval and period controls how frequent the notification is being sent out. 
If you want to monitor Ping, you can add the following line on the bottom of the same file
define service {       
use                             generic-service       
host_name                       yourhost       
service_description             PING       
check_command                   check_ping!100.0,20%!500.0,60%
}
This will monitor Ping

Remember the NRPE we made just now ? You can build the same thing here creating a new function based on it.
define service {       
use                             generic-service      
host_name                       yourhost      
service_description             PING      
check_command                   check_nrpe!checkhda1
}
Notice the check_command section follow by check_nrpe
Do not modify check_command.
check_nrpe is used to initiate to tell core to go and look for the nrpe.cfg file in the remote server, then check_hda to tell the core to look at the command for check_hda1 which I tell you not to change it earlier on.
To take effect after the change, you just restart it with sudo service nagios reload
Login to your web interface next and VOILA ... Ping and DISK monitoring is there !!!!
MISSION ACCOMPLISHED !
For windows monitoring you need NSClient++

The post have no image yet, will most likely upload them soon. I used to work with a company running on Nagios system and the reliability of this software is definitely good. Majority of my work today covers in Compute Virtualization. As a system administrator or system architect, it is always crucial for you to setup monitoring tools for your subordinates and the team.

Prepared and written by Ruben.Rubin.Ruban.Reuben.Rubun(?).


Monday, September 4, 2017

05.09.2017: Updates

--
Past

It's been sometime I haven't update anything or write anything. Not even doing any updates on my Part 2 of web hosting guide. The intention of writing it initially was just to create mark for myself to remember my first ever office job in a web hosting company and a guide for anyone that visited the site. At least when I read through it something was there for me to think of it.

Its already 2 months I work in a new place, there were a lot of memories and people in my previous workplace which was one of the motivation that keeps my adrenaline pumping. I knew the job was definitely making me lazy and kills my progression. It's probably a good time for me to quit it and try out a new place. The feeling was heavy and was definitely a hard decision for me, this workplace was like my second home and the people are like my family.

I still remember staying up late due to the nature of shift work, staying alone in office with one of my best pal J/G/A/M/Az and the most loudest person M. We both will laughs like madness in late hours because the whole office is empty and you know empty offices are damn scary. My favorite part of the work is to wake early and to start working especially from home or even office. The environment changes last year, people start working on their own matters and I find myself really out of reach to an extent I find myself bored and start losing my passion in the work. Multiple times I requested to move somewhere I could at least do more but it always fail. I was not even trying hard to convince my bosses though, my fault on it.

There was always an intense memories whenever I walk through my previous desk. I was allocated to the very corner of the office nearing the door, leading to the door is pantry. Whenever someone heats their food, I will smell it. Cups and tumblers is always on my table and I was like the traffic police whenever someone does not have their access card (because the door is locked with security). I still remember someone breaks my mug in the first week. I cant find it and its important to me, I don't think I will ever find it again. I always place sweets on my table but it always gone missing (a perk for sitting near the door). I was soon being moved to a new place when I was being transferred to another team, another story begins. A bunch of interns, a bunch of newbies, a bunch of lovely people. A story full of ups and downs probably leads to the event today.

In my last day of work, there was a weird feeling inside me. Suddenly I felt like I am all alone, my seniors and my juniors celebrated my farewell. Hours and hours past until the end of work, people start going home. My friends all volunteered to help me out in packing and sending me out (it is like moment of judgement). Some touchy message appeared and they really make me burst out of tear. 'Thank you Akka' is the only words I can said.

I will revisit the place one day for sure !

--
Today

I am working in a new place, starting back my phase of learning sparking up my passion again. Its funny how when you have accepted a job and all the other company you interviewed called you and said you have been accepted as well (too bad, next time). Start as a junior picking up things I haven't learn before, proving my capability, upgrading myself with more knowledge, communicates with new people. Its hell of a hefty job to do, I used to work with people inside a small office but now with a factory of global scale. Tough but manageable. A lot of things going in my mind all the time but I couldn't care less but to work. At least it kills my time and kills all my unfruitful thoughts.

Picking up my hobby I used to drop out, my dad likes to take photo as well but I knew he kept a camera to the point it broken, its based on the 35mm film type (Leica-ish camera). I knew he work hard throughout his life to the point he never have anytime to actually enjoyed what he likes to do. I knew I should not be like that, pick up my camera and start learning from the scratch again. Its no easy task to learn composition, exposure, processing, subject, and etc. But at least its fun, knowing you got a machine in your hand that creates memories that last forever the way you wanted it to be. It is a very expensive hobby though, lens cost at least a thousand and sometimes ten thousands. But you know, guys like expensive toys.

Been doing some electronic stuff as well especially IoT stuff and some computer modding as well. They really kills a lot of your time. Start my competitive gaming session again now. But I don't find gaming to be amusing nowadays anymore but a temporal relieve. Tried cooking as well and I am kinda in love with it. I always tell my mom, people who cooks is the magician in the house and my mom was probably the Houdini of my house. Remember, our parents are getting older day by day.. spend time with them now and start from an hour now, you will never regret of it. Not only that, spend more time with the people you love you cherish for, every moments you build make it a mark not a scar, a smile in their face is worth more than ten thousand words, cheer up the day for you and for them.

--
End

Learn from a Japanese: Love is not business, it doesn't trade. It worth zero values, never expect return when you give. When you give, you give it from deep inside your heart; when you receive, you receive it with full gratitude. Because if love is a business is a trade, it means you are replaceable, it means you expect return when you give. It is wrong because you should believe you are one and only irreplaceable, you are destined to bring changes to people, you bring joy to people. It is not creating the fire that is hard, the hardest thing is to keep the fire alive throughout your life be it small or big.
P/S: No images for the post plus I am sleepy as h...

 Peace Out. Until next time.
Choo Choo ... Im out ...

WongWian Yai station, Bangkok

Extra: I actually likes train a lot. 

Wednesday, May 10, 2017

Tech Tips: Disabling Windows Update

Everybody probably trying to look for how to or even you ask why do you need to switch off Windows Update in the first place. You are probably running on Windows 10 if you have stumble upon this post and ever since Windows 10 is introduced, it is something pain in the arse for users with limited network bandwidth or someone in urgent to use of full network bandwidth.

Some people even asked, why is my Internet getting freaking-slow after Windows 10. Yes, the answer is clear, Windows Update. Microsoft have decided to let the service to go autopilot and you probably see they run almost every time you start up your machine. Wicked or Mindful? Ask Microsoft. 

Lets get to the point !

Step 1:


- Click/Touch/Press on your Start key
- Type in 'services'
- Click on the 'Services' with a cogwheel logo

Step 2:

- Find Windows Update, right click on it and click Stop
- Do the same for another service 'Background Intelligent Transfer Service' as well.

BITS is used since early windows to utilize idle network bandwidth for downloading the Windows Update, exposed through COM and can be utilized in other way. More information for the COM can be found here.
https://www.codeproject.com/Articles/17639/Using-the-Background-Intelligent-Transfer-Service

Step 3:
Actually your done. But just in case do check your network bandwidth by right clicking on the taskbar and open up your task manager.




This step actually suspend the Windows Update process and they will resume when you reboot.

SUPER SIMPLE MODE.
1. Launch command prompt in administrator
2. Copy this and throw them into your CMD
- net stop wuauserv
- net stop bits

Extra Tips :
If you are running on WiFi, you can just follow this :

Search for "Change Wi-Fi settings", click on Advanced Options, enable the Metered Connection.

This will delay the updates until you decide to turn it off again.

END

* I do not actually recommend you to turn off Windows Update permanently but this is just a temporary solution in case you need it. Windows Update are a crucial element of Windows itself and updating Windows to the latest one is always recommended. Security wise, stability wise. 

Netezza Administration : Getting each Database size

Run query ! Just like MAGIC ! - SELECT current_timestamp AS SAMPLE_TIME        ,t. database AS DATABASE_NAME        , round(nvl (...