Skip to content

Commit

Permalink
Adding needrestart probe
Browse files Browse the repository at this point in the history
  • Loading branch information
carsso committed Aug 8, 2023
1 parent 8dc99ba commit 44a9132
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ The directory name is the interval of check in seconds
├── hardware_load_average -> ../../probes-examples/hardware_load_average
├── hardware_memory -> ../../probes-examples/hardware_memory
├── ifstat -> ../../probes-examples/ifstat
└── supervisord
├── supervisord
└── needrestart

```

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.73.27
0.73.28
2 changes: 1 addition & 1 deletion build/deb/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "Installing WiGO on your system"

WIGOPATH="/usr/local/wigo"
EXAMPLEPROBES60=( hardware_load_average hardware_disks hardware_memory ifstat supervisord check_mdadm check_process haproxy lm-sensors iostat check_uptime )
EXAMPLEPROBES60=( hardware_load_average hardware_disks hardware_memory ifstat supervisord needrestart check_mdadm check_process haproxy lm-sensors iostat check_uptime )
EXAMPLEPROBES300=( smart check_ntp packages-apt )

# Fixing logrotate permissions
Expand Down
2 changes: 1 addition & 1 deletion build/rpm/wigo.spec
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ rm -rf %{buildroot}

%post
WIGOPATH="/usr/local/wigo"
EXAMPLEPROBES60=( hardware_load_average hardware_disks hardware_memory ifstat supervisord check_mdadm check_process haproxy lm-sensors iostat check_uptime)
EXAMPLEPROBES60=( hardware_load_average hardware_disks hardware_memory ifstat supervisord needrestart check_mdadm check_process haproxy lm-sensors iostat check_uptime)
EXAMPLEPROBES300=( smart check_ntp packages-yum )

# Enabling default probes on 60 directory
Expand Down
4 changes: 4 additions & 0 deletions etc/conf.d/needrestart.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"enabled" : true,
"needrestart" : "/usr/sbin/needrestart"
}
53 changes: 53 additions & 0 deletions probes/examples/needrestart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/perl

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../../lib";
use Wigo::Probe qw/:all/;

###
# DEFAULT CONFIG
###

my $conf = {
'needrestart' => '/usr/sbin/needrestart',
};

init( config => $conf );

my $needrestart = config->{'needrestart'};
unless ( -x $needrestart )
{
status 403;
message "needrestart $needrestart is not executable";
output 13;
}

###
# GET STATUS LIST
###

my $outNeedRestart = `$needrestart -k -p -l`;
my $returnCode = $?;
if($returnCode == 512)
{
status 200;
message "Restart needed";
}
elsif($returnCode)
{
status 500;
message "Error while getting restart status";
output 1;
}
else
{
message "Restart not needed";
}

my @lines = split("\n", $outNeedRestart);
detail->{'output'} = $lines[0];

output 0;

0 comments on commit 44a9132

Please sign in to comment.