[Java] Eclipse IDE.

  1. Download and install JDK.

  2. Edit Windows Environment setting. (Advanced system settings => Advance => Environment variables => Choose Path and click edited => Add the location of the bin folder of the JDK installation.)

    Ex: “C:Program Files (x86)Javajre1.8.0_31bin”

  3. Check the Step. 2. Open the command window and run “java -version”.

    C:UsersCS>java -version
    java version “1.8.0_40”
    Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
    Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

  4. Download the Eclipse IDE and extract it. Then you can start to make some java codes with Eclipse IDE.

Posted in Eclipse, Java | Leave a comment

[Excel] Find the latest value

20150304 If we want use excel to get the value F.

F = A * B * C * D * E

The common method is using the upper mathematical formulas. But if we adjust the columns, we may get the wrong value because there are some exceptions in the reference columns. So if we can use E to find the location of A or B, this problems are not exit. If E’s location is W7.

W7 = LOOKUP(2,1/($H$5:$H7<>""),$H$5:$H7) * LOOKUP(2,1/($M$5:$M7<>""),$M$5:$M7),$P7,S7) * P7 * R7
Posted in Excel | Leave a comment

[Elasticsearch] The health status means…

When we list the indexes, we will get the status information. It shows the health of index in the elasticsearch cluster.

  • green
    All shards are allocated.
  • yellow
    The primary shard is allocated but replicas are not.
  • red
    The specific shard is not allocated in the cluster.

Because in the our experiment environment, we do not use the elasticsearch cluster. So the status is yellow is right.

Posted in Elasticsearch | Leave a comment

[Elasticsearch] List all indexes and optimize it.

When we deleted the indexes, the data were just marked by deleted.
We can list all indexes to show status.

sudo curl 'localhost:9200/_cat/indices?v'

It will show the health, index name, pri, rep, docs.count, docs.deleted, store.size, pri.store.size.

health index               pri rep docs.count docs.deleted store.size pri.store.size
yellow kibana-int            5   1          5            0     66.7kb         66.7kb
yellow logstash-2015.02.13   5   1     402030      3366353      1.2gb          1.2gb
yellow logstash-2015.02.18   5   1      86843      3393979      1.1gb          1.1gb
yellow logstash-2015.02.15   5   1     218402      3063776      1.2gb          1.2gb
yellow logstash-2015.02.03   5   1     178621      2072000    756.3mb        756.3mb
yellow logstash-2015.02.06   5   1     466185      2479658    963.4mb        963.4mb
yellow logstash-2015.02.24   5   1     364473            0    166.5mb        166.5mb
yellow logstash-2015.02.02   5   1     313488      1838855    710.1mb        710.1mb
yellow logstash-2015.02.07   5   1     371602      3397300      1.2gb          1.2gb
yellow logstash-2015.02.21   5   1    3583288            0      1.2gb          1.2gb
yellow logstash-2015.02.22   5   1    3554707            0      1.1gb          1.1gb
yellow logstash-2015.02.23   5   1    3680625            0      1.2gb          1.2gb

If we want to clear the deleted indexes, we can optimize it.

sudo curl -XPOST 'http://localhost:9200/_optimize'

And it will reply this message.

{"_shards":{"total":310,"successful":155,"failed":0}}

Then when we list all indexes again, we will see the deleted indexes are gone.

cowman@roamingcacti:~$ sudo curl 'localhost:9200/_cat/indices?v'
health index               pri rep docs.count docs.deleted store.size pri.store.size
yellow kibana-int            5   1          5            0     66.5kb         66.5kb
yellow logstash-2015.02.13   5   1     402030      1512300    611.7mb        611.7mb
yellow logstash-2015.02.18   5   1      86843      1374178    491.9mb        491.9mb
yellow logstash-2015.02.15   5   1     218402      1404862    536.7mb        536.7mb
yellow logstash-2015.02.03   5   1     178621      2072000    756.2mb        756.2mb
yellow logstash-2015.02.06   5   1     466185      2479658    963.4mb        963.4mb
yellow logstash-2015.02.24   5   1     378777            0    156.9mb        156.9mb
yellow logstash-2015.02.02   5   1     313488      1838855    710.1mb        710.1mb
yellow logstash-2015.02.07   5   1     371602      1394610    566.5mb        566.5mb
yellow logstash-2015.02.21   5   1    3583288            0      1.2gb          1.2gb
yellow logstash-2015.02.22   5   1    3554707            0      1.1gb          1.1gb
yellow logstash-2015.02.23   5   1    3680625            0      1.2gb          1.2gb
Posted in Elasticsearch | Leave a comment

[Nagios][Cacti] Monitor disk space > 8TB

Because the limitation of snmp, when the disk space is more than 8TB, we will get the wrong value. Whether we use snmpwalk or snmpget, the results are all the same. Therefore, we need to restore the correct value.

If we get the disk space is A, and the block size is B.

if (A <0){
  return (A + 4294967296) * B;
} else {
  return A * B;
}

Then we will get the C.
If we want to calculate the disk space in GB.

return C * B / 1024 / 1024
Posted in Cacti, Nagios, SNMP | Leave a comment

[Logstash] Pattern set in grok.

The original warning message is this.

"You are using a deprecated config setting "pattern" set in grok. Deprecated settings will continue to work, but are scheduled for removal from logstash in the future. You should use this instead: match => { "message" => "your pattern here" } If you have any questions about this, please visit the #logstash channel on freenode irc.""

And here is the original server config.

if [type] == "nginx-access" {
  grok {
    type => "nginx-access"
    pattern => "%{NGINXACCESS}"
    patterns_dir => ["/opt/logstash/patterns"]
  }
}

So what we should do is modify the config. Using the match function to replace the pattern, like this.

if [type] == "nginx-access" {
  grok {
    patterns_dir => "/opt/logstash/patterns"
    type => "nginx-access"
    match => ["message", "%{NGINXACCESS}"]
  }
}
Posted in Logstash | Leave a comment

[Sublime Text] Enable BIG5 support

In default, sublime text editor does not support BIG5 character, so you must install “ConvertToUTF8” package.

Posted in Sublime Text 2 | Leave a comment

[Kibana] Time range search

If I want to search information within these seven days.

@timestamp:["now-7d" TO "now"]

If I want to search information between 2015-01-01 and 2015-01-31.

@timestamp:["2015-01-01" TO "2015-01-31"]

If I want to search information between 2015-02-01 13:00:00 and 2015-02-01 18:00:00.

@timestamp:["2015-02-01T13:00:00" TO "2015-02-01T18:00:00"]
Posted in Kibana | Leave a comment

[Splunk] Get the quota exceeded count

When we want to find some way to get the count of the quota exceed event, we might find this page “Splunk > Wiki : Community:TroubleshootingIndexedDataVolume Troubleshooting Indexed Data Volume”.

Then we could use the following to get the count.

index=_internal source=*license_audit.log LicenseManager-Audit  
| streamstats current=f global=f window=1 first(quotaExceededCount) as next_quotaExceededCount by host 
| eval quotadiff = next_quotaExceededCount - quotaExceededCount 
| search quotadiff>0

But in my case, I only want to know the last value of the quotaExceededCount. So I modified it.

index=_internal licensemanager | stats first(quotaExceededCount) by host

Finally, I would use the quotaExceededCount value to judge is not able to import data.

Posted in Splunk | Leave a comment

[Ubuntu] Enable power saving in Lenovo X61

Ref: http://www.webupd8.org/2014/04/prevent-your-laptop-from-overheating.html

Because I installed Ubuntu 14.04 in my Lenovo X61.
Although it could switch into the sleep mode after closing the lid. It’s not really using the power saving mode.
So we must edit the GRUB file.

sudo vim /etc/default/grub

Find the “GRUB_CMDLINE_LINUX_DEFAULT”, and add “intel_pstate=enable” at the end, like this.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_pstate=enable"

Then update the grub config

sudo update-grub

Finally, we must reboot and use powertop to check its status.

Posted in Ubuntu | Leave a comment