File: update

package info (click to toggle)
taskd 1.1.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,576 kB
  • ctags: 1,141
  • sloc: cpp: 13,971; python: 1,523; sh: 1,080; perl: 610; ansic: 48; makefile: 21
file content (56 lines) | stat: -rwxr-xr-x 1,684 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl

use strict;
use warnings;

my $datafile = './taskd.rrd';
$datafile = shift if @ARGV;;
die "Could not find data file: $datafile\n"
  unless -f $datafile;

my $server = 'localhost:53589';

# $ taskd client <server>:<port> stats.request 
# >>> stats.request
# <<<
# average request bytes: 0
# average response bytes: 0
# average response time: 0.000000
# client: taskd 1.0.0.beta1
# code: 200
# errors: 0
# idle: 1.000000
# maximum response time: 0.000000
# organizations: 2
# status: Ok
# total bytes in: 0
# total bytes out: 0
# tps: 0.000000
# transactions: 1
# uptime: 22
# user data: 59045
# users: 3

my $statistics = qx{/usr/local/bin/taskd client $server stats.request};

my ($avgReq)   = $statistics =~ /average request bytes: (\d+)/;
my ($avgResp)  = $statistics =~ /average response bytes: (\d+)/;
my ($avgTime)  = $statistics =~ /average response time: ([0-9.]+)/;
my ($errors)   = $statistics =~ /errors: (\d+)/;
my ($idle)     = $statistics =~ /idle: ([0-9.]+)/;
my ($maxResp)  = $statistics =~ /maximum response time: ([0-9.]+)/;
my ($tps)      = $statistics =~ /tps: ([0-9.]+)/;
my ($totalIn)  = $statistics =~ /total bytes in: (\d+)/;
my ($totalOut) = $statistics =~ /total bytes out: (\d+)/;
my ($tx)       = $statistics =~ /transactions: (\d+)/;
my ($uptime)   = $statistics =~ /uptime: (\d+)/;
my ($orgs)     = $statistics =~ /organizations: (\d+)/;
my ($users)    = $statistics =~ /users: (\d+)/;
my ($data)     = $statistics =~ /user data: (\d+)/;

# Remove commas in transaction count.
$tx =~ s/,//g;

qx{rrdtool update $datafile N:$avgReq:$avgResp:$maxResp:$avgTime:$errors:$idle:$tps:$totalIn:$totalOut:$tx:$uptime:$orgs:$users:$data};

exit 0;