How to Install SNMP service on CentOS 7

Install SNMP service on CentOS 7

Check if the package is already installed

rpm -qa | grep net-snmp*

install the package

yum install net-snmp net-snmp-utils –y

verify installation

rpm -qa | grep net-snmp*

display SNMP configuration file without comments

grep -v “^$” /etc/snmp/snmpd.conf | grep -v ‘^ *#’

Firewall Configuration – Open UDP Port

firewall-cmd –permanent –add-port=161/udp

Firewall Configuration – Reload

firewall-cmd –reload

Firewall Configuration – List

firewall-cmd –list-all

starts SNMP service

systemctl start snmpd

snmpwalk – localhost Query

snmpwalk -v 1 -c public -O e 127.0.0.1

snmpwalk – Remote Query

snmpwalk -v 1 -c public -O e 192.168.1.7

Enable the service to start at boot and start automatically

systemctl enable snmpd

fix cacti can’t get information from SNMP

The problem resides in the permissions for SNMP version 1 users in the /etc/snmp/snmpd.conf file

You need to change the following limits:
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1

to:
view systemview included .1.3.6.1.2.1
view systemview included .1.3.6.1.2.1.25.1.1 

How To Configure BIND as a Private Network DNS Server on CentOS 7

How To Configure BIND as a Private Network DNS Server on CentOS 7

Introduction

An important part of managing server configuration and infrastructure includes maintaining an easy way to look up network interfaces and IP addresses by name, by setting up a proper Domain Name System (DNS). Using fully qualified domain names (FQDNs), instead of IP addresses, to specify network addresses eases the configuration of services and applications, and increases the maintainability of configuration files. Setting up your own DNS for your private network is a great way to improve the management of your servers.

In this tutorial, we will go over how to set up an internal DNS server, using the BIND name server software (BIND9) on CentOS 7, that can be used by your Virtual Private Servers (VPS) to resolve private host names and private IP addresses. This provides a central way to manage your internal hostnames and private IP addresses, which is indispensable when your environment expands to more than a few hosts.

Prerequisites

To complete this tutorial, you will need the following:

  • Some servers that are running in the same datacenter and have private networking enabled
  • A new VPS to serve as the Primary DNS server, ns1
  • Optional: A new VPS to serve as a Secondary DNS server, ns2
  • Root access to all of the above.

Example Hosts

For example purposes, we will assume the following:

  • We have two existing VPS called “host1” and “host2”
  • Both VPS exist in the nyc3 datacenter
  • Both VPS have private networking enabled (and are on the 10.128.0.0/16 subnet)
  • Both VPS are somehow related to our web application that runs on “example.com”

With these assumptions, we decide that it makes sense to use a naming scheme that uses “nyc3.example.com” to refer to our private subnet or zone. Therefore, host1‘s private Fully-Qualified Domain Name (FQDN) will be “host1.nyc3.example.com”. Refer to the following table the relevant details:

Host Role Private FQDN Private IP Address
host1 Generic Host 1 host1.nyc3.example.com 10.128.100.101
host2 Generic Host 2 host2.nyc3.example.com 10.128.200.102

Note: Your existing setup will be different, but the example names and IP addresses will be used to demonstrate how to configure a DNS server to provide a functioning internal DNS. You should be able to easily adapt this setup to your own environment by replacing the host names and private IP addresses with your own. It is not necessary to use the region name of the datacenter in your naming scheme, but we use it here to denote that these hosts belong to a particular datacenter’s private network. If you utilize multiple datacenters, you can set up an internal DNS within each respective datacenter.

Our Goal

By the end of this tutorial, we will have a primary DNS server, ns1, and optionally a secondary DNS server,ns2, which will serve as a backup.

Here is a table with example names and IP addresses:

Host Role Private FQDN Private IP Address
ns1 Primary DNS Server ns1.nyc3.example.com 10.128.10.11
ns2 Secondary DNS Server ns2.nyc3.example.com 10.128.20.12

Let’s get started by installing our Primary DNS server, ns1.

Install BIND on DNS Servers

Note: Text that is highlighted in red is important! It will often be used to denote something that needs to be replaced with your own settings or that it should be modified or added to a configuration file. For example, if you see something like host1.nyc3.example.com, replace it with the FQDN of your own server. Likewise, if you see host1_private_IP, replace it with the private IP address of your own server.

On both DNS servers, ns1 and ns2, install BIND with yum:

  • sudo yum install bind bind-utils

Confirm the prompt by entering y.

Now that BIND is installed, let’s configure the primary DNS server.

Configure Primary DNS Server

BIND’s configuration consists of multiple files, which are included from the main configuration file,named.conf. These filenames begin with “named” because that is the name of the process that BIND runs. We will start with configuring the options file.

Configure Bind

BIND’s process is known as named. As such, many of the files refer to “named” instead of “BIND”.

On ns1, open the named.conf file for editing:

  • sudo vi /etc/named.conf

Above the existing options block, create a new ACL block called “trusted”. This is where we will define list of clients that we will allow recursive DNS queries from (i.e. your servers that are in the same datacenter as ns1). Using our example private IP addresses, we will add ns1ns2host1, and host2 to our list of trusted clients:

/etc/named.conf — 1 of 4

acl “trusted” {

10.128.10.11;    # ns1 – can be set to localhost

10.128.20.12;    # ns2

10.128.100.101;  # host1

10.128.200.102;  # host2

};

Now that we have our list of trusted DNS clients, we will want to edit the options block. Add the private IP address of ns1 to the listen-on port 53 directive, and comment out the listen-on-v6 line:

/etc/named.conf — 2 of 4

options {

listen-on port 53 { 127.0.0.1; 10.128.10.11; };

#        listen-on-v6 port 53 { ::1; };

Below those entries, change the allow-transfer directive to from “none” to ns2‘s private IP address. Also, change allow-query directive from “localhost” to “trusted”:

/etc/named.conf — 3 of 4

options {

allow-transfer { 10.128.20.12; };      # disable zone transfers by default

allow-query { trusted; };  # allows queries from “trusted” clients

At the end of the file, add the following line:

/etc/named.conf — 4 of 4

include “/etc/named/named.conf.local”;

Now save and exit named.conf. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.

Next, we will configure the local file, to specify our DNS zones.

Configure Local File

On ns1, open the named.conf.local file for editing:

  • sudo vi /etc/named/named.conf.local

The file should be empty. Here, we will specify our forward and reverse zones.

Add the forward zone with the following lines (substitute the zone name with your own):

/etc/named/named.conf.local — 1 of 2

zone “nyc3.example.com” {

type master;

file “/etc/named/zones/db.nyc3.example.com”; # zone file path

};

Assuming that our private subnet is 10.128.0.0/16, add the reverse zone by with the following lines (note that our reverse zone name starts with “128.10” which is the octet reversal of “10.128”):

/etc/named/named.conf.local — 2 of 2

zone “128.10.in-addr.arpa” {

type master;

file “/etc/named/zones/db.10.128”;  # 10.128.0.0/16 subnet

};

If your servers span multiple private subnets but are in the same datacenter, be sure to specify an additional zone and zone file for each distinct subnet. When you are finished adding all of your desired zones, save and exit the named.conf.local file.

Now that our zones are specified in BIND, we need to create the corresponding forward and reverse zone files.

Create Forward Zone File

The forward zone file is where we define DNS records for forward DNS lookups. That is, when the DNS receives a name query, “host1.nyc3.example.com” for example, it will look in the forward zone file to resolve host1‘s corresponding private IP address.

Let’s create the directory where our zone files will reside. According to our named.conf.local configuration, that location should be /etc/named/zones:

  • sudo chmod 755 /etc/named
  • sudo mkdir /etc/named/zones

Now let’s edit our forward zone file:

  • sudo vi /etc/named/zones/db.example.com

First, you will want to add the SOA record. Replace the highlighted ns1 FQDN with your own FQDN, then replace the second “nyc3.example.com” with your own domain. Every time you edit a zone file, you should increment the serial value before you restart the named process–we will increment it to “3”. It should look something like this:

/etc/named/zones/db.nyc3.example.com — 1 of 3

@       IN      SOA     ns1.nyc3.example.com. admin.nyc3.example.com. (

3         ; Serial

604800     ; Refresh

86400     ; Retry

2419200     ; Expire

604800 )   ; Negative Cache TTL

After that, add your nameserver records with the following lines (replace the names with your own). Note that the second column specifies that these are “NS” records:

/etc/named/zones/db.nyc3.example.com — 2 of 3

; name servers – NS records

IN      NS      ns1.nyc3.example.com.

IN      NS      ns2.nyc3.example.com.

Then add the A records for your hosts that belong in this zone. This includes any server whose name we want to end with “.nyc3.example.com” (substitute the names and private IP addresses). Using our example names and private IP addresses, we will add A records for ns1ns2host1, and host2 like so:

/etc/named/zones/db.nyc3.example.com — 3 of 3

; name servers – A records

ns1.nyc3.example.com.          IN      A       10.128.10.11

ns2.nyc3.example.com.          IN      A       10.128.20.12

 

; 10.128.0.0/16 – A records

host1.nyc3.example.com.        IN      A      10.128.100.101

host2.nyc3.example.com.        IN      A      10.128.200.102

Save and exit the db.nyc3.example.com file.

Our final example forward zone file looks like the following:

/etc/named/zones/db.nyc3.example.com — complete

  • $TTL 604800
  • @ IN      SOA     nyc3.example.com. admin.nyc3.example.com. (
  • 3       ; Serial
  • 604800     ; Refresh
  • 86400     ; Retry
  • 2419200     ; Expire
  •     604800 )   ; Negative Cache TTL
  • ;
  • ; name servers – NS records
  • IN      NS      nyc3.example.com.
  • IN      NS      nyc3.example.com.
  • ; name servers – A records
  • nyc3.example.com. IN      A       10.128.10.11
  • nyc3.example.com. IN      A       10.128.20.12
  • ; 10.128.0.0/16 – A records
  • nyc3.example.com. IN      A      10.128.100.101
  • nyc3.example.com. IN      A      10.128.200.102

Now let’s move onto the reverse zone file(s).

Create Reverse Zone File(s)

Reverse zone file are where we define DNS PTR records for reverse DNS lookups. That is, when the DNS receives a query by IP address, “10.128.100.101” for example, it will look in the reverse zone file(s) to resolve the corresponding FQDN, “host1.nyc3.example.com” in this case.

On ns1, for each reverse zone specified in the named.conf.local file, create a reverse zone file.

Edit the reverse zone file that corresponds to the reverse zone(s) defined in named.conf.local:

  • sudo vi /etc/named/zones/db.128

In the same manner as the forward zone file, replace the highlighted ns1 FQDN with your own FQDN, then replace the second “nyc3.example.com” with your own domain. Every time you edit a zone file, you should increment the serial value before you restart the named process–we will increment it to “3”. It should look something like this:

/etc/named/zones/db.10.128 — 1 of 3

@       IN      SOA     ns1.nyc3.example.com. admin.nyc3.example.com. (

3         ; Serial

604800         ; Refresh

86400         ; Retry

2419200         ; Expire

604800 )       ; Negative Cache TTL

After that, add your nameserver records with the following lines (replace the names with your own). Note that the second column specifies that these are “NS” records:

/etc/named/zones/db.10.128 — 2 of 3

; name servers – NS records

IN      NS      ns1.nyc3.example.com.

IN      NS      ns2.nyc3.example.com.

Then add PTR records for all of your servers whose IP addresses are on the subnet of the zone file that you are editing. In our example, this includes all of our hosts because they are all on the 10.128.0.0/16 subnet. Note that the first column consists of the last two octets of your servers’ private IP addresses in reversed order. Be sure to substitute names and private IP addresses to match your servers:

/etc/named/zones/db.10.128 — 3 of 3

; PTR Records

11.10   IN      PTR     ns1.nyc3.example.com.    ; 10.128.10.11

12.20   IN      PTR     ns2.nyc3.example.com.    ; 10.128.20.12

101.100 IN      PTR     host1.nyc3.example.com.  ; 10.128.100.101

102.200 IN      PTR     host2.nyc3.example.com.  ; 10.128.200.102

Save and exit the reverse zone file (repeat this section if you need to add more reverse zone files).

Our final example reverse zone file looks like the following:

/etc/named/zones/db.10.128 — complete

  • $TTL 604800
  • @ IN      SOA     example.com. admin.nyc3.example.com. (
  • 3         ; Serial
  • 604800         ; Refresh
  • 86400         ; Retry
  • 2419200         ; Expire
  • 604800 )       ; Negative Cache TTL
  • ; name servers
  • IN      NS      nyc3.example.com.
  • IN      NS      nyc3.example.com.
  • ; PTR Records
  • 10 IN      PTR     ns1.nyc3.example.com.    ; 10.128.10.11
  • 20 IN      PTR     ns2.nyc3.example.com.    ; 10.128.20.12
  • 100 IN PTR     host1.nyc3.example.com.  ; 10.128.100.101
  • 200 IN PTR     host2.nyc3.example.com.  ; 10.128.200.102

Check BIND Configuration Syntax

Run the following command to check the syntax of the named.conf* files:

  • sudo named-checkconf

If your named configuration files have no syntax errors, you will return to your shell prompt and see no error messages. If there are problems with your configuration files, review the error message and the Configure Primary DNS Server section, then try named-checkconf again.

The named-checkzone command can be used to check the correctness of your zone files. Its first argument specifies a zone name, and the second argument specifies the corresponding zone file, which are both defined in named.conf.local.

For example, to check the “nyc3.example.com” forward zone configuration, run the following command (change the names to match your forward zone and file):

  • sudo named-checkzone example.com /etc/named/zones/db.nyc3.example.com

And to check the “128.10.in-addr.arpa” reverse zone configuration, run the following command (change the numbers to match your reverse zone and file):

  • sudo named-checkzone 10.in-addr.arpa /etc/named/zones/db.10.128

When all of your configuration and zone files have no errors in them, you should be ready to restart the BIND service.

Start BIND

Start BIND:

  • sudo systemctl start named

Now you will want to enable it, so it will start on boot:

  • sudo systemctl enable named

Your primary DNS server is now setup and ready to respond to DNS queries. Let’s move on to creating the secondary DNS server.

Configure Secondary DNS Server

In most environments, it is a good idea to set up a secondary DNS server that will respond to requests if the primary becomes unavailable. Luckily, the secondary DNS server is much easier to configure.

On ns2, edit the named.conf file:

  • sudo vi /etc/named.conf

Note: If you prefer to skip these instructions, you can copy ns1‘s named.conf file and modify it to listen onns2‘s private IP address, and not allow transfers.
Above the existing options block, create a new ACL block called “trusted”. This is where we will define list of clients that we will allow recursive DNS queries from (i.e. your servers that are in the same datacenter as ns1). Using our example private IP addresses, we will add ns1ns2host1, and host2 to our list of trusted clients:

/etc/named.conf — 1 of 4

acl “trusted” {

10.128.10.11;    # ns1 – can be set to localhost

10.128.20.12;    # ns2

10.128.100.101;  # host1

10.128.200.102;  # host2

};

Now that we have our list of trusted DNS clients, we will want to edit the options block. Add the private IP address of ns1 to the listen-on port 53 directive, and comment out the listen-on-v6 line:

/etc/named.conf — 2 of 4

options {

listen-on port 53 { 127.0.0.1; 10.128.20.12; };

#        listen-on-v6 port 53 { ::1; };

Change allow-query directive from “localhost” to “trusted”:

/etc/named.conf — 3 of 4

options {

allow-query { trusted; }; # allows queries from “trusted” clients

At the end of the file, add the following line:

/etc/named.conf — 4 of 4

include “/etc/named/named.conf.local”;

Now save and exit named.conf. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.

Next, we will configure the local file, to specify our DNS zones.

Save and exit named.conf.

Now edit the named.conf.local file:

  • sudo chmod 755 /etc/named
  • sudo vi /etc/named/named.conf.local

Define slave zones that correspond to the master zones on the primary DNS server. Note that the type is “slave”, the file does not contain a path, and there is a masters directive which should be set to the primary DNS server’s private IP. If you defined multiple reverse zones in the primary DNS server, make sure to add them all here:

/etc/named/named.conf.local

  • zone “example.com” {
  • type slave;
  • file “slaves/db.example.com”;
  • masters { 128.10.11; };  # ns1 private IP
  • };
  • zone “10.in-addr.arpa” {
  • type slave;
  • file “slaves/db.128”;
  • masters { 128.10.11; };  # ns1 private IP
  • };

Now save and exit named.conf.local.

Run the following command to check the validity of your configuration files:

  • sudo named-checkconf

Once that checks out, start BIND:

  • sudo systemctl start named

Enable BIND to start on boot:

sudo systemctl enable named

Now you have primary and secondary DNS servers for private network name and IP address resolution. Now you must configure your servers to use your private DNS servers.

Configure DNS Clients

Before all of your servers in the “trusted” ACL can query your DNS servers, you must configure each of them to use ns1 and ns2 as nameservers. This process varies depending on OS, but for most Linux distributions it involves adding your name servers to the /etc/resolv.conf file.

CentOS Clients

On CentOS, RedHat, and Fedora Linux VPS, simply edit the resolv.conf file:

  • sudo vi /etc/resolv.conf

Then add the following lines to the TOP of the file (substitute your private domain, and ns1 and ns2 private IP addresses):

/etc/resolv.conf

search nyc3.example.com  # your private domain

nameserver 10.128.10.11  # ns1 private IP address

nameserver 10.128.20.12  # ns2 private IP address

Now save and exit. Your client is now configured to use your DNS servers.

Ubuntu Clients

On Ubuntu and Debian Linux VPS, you can edit the head file, which is prepended to resolv.conf on boot:

  • sudo vi /etc/resolvconf/resolv.conf.d/head

Add the following lines to the file (substitute your private domain, and ns1 and ns2 private IP addresses):

/etc/resolvconf/resolv.conf.d/head

search nyc3.example.com  # your private domain

nameserver 10.128.10.11  # ns1 private IP address

nameserver 10.128.20.12  # ns2 private IP address

Now run resolvconf to generate a new resolv.conf file:

  • sudo resolvconf -u

Your client is now configured to use your DNS servers.

Test Clients

Use nslookup—included in the “bind-utils” package—to test if your clients can query your name servers. You should be able to do this on all of the clients that you have configured and are in the “trusted” ACL.

Forward Lookup

For example, we can perform a forward lookup to retrieve the IP address of host1.nyc3.example.com by running the following command:

  • nslookup host1

Querying “host1” expands to “host1.nyc3.example.com because of the search option is set to your private subdomain, and DNS queries will attempt to look on that subdomain before looking for the host elsewhere. The output of the command above would look like the following:

Output:

Server:     10.128.10.11

Address:    10.128.10.11#53

 

Name:   host1.nyc3.example.com

Address: 10.128.100.101

Reverse Lookup

To test the reverse lookup, query the DNS server with host1‘s private IP address:

  • nslookup 10.128.100.101

You should see output that looks like the following:

Output:

Server:     10.128.10.11

Address:    10.128.10.11#53

 

11.10.128.10.in-addr.arpa   name = host1.nyc3.example.com.

If all of the names and IP addresses resolve to the correct values, that means that your zone files are configured properly. If you receive unexpected values, be sure to review the zone files on your primary DNS server (e.g. db.nyc3.example.com and db.10.128).

Congratulations! Your internal DNS servers are now set up properly! Now we will cover maintaining your zone records.

Maintaining DNS Records

Now that you have a working internal DNS, you need to maintain your DNS records so they accurately reflect your server environment.

Adding Host to DNS

Whenever you add a host to your environment (in the same datacenter), you will want to add it to DNS. Here is a list of steps that you need to take:

Primary Nameserver

  • Forward zone file: Add an “A” record for the new host, increment the value of “Serial”
  • Reverse zone file: Add a “PTR” record for the new host, increment the value of “Serial”
  • Add your new host’s private IP address to the “trusted” ACL (conf.options)

Then reload BIND:

  • sudo systemctl reload named

Secondary Nameserver

  • Add your new host’s private IP address to the “trusted” ACL (conf.options)

Then reload BIND:

  • sudo systemctl reload named

Configure New Host to Use Your DNS

  • Configure resolv.conf to use your DNS servers
  • Test using nslookup

Removing Host from DNS

If you remove a host from your environment or want to just take it out of DNS, just remove all the things that were added when you added the server to DNS (i.e. the reverse of the steps above).

Conclusion

Now you may refer to your servers’ private network interfaces by name, rather than by IP address. This makes configuration of services and applications easier because you no longer have to remember the private IP addresses, and the files will be easier to read and understand. Also, now you can change your configurations to point to a new servers in a single place, your primary DNS server, instead of having to edit a variety of distributed configuration files, which eases maintenance.

Once you have your internal DNS set up, and your configuration files are using private FQDNs to specify network connections, it is critical that your DNS servers are properly maintained. If they both become unavailable, your services and applications that rely on them will cease to function properly. This is why it is recommended to set up your DNS with at least one secondary server, and to maintain working backups of all of them.

Source: How To Configure BIND as a Private Network DNS Server on CentOS 7 | DigitalOcean

Prevent false positive email marked as spam in office 365

Tips for Office 365 Admins to prevent good email marked as spam from being sent to quarantine as a false positive. Customize a safelist and other options to prevent good email marked as spam.

Prevent false positive email marked as spam in office 365

  1. Obtain the headers for the message you want to allow in your mail client such as Outlook or Outlook Web App, as described in Message Header Analyzer.
  1. Open the message.
  2. Go to Options > properties.
  3. Copy the internet headers section.
  4. Go to Message Header Analyzer.
  5. Paste the internet headers section.
  6. Click analyze
  1. Search for the IP address following the CIP tag in the X-Forefront-Antispam-Report header manually or by using the message header analyzer.
  2. Add the IP address to the IP Allow list by following the steps in “Use the EAC to edit the default connection filter policy” in Configure the connection filter policy.
  3. In the Exchange admin center (EAC), navigate to Protection > Connection filter, and then double-click the default policy.
  4. Click the Connection filtering menu item and then create the lists you want: an IP Allow list, an IP Block list, or both.
  5. Click  . In the subsequent dialog box, specify the IP address or address range, and then click ok. Repeat this process to add additional addresses. (you can also edit or remove IP addresses after they have been added.)
  6. Optionally, select the enable safe list check box to prevent missing email from certain well-known senders. How? Microsoft subscribes to third-party sources of trusted senders. Using this safe list means that these trusted senders aren’t mistakenly marked as spam. We recommend selecting this option because it should reduce the number of false positives (good mail that’s classified as spam) you receive.
  7. Click save. A summary of your default policy settings appears in the right pane.
  • Note:
  • If you add an IP address to both lists, email sent from it is allowed.
  • IPv4 IP addresses must be specified in the format nnn.nnn.nnn.nnn.
  • You can also specify classless inter-domain routing (cidr) ranges in the format nnn.nnn.nnn.nnn/rr.
  • You can specify a maximum of 1273 entries, where an entry is either a single IP address or a cidr range of IP addresses from /24 to /32.

 

Source: Prevent false positive email marked as spam with a safelist or other techniques – Office 365

 

Add PowerShell to Windows Explorer Context Menu in Windows 10

Here’s a quick tutorial on how to add PowerShell to the Windows Explorer context menu in Windows 10.

Source: Add PowerShell to Windows Explorer Context Menu in Windows 10 – Petri

1. Open the Registry Editor. You can do this by clicking on Start and typing regedit.

2. Navigate to the following path:

HKEY_CLASSES_ROOT\Directory\Shell

Create a new key by clicking Edit > New > Key.

Call the new key “PowerShell.”

3. Modify the default string in the “PowerShell” key by right-clicking it and selecting “Modify…”

Call the new value “Open PowerShell Here.” Click “OK.

4. In the PowerShell key, create a new key by clicking Edit > New > Key.

5. Call the new key “command.”

6. Modify the default string in the command key by using the following text:

C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command Set-Location -LiteralPath ‘%L’

Click “OK.”

7. Add a new string by clicking Edit > New > String value.

Let’s call it “Icon.”

8. Modify the value by using the following text:

“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe”,0

Click “OK.”

9. After completing these steps, close the registry, and open Windows Explorer. Go to any folder of your choice and right-click the folder

 

 

 

 

Process Monitoring with PowerShell

PowerShell MVP Jeff Hicks shares his script for watching processes using a WMI event subscription using the CIM cmdlets.

Source: Process Monitoring with PowerShell – Petri

$Poll = 120 #check the computer every two minutes

<#
I want to select all properties from the WMI class called CIM_InstModification.
This is a special system class that’s triggered when an object is modified.
I don’t want to find every object, as it is changed every second. So I tell WMI to check within a time frame of seconds.
When this event fires, WMI will have a new object called the TargetInstance.
This will be the changed object, and I only care about those that are Win32_Process objects.
The ISA operator accomplishes that.
The last part of the query is to limit results to those process objects, which is what the TargetInstance is, with a WorkingSetSize property of greater or equal to 500 MB.
#>

$query = “Select * from CIM_InstModification within $Poll where TargetInstance ISA ‘Win32_Process’ AND TargetInstance.WorkingSetSize>=$(1000MB)” #WMI query

<#
When you create the event subscriber, you can choose to simply record the events in your PowerShell session as matching events are detected.
Or you can take action.
In my case, I want to do a few things everytime a matching process is found.
I want to create a log file, and I want to display a popup message.
#>

$action={
#create a log file
$logPath= “C:\Work\HighMemLog.txt”
“[$(Get-Date)] Computername = $($Event.SourceEventArgs.NewEvent.SourceInstance.CSName)” | Out-File -FilePath $logPath -Append -Encoding ascii
“[$(Get-Date)] Process = $($Event.SourceEventArgs.NewEvent.SourceInstance.Name)” | Out-File -FilePath $logPath -Append -Encoding ascii
“[$(Get-Date)] Command = $($Event.SourceEventArgs.NewEvent.SourceInstance.Commandline)” | Out-File -FilePath $logPath -Append -Encoding ascii
“[$(Get-Date)] PID = $($Event.SourceEventArgs.NewEvent.SourceInstance.ProcessID)” | Out-File -FilePath $logPath -Append -Encoding ascii
“[$(Get-Date)] WS(MB) = $([math]::Round($Event.SourceEventArgs.NewEvent.SourceInstance.WorkingSetSize/1MB,2))” | Out-File -FilePath $logPath -Append -Encoding ascii
“[$(Get-Date)] $(‘*’ * 60)” | Out-File -FilePath $logPath -Append -Encoding ascii

#create a popup
$wsh = New-Object -ComObject Wscript.shell
$Title = “$(Get-Date) High Memory Alert”
$msg = @”
Process = $($Event.SourceEventArgs.NewEvent.SourceInstance.Name)
PID = $($Event.SourceEventArgs.NewEvent.SourceInstance.ProcessID)
WS(MB) = $([math]::Round($Event.SourceEventArgs.NewEvent.SourceInstance.WorkingSetSize/1MB,2))
“@

#timeout in seconds. Use -1 to require a user to click OK.
$Timeout = 10
$wsh.Popup($msg,$TimeOut,$Title,16+32)

}

#Now that I have the action scriptblock all that remains is to register the subscription with the Register-CimIndicationEvent.#
Register-CimIndicationEvent -Query $query -SourceIdentifier “HighProcessMemory” -Action $action

#You can see the registration with the Get-EventSubscriber cmdlet.
#This subscription will run for as long as my PowerShell session is running.
#The corollary is that I will need to recreate it every time I want to start monitoring.
#If this is a daily task, I could put it in my PowerShell profile script.

#If you want to get rid of the subscriber, simply unregister it.
#Get-EventSubscriber -SourceIdentifier “HighProcessMemory” | Unregister-Event

 

How to Create a Bootable USB Drive

Step 1: Using DISKPART command

  1. Insert your USB flash drive to your running computer.
  2. Run Command Prompt as administrator.
  3. Type ‘diskpart‘ on Command Prompt (without quotes) and hit Enter.
  4. Type ‘list disk‘ to view active disks on your computer and hit Enter and find the USB drive disk #.
  5. Type ‘select disk 1‘ (or whatever the USB drive is).
  6. Type ‘clean‘ and hit Enter to remove all of data in the drive.
  7. Type ‘create partition primary‘ and hit Enter. Creating a primary partition and further recognized by Windows as ‘partition 1‘.
  8. Type ‘select partition 1‘ and hit Enter. Choosing the ‘partition 1‘ for setting up it as an active partition.
  9. Type ‘active‘ and hit Enter. Activating current partition.
  10. Type ‘format fs=ntfs quick‘ and hit Enter. Formatting current partition as NTFS file system quickly.
  11. Type ‘exit‘ and hit Enter. Leaving DISKPART program but don’t close the Command Prompt instead. We would still need it for next process.

Step 2: Creating Boot Sector

Mount the ISO file to a drive.

Let us assume that the flash / USB drive is the D: drive and the DVD installer located on drive F:The first step, we will navigate Command Prompt to set installation DVD as its active directory.

  • (if you want to create boot from ISO file then, first thing to do is to mount the ISO of the Windows OS you just downloaded. Double-click the ISO file to mount it. Check the drive letter and make note of the drive letter).
  1. By default, Command Prompt’s active directory for Administrator permission is on C:\Windows\System32>. We will navigate Command Prompt to set on DVD (F:) as its active directory. Just type ‘f:‘ then hit Enter, and the active directory changed to F:
  2. Type ‘cd boot‘ and hit Enter. Active directory changed to F:\boot>.
  3. Type ‘bootsect /nt60 d:‘ and hit Enter. Creating boot sector on D: drive (USB flash drive).
  4. Type ‘exit‘ and hit Enter to close the Command Prompt. Until this step we have made a bootable USB drive successfully, and the flash drive is ready to be used as a boot media.

Step 3: Copying Installation Files

To install Windows from a bootable USB drive, we just need to copy the whole installation files contained on the DVD installer to flash drive. To do this, open the Command Prompt as in previous steps. Once it opens, type ‘xcopy f:\*.* d:\ /E /H /F‘ and then press Enter. Wait until all the files in the DVD installer copied to the flash drive. Now bootable USB drive is ready to be used for installing Windows from flash drive and you’re done !

 

Error 0x80004005 accessing CIFS from Windows server

Issue: Accessing shares hosted on third party file server (like NetApp or EMC) from Windows server 2012 returns error

Windows cannot access \\ServerName

Check the spelling of the name. Otherwise, there might be a problem with your network. To try to identify and resolve network problems, click Diagnose.

Error code: 0x80004005
Unspecified error

Cause:

With Windows server 2012 and Windows 8, Secure dialect negotiation is introduced in SMB 3.0. This feature depends upon the correct signing of error responses by all SMBv2 servers, including servers that support only protocol versions 2.0 and 2.1. Some third-party file servers do not return a signed error response. Therefore, the connection fails.

Resolution:

On the Netapp filer:

Disable SMB2 on the storage server by entering the following command: options cifs.smb2.client.enable off

options cifs.smb2.signing.required on

http://mysupport.netapp.com/NOW/cgi-bin/bol?Type=Detail&Display=474548

On the server:

Run the Powershell command:

Set-ItemProperty -Path “HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters” RequireSecureNegotiate -Value 0 –Force

or

Set-SmbClientConfiguration – RequireSecureNegotiate 0

how to solve: This product can only be installed on Windows XP SP2 and above when Installing vSphere Client 5.0 on Windows 8.

Symptoms

  • Installing vSphere Client 5.0 fails on Windows 8
  • You see the error:
    This product can only be installed on Windows XP SP2 and above

Resolution

This issue is resolved in vCenter Server 5.0 Update 2, available at VMware Downlaods.
To work around this issue:
  1. Right-click the VMware-viclient-build number.exe file and click Properties.
  2. On the Compatibility tab, select Run this program in compatibility mode for: and select Windows 7 from the list.
  3. Click OK.
  4. Run the VMware-viclient-build number.exe file.

Source: VMware KB: Installing vSphere Client 5.0 on Windows 8 fails with the error: This product can only be installed on Windows XP SP2 and above

How to Shutdown a Failover Cluster or a Node.

Shutting Down a Node

When shutting down or rebooting a node in a Failover Cluster, you first want to drain (move off) any roles running on that server (such as a virtual machine).  This ensures that the shutting down of a node is graceful to any applications running on that node.

  1. Open Failover Cluster Manager (CluAdmin.msc)
  2. Click on “Nodes”
  3. Right-click on the node name and under ‘Pause’ click on ‘Drain Roles’
  4. Under Status the node will appear as ‘Paused’.  At the bottom of the center pane click on the ‘Roles’ tab.  Once all roles have moved off this node, it is safe to shut down or reboot the node.

    To resume the node after it has been restarted…

    When the node is once again powered on and ready to be put back into service, use the Resume action to re-enable the node to host roles.

    1. Open Failover Cluster Manager (CluAdmin.msc)
    2. Click on “Nodes”
    3. Right-click on the node name and select ‘Resume’, then select either:
      1. Fail Roles Back’ – This will resume the node and move any roles which were running on the node prior to the node back.  Caution:  This could incur downtime based on the role
      2. Do Not Fail Roles Back’ – This will resume the node and not move any roles back.

Shutting Down a Node with Windows PowerShell®

  1. Open a PowerShell window as Administrator
  2. Type:  Suspend-ClusterNode -Drain
  3. Type:  Get-ClusterGroup
    1. Verify that there are no roles listed under “OwnerNode” for that node
    2. This could be scripted with the following syntax:
      PS C:\> (Get-ClusterGroup).OwnerNode –eq “NodeBeingDrained”
  4. Shutdown or restart the computer by typing either:
    1. Stop-Computer
    1. Restart-Computer

To resume the node after it has been restarted…

  1. Open a PowerShell window as Administrator
  2. Type:  Resume-ClusterNode
    1. If you wish to fail back the roles which were previously running on this node type:

PS C:\> Resume-ClusterNode –Failback Immediate

Shutting Down a Cluster

Shutting down the entire cluster involves stopping all roles and then stopping the Cluster Service on all nodes.  While you can shut down each node in the cluster individually, using the cluster UI will ensure the shutdown is done gracefully.

  1. Open Failover Cluster Manager (CluAdmin.msc)
  2. Right-click on the cluster name, select ‘More Actions’, then “Shut Down Cluster…”
  3. When prompted if you are sure you want to shut down the cluster, click “Yes”

Shutting Down a Cluster with PowerShell

  1. Open a PowerShell window as Administrator
  2. Type:  Stop-Cluster

Controlling VM Behavior on Shutdown

When the cluster is shut down, the VMs will be placed in a Saved state.  This can be controlled using the OfflineActionproperty.

To configure the shut down action for an individual VM (where “Virtual Machine” is the name of the VM):

PS C:\> Get-ClusterResource “Virtual Machine” | Set-ClusterParameter OfflineAction 1

 

 Value  Effect
 0  The VM is turned off
 1 (default)  The VM is saved
 2  The guest OS is shut down
 3  The guest OS is shut down forcibly

To start the cluster after it has been shut down

  1. Type:  Start-Cluster

Source: How to Properly Shutdown a Failover Cluster or a Node – Clustering and High-Availability – Site Home – MSDN Blogs

how to fix GUI is not working in f5 BIG-IP

 

Workaround

To work around this issue, close the dashboard window when it is not in use.

To recover from this issue, restart the httpd and tomcat services. To do so, perform  the following procedure:

Impact of workaround: The BIG-IP Configuration utility is not accessible while services are restarting.

  1. Log in to the command line.
  2. Type the following command to restart the httpd daemon:

    bigstart restart httpd

  3. Type the following command to restart the tomcat daemon:

    bigstart restart tomcat or in old BIG-IP versions bigstart restart tomcat4

Source: SOL14552 – Leaving the BIG-IP dashboard page running will result in an rtstats memory leak