Skip to content

Commit

Permalink
Merge pull request #55 from instana/InormixOsCheck
Browse files Browse the repository at this point in the history
Code for Os Auto check
  • Loading branch information
vivek-22 authored Jul 30, 2024
2 parents 0efe038 + bbe5e03 commit 7777b23
Show file tree
Hide file tree
Showing 24 changed files with 317 additions and 3 deletions.
5 changes: 4 additions & 1 deletion rdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation("mysql:mysql-connector-java:5.1.46")
implementation(files("libs/DmJdbcDriver18.jar"))
implementation(files("libs/vault-1.0.0.jar"))
implementation 'org.apache.commons:commons-lang3:3.6'
}

application {
Expand All @@ -45,7 +46,9 @@ applicationDistribution.from("config") {
applicationDistribution.from("scripts/informix") {
into "scripts"
}

applicationDistribution.from("scripts/informix_solaris10") {
into "scripts_solaris10"
}
test {
useJUnitPlatform()
}
18 changes: 18 additions & 0 deletions rdb/scripts/informix_solaris10/active_session_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# !/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
INFORMIXDIR=$2 &&
export INFORMIXDIR &&
ONCONFIG=$3 &&
export ONCONFIG &&
INFORMIXSERVER=$4 &&
export INFORMIXSERVER &&
PATH=$INFORMIXDIR/bin:$PATH &&
export PATH &&
INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
export INFORMIXSQLHOSTS &&
./onstat -g ses active | awk 'NR==2 {linecount = NF -2; if (linecount>0) print linecount; else print 0}')

echo $result
18 changes: 18 additions & 0 deletions rdb/scripts/informix_solaris10/cache_read_ratio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# !/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
INFORMIXDIR=$2 &&
export INFORMIXDIR &&
ONCONFIG=$3 &&
export ONCONFIG &&
INFORMIXSERVER=$4 &&
export INFORMIXSERVER &&
PATH=$INFORMIXDIR/bin:$PATH &&
export PATH &&
INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
export INFORMIXSQLHOSTS &&
./onstat -p |head -n 6| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $4}')

echo $result|cut -d'.' -f 1
18 changes: 18 additions & 0 deletions rdb/scripts/informix_solaris10/cache_write_ratio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# !/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
INFORMIXDIR=$2 &&
export INFORMIXDIR &&
ONCONFIG=$3 &&
export ONCONFIG &&
INFORMIXSERVER=$4 &&
export INFORMIXSERVER &&
PATH=$INFORMIXDIR/bin:$PATH &&
export PATH &&
INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
export INFORMIXSQLHOSTS &&
./onstat -p |head -n 6| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $8}')

echo $result|cut -d'.' -f 1
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/disk_read.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -p | awk 'NR==6 {print $1}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/disk_write.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -p | awk 'NR==6 {print $5}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/io_read_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -g iof | awk 'NR==11 {print $2}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/io_write_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -g iof | awk 'NR==12 {print $2}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/lock_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -k | awk '{a[NR]=$0} END{print a[NR-1]}' |awk '{print $1}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/lock_waits.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -p |head -n 18| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $2}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/lru_writes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -F| head -n 6| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $2}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/memory_utilization.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -g seg | grep -i 'total' | awk '{print $7*100/($7+$8)}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/overflow_lock_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -p |head -n 15| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $1}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/overflow_transaction_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -p |head -n 15| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $3}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/overflow_user_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -p |head -n 15| awk '{a[NR]=$0} END{print a[NR]}'| awk '{print $2}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/session_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -g ses | awk 'NR==2 {linecount = NF -2; if (linecount>0) print linecount; else print 0}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/sql_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -g his 1 | head -n 10 | awk '{a[NR]=$0} END{print a[NR-1]}' | awk '{print $4}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/tablespace_max.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -T | grep 'sysmaster' |awk '{print $8}' | awk '{sum+=$0;}END{print sum;}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/tablespace_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -T | awk '{print $7}' | awk '{sum+=$0;}END{print sum;}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/tablespace_used.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -T | awk '{print $8}' | awk '{sum+=$0;}END{print sum;}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/tablespace_utilization.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -T | grep 'sysmaster' |awk '{print $7}' | awk '{sum+=$0;}END{print sum;}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/task_wait_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFO RMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -g wai | awk '{RS=""; FS="\n"} NR==2 {linecount = NF -2; if (linecount>0) print linecount; else print 0}')

echo $result
13 changes: 13 additions & 0 deletions rdb/scripts/informix_solaris10/transaction_count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# (c) Copyright IBM Corp. 2024
# (c) Copyright Instana Inc.

result=$(cd $1 &&
export INFORMIXDIR=$2 &&
export ONCONFIG=$3 &&
export INFORMIXSERVER=$4 &&
export PATH=$INFORMIXDIR/bin:$PATH &&
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/$5 &&
./onstat -x | awk '{a[NR]=$0} END{print a[NR-1]}'| awk '{print $1}')

echo $result
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang3.SystemUtils;

public class OnstatCommandExecutor {
private static final Logger LOGGER = Logger.getLogger(OnstatCommandExecutor.class.getName());
public static final String SHELL_SCRIPT = "sh";
public static String SHELL_SCRIPT;
public static final String LINE_BREAK = "\n";
private final String dbPath;
private final String binPath;
Expand All @@ -39,7 +40,16 @@ public OnstatCommandExecutor(String dbPath, String serverName) {
* @return : Value as String[]
*/
public Optional<String[]> executeCommand(String fileName) {
String path = "scripts/" + fileName;
String path;
if(SystemUtils.OS_NAME.equals("SunOS") && SystemUtils.OS_VERSION.equals("5.10")) {
path = "scripts_solaris10/" + fileName;
SHELL_SCRIPT = "ksh";
}
else {
path = "scripts/" + fileName;
SHELL_SCRIPT = "sh";
}

String[] command = new String[]{
SHELL_SCRIPT,
path,
Expand Down

0 comments on commit 7777b23

Please sign in to comment.