How to push the process running status in centos machine using telegraf? - plugins

I am trying to monitor the running process in my machine.
To achieve this i leveraged Telegraf, Influxdb, Grafana
In telegraf I used procstat plugin and i used the tag procstat_lookup
My telegraf conf file:
[[inputs.procstat]]
pid_tag = true
exe = ""
systemd_unit = "sshd"
[[inputs.procstat]]
pid_tag = true
exe = ""
systemd_unit = "influxd"
When i run the query Select * from procstat_lookup where time >= now() - 120s in Ubuntu Machine I get the output:
time exe pattern pid_count pid_finder result result_code running
systemd_unit
---- --- ------- --------- ---------- ------ ----------- ------- ------------
1569906900000000000 1 pgrep success 0 1 apache2
1569906900000000000 1 pgrep success 0 1 sshd
But when i run the same query in Centos Machine I get the output:
time pid_count systemd_unit
---- --------- ------------
1569909600000000000 1 apache2
1569909600000000000 1 sshd
I wonder why there is a different output for the same configuration in the two different OS

Related

/opt/gitlab/embedded/bin/ruby: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

I'm trying to install gitlab-ce on my raspberry pi 4B, 4GB model. My operating system is Raspberry Pi OS Lite 64bit.
Installer taken from here
There was an error running gitlab-ctl reconfigure:
Multiple failures occurred:
* Mixlib::ShellOut::ShellCommandFailed occurred in Chef Infra Client run: runit_service[gitlab-kas] (gitlab-kas::enable line 121) had an error: Mixlib::ShellOut::ShellCommandFailed: ruby_block[restart_log_service] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb line 65) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas/log ----
STDOUT: timeout: run: /opt/gitlab/service/gitlab-kas/log: (pid 21560) 34s, got TERM
STDERR:
---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas/log ----
Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas/log returned 1
* Mixlib::ShellOut::ShellCommandFailed occurred in delayed notification: execute[clear the gitlab-rails cache] (gitlab::gitlab-rails line 477) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '127'
---- Begin output of /opt/gitlab/bin/gitlab-rake cache:clear ----
STDOUT:
STDERR: /opt/gitlab/embedded/bin/ruby: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
---- End output of /opt/gitlab/bin/gitlab-rake cache:clear ----
Ran /opt/gitlab/bin/gitlab-rake cache:clear returned 127
* Mixlib::ShellOut::ShellCommandFailed occurred in delayed notification: runit_service[gitlab-kas] (gitlab-kas::enable line 121) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----
STDOUT: timeout: run: /opt/gitlab/service/gitlab-kas: (pid 21561) 65s, got TERM
STDERR:
---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----
Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas returned 1
*Update: Distro info:
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
The installation scripts for the Raspberry Pi only work on debian buster. Notice the distro/version specified for the package is raspbian/buster:
However, you have installed the newer bullseye version of raspbian:
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
In order to use this install script, you'll need to use the legacy debian buster release for Raspberry PI OS.

How to add/replace psobject

I am trying to write a script about the state of the server hardware
The following functions have been completed.
Get-SummaryStatus.ps1
Get-Memory.ps1
Get-PowerSupply.ps1
Get-Proecssor.ps1
Get-Fanstatus.ps1
Get-SummaryStatus.ps1 output is
Server ServerStatus
------ ------------
AAA {System.Collections.Hashtable}
$report.server output is
AAA
$report.serverstatus output is
Name Value
---- -----
MemoryStatus OK
PowerStatus OK
ProcessorStatus OK
Fanstatus OK
Get-Memory.ps1 output is
Server MemoryStatus
------ ------------
AAA {System.Collections.Hashtable, System.Collections.Hashtable}
$report.server output is
AAA
$report.MemoryStatus output is
Name Value
---- -----
MemoryID 1
MemoryStatus OK
MemoryID 2
MemoryStatus OK
Get-PowerSupply.ps1 output is
Server MemoryStatus
------ ------------
AAA {System.Collections.Hashtable, System.Collections.Hashtable}
$report.server output is
AAA
$report.PowerStatus output is
Name Value
---- -----
PowerID 1
PowerStatus OK
PowerID 2
PowerStatus OK
Get-Proecssor.ps1 output Similar to the three above
Get-Fanstatus.ps1 output Similar to the three above
Duo to I have more than 1000 services that need to be monitored, So I want to make the following steps to improve efficiency.
I created a new main function(ServerHealthCheck) and call all sub-founcitons(summary,memory,power...) to main function. (completed)
If the summary state are OK, and then output summarystatus. (completed.)
If Summary memory status is failed. and then will call Get-Memory.ps1 to find which memory is bad.(completed)
If Summary power status is failed. and then will call Get-powersupply.ps1 to find which powersupply is bad.(completed.)
if One of the hardware was failed , I want to rearrange a new object.
my question is How to add/replace object to get expected output? thanks in advance.
Expected output(if summary memory status is failed):
Server ServerStatus
------ ------------
AAA {System.Collections.Hashtable}
$report.server output is
AAA
$report.serverstatus output is
Name Value
---- -----
MemoryID 1
MemoryStatus failed
PowerStatus OK
ProcessorStatus OK
Fanstatus OK

How can I use powershell to intercept a specified string of a command output?

I use ipptool to get the status of the current print job.
C:\Users\Administrator>ipptool http://localhost/ipp/printers get-completed-jobs.test
job-id job-state job-name job-originating-user-name job-media-sheets-completed
------ --------- -------- ------------------------- --------------------------
14 canceled RedHat 1
13 completed RedHat 1
12 completed RedHat 1
11 completed RedHat 1
How do I get the specified job-id and job-state?
What method does Powershell use to intercept strings?
Question 1:
Get the following string:
14 canceled
Question 2 :
Get the following string:
13 completed
12 completed
Question 3 :
How do I get the most recent job-id and job-state?
The cmdlet ConvertFrom-SourceTable available for download from the PowerShell gallery (GitHub: iRon7/ConvertFrom-SourceTable) is capable of reading this type of data tables:
$Jobs = ConvertFrom-SourceTable '
job-id job-state job-name job-originating-user-name job-media-sheets-completed
------ --------- -------- ------------------------- --------------------------
14 canceled RedHat 1
13 completed RedHat 1
12 completed RedHat 1
11 completed RedHat 1
'
In your case, it is probably something like:
$Jobs = $(.\ipptool http://localhost/ipp/printers get-completed-jobs.test) | ConvertFrom-SourceTable
The rest of your questions are actually a matter of basic PowerShell commands.
As in this example, the Jobs object will give you access to e.g. the status of job 14:
$Jobs | ?{$_."job-id" -eq 14} | Select -Expand "job-state"
canceled
And "How do I get the most recent job-id and job-state?":
(presuming that the most recent job is always on top)
$Jobs | Select "job-id", "job-state" -First 1
job-id job-state
------ ---------
14 canceled
(For other ConvertFrom-SourceTable examples see: https://stackoverflow.com/search?q=ConvertFrom-SourceTable)

vscode install failed with "install failed error" on windows7

I try to install vscode on windows7 and get "install failed error", no detailed information, is there someone get the same error? It is crazy that vscode can not be installed on windows.
Use something like 7Zip to extract the archived files to a VSCodeSetup folder, with the resulting files:
Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 4/22/2015 8:28 AM 140782 background.gif
----- 4/27/2015 6:22 PM 60255967 Code-0.1.0-full.nupkg
----- 4/27/2015 6:22 PM 74 RELEASES
-a--- 4/30/2015 9:25 AM 1911 SquirrelSetup.log
----- 4/24/2015 11:12 AM 1492992 Update.exe
Then open PowerShell (a CMD window would also work). I cd'd into the VSCodeSetup folder and ran the following command:
PS>.\Update.exe --install=.
(You may need to run PS or the CMD window as Administrator)
Referenced post: VSCode Installation Failed - Failed to extract installer

Devel::Cover merging coverage data for Perl scripts and modules

I'm having issues merging data for coverage on Perl scripts and modules.. Running Devel::Cover individually works just fine, but when I try to combine the data I lose statistics for just the Perl script not the module..
Let me explain..
I have a directory tree that looks like so..
Code_Coverage_Test
|
|---->lib
|
|---->t
|
Inside the root Code_Coverage_Test directory I have the Build.pl file that builds the tests for the module and script that kickoff two other scripts that automate some commands for me..
./Build.pl
#!/usr/bin/perl -w
use strict;
use Module::Build;
my $buildTests = Module::Build->new(
module_name => 'testPMCoverage',
license => 'perl',
dist_abstract => 'Perl .pm Test Code Coverage',
dist_author => 'me#myEmail.com',
build_requires => {
'Test::More' => '0.10',
},
);
$buildTests->create_build_script();
./startTests.sh
#!/bin/sh
cd t
./doPMtest.sh
./doPLtest.sh
cd ../
perl Build testcover
Inside the lib dir I have the files I'm trying to run Code coverage on..
lib/testPLCoverage.pl
#!/usr/bin/perl -w
use strict;
print "Ok!";
lib/testPMCoverage.pm
use strict;
use warnings;
package testPMCoverage;
sub hello {
return "Hello";
}
sub bye {
return "Bye";
}
1;
In the t dir I have my .t test file for the module and 2 scripts that kickoff the tests for me.. Both of which are called by the startTests.sh in the root directory
t/testPMCoverage.t
#!/usr/bin/perl -w
use strict;
use Test::More;
require_ok( 'testPMCoverage' );
my $test = testPMCoverage::hello();
is($test, "Hello", "hello() test");
done_testing();
t/doPLtest.sh
#!/bin/sh
#Test 1
cd ../
cd lib
perl -MDevel::Cover=-db,../cover_db testPLCoverage.pl
t/doPMtest.sh
#!/bin/bash
cd ../
perl Build.pl
perl Build test
The issue I'm running into is that when the doPLtests.sh script runs, I get coverage data, no problem..
---------------------------- ------ ------ ------ ------ ------ ------ ------
File STMT Bran Cond Sub pod Time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
testPLCoverage.pl 100.0 n/a n/a 100.0 n/a 100.0 100.0
Total 100.0 n/a n/a 100.0 n/a 100.0 100.0
---------------------------- ------ ------ ------ ------ ------ ------ ------
However, when the doPMtest.sh script finishes and the startTests.sh script initiates the Build testcover command I lose that data along the way and I get these messages ...
Reading database path/Code_Coverage_Tests/cover_db
Devel::Cover: Warning: can't open testPLCoverage.pl for MD5 digest: No such file or directory
Devel::Cover: Warning: can't locate structure for statement in testPLCoverage.pl
Devel::Cover: Warning: can't locate structure for subroutine in testPLCoverage.pl
Devel::Cover: Warning: can't locate structure for time in testPLCoverage.pl
..and somehow I lose the data
---------------------------- ------ ------ ------ ------ ------ ------ ------
File STMT Bran Cond Sub pod Time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
blib/lib/testPMCoverage.pm 87.5 n/a n/a 75.0 0.0 100.0 71.4
testPLCoverage.pl n/a n/a n/a n/a n/a n/a n/a
Total 87.5 n/a n/a 75.0 0.0 100.0 71.4
---------------------------- ------ ------ ------ ------ ------ ------ ------
How can I combine the Perl module and Perl script tests to get valid code coverage in ONE file?
Perl doesn't store the full path to the files it uses. If it finds the file via a relative path then only the relative path is stored. You can see this in the paths perl shows in the warning and error messages from those files.
When Devel::Cover deals with files it uses the path given by perl. You can see this in the reports from Devel::Cover where you have testPLCoverage.pl and blib/lib/testPMCoverage.pm.
What this means for you in practice is that whenever you put coverage into a coverage DB you should ensure that you are doing it from the same directory, so that Devel::Cover can match and locate the files in the coverage DB.
I think this is the problem you are hitting.
My suggestion is that in t/doPLtest.sh you don't cd into lib. You can run something like:
perl -Mblib -MDevel::Cover=-db,../cover_db lib/testPLCoverage.pl
(As an aside, why is that file in lib?)
I think that would mean that Devel::Cover would be running from the project root in each case and so should allow it to match and find the files.