-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add --dbiflist also to vnstati command, remove dependency to vnstat c…
…ommand from vnstat.cgi
- Loading branch information
Showing
10 changed files
with
142 additions
and
70 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
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,51 @@ | ||
#include "common.h" | ||
#include "iflist.h" | ||
#include "dbsql.h" | ||
#include "clicommon.h" | ||
|
||
void showdbiflist(const int mode) | ||
{ | ||
int dbifcount; | ||
iflist *dbifl = NULL, *dbifl_i = NULL; | ||
|
||
if (db == NULL && !db_open_ro()) { | ||
printf("Error: Failed to open database \"%s/%s\" in read-only mode.\n", cfg.dbdir, DATABASEFILE); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
if (mode == 2) { | ||
dbifcount = db_getinterfacecount(); | ||
printf("%d\n", dbifcount); | ||
db_close(); | ||
return; | ||
} | ||
|
||
dbifcount = db_getiflist(&dbifl); | ||
if (dbifcount < 0) { | ||
printf("Error: Failed to get interface list from database \"%s/%s\".\n", cfg.dbdir, DATABASEFILE); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
if (dbifcount == 0 && mode == 0) { | ||
printf("Database is empty.\n"); | ||
} else { | ||
dbifl_i = dbifl; | ||
|
||
if (mode == 0) { | ||
printf("Interfaces in database:"); | ||
while (dbifl_i != NULL) { | ||
printf(" %s", dbifl_i->interface); | ||
dbifl_i = dbifl_i->next; | ||
} | ||
printf("\n"); | ||
} else { | ||
while (dbifl_i != NULL) { | ||
printf("%s\n", dbifl_i->interface); | ||
dbifl_i = dbifl_i->next; | ||
} | ||
} | ||
} | ||
|
||
iflistfree(&dbifl); | ||
db_close(); | ||
} |
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,6 @@ | ||
#ifndef CLICOMMON_H | ||
#define CLICOMMON_H | ||
|
||
void showdbiflist(const int mode); | ||
|
||
#endif |
Oops, something went wrong.