-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pcp2openmetrics' of https://github.com/lmchilton/pcp in…
…to lmchilton-pcp2openmetrics
- Loading branch information
Showing
10 changed files
with
1,509 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/sh | ||
# PCP QA Test No. 1589 | ||
# Exercise pcp2openmetrics HTTP POST functionality. | ||
# | ||
# Copyright (c) 2024 Red Hat. All Rights Reserved. | ||
# | ||
|
||
#set -x | ||
|
||
seq=`basename $0` | ||
echo "QA output created by $seq" | ||
|
||
. ./common.python | ||
|
||
which pcp2openmetrics >/dev/null 2>&1 || _notrun "pcp2openmetrics not installed" | ||
|
||
_cleanup() | ||
{ | ||
cd $here | ||
$sudo rm -rf $tmp $tmp.* | ||
} | ||
|
||
status=0 # success is the default! | ||
cpus=`pmprobe -v hinv.ncpu | awk '{print $3}'` | ||
hostname=`hostname` | ||
machineid=`_machine_id` | ||
domainid=`_domain_name` | ||
$sudo rm -rf $tmp $tmp.* $seq.full | ||
trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
|
||
|
||
_filter_pcp2openmetrics_http() | ||
{ | ||
tee -a $here/$seq.full \ | ||
| col -b \ | ||
| sed \ | ||
-e '/domainname=/ s/'$domainid'/DOMAINID/' \ | ||
-e '/machineid=/ s/'$machineid'/MACHINEID/' \ | ||
-e '/groupid=/ s/'$UID'/GROUPID/' \ | ||
-e '/userid=/ s/'$UID'/USERID/' \ | ||
-e '/hostname=/ s/'$hostname'/HOST/' \ | ||
-e 's/- - \[[^]]*\]/- -[DATE]/g' \ | ||
-e 's/.*- -/[IP ADDRESS]/g' \ | ||
-e "s/^\(Host: localhost\):$port/\1:PORT/g" \ | ||
-e 's/^\(Content-Length:\) [1-9][0-9]*/\1 SIZE/g' \ | ||
-e 's/^\(User-Agent: python-requests\).*/\1 VERSION/g' \ | ||
-e 's/^\(Date:\).*/\1 DATE/g' \ | ||
-e 's/\(\"context\":\) [0-9][0-9]*/\1 CTXID/g' \ | ||
-e '/^Accept-Encoding: /d' \ | ||
-e 's/\(\hostname=\): \""$hostname"\"/\1:HOST/g' \ | ||
-e '/^Connection: keep-alive/d' \ | ||
-e '/ using stream socket$/d' \ | ||
| LC_COLLATE=POSIX sort | ||
} | ||
|
||
# real QA test starts here | ||
port=`_find_free_port` | ||
$PCP_PYTHON_PROG $here/src/pythonserver.py $port &> $tmp.python.out & | ||
pid=$! | ||
sleep 2 # let server start up | ||
|
||
echo "pcp2openmetrics invocation" | tee -a $here/$seq.full | ||
pcp2openmetrics -s1 -u http://localhost:$port hinv.ncpu >$tmp.openmetrics.out 2>$tmp.openmetrics.err | ||
|
||
echo "pcp2openmetrics HTTP POST (sorted):" | ||
_filter_pcp2openmetrics_http <$tmp.python.out | ||
|
||
($signal $pid ) >>$seq.full 2>&1 & | ||
|
||
# success, all done | ||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
QA output created by 1827 | ||
pcp2openmetrics invocation | ||
pcp2openmetrics HTTP POST (sorted): | ||
|
||
|
||
|
||
|
||
|
||
|
||
# HELP hinv_ncpu number of CPUs in the system | ||
# TYPE hinv_ncpu gauge | ||
Accept: */* | ||
Body: | ||
Content-Length: SIZE | ||
Content-Type: application/openmetrics-text | ||
Headers: | ||
Host: localhost:PORT | ||
INFO:root:POST request, | ||
INFO:root:Starting httpd... | ||
Path: / | ||
User-Agent: python-requests VERSION | ||
[IP ADDRESS][DATE] "POST / HTTP/1.1" 200 - | ||
hinv_ncpu{domainname="DOMAINID",groupid="GROUPID",hostname="HOST",machineid="MACHINEID",userid="USERID",agent="linux"} 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# Copyright (c) 2024 Red Hat. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License as published by the | ||
# Free Software Foundation; either version 2 of the License, or (at your | ||
# option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# for more details. | ||
# | ||
|
||
TOPDIR = ../.. | ||
include $(TOPDIR)/src/include/builddefs | ||
|
||
TARGET = pcp2openmetrics | ||
MAN_SECTION = 1 | ||
MAN_PAGES = $(TARGET).$(MAN_SECTION) | ||
MAN_DEST = $(PCP_MAN_DIR)/man$(MAN_SECTION) | ||
BASHDIR = $(PCP_BASHSHARE_DIR)/completions | ||
|
||
default: $(TARGET).py $(MAN_PAGES) | ||
|
||
default: | ||
|
||
include $(BUILDRULES) | ||
|
||
install: default | ||
ifeq "$(HAVE_PYTHON)" "true" | ||
$(INSTALL) -m 755 $(TARGET).py $(PCP_BIN_DIR)/$(TARGET) | ||
$(INSTALL) -S $(BASHDIR)/pcp $(BASHDIR)/$(TARGET) | ||
@$(INSTALL_MAN) | ||
endif | ||
|
||
default_pcp: default | ||
|
||
install_pcp: install | ||
|
||
check:: $(TARGET).py | ||
$(PYLINT) $^ | ||
|
||
check :: $(MAN_PAGES) | ||
$(MANLINT) $^ | ||
|
Oops, something went wrong.