Automatic Update phpipam hostname and mac address

#!/usr/bin/perl

# Script for update hostname and mac address using nbtscan
# Requirement : perl and nbtscan dbi and net:IPAddress
# By : s.suyanto@gmail.com
# Add to crontab to update periodically
# NEED libnet-address-ip-local-perl
# update-ipam.pl

use DBI;
use Net::IPAddress;
require “/usr/bin/Konfig.pl”;

print “content-type: text/html \n\n”;

#system($dumpipcmd);

# system(“nbtscan -s = 192.168.0.0/16 > /usr/bin/macaddress.txt “);

my $dbh = DBI->connect(“dbi:mysql:$database:$host:3306”, $user, $pw);

$UNIXFILE = “/usr/bin/macaddress.txt”;
open(UNIXFILE) or die(“Could not open UNIX FILE.”);
foreach $line () {
($ip,$nama,$server,$desc,$mac)=split(/\=/ ,$line);
$macaddr = trim(“$mac”);
$ipaddr = trim(“$ip”);
$sysname = trim(“$nama”);
if ( $macaddr !~ ” ” ) {
#printf “$macaddr\n”;
$titik=1;
$baris=””;
@mac = split(/:/, $macaddr);
foreach $macall (@mac) {
if ($titik==2 || $titik==4) {
$baris=”$baris$macall.”;
}
else {
$baris=”$baris$macall”;
}
$titik=$titik+1;
}
$titik=1;
}
$ipnum = ip2num(“$ipaddr”);
printf “$ipnum : $ipaddr : $macaddr : $baris : $sysname \n “;
my $sth = $dbh->prepare(“UPDATE ipaddresses SET dns_name=’$sysname’, mac=’$macaddr’ WHERE ip_addr=’$ipnum'”);
$sth->execute();
}
close(UNIXFILE);
$dbh->disconnect();

================
konfig.pl
===================
#!/usr/bin/perl;

# MYSQL CONFIG VARIABLES 1
$host = “localhost”;
$database = “databasename”;
$user = “username”;
$pw = “password”;

sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

Quote

Menambahkan otomatis kedalam icinga .

#!/usr/bin/perl
# dijalankan tiap hari berdasarkan crontab daily

use DBI;
require “/etc/icinga/Konfig.pl”;
print “content-type: text/html \n\n”; #The header

my $filename = ‘/etc/icinga/rekind/hosts.cfg’;
open(my $fh, ‘>’, $filename) or die “Could not open file ‘$filename’ $!”;

my $dbh2 = DBI->connect(“dbi:mysql:$database2:$host2:3306”, $user2, $pw2);
my $sth2 = $dbh2->prepare(“SELECT device,devip,serial,location,type,description FROM devices”);
$sth2->execute();

$sth2->bind_columns(undef, \$device, \$devip,\$serial,\$location,\$type,\$description);

while($sth2->fetch()) {

$ipaddr=dec2dot($devip);

print $fh “define host{\n”;
print $fh ” use generic-switch\n”;
print $fh ” host_name $device\n”;
print $fh ” alias $device\n”;
print $fh ” address $ipaddr \n”;
print $fh ” hostgroups all \n”;
print $fh ” }\n”;
print $fh ” \n”;
print $fh ” define service{\n”;
print $fh ” use generic-service \n”;
print $fh ” host_name $device\n”;
print $fh ” service_description PING\n”;
print $fh ” check_command check_ping!200.0,20%!600.0,60%\n”;
print $fh ” check_interval 5 \n”;
print $fh ” retry_interval 1\n”;
print $fh ” }\n”;

}

close (HTML);
$dbh2->disconnect();

Menambahkan otomatis kedalam icinga

Stack Cisco Tips

Tips to Add a Switch as a Slave to the Stack

To add a switch, as a slave, to a stack, complete these steps:

Note: Make sure the switch that you add into the stack has the same IOS version as the switches in the stack. Refer to to upgrade the IOS in a catalyst 3750 switch.

  1. Change the switch priority of the switch to be added to “1”.switch stack-member-number priority new-priority-value Note: This step is optional, but it will make sure that the switch has fewer chances to become a stackmaster in the future.
  2. Power off the switch that is to be added.
  3. Make sure that the stack is fully connected so that, when you connect the new switch, the stack will be at least in half connectivity and does not partition.
  4. Connect the new switch to the stack with the StackWise ports.
  5. Power on the newly added switch.
  6. After the new switch comes up, issue the command show switch to verify stack membership.

 

Source : http://www.cisco.com/c/en/us/support/docs/switches/catalyst-3750-series-switches/71925-cat3750-create-switch-stks.html#anc11

Quote

conf t
ip access-list extended UDP-DDOS
permit udp any any
exit

class-map match-all UDP
match access-group name UDP-DDOS
policy-map 1.0
class UDP
police 1024000 conform-action transmit exceed-action drop
exit
control-plane
service-policy input 1.0
end
wr mem

show policy-map control-plane

Limit UDP On Cisco using policy Map

Port Whatsap

TCP /UDP 4244,5222,5223,5228,5242,5060,5064,59234,50318,8080

UDP : 3478, 45395

By yans008 Posted in Uncategorized

Mikrotik grep dns

# List name
:local LISTNAME “FACEBOOK”
# Check DNS entries and collect matching names
:foreach i in=[/ip dns cache all find where (name ~”facebook.com” || name ~”fbcd.net” || name ~”facebook.net”) && (type=”A”) ] do={
# Get IP Address from the names and hold it in temporary buffer
:local Buffer [/ip dns cache get $i address];
delay delay-time=10ms
# Check if entry is already not exists, then OK, otherwise ignore duplication
:if ( [/ip firewall address-list find where address=$Buffer] = “”) do={
# Fetch DNS names for the entries
:local sitednsname [/ip dns cache get $i name] ;
# Print name in LOG window
:log info (“added entry: $sitednsname $Buffer”);
# Add IP addresses and there names to the address list
/ip firewall address-list add address=$Buffer list=$LISTNAME comment=$sitednsname;
}
}

#YOUTUBE
# List name
:local LISTNAME “YOUTUBE”
# Check DNS entries and collect matching names
:foreach i in=[/ip dns cache all find where (name ~”1e100″ || name ~”twitter” || name ~”instagram” || name ~”.dynect.net” || name ~”video” || name ~”ytimg” || name ~”youtube” || name ~”googlevideo”) && (type=”A”) ] do={
# Get IP Address from the names and hold it in temporary buffer
:local Buffer [/ip dns cache get $i address];
delay delay-time=10ms
# Check if entry is already not exists, then OK, otherwise ignore duplication
:if ( [/ip firewall address-list find where address=$Buffer] = “”) do={
# Fetch DNS names for the entries
:local sitednsname [/ip dns cache get $i name] ;
# Print name in LOG window
:log info (“added entry: $sitednsname $Buffer”);
# Add IP addresses and there names to the address list
/ip firewall address-list add address=$Buffer list=$LISTNAME comment=$sitednsname;
}
}

# List name
:local LISTNAME “LINKED”
# Check DNS entries and collect matching names
:foreach i in=[/ip dns cache all find where (name ~”licdn” || name ~”linkedin”) && (type=”A”) ] do={
# Get IP Address from the names and hold it in temporary buffer
:local Buffer [/ip dns cache get $i address];
delay delay-time=10ms
# Check if entry is already not exists, then OK, otherwise ignore duplication
:if ( [/ip firewall address-list find where address=$Buffer] = “”) do={
# Fetch DNS names for the entries
:local sitednsname [/ip dns cache get $i name] ;
# Print name in LOG window
:log info (“added entry: $sitednsname $Buffer”);
# Add IP addresses and there names to the address list
/ip firewall address-list add address=$Buffer list=$LISTNAME comment=$sitednsname;
}
}

Gluster distribute replicate

Trial GlusterFS distributed (replicated) volume with a two-way mirror (Mode High Availability 2, 4, 6, 8)
=======================================================================

1. INSTALL DEBIAN JESSIE (DEBIAN 8) DENGAN STANDARD SYSTEM (NON DESKTOP)
2. Setting nama domain dan hostname
3. Pada Gluster Server 1, 2 dst
wget -O – http://download.gluster.org/pub/gluster/glusterfs/LATEST/rsa.pub | apt-key add –
echo deb http://kambing.ui.ac.id/debian/ jessie main > /etc/apt/sources.list.d/kambing.list
echo deb http://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/jessie/apt jessie main > /etc/apt/sources.list.d/gluster.list
apt-get update
apt-get install glusterfs-server

4. Probe server
gluster peer probe server2.example.com
gluster peer probe server3.example.com
gluster peer probe server4.example.com
dst.

5. gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
Trial install Client Gluster
========================================================
1. INSTALL DEBIAN JESSIE (DEBIAN 8) DENGAN STANDARD SYSTEM (NON DESKTOP)
=====================

wget -O – http://download.gluster.org/pub/gluster/glusterfs/LATEST/rsa.pub | apt-key add –
echo deb http://kambing.ui.ac.id/debian/ jessie main > /etc/apt/sources.list.d/kambing.list
echo deb http://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/jessie/apt jessie main > /etc/apt/sources.list.d/gluster.list
apt-get update
apt-get -y install glusterfs-client
mkdir /mnt/glusterfs
mount.glusterfs server1.example.com:/testvol /mnt/glusterfs
mount

By yans008 Posted in Uncategorized

Manual ownCloud Upgrade

Manual ownCloud Upgrade

Always start by making a fresh backup and disabling all 3rd party apps.

Put your server in maintenance mode. This prevents new logins, locks the sessions of logged-in users, and displays a status screen so users know what is happening. There are two ways to do this, and the preferred method is to use theocc command, which you must run as your HTTP user. This example is for Ubuntu Linux:

sudo -u www-data php occ maintenance:mode --on

The other way is by entering your config.php file and changing 'maintenance' => false, to 'maintenance' =>true,.

  1. Back up your existing ownCloud Server database, data directory, and config.php file. (See Backing up ownCloud.)

  2. Download and unpack the latest ownCloud Server release (Archive file) from owncloud.org/install/ into an empty directory outside of your current installation.

    To unpack your new tarball, run: tar xjf owncloud-[version].tar.bz2

Enterprise users must download their new ownCloud archives from their accounts onhttps://customer.owncloud.com/owncloud/

  1. Stop your Web server.

  2. Rename your current ownCloud directory, for example owncloud-old.

  3. Unpacking the new archive creates a new owncloud directory populated with your new server files. Copy this directory and its contents to the original location of your old server, for example /var/www/, so that once again you have /var/www/owncloud.

  4. Copy the config.php file from your old ownCloud directory to your new ownCloud directory.

  5. If you keep your data/ directory in your owncloud/ directory, copy it from your old version of ownCloud to your new owncloud/. If you keep it outside of owncloud/ then you don’t have to do anything with it, because its location is configured in your original config.php, and none of the upgrade steps touch it.

  6. If you are using 3rd party applications, look in your new owncloud/apps/ directory to see if they are there. If not, copy them from your old apps/ directory to your new one. Make sure the directory permissions of your third party application directories are the same as for the other ones.

  7. Restart your Web server.

  8. Now launch the upgrade from the command line using occ, like this example on CentOS Linux:

    sudo -u apache php occ upgrade
    
  9. The upgrade operation takes a few minutes to a few hours, depending on the size of your installation. When it is finished you will see a success message, or an error message that will tell where it went wrong.

Assuming your upgrade succeeded, disable the maintenance mode:

sudo -u www-data php occ maintenance:mode --off

Login and take a look at the bottom of your Admin page to verify the version number. Check your other settings to make sure they’re correct. Go to the Apps page and review the core apps to make sure the right ones are enabled. Re-enable your third-party apps. Then apply strong permissions to your ownCloud directories (Setting Strong Directory Permissions).

 sumber : https://doc.owncloud.org/server/9.0/admin_manual/maintenance/manual_upgrade.html
By yans008 Posted in Uncategorized

Backing up ownCloud

Backing up ownCloud

To backup an ownCloud installation there are three main things you need to retain:

  1. The config folder
  2. The data folder
  3. The database

Backup Folders

Simply copy your config and data folder (or even your whole ownCloud install and data folder) to a place outside of your ownCloud environment. You could use this command:

rsync -Aax owncloud/ owncloud-dirbkp_`date +"%Y%m%d"`/

Backup Database

MySQL/MariaDB

MySQL or MariaDB, which is a drop-in MySQL replacement, is the recommended database engine. To backup MySQL/MariaDB:

mysqldump --lock-tables -h [server] -u [username] -p[password] [db_name] > owncloud-sqlbkp_`date +"%Y%m%d"`.bak

SQLite

sqlite3 data/owncloud.db .dump > owncloud-sqlbkp_`date +"%Y%m%d"`.bak

PostgreSQL

PGPASSWORD="password" pg_dump [db_name] -h [server] -U [username] -f owncloud-sqlbkp_`date +"%Y%m%d"`.bak

sumber : https://doc.owncloud.org/server/9.0/admin_manual/maintenance/backup.html
By yans008 Posted in Uncategorized

ISPCONFIG Password store

ISPConfig 3 has two different configuration files, one for the server part and one for the interface.

Interface:

/usr/local/ispconfig/interface/lib/config.inc.php

Server:

/usr/local/ispconfig/server/lib/config.inc.php

The mysql root password which is only used to create new mysql databases is stored in the file:

/usr/local/ispconfig/server/lib/mysql_clientdb.conf