Imported Upstream version 2.6.4
This commit is contained in:
parent
fad6ced6f6
commit
fefe62b2bd
257 changed files with 6020 additions and 1394 deletions
|
|
@ -1,6 +1,8 @@
|
|||
/* upsmon - monitor power status over the 'net (talks to upsd via TCP)
|
||||
|
||||
Copyright (C) 1998 Russell Kroll <rkroll@exploits.org>
|
||||
Copyright (C)
|
||||
1998 Russell Kroll <rkroll@exploits.org>
|
||||
2012 Arnaud Quette <arnaud.quette.free.fr>
|
||||
|
||||
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
|
||||
|
|
@ -79,12 +81,6 @@ static int opt_af = AF_UNSPEC;
|
|||
static struct sigaction sa;
|
||||
static sigset_t nut_upsmon_sigmask;
|
||||
|
||||
#ifdef SHUT_RDWR
|
||||
#define shutdown_how SHUT_RDWR
|
||||
#else
|
||||
#define shutdown_how 2
|
||||
#endif
|
||||
|
||||
static void setflag(int *val, int flag)
|
||||
{
|
||||
*val |= flag;
|
||||
|
|
@ -696,7 +692,7 @@ static void recalc(void)
|
|||
}
|
||||
|
||||
/* note: we assume that a UPS that isn't critical must be OK *
|
||||
* *
|
||||
* *
|
||||
* this means a UPS we've never heard from is assumed OL *
|
||||
* whether this is really the best thing to do is undecided */
|
||||
|
||||
|
|
@ -709,12 +705,12 @@ static void recalc(void)
|
|||
ups = ups->next;
|
||||
}
|
||||
|
||||
/* upsdebugx(3, "Current power value: %d", val_ol);
|
||||
upsdebugx(3, "Minimum power value: %d", minsupplies); */
|
||||
upsdebugx(3, "Current power value: %d", val_ol);
|
||||
upsdebugx(3, "Minimum power value: %d", minsupplies);
|
||||
|
||||
if (val_ol < minsupplies)
|
||||
forceshutdown();
|
||||
}
|
||||
}
|
||||
|
||||
static void ups_low_batt(utype_t *ups)
|
||||
{
|
||||
|
|
@ -792,10 +788,7 @@ static void redefine_ups(utype_t *ups, int pv, const char *un,
|
|||
|
||||
free(ups->un);
|
||||
|
||||
if (un)
|
||||
ups->un = xstrdup(un);
|
||||
else
|
||||
ups->un = NULL;
|
||||
ups->un = xstrdup(un);
|
||||
|
||||
/*
|
||||
* if not logged in force a reconnection since this
|
||||
|
|
@ -954,7 +947,7 @@ static void addups(int reloading, const char *sys, const char *pvs,
|
|||
else
|
||||
upslogx(LOG_INFO, "UPS: %s (monitoring only)", tmp->sys);
|
||||
|
||||
tmp->upsname = tmp->hostname = NULL;
|
||||
tmp->upsname = tmp->hostname = NULL;
|
||||
|
||||
if (upscli_splitname(tmp->sys, &tmp->upsname, &tmp->hostname,
|
||||
&tmp->port) != 0) {
|
||||
|
|
@ -1945,6 +1938,15 @@ int main(int argc, char *argv[])
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* otherwise, we are being asked to start.
|
||||
* so check if a previous instance is running by sending signal '0'
|
||||
* (Ie 'kill <pid> 0') */
|
||||
if (sendsignal(prog, 0) == 0) {
|
||||
printf("Fatal error: A previous upsmon instance is already running!\n");
|
||||
printf("Either stop the previous instance first, or use the 'reload' command.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
|
|
@ -1961,6 +1963,8 @@ int main(int argc, char *argv[])
|
|||
/* we may need to get rid of a flag from a previous shutdown */
|
||||
if (powerdownflag != NULL)
|
||||
clear_pdflag();
|
||||
/* FIXME (else): POWERDOWNFLAG is not defined!!
|
||||
* => fallback to a default value */
|
||||
|
||||
if (totalpv < minsupplies) {
|
||||
printf("\nFatal error: insufficient power configured!\n\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue