Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
30418e9a
Commit
30418e9a
authored
Dec 10, 2015
by
System Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
open_vestat
parent
b1d619a1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
224 additions
and
13 deletions
+224
-13
check_git_activity.sh
git/check_git_activity.sh
+3
-3
.gitignore
nginx/.gitignore
+2
-0
url_stats_404.sh
nginx/url_stats_404.sh
+0
-10
open_vestat
vz/open_vestat
+219
-0
No files found.
git/check_git_activity.sh
View file @
30418e9a
...
...
@@ -8,15 +8,15 @@ then
exit
0
fi
cd
$TOPDIR
||
exit
LIST
=
$(
find
./azbyka_
*
-maxdepth
6
-name
'.git'
)
#
cd $TOPDIR || exit
LIST
=
$(
find
$TOPDIR
/
-maxdepth
7
-name
'.git'
)
#LIST=$(echo $TOPDIR/azbyka_*/www/*/*/.git)
T
=
"
$1
"
for
i
in
$LIST
do
cd
/azbyka/
$i
/..
cd
$i
/..
FILES
=
"
$(
git status
--porcelain
)
"
M
=
$(
echo
"
$FILES
"
|grep
-c
' M '
)
D
=
$(
echo
"
$FILES
"
|grep
-c
' D '
)
...
...
nginx/.gitignore
0 → 100644
View file @
30418e9a
config
*.report
nginx/url_stats_404.sh
deleted
100755 → 0
View file @
b1d619a1
#!/bin/sh
.
./config
test
-z
"
$1
"
||
FILE
=
"
$1
"
REPORT
=
url_stats_com.report
echo
"=== Requests which took most of the time (from
$FILE
) ==="
>
$REPORT
echo
"percent - overall time - number of requests - average time - url"
>>
$REPORT
cat
$FILE
| ./url_stats_com.py
>>
$REPORT
vz/open_vestat
0 → 100755
View file @
30418e9a
#!/usr/bin/perl
use
strict
;
use
warnings
;
use
Getopt::
Long
;
use
Pod::
Usage
qw(pod2usage)
;
my
$cpu_scheduler_path
=
'/proc/vz/fairsched'
;
my
$blkio_sheduler_path
=
'/proc/vz/beancounter'
;
my
$vzlist
=
"/usr/sbin/vzlist"
;
my
@containers
=
get_all_running_containers
();
my
$cpu_data_storage
=
{};
my
$cpu_consumption
=
{};
my
@checks
=
(
"disk_time"
,
"disk_sectors"
,
"cpu"
);
# sort by cpu by default
my
$default_check_type
=
'cpu'
;
my
$check_type
;
my
$help
;
GetOptions
(
"--help"
=>
\
$help
,
#Only help message
"--sort-by=s"
=>
\
$check_type
,
#Our check_type
)
or
pod2usage
(
-
message
=>
"Error in command line argumtnts!\n"
,
-
verbose
=>
0
,
-
noperldoc
=>
1
,
-
exitval
=>
1
,);
if
(
$help
)
{
pod2usage
(
-
verbose
=>
3
,
-
noperldoc
=>
1
,
-
exitval
=>
0
,);
}
if
(
defined
$check_type
)
{
if
(
not
grep
{
/^$check_type$/
}
@checks
)
{
pod2usage
(
-
message
=>
"Error - \"$check_type\" incorrect param! You can use cpu, disk_time or disk_sectors\n"
,
-
verbose
=>
0
,
-
noperldoc
=>
1
,
-
exitval
=>
1
,);
}
}
else
{
$check_type
=
$default_check_type
;
}
for
my
$check
(
@checks
)
{
$cpu_data_storage
->
{
$check
}
=
{};
$cpu_consumption
->
{
$check
}
=
{};
}
while
(
1
)
{
for
my
$check
(
@checks
)
{
calc_resources_consumption
(
\
@containers
,
$check
);
}
my
$number_of_top_records
=
20
;
my
$counter
=
0
;
print
"We sort data by $check_type\n"
;
my
@keys_sorted_by_custom_parameter
=
reverse
sort
{
$cpu_consumption
->
{
$check_type
}
->
{
$a
}
<=>
$cpu_consumption
->
{
$check_type
}
->
{
$b
}
}
keys
%
{
$cpu_consumption
->
{
$check_type
}
};
for
my
$key
(
@keys_sorted_by_custom_parameter
)
{
if
(
$counter
>
$number_of_top_records
)
{
last
;
}
# skip HWN
if
(
$key
eq
'hwn'
)
{
next
;
}
print
"$key:\t"
;
for
my
$check
(
@checks
)
{
unless
(
$cpu_consumption
->
{
$check
}
->
{
hwn
})
{
next
;
}
print
"$check: "
.
sprintf
(
"%.1f"
,
$cpu_consumption
->
{
$check
}
->
{
$key
}
/
$cpu_consumption
->
{
$check
}
->
{
hwn
}
*
100
)
.
" %\t"
;
}
print
"\n"
;
#print "process snapshot:\n";
#print `vzprocess $key|sort -g -k 3|tail -n 1`;
$counter
++
;
}
sleep
(
5
);
system
(
'clear'
);
}
sub
calc_resources_consumption
{
my
@containers
=
@
{
$_
[
0
]
};
my
$type
=
$_
[
1
];
my
$main_path
=
''
;
my
$value_path
=
''
;
if
(
$type
eq
'cpu'
)
{
$main_path
=
$cpu_scheduler_path
;
$value_path
=
'cpuacct.usage'
;
}
elsif
(
$type
eq
'disk_time'
)
{
$main_path
=
$blkio_sheduler_path
;
$value_path
=
'blkio.time'
;
}
elsif
(
$type
eq
'disk_sectors'
)
{
$main_path
=
$blkio_sheduler_path
;
$value_path
=
'blkio.sectors'
;
#$value_path = 'blkio.io_serviced';
}
else
{
die
"Unexpected type"
;
}
my
$server_total_cpu_usage
;
if
(
$type
=~
/^disk/
)
{
$server_total_cpu_usage
=
get_sum_disk_count
(
"$main_path/$value_path"
);
}
else
{
$server_total_cpu_usage
=
read_file_contents
(
"$main_path/$value_path"
);
}
if
(
defined
$cpu_data_storage
->
{
$type
}
->
{
hwn
})
{
$cpu_consumption
->
{
$type
}
->
{
hwn
}
=
$server_total_cpu_usage
-
$cpu_data_storage
->
{
$type
}
->
{
hwn
};
}
$cpu_data_storage
->
{
$type
}
->
{
hwn
}
=
$server_total_cpu_usage
;
for
my
$ct
(
@containers
)
{
my
$ct_cpu_usage
;
if
(
$type
=~
/^disk/
)
{
$ct_cpu_usage
=
get_sum_disk_count
(
"$main_path/$ct/$value_path"
);
}
else
{
$ct_cpu_usage
=
read_file_contents
(
"$main_path/$ct/$value_path"
);
}
if
(
defined
$cpu_data_storage
->
{
$type
}
->
{
$ct
})
{
$cpu_consumption
->
{
$type
}
->
{
$ct
}
=
$ct_cpu_usage
-
$cpu_data_storage
->
{
$type
}
->
{
$ct
};
}
$cpu_data_storage
->
{
$type
}
->
{
$ct
}
=
$ct_cpu_usage
;
}
}
sub
get_all_running_containers
{
my
@containers
=
`$vzlist -H1`
;
chomp
@containers
;
map
{
s/^\s+//
;
s/\s+$//
;
}
@containers
;
return
@containers
;
}
sub
get_sum_disk_count
{
my
$file
=
shift
;
my
$result
=
0
;
open
my
$file_handler
,
"<"
,
$file
or
return
0
;
while
(
my
$line
=
<
$file_handler
>
)
{
$result
+=
(
split
/\s+/
,
$line
)[
1
];
}
close
$file_handler
;
return
$result
;
}
sub
read_file_contents
{
my
$path
=
shift
;
open
my
$fl
,
"<"
,
$path
or
die
"Can't open file"
;
my
$data
=
''
;
while
(
<
$fl
>
)
{
chomp
;
$data
.=
$_
;
}
close
$fl
;
return
$data
;
}
__END__
=head1 NAME
open_vestat - script for output top 20 openvz containers for load on cpu/disk
=head1 SYNOPSIS
open_vestat [ --sort-by ( cpu | disk_time | disk_sectors ) ] [ --help ]
=head1 OPTIONS
=over 8
=item B<--help>
Print this message
=item B<--sort-by>
Sorting output for cpu or disk_time or disk_sectors
=back
=head1 DESCRIPTION
We use cgroups for count use cpu/blkio.time/blkio.sectors
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment